viem 2.9.31 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/_cjs/accounts/index.js +4 -3
- package/_cjs/accounts/index.js.map +1 -1
- package/_cjs/accounts/utils/signMessage.js +2 -2
- package/_cjs/accounts/utils/signMessage.js.map +1 -1
- package/_cjs/accounts/utils/signTypedData.js +2 -2
- package/_cjs/accounts/utils/signTypedData.js.map +1 -1
- package/_cjs/actions/public/verifyHash.js +2 -2
- package/_cjs/actions/public/verifyHash.js.map +1 -1
- package/_cjs/constants/bytes.js +2 -1
- package/_cjs/constants/bytes.js.map +1 -1
- package/_cjs/ens/index.js +5 -1
- package/_cjs/ens/index.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/experimental/eip3074/invokers/getInvoker.js +2 -2
- package/_cjs/experimental/eip3074/utils/signAuthMessage.js +2 -2
- package/_cjs/experimental/eip3074/utils/signAuthMessage.js.map +1 -1
- package/_cjs/experimental/erc6492/isErc6492Signature.js +10 -0
- package/_cjs/experimental/erc6492/isErc6492Signature.js.map +1 -0
- package/_cjs/experimental/erc6492/parseErc6492Signature.js +13 -0
- package/_cjs/experimental/erc6492/parseErc6492Signature.js.map +1 -0
- package/_cjs/experimental/erc6492/serializeErc6492Signature.js +15 -0
- package/_cjs/experimental/erc6492/serializeErc6492Signature.js.map +1 -0
- package/_cjs/experimental/index.js +7 -1
- package/_cjs/experimental/index.js.map +1 -1
- package/_cjs/index.js +15 -11
- package/_cjs/index.js.map +1 -1
- package/_cjs/utils/abi/parseEventLogs.js.map +1 -1
- package/_cjs/utils/ens/avatar/parseAvatarRecord.js.map +1 -1
- package/_cjs/utils/ens/packetToBytes.js.map +1 -1
- package/_cjs/utils/signature/{hexToCompactSignature.js → parseCompactSignature.js} +5 -5
- package/_cjs/utils/signature/{hexToCompactSignature.js.map → parseCompactSignature.js.map} +1 -1
- package/_cjs/utils/signature/{hexToSignature.js → parseSignature.js} +4 -4
- package/_cjs/utils/signature/{hexToSignature.js.map → parseSignature.js.map} +1 -1
- package/_cjs/utils/signature/{compactSignatureToHex.js → serializeCompactSignature.js} +4 -4
- package/_cjs/utils/signature/serializeCompactSignature.js.map +1 -0
- package/_cjs/utils/signature/{signatureToHex.js → serializeSignature.js} +5 -5
- package/_cjs/utils/signature/serializeSignature.js.map +1 -0
- package/_esm/accounts/index.js +3 -1
- package/_esm/accounts/index.js.map +1 -1
- package/_esm/accounts/utils/signMessage.js +2 -2
- package/_esm/accounts/utils/signMessage.js.map +1 -1
- package/_esm/accounts/utils/signTypedData.js +2 -2
- package/_esm/accounts/utils/signTypedData.js.map +1 -1
- package/_esm/actions/public/verifyHash.js +2 -2
- package/_esm/actions/public/verifyHash.js.map +1 -1
- package/_esm/constants/bytes.js +1 -0
- package/_esm/constants/bytes.js.map +1 -1
- package/_esm/ens/index.js +2 -0
- package/_esm/ens/index.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/experimental/eip3074/invokers/getInvoker.js +2 -2
- package/_esm/experimental/eip3074/utils/signAuthMessage.js +2 -2
- package/_esm/experimental/eip3074/utils/signAuthMessage.js.map +1 -1
- package/_esm/experimental/erc6492/isErc6492Signature.js +7 -0
- package/_esm/experimental/erc6492/isErc6492Signature.js.map +1 -0
- package/_esm/experimental/erc6492/parseErc6492Signature.js +20 -0
- package/_esm/experimental/erc6492/parseErc6492Signature.js.map +1 -0
- package/_esm/experimental/erc6492/serializeErc6492Signature.js +21 -0
- package/_esm/experimental/erc6492/serializeErc6492Signature.js.map +1 -0
- package/_esm/experimental/index.js +3 -0
- package/_esm/experimental/index.js.map +1 -1
- package/_esm/index.js +12 -4
- package/_esm/index.js.map +1 -1
- package/_esm/utils/abi/parseEventLogs.js +1 -0
- package/_esm/utils/abi/parseEventLogs.js.map +1 -1
- package/_esm/utils/ens/avatar/parseAvatarRecord.js +10 -0
- package/_esm/utils/ens/avatar/parseAvatarRecord.js.map +1 -1
- package/_esm/utils/ens/packetToBytes.js +7 -0
- package/_esm/utils/ens/packetToBytes.js.map +1 -1
- package/_esm/utils/signature/compactSignatureToSignature.js +1 -1
- package/_esm/utils/signature/{hexToCompactSignature.js → parseCompactSignature.js} +4 -4
- package/_esm/utils/signature/parseCompactSignature.js.map +1 -0
- package/_esm/utils/signature/{hexToSignature.js → parseSignature.js} +3 -3
- package/_esm/utils/signature/{hexToSignature.js.map → parseSignature.js.map} +1 -1
- package/_esm/utils/signature/{compactSignatureToHex.js → serializeCompactSignature.js} +3 -3
- package/_esm/utils/signature/serializeCompactSignature.js.map +1 -0
- package/_esm/utils/signature/{signatureToHex.js → serializeSignature.js} +4 -4
- package/_esm/utils/signature/serializeSignature.js.map +1 -0
- package/_types/accounts/index.d.ts +5 -1
- package/_types/accounts/index.d.ts.map +1 -1
- package/_types/accounts/utils/signMessage.d.ts +2 -2
- package/_types/accounts/utils/signMessage.d.ts.map +1 -1
- package/_types/accounts/utils/signTypedData.d.ts +2 -2
- package/_types/accounts/utils/signTypedData.d.ts.map +1 -1
- package/_types/constants/bytes.d.ts +1 -0
- package/_types/constants/bytes.d.ts.map +1 -1
- package/_types/ens/index.d.ts +2 -0
- package/_types/ens/index.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/experimental/eip3074/invokers/getInvoker.d.ts +2 -2
- package/_types/experimental/eip3074/utils/signAuthMessage.d.ts +2 -2
- package/_types/experimental/eip3074/utils/signAuthMessage.d.ts.map +1 -1
- package/_types/experimental/erc6492/isErc6492Signature.d.ts +9 -0
- package/_types/experimental/erc6492/isErc6492Signature.d.ts.map +1 -0
- package/_types/experimental/erc6492/parseErc6492Signature.d.ts +38 -0
- package/_types/experimental/erc6492/parseErc6492Signature.d.ts.map +1 -0
- package/_types/experimental/erc6492/serializeErc6492Signature.d.ts +25 -0
- package/_types/experimental/erc6492/serializeErc6492Signature.d.ts.map +1 -0
- package/_types/experimental/index.d.ts +3 -0
- package/_types/experimental/index.d.ts.map +1 -1
- package/_types/index.d.ts +20 -4
- package/_types/index.d.ts.map +1 -1
- package/_types/utils/abi/parseEventLogs.d.ts.map +1 -1
- package/_types/utils/ens/avatar/parseAvatarRecord.d.ts.map +1 -1
- package/_types/utils/ens/packetToBytes.d.ts.map +1 -1
- package/_types/utils/signature/compactSignatureToSignature.d.ts +1 -1
- package/_types/utils/signature/{hexToCompactSignature.d.ts → parseCompactSignature.d.ts} +5 -5
- package/_types/utils/signature/parseCompactSignature.d.ts.map +1 -0
- package/_types/utils/signature/{hexToSignature.d.ts → parseSignature.d.ts} +4 -4
- package/_types/utils/signature/{hexToSignature.d.ts.map → parseSignature.d.ts.map} +1 -1
- package/_types/utils/signature/recoverTransactionAddress.d.ts +2 -2
- package/_types/utils/signature/recoverTransactionAddress.d.ts.map +1 -1
- package/_types/utils/signature/{compactSignatureToHex.d.ts → serializeCompactSignature.d.ts} +4 -4
- package/_types/utils/signature/serializeCompactSignature.d.ts.map +1 -0
- package/_types/utils/signature/{signatureToHex.d.ts → serializeSignature.d.ts} +6 -6
- package/_types/utils/signature/serializeSignature.d.ts.map +1 -0
- package/accounts/index.ts +7 -3
- package/accounts/utils/signMessage.ts +5 -5
- package/accounts/utils/signTypedData.ts +5 -5
- package/actions/public/verifyHash.ts +2 -2
- package/constants/bytes.ts +3 -0
- package/ens/index.ts +8 -0
- package/errors/version.ts +1 -1
- package/experimental/eip3074/invokers/getInvoker.ts +5 -5
- package/experimental/eip3074/utils/signAuthMessage.ts +5 -5
- package/experimental/erc6492/isErc6492Signature.ts +15 -0
- package/experimental/erc6492/parseErc6492Signature.ts +65 -0
- package/experimental/erc6492/serializeErc6492Signature.ts +42 -0
- package/experimental/index.ts +19 -0
- package/index.ts +30 -14
- package/package.json +1 -1
- package/utils/abi/parseEventLogs.ts +2 -0
- package/utils/ens/avatar/parseAvatarRecord.ts +10 -0
- package/utils/ens/packetToBytes.ts +7 -0
- package/utils/signature/compactSignatureToSignature.ts +1 -1
- package/utils/signature/{hexToCompactSignature.ts → parseCompactSignature.ts} +4 -7
- package/utils/signature/{hexToSignature.ts → parseSignature.ts} +3 -3
- package/utils/signature/recoverTransactionAddress.ts +2 -2
- package/utils/signature/{compactSignatureToHex.ts → serializeCompactSignature.ts} +5 -3
- package/utils/signature/{signatureToHex.ts → serializeSignature.ts} +5 -8
- package/_cjs/utils/signature/compactSignatureToHex.js.map +0 -1
- package/_cjs/utils/signature/signatureToHex.js.map +0 -1
- package/_esm/utils/signature/compactSignatureToHex.js.map +0 -1
- package/_esm/utils/signature/hexToCompactSignature.js.map +0 -1
- package/_esm/utils/signature/signatureToHex.js.map +0 -1
- package/_types/utils/signature/compactSignatureToHex.d.ts.map +0 -1
- package/_types/utils/signature/hexToCompactSignature.d.ts.map +0 -1
- package/_types/utils/signature/signatureToHex.d.ts.map +0 -1
@@ -7,9 +7,9 @@ import {
|
|
7
7
|
hashTypedData,
|
8
8
|
} from '../../utils/signature/hashTypedData.js'
|
9
9
|
import {
|
10
|
-
type
|
11
|
-
|
12
|
-
} from '../../utils/signature/
|
10
|
+
type SerializeSignatureErrorType,
|
11
|
+
serializeSignature,
|
12
|
+
} from '../../utils/signature/serializeSignature.js'
|
13
13
|
|
14
14
|
import type { ErrorType } from '../../errors/utils.js'
|
15
15
|
import { type SignErrorType, sign } from './sign.js'
|
@@ -27,7 +27,7 @@ export type SignTypedDataReturnType = Hex
|
|
27
27
|
export type SignTypedDataErrorType =
|
28
28
|
| HashTypedDataErrorType
|
29
29
|
| SignErrorType
|
30
|
-
|
|
30
|
+
| SerializeSignatureErrorType
|
31
31
|
| ErrorType
|
32
32
|
|
33
33
|
/**
|
@@ -48,5 +48,5 @@ export async function signTypedData<
|
|
48
48
|
hash: hashTypedData(typedData),
|
49
49
|
privateKey,
|
50
50
|
})
|
51
|
-
return
|
51
|
+
return serializeSignature(signature)
|
52
52
|
}
|
@@ -19,7 +19,7 @@ import {
|
|
19
19
|
import { type IsHexErrorType, isHex } from '../../utils/data/isHex.js'
|
20
20
|
import { type ToHexErrorType, bytesToHex } from '../../utils/encoding/toHex.js'
|
21
21
|
import { getAction } from '../../utils/getAction.js'
|
22
|
-
import {
|
22
|
+
import { serializeSignature } from '../../utils/signature/serializeSignature.js'
|
23
23
|
import { type CallErrorType, type CallParameters, call } from './call.js'
|
24
24
|
|
25
25
|
export type VerifyHashParameters = Pick<
|
@@ -58,7 +58,7 @@ export async function verifyHash<TChain extends Chain | undefined>(
|
|
58
58
|
const signatureHex = (() => {
|
59
59
|
if (isHex(signature)) return signature
|
60
60
|
if (typeof signature === 'object' && 'r' in signature && 's' in signature)
|
61
|
-
return
|
61
|
+
return serializeSignature(signature)
|
62
62
|
return bytesToHex(signature)
|
63
63
|
})()
|
64
64
|
|
package/constants/bytes.ts
CHANGED
package/ens/index.ts
CHANGED
@@ -31,3 +31,11 @@ export {
|
|
31
31
|
} from '../actions/ens/getEnsText.js'
|
32
32
|
export { type LabelhashErrorType, labelhash } from '../utils/ens/labelhash.js'
|
33
33
|
export { type NamehashErrorType, namehash } from '../utils/ens/namehash.js'
|
34
|
+
export {
|
35
|
+
parseAvatarRecord,
|
36
|
+
type ParseAvatarRecordErrorType,
|
37
|
+
} from '../utils/ens/avatar/parseAvatarRecord.js'
|
38
|
+
export {
|
39
|
+
packetToBytes,
|
40
|
+
type PacketToBytesErrorType,
|
41
|
+
} from '../utils/ens/packetToBytes.js'
|
package/errors/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = '2.
|
1
|
+
export const version = '2.10.0'
|
@@ -25,9 +25,9 @@ import {
|
|
25
25
|
keccak256,
|
26
26
|
} from '../../../utils/hash/keccak256.js'
|
27
27
|
import {
|
28
|
-
type
|
29
|
-
|
30
|
-
} from '../../../utils/signature/
|
28
|
+
type ParseSignatureErrorType,
|
29
|
+
parseSignature,
|
30
|
+
} from '../../../utils/signature/parseSignature.js'
|
31
31
|
import {
|
32
32
|
type SignAuthMessageErrorType,
|
33
33
|
signAuthMessage,
|
@@ -59,7 +59,7 @@ export type InvokerExecuteParameters<
|
|
59
59
|
|
60
60
|
export type InvokerExecuteErrorType =
|
61
61
|
| WriteContractErrorType
|
62
|
-
|
|
62
|
+
| ParseSignatureErrorType
|
63
63
|
| ErrorType
|
64
64
|
|
65
65
|
export type InvokerSignParameters<
|
@@ -136,7 +136,7 @@ export function getInvoker<
|
|
136
136
|
invokerAddress: address,
|
137
137
|
})
|
138
138
|
|
139
|
-
const { r, s, yParity } =
|
139
|
+
const { r, s, yParity } = parseSignature(signature)
|
140
140
|
return getAction(
|
141
141
|
client,
|
142
142
|
writeContract,
|
@@ -3,9 +3,9 @@ import type { ErrorType } from '../../../errors/utils.js'
|
|
3
3
|
import type { Hex } from '../../../types/misc.js'
|
4
4
|
import { keccak256 } from '../../../utils/hash/keccak256.js'
|
5
5
|
import {
|
6
|
-
type
|
7
|
-
|
8
|
-
} from '../../../utils/signature/
|
6
|
+
type SerializeSignatureErrorType,
|
7
|
+
serializeSignature,
|
8
|
+
} from '../../../utils/signature/serializeSignature.js'
|
9
9
|
import {
|
10
10
|
type ToAuthMessageErrorType,
|
11
11
|
type ToAuthMessageParameters,
|
@@ -22,7 +22,7 @@ export type SignAuthMessageReturnType = Hex
|
|
22
22
|
export type SignAuthMessageErrorType =
|
23
23
|
| SignErrorType
|
24
24
|
| ToAuthMessageErrorType
|
25
|
-
|
|
25
|
+
| SerializeSignatureErrorType
|
26
26
|
| ErrorType
|
27
27
|
|
28
28
|
/**
|
@@ -36,5 +36,5 @@ export async function signAuthMessage(
|
|
36
36
|
hash: keccak256(toAuthMessage(parameters)),
|
37
37
|
privateKey,
|
38
38
|
})
|
39
|
-
return
|
39
|
+
return serializeSignature(signature)
|
40
40
|
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { erc6492MagicBytes } from '../../constants/bytes.js'
|
2
|
+
import type { ErrorType } from '../../errors/utils.js'
|
3
|
+
import type { Hex } from '../../types/misc.js'
|
4
|
+
import { type SliceHexErrorType, sliceHex } from '../../utils/data/slice.js'
|
5
|
+
|
6
|
+
export type IsErc6492SignatureParameters = Hex
|
7
|
+
export type IsErc6492SignatureReturnType = boolean
|
8
|
+
export type IsErc6492SignatureErrorType = SliceHexErrorType | ErrorType
|
9
|
+
|
10
|
+
/** Whether or not the signature is an ERC-6492 formatted signature. */
|
11
|
+
export function isErc6492Signature(
|
12
|
+
signature: IsErc6492SignatureParameters,
|
13
|
+
): IsErc6492SignatureReturnType {
|
14
|
+
return sliceHex(signature, -32) === erc6492MagicBytes
|
15
|
+
}
|
@@ -0,0 +1,65 @@
|
|
1
|
+
import type { Address } from 'abitype'
|
2
|
+
import type { ErrorType } from '../../errors/utils.js'
|
3
|
+
import type { Hex } from '../../types/misc.js'
|
4
|
+
import type { OneOf, Prettify } from '../../types/utils.js'
|
5
|
+
import {
|
6
|
+
type DecodeAbiParametersErrorType,
|
7
|
+
decodeAbiParameters,
|
8
|
+
} from '../../utils/abi/decodeAbiParameters.js'
|
9
|
+
import {
|
10
|
+
type IsErc6492SignatureErrorType,
|
11
|
+
isErc6492Signature,
|
12
|
+
} from './isErc6492Signature.js'
|
13
|
+
|
14
|
+
export type ParseErc6492SignatureParameters = Hex
|
15
|
+
|
16
|
+
export type ParseErc6492SignatureReturnType = Prettify<
|
17
|
+
OneOf<
|
18
|
+
| {
|
19
|
+
/**
|
20
|
+
* The ERC-4337 Account Factory or preparation address to use for counterfactual verification.
|
21
|
+
* `undefined` if the signature is not in ERC-6492 format.
|
22
|
+
*/
|
23
|
+
address: Address
|
24
|
+
/**
|
25
|
+
* Calldata to pass to deploy account (if not deployed) for counterfactual verification.
|
26
|
+
* `undefined` if the signature is not in ERC-6492 format.
|
27
|
+
*/
|
28
|
+
data: Hex
|
29
|
+
/** The original signature. */
|
30
|
+
signature: Hex
|
31
|
+
}
|
32
|
+
| {
|
33
|
+
/** The original signature. */
|
34
|
+
signature: Hex
|
35
|
+
}
|
36
|
+
>
|
37
|
+
>
|
38
|
+
|
39
|
+
export type ParseErc6492SignatureErrorType =
|
40
|
+
| IsErc6492SignatureErrorType
|
41
|
+
| DecodeAbiParametersErrorType
|
42
|
+
| ErrorType
|
43
|
+
|
44
|
+
/**
|
45
|
+
* @description Parses a hex-formatted ERC-6492 flavoured signature.
|
46
|
+
* If the signature is not in ERC-6492 format, then the underlying (original) signature is returned.
|
47
|
+
*
|
48
|
+
* @param signature ERC-6492 signature in hex format.
|
49
|
+
* @returns The parsed ERC-6492 signature.
|
50
|
+
*
|
51
|
+
* @example
|
52
|
+
* parseSignature('0x000000000000000000000000cafebabecafebabecafebabecafebabecafebabe000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000004deadbeef000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041a461f509887bd19e312c0c58467ce8ff8e300d3c1a90b608a760c5b80318eaf15fe57c96f9175d6cd4daad4663763baa7e78836e067d0163e9a2ccf2ff753f5b1b000000000000000000000000000000000000000000000000000000000000006492649264926492649264926492649264926492649264926492649264926492')
|
53
|
+
* // { address: '0x...', data: '0x...', signature: '0x...' }
|
54
|
+
*/
|
55
|
+
export function parseErc6492Signature(
|
56
|
+
signature: ParseErc6492SignatureParameters,
|
57
|
+
): ParseErc6492SignatureReturnType {
|
58
|
+
if (!isErc6492Signature(signature)) return { signature }
|
59
|
+
|
60
|
+
const [address, data, signature_] = decodeAbiParameters(
|
61
|
+
[{ type: 'address' }, { type: 'bytes' }, { type: 'bytes' }],
|
62
|
+
signature,
|
63
|
+
)
|
64
|
+
return { address, data, signature: signature_ }
|
65
|
+
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import type { Address } from 'abitype'
|
2
|
+
import { erc6492MagicBytes } from '../../constants/bytes.js'
|
3
|
+
import type { ErrorType } from '../../errors/utils.js'
|
4
|
+
import type { Hex } from '../../types/misc.js'
|
5
|
+
import { encodeAbiParameters } from '../../utils/abi/encodeAbiParameters.js'
|
6
|
+
import { concatHex } from '../../utils/data/concat.js'
|
7
|
+
|
8
|
+
export type SerializeErc6492SignatureParameters = {
|
9
|
+
/** The ERC-4337 Account Factory address to use for counterfactual verification. */
|
10
|
+
address: Address
|
11
|
+
/** Calldata to pass to deploy account (if not deployed) for counterfactual verification. */
|
12
|
+
data: Hex
|
13
|
+
/** The original signature. */
|
14
|
+
signature: Hex
|
15
|
+
}
|
16
|
+
|
17
|
+
export type SerializeErc6492SignatureReturnType = Hex
|
18
|
+
|
19
|
+
export type SerializeErc6492SignatureErrorType = ErrorType
|
20
|
+
|
21
|
+
/**
|
22
|
+
* @description Serializes a ERC-6492 flavoured signature into hex format.
|
23
|
+
*
|
24
|
+
* @param signature ERC-6492 signature in object format.
|
25
|
+
* @returns ERC-6492 signature in hex format.
|
26
|
+
*
|
27
|
+
* @example
|
28
|
+
* serializeSignature({ address: '0x...', data: '0x...', signature: '0x...' })
|
29
|
+
* // '0x000000000000000000000000cafebabecafebabecafebabecafebabecafebabe000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000004deadbeef000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041a461f509887bd19e312c0c58467ce8ff8e300d3c1a90b608a760c5b80318eaf15fe57c96f9175d6cd4daad4663763baa7e78836e067d0163e9a2ccf2ff753f5b1b000000000000000000000000000000000000000000000000000000000000006492649264926492649264926492649264926492649264926492649264926492'
|
30
|
+
*/
|
31
|
+
export function serializeErc6492Signature(
|
32
|
+
parameters: SerializeErc6492SignatureParameters,
|
33
|
+
): SerializeErc6492SignatureReturnType {
|
34
|
+
const { address, data, signature } = parameters
|
35
|
+
return concatHex([
|
36
|
+
encodeAbiParameters(
|
37
|
+
[{ type: 'address' }, { type: 'bytes' }, { type: 'bytes' }],
|
38
|
+
[address, data, signature],
|
39
|
+
),
|
40
|
+
erc6492MagicBytes,
|
41
|
+
])
|
42
|
+
}
|
package/experimental/index.ts
CHANGED
@@ -76,3 +76,22 @@ export {
|
|
76
76
|
type WalletActionsEip5792,
|
77
77
|
walletActionsEip5792,
|
78
78
|
} from './eip5792/decorators/eip5792.js'
|
79
|
+
|
80
|
+
export {
|
81
|
+
type ParseErc6492SignatureErrorType,
|
82
|
+
type ParseErc6492SignatureParameters,
|
83
|
+
type ParseErc6492SignatureReturnType,
|
84
|
+
parseErc6492Signature,
|
85
|
+
} from './erc6492/parseErc6492Signature.js'
|
86
|
+
export {
|
87
|
+
type IsErc6492SignatureErrorType,
|
88
|
+
type IsErc6492SignatureParameters,
|
89
|
+
type IsErc6492SignatureReturnType,
|
90
|
+
isErc6492Signature,
|
91
|
+
} from './erc6492/isErc6492Signature.js'
|
92
|
+
export {
|
93
|
+
type SerializeErc6492SignatureErrorType,
|
94
|
+
type SerializeErc6492SignatureParameters,
|
95
|
+
type SerializeErc6492SignatureReturnType,
|
96
|
+
serializeErc6492Signature,
|
97
|
+
} from './erc6492/serializeErc6492Signature.js'
|
package/index.ts
CHANGED
@@ -1209,13 +1209,21 @@ export {
|
|
1209
1209
|
compactSignatureToSignature,
|
1210
1210
|
} from './utils/signature/compactSignatureToSignature.js'
|
1211
1211
|
export {
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
type
|
1217
|
-
|
1218
|
-
} from './utils/signature/
|
1212
|
+
/** @deprecated Use `ParseCompactSignatureErrorType`. */
|
1213
|
+
type ParseCompactSignatureErrorType as HexToCompactSignatureErrorType,
|
1214
|
+
/** @deprecated Use `parseCompactSignature`. */
|
1215
|
+
parseCompactSignature as hexToCompactSignature,
|
1216
|
+
type ParseCompactSignatureErrorType,
|
1217
|
+
parseCompactSignature,
|
1218
|
+
} from './utils/signature/parseCompactSignature.js'
|
1219
|
+
export {
|
1220
|
+
/** @deprecated Use `ParseSignatureErrorType`. */
|
1221
|
+
type ParseSignatureErrorType as HexToSignatureErrorType,
|
1222
|
+
/** @deprecated Use `parseSignature`. */
|
1223
|
+
parseSignature as hexToSignature,
|
1224
|
+
type ParseSignatureErrorType,
|
1225
|
+
parseSignature,
|
1226
|
+
} from './utils/signature/parseSignature.js'
|
1219
1227
|
export {
|
1220
1228
|
type RecoverAddressErrorType,
|
1221
1229
|
type RecoverAddressParameters,
|
@@ -1251,13 +1259,21 @@ export {
|
|
1251
1259
|
signatureToCompactSignature,
|
1252
1260
|
} from './utils/signature/signatureToCompactSignature.js'
|
1253
1261
|
export {
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
type
|
1259
|
-
|
1260
|
-
} from './utils/signature/
|
1262
|
+
/** @deprecated Use `SignatureToHexErrorType` instead. */
|
1263
|
+
type SerializeCompactSignatureErrorType as CompactSignatureToHexErrorType,
|
1264
|
+
/** @deprecated Use `serializeCompactSignature` instead. */
|
1265
|
+
serializeCompactSignature as compactSignatureToHex,
|
1266
|
+
type SerializeCompactSignatureErrorType,
|
1267
|
+
serializeCompactSignature,
|
1268
|
+
} from './utils/signature/serializeCompactSignature.js'
|
1269
|
+
export {
|
1270
|
+
/** @deprecated Use `SignatureToHexErrorType` instead. */
|
1271
|
+
type SerializeSignatureErrorType as SignatureToHexErrorType,
|
1272
|
+
/** @deprecated Use `serializeSignature` instead. */
|
1273
|
+
serializeSignature as signatureToHex,
|
1274
|
+
type SerializeSignatureErrorType,
|
1275
|
+
serializeSignature,
|
1276
|
+
} from './utils/signature/serializeSignature.js'
|
1261
1277
|
export {
|
1262
1278
|
bytesToRlp,
|
1263
1279
|
type BytesToRlpErrorType,
|
package/package.json
CHANGED
@@ -24,6 +24,16 @@ export type ParseAvatarRecordErrorType =
|
|
24
24
|
| ParseAvatarUriErrorType
|
25
25
|
| ErrorType
|
26
26
|
|
27
|
+
/*
|
28
|
+
* @description Parses an ENS avatar record.
|
29
|
+
*
|
30
|
+
* @example
|
31
|
+
* parseAvatarRecord('eip155:1/erc1155:0xb32979486938aa9694bfc898f35dbed459f44424/10063')
|
32
|
+
* 'https://ipfs.io/ipfs/QmSP4nq9fnN9dAiCj42ug9Wa79rqmQerZXZch82VqpiH7U/image.gif'
|
33
|
+
*
|
34
|
+
* @see https://docs.ens.domains/web/avatars
|
35
|
+
*
|
36
|
+
*/
|
27
37
|
export async function parseAvatarRecord<TChain extends Chain | undefined>(
|
28
38
|
client: Client<Transport, TChain>,
|
29
39
|
{
|
@@ -19,6 +19,13 @@ export type PacketToBytesErrorType =
|
|
19
19
|
|
20
20
|
/*
|
21
21
|
* @description Encodes a DNS packet into a ByteArray containing a UDP payload.
|
22
|
+
*
|
23
|
+
* @example
|
24
|
+
* packetToBytes('awkweb.eth')
|
25
|
+
* '0x0661776b7765620365746800'
|
26
|
+
*
|
27
|
+
* @see https://docs.ens.domains/resolution/names#dns
|
28
|
+
*
|
22
29
|
*/
|
23
30
|
export function packetToBytes(packet: string): ByteArray {
|
24
31
|
// strip leading and trailing `.`
|
@@ -15,7 +15,7 @@ export type CompactSignatureToSignatureErrorType =
|
|
15
15
|
* @returns The compact signature in signature format.
|
16
16
|
*
|
17
17
|
* @example
|
18
|
-
*
|
18
|
+
* compactSignatureToSignature({
|
19
19
|
* r: '0x68a020a209d3d56c46f38cc50a33f704f4a9a10a59377f8dd762ac66910e9b90',
|
20
20
|
* yParityAndS: '0x7e865ad05c4035ab5792787d4a0297a43617ae897930a6fe4d822b8faea52064',
|
21
21
|
* })
|
@@ -2,12 +2,9 @@ import { secp256k1 } from '@noble/curves/secp256k1'
|
|
2
2
|
|
3
3
|
import type { ErrorType } from '../../errors/utils.js'
|
4
4
|
import type { CompactSignature, Hex } from '../../types/misc.js'
|
5
|
-
import {
|
6
|
-
type NumberToHexErrorType,
|
7
|
-
numberToHex,
|
8
|
-
} from '../../utils/encoding/toHex.js'
|
5
|
+
import { type NumberToHexErrorType, numberToHex } from '../encoding/toHex.js'
|
9
6
|
|
10
|
-
export type
|
7
|
+
export type ParseCompactSignatureErrorType = NumberToHexErrorType | ErrorType
|
11
8
|
|
12
9
|
/**
|
13
10
|
* @description Parses a hex formatted compact signature into a structured compact signature.
|
@@ -16,10 +13,10 @@ export type HexToCompactSignatureErrorType = NumberToHexErrorType | ErrorType
|
|
16
13
|
* @returns The structured signature.
|
17
14
|
*
|
18
15
|
* @example
|
19
|
-
*
|
16
|
+
* parseCompactSignature('0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db81c')
|
20
17
|
* // { r: '0x...', yParityAndS: '0x...' }
|
21
18
|
*/
|
22
|
-
export function
|
19
|
+
export function parseCompactSignature(signatureHex: Hex): CompactSignature {
|
23
20
|
const { r, s } = secp256k1.Signature.fromCompact(signatureHex.slice(2, 130))
|
24
21
|
return {
|
25
22
|
r: numberToHex(r, { size: 32 }),
|
@@ -7,7 +7,7 @@ import {
|
|
7
7
|
numberToHex,
|
8
8
|
} from '../../utils/encoding/toHex.js'
|
9
9
|
|
10
|
-
export type
|
10
|
+
export type ParseSignatureErrorType = NumberToHexErrorType | ErrorType
|
11
11
|
|
12
12
|
/**
|
13
13
|
* @description Parses a hex formatted signature into a structured signature.
|
@@ -16,10 +16,10 @@ export type HexToSignatureErrorType = NumberToHexErrorType | ErrorType
|
|
16
16
|
* @returns The structured signature.
|
17
17
|
*
|
18
18
|
* @example
|
19
|
-
*
|
19
|
+
* parseSignature('0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db81c')
|
20
20
|
* // { r: '0x...', s: '0x...', v: 28n }
|
21
21
|
*/
|
22
|
-
export function
|
22
|
+
export function parseSignature(signatureHex: Hex) {
|
23
23
|
const { r, s } = secp256k1.Signature.fromCompact(signatureHex.slice(2, 130))
|
24
24
|
const yParityOrV = Number(`0x${signatureHex.slice(130)}`)
|
25
25
|
const [v, yParity] = (() => {
|
@@ -12,7 +12,7 @@ import {
|
|
12
12
|
type RecoverAddressErrorType,
|
13
13
|
recoverAddress,
|
14
14
|
} from './recoverAddress.js'
|
15
|
-
import type {
|
15
|
+
import type { SerializeSignatureErrorType } from './serializeSignature.js'
|
16
16
|
|
17
17
|
export type RecoverTransactionAddressParameters = {
|
18
18
|
serializedTransaction: TransactionSerialized
|
@@ -25,7 +25,7 @@ export type RecoverTransactionAddressErrorType =
|
|
25
25
|
| SerializeTransactionErrorType
|
26
26
|
| RecoverAddressErrorType
|
27
27
|
| Keccak256ErrorType
|
28
|
-
|
|
28
|
+
| SerializeSignatureErrorType
|
29
29
|
| ErrorType
|
30
30
|
|
31
31
|
export async function recoverTransactionAddress(
|
@@ -3,7 +3,9 @@ import type { ErrorType } from '../../errors/utils.js'
|
|
3
3
|
import type { CompactSignature, Hex } from '../../types/misc.js'
|
4
4
|
import { type HexToBigIntErrorType, hexToBigInt } from '../encoding/fromHex.js'
|
5
5
|
|
6
|
-
export type
|
6
|
+
export type SerializeCompactSignatureErrorType =
|
7
|
+
| HexToBigIntErrorType
|
8
|
+
| ErrorType
|
7
9
|
|
8
10
|
/**
|
9
11
|
* @description Converts an [EIP-2098 compact signature](https://eips.ethereum.org/EIPS/eip-2098) into hex format.
|
@@ -12,13 +14,13 @@ export type CompactSignatureToHexErrorType = HexToBigIntErrorType | ErrorType
|
|
12
14
|
* @returns The compact signature in hex format.
|
13
15
|
*
|
14
16
|
* @example
|
15
|
-
*
|
17
|
+
* serializeCompactSignature({
|
16
18
|
* r: '0x68a020a209d3d56c46f38cc50a33f704f4a9a10a59377f8dd762ac66910e9b90',
|
17
19
|
* yParityAndS: '0x7e865ad05c4035ab5792787d4a0297a43617ae897930a6fe4d822b8faea52064',
|
18
20
|
* })
|
19
21
|
* // "0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db81c"
|
20
22
|
*/
|
21
|
-
export function
|
23
|
+
export function serializeCompactSignature({
|
22
24
|
r,
|
23
25
|
yParityAndS,
|
24
26
|
}: CompactSignature): Hex {
|
@@ -2,13 +2,10 @@ import { secp256k1 } from '@noble/curves/secp256k1'
|
|
2
2
|
|
3
3
|
import type { ErrorType } from '../../errors/utils.js'
|
4
4
|
import type { Hex, Signature } from '../../types/misc.js'
|
5
|
-
import {
|
6
|
-
|
7
|
-
hexToBigInt,
|
8
|
-
} from '../../utils/encoding/fromHex.js'
|
9
|
-
import type { ToHexErrorType } from '../../utils/encoding/toHex.js'
|
5
|
+
import { type HexToBigIntErrorType, hexToBigInt } from '../encoding/fromHex.js'
|
6
|
+
import type { ToHexErrorType } from '../encoding/toHex.js'
|
10
7
|
|
11
|
-
export type
|
8
|
+
export type SerializeSignatureErrorType =
|
12
9
|
| HexToBigIntErrorType
|
13
10
|
| ToHexErrorType
|
14
11
|
| ErrorType
|
@@ -20,14 +17,14 @@ export type SignatureToHexErrorType =
|
|
20
17
|
* @returns The signature in hex format.
|
21
18
|
*
|
22
19
|
* @example
|
23
|
-
*
|
20
|
+
* serializeSignature({
|
24
21
|
* r: '0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf',
|
25
22
|
* s: '0x4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db8',
|
26
23
|
* yParity: 1
|
27
24
|
* })
|
28
25
|
* // "0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db81c"
|
29
26
|
*/
|
30
|
-
export function
|
27
|
+
export function serializeSignature({ r, s, v, yParity }: Signature): Hex {
|
31
28
|
const yParity_ = (() => {
|
32
29
|
if (yParity === 0 || yParity === 1) return yParity
|
33
30
|
if (v && (v === 27n || v === 28n || v >= 35n)) return v % 2n === 0n ? 1 : 0
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"compactSignatureToHex.js","sourceRoot":"","sources":["../../../utils/signature/compactSignatureToHex.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;AAGnD,uDAA+E;AAiB/E,SAAgB,qBAAqB,CAAC,EACpC,CAAC,EACD,WAAW,GACM;IACjB,OAAO,KAAK,IAAI,qBAAS,CAAC,SAAS,CACjC,IAAA,wBAAW,EAAC,CAAC,CAAC,EACd,IAAA,wBAAW,EAAC,WAAW,CAAC,CACzB,CAAC,YAAY,EAAE,EAAE,CAAA;AACpB,CAAC;AARD,sDAQC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"signatureToHex.js","sourceRoot":"","sources":["../../../utils/signature/signatureToHex.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;AAInD,gEAGwC;AAsBxC,SAAgB,cAAc,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,OAAO,EAAa;IAC5D,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE;QACrB,IAAI,OAAO,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC;YAAE,OAAO,OAAO,CAAA;QAClD,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,GAAG,CAAC;YAAE,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QAC3E,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;IACnD,CAAC,CAAC,EAAE,CAAA;IACJ,OAAO,KAAK,IAAI,qBAAS,CAAC,SAAS,CACjC,IAAA,wBAAW,EAAC,CAAC,CAAC,EACd,IAAA,wBAAW,EAAC,CAAC,CAAC,CACf,CAAC,YAAY,EAAE,GAAG,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;AACnD,CAAC;AAVD,wCAUC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"compactSignatureToHex.js","sourceRoot":"","sources":["../../../utils/signature/compactSignatureToHex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAGnD,OAAO,EAA6B,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAI/E;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,qBAAqB,CAAC,EACpC,CAAC,EACD,WAAW,GACM;IACjB,OAAO,KAAK,IAAI,SAAS,CAAC,SAAS,CACjC,WAAW,CAAC,CAAC,CAAC,EACd,WAAW,CAAC,WAAW,CAAC,CACzB,CAAC,YAAY,EAAE,EAAE,CAAA;AACpB,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"hexToCompactSignature.js","sourceRoot":"","sources":["../../../utils/signature/hexToCompactSignature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAInD,OAAO,EAEL,WAAW,GACZ,MAAM,+BAA+B,CAAA;AAItC;;;;;;;;;GASG;AACH,MAAM,UAAU,qBAAqB,CAAC,YAAiB;IACrD,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,SAAS,CAAC,WAAW,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAA;IAC5E,OAAO;QACL,CAAC,EAAE,WAAW,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;QAC/B,WAAW,EAAE,WAAW,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;KAC1C,CAAA;AACH,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"signatureToHex.js","sourceRoot":"","sources":["../../../utils/signature/signatureToHex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAInD,OAAO,EAEL,WAAW,GACZ,MAAM,iCAAiC,CAAA;AAQxC;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,cAAc,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,OAAO,EAAa;IAC5D,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE;QACrB,IAAI,OAAO,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC;YAAE,OAAO,OAAO,CAAA;QAClD,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,GAAG,CAAC;YAAE,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QAC3E,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;IACnD,CAAC,CAAC,EAAE,CAAA;IACJ,OAAO,KAAK,IAAI,SAAS,CAAC,SAAS,CACjC,WAAW,CAAC,CAAC,CAAC,EACd,WAAW,CAAC,CAAC,CAAC,CACf,CAAC,YAAY,EAAE,GAAG,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;AACnD,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"compactSignatureToHex.d.ts","sourceRoot":"","sources":["../../../utils/signature/compactSignatureToHex.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAA;AAChE,OAAO,EAAE,KAAK,oBAAoB,EAAe,MAAM,wBAAwB,CAAA;AAE/E,MAAM,MAAM,8BAA8B,GAAG,oBAAoB,GAAG,SAAS,CAAA;AAE7E;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,CAAC,EACD,WAAW,GACZ,EAAE,gBAAgB,GAAG,GAAG,CAKxB"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"hexToCompactSignature.d.ts","sourceRoot":"","sources":["../../../utils/signature/hexToCompactSignature.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAA;AAChE,OAAO,EACL,KAAK,oBAAoB,EAE1B,MAAM,+BAA+B,CAAA;AAEtC,MAAM,MAAM,8BAA8B,GAAG,oBAAoB,GAAG,SAAS,CAAA;AAE7E;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,GAAG,GAAG,gBAAgB,CAMzE"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"signatureToHex.d.ts","sourceRoot":"","sources":["../../../utils/signature/signatureToHex.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,EACL,KAAK,oBAAoB,EAE1B,MAAM,iCAAiC,CAAA;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAEnE,MAAM,MAAM,uBAAuB,GAC/B,oBAAoB,GACpB,cAAc,GACd,SAAS,CAAA;AAEb;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,SAAS,GAAG,GAAG,CAUnE"}
|