-
-
Notifications
You must be signed in to change notification settings - Fork 823
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ERC-6492 sig utils * update name to parseERC6492Signature * fmt * tweak: refactor + docs --------- Co-authored-by: moxey.eth <jakemoxey@gmail.com>
- Loading branch information
1 parent
242ff09
commit 76a92bb
Showing
40 changed files
with
547 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
"viem": minor | ||
--- | ||
|
||
Added [ERC-6492](https://eips.ethereum.org/EIPS/eip-6492) signature utilities: | ||
|
||
- `isErc6492Signature` | ||
- `parseErc6492Signature` | ||
- `serializeErc6492Signature` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
"viem": minor | ||
--- | ||
|
||
Deprecated utilities (will be removed in v3): | ||
|
||
- `hexToSignature` – use `parseSignature` instead. | ||
- `hexToCompactSignature` – use `parseCompactSignature` instead. | ||
- `compactSignatureToHex` – use `serializeCompactSignature` instead. | ||
- `signatureToHex` – use `serializeSignature` instead. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
description: Checks whether the signature is in ERC-6492 format. | ||
--- | ||
|
||
# isErc6492Signature | ||
|
||
Checks whether the signature is in [ERC-6492](https://eips.ethereum.org/EIPS/eip-6492) format. | ||
|
||
## Import | ||
|
||
```ts | ||
import { isErc6492Signature } from 'viem' | ||
``` | ||
|
||
## Usage | ||
|
||
```ts twoslash | ||
import { isErc6492Signature } from 'viem' | ||
|
||
const result = isErc6492Signature('0x000000000000000000000000cafebabecafebabecafebabecafebabecafebabe000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000004deadbeef000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041a461f509887bd19e312c0c58467ce8ff8e300d3c1a90b608a760c5b80318eaf15fe57c96f9175d6cd4daad4663763baa7e78836e067d0163e9a2ccf2ff753f5b1b000000000000000000000000000000000000000000000000000000000000006492649264926492649264926492649264926492649264926492649264926492') | ||
``` | ||
|
||
## Returns | ||
|
||
`boolean` | ||
|
||
Whether the signature is in ERC-6492 format. | ||
|
||
## Parameters | ||
|
||
### signature | ||
|
||
- **Type:** [`Hex`](/docs/glossary/types#hex) | ||
|
||
The signature to check. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
description: Parses a hex-formatted ERC-6492 flavoured signature. | ||
--- | ||
|
||
# parseErc6492Signature | ||
|
||
Parses a hex-formatted [ERC-6492](https://eips.ethereum.org/EIPS/eip-6492) flavoured signature. | ||
|
||
If the signature is not in ERC-6492 format, then the underlying (original) signature is returned. | ||
|
||
## Import | ||
|
||
```ts | ||
import { parseErc6492Signature } from 'viem' | ||
``` | ||
|
||
## Usage | ||
|
||
```ts twoslash | ||
import { parseErc6492Signature } from 'viem' | ||
|
||
const { // [!code focus:99] | ||
factoryAddress, | ||
factoryData, | ||
signature, | ||
} = parseErc6492Signature('0x000000000000000000000000cafebabecafebabecafebabecafebabecafebabe000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000004deadbeef000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041a461f509887bd19e312c0c58467ce8ff8e300d3c1a90b608a760c5b80318eaf15fe57c96f9175d6cd4daad4663763baa7e78836e067d0163e9a2ccf2ff753f5b1b000000000000000000000000000000000000000000000000000000000000006492649264926492649264926492649264926492649264926492649264926492') | ||
/** | ||
* { | ||
* factoryAddress: '0xCafEBAbECAFEbAbEcaFEbabECAfebAbEcAFEBaBe', | ||
* factoryData: '0xdeadbeef', | ||
* signature: '0xa461f509887bd19e312c0c58467ce8ff8e300d3c1a90b608a760c5b80318eaf15fe57c96f9175d6cd4daad4663763baa7e78836e067d0163e9a2ccf2ff753f5b1b' | ||
* } | ||
*/ | ||
``` | ||
|
||
## Returns | ||
|
||
`ParseErc6492SignatureReturnType` | ||
|
||
The ERC-6492 signature components. | ||
|
||
## Parameters | ||
|
||
### signature | ||
|
||
- **Type:** [`Hex`](/docs/glossary/types#hex) | ||
|
||
The ERC-6492 signature in hex format. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
...s/docs/utilities/compactSignatureToHex.md → ...cs/utilities/serializeCompactSignature.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
description: Serializes a ERC-6492 flavoured signature into hex format. | ||
--- | ||
|
||
# serializeErc6492Signature | ||
|
||
Serializes a [ERC-6492](https://eips.ethereum.org/EIPS/eip-6492) flavoured signature into hex format. | ||
|
||
## Import | ||
|
||
```ts | ||
import { serializeErc6492Signature } from 'viem' | ||
``` | ||
|
||
## Usage | ||
|
||
```ts twoslash | ||
import { serializeErc6492Signature } from 'viem' | ||
|
||
serializeErc6492Signature({ // [!code focus:99] | ||
factoryAddress: '0xcafebabecafebabecafebabecafebabecafebabe', | ||
factoryData: '0xdeadbeef', | ||
signature: '0x41a461f509887bd19e312c0c58467ce8ff8e300d3c1a90b608a760c5b80318eaf15fe57c96f9175d6cd4daad4663763baa7e78836e067d0163e9a2ccf2ff753f5b1b', | ||
}) | ||
// "0x000000000000000000000000cafebabecafebabecafebabecafebabecafebabe000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000004deadbeef000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041a461f509887bd19e312c0c58467ce8ff8e300d3c1a90b608a760c5b80318eaf15fe57c96f9175d6cd4daad4663763baa7e78836e067d0163e9a2ccf2ff753f5b1b000000000000000000000000000000000000000000000000000000000000006492649264926492649264926492649264926492649264926492649264926492" | ||
``` | ||
|
||
## Returns | ||
|
||
[`Hex`](/docs/glossary/types#hex) | ||
|
||
The hex formatted signature. | ||
|
||
## Parameters | ||
|
||
### factoryAddress | ||
|
||
- **Type:** `Address` | ||
|
||
The ERC-4337 Account Factory address to use for counterfactual verification. | ||
|
||
### factoryData | ||
|
||
- **Type:** `Hex` | ||
|
||
Calldata to pass to deploy the ERC-4337 Account (if not deployed) for counterfactual verification. | ||
|
||
### signature | ||
|
||
- **Type:** `Hex` | ||
|
||
The original signature. |
12 changes: 6 additions & 6 deletions
12
site/pages/docs/utilities/signatureToHex.md → ...ages/docs/utilities/serializeSignature.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.