ox 0.14.57 → 0.14.59
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 +26 -0
- package/_cjs/core/AbiEvent.js +16 -4
- package/_cjs/core/AbiEvent.js.map +1 -1
- package/_cjs/core/Authorization.js +37 -6
- package/_cjs/core/Authorization.js.map +1 -1
- package/_cjs/core/Hex.js +5 -3
- package/_cjs/core/Hex.js.map +1 -1
- package/_cjs/core/RpcTransport.js +32 -19
- package/_cjs/core/RpcTransport.js.map +1 -1
- package/_cjs/core/Siwe.js +1 -1
- package/_cjs/core/Siwe.js.map +1 -1
- package/_cjs/core/TypedData.js +1 -1
- package/_cjs/core/TypedData.js.map +1 -1
- package/_cjs/core/internal/abiItem.js +46 -14
- package/_cjs/core/internal/abiItem.js.map +1 -1
- package/_cjs/tempo/AccountConfig.js +3 -10
- package/_cjs/tempo/AccountConfig.js.map +1 -1
- package/_cjs/tempo/index.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/core/AbiEvent.js +19 -4
- package/_esm/core/AbiEvent.js.map +1 -1
- package/_esm/core/Authorization.js +47 -6
- package/_esm/core/Authorization.js.map +1 -1
- package/_esm/core/Hex.js +5 -3
- package/_esm/core/Hex.js.map +1 -1
- package/_esm/core/RpcTransport.js +38 -19
- package/_esm/core/RpcTransport.js.map +1 -1
- package/_esm/core/Siwe.js +1 -1
- package/_esm/core/Siwe.js.map +1 -1
- package/_esm/core/TypedData.js +1 -1
- package/_esm/core/TypedData.js.map +1 -1
- package/_esm/core/internal/abiItem.js +51 -17
- package/_esm/core/internal/abiItem.js.map +1 -1
- package/_esm/tempo/AccountConfig.js +8 -26
- package/_esm/tempo/AccountConfig.js.map +1 -1
- package/_esm/tempo/AccountOperation.js +1 -1
- package/_esm/tempo/index.js +1 -3
- package/_esm/tempo/index.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/core/AbiEvent.d.ts.map +1 -1
- package/_types/core/Authorization.d.ts.map +1 -1
- package/_types/core/Hex.d.ts +13 -1
- package/_types/core/Hex.d.ts.map +1 -1
- package/_types/core/RpcTransport.d.ts.map +1 -1
- package/_types/core/Siwe.d.ts.map +1 -1
- package/_types/core/internal/abiItem.d.ts.map +1 -1
- package/_types/tempo/AccountConfig.d.ts +7 -17
- package/_types/tempo/AccountConfig.d.ts.map +1 -1
- package/_types/tempo/AccountOperation.d.ts +1 -1
- package/_types/tempo/index.d.ts +1 -3
- package/_types/tempo/index.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/core/AbiEvent.ts +24 -3
- package/core/Authorization.ts +46 -6
- package/core/Hex.ts +17 -3
- package/core/RpcTransport.ts +40 -22
- package/core/Siwe.ts +1 -1
- package/core/TypedData.ts +1 -1
- package/core/internal/abiItem.ts +70 -21
- package/package.json +1 -1
- package/tempo/AccountConfig.test.ts +34 -47
- package/tempo/AccountConfig.ts +9 -37
- package/tempo/AccountOperation.test.ts +36 -37
- package/tempo/AccountOperation.ts +1 -1
- package/tempo/SignatureEnvelope.test.ts +1 -3
- package/tempo/configurableAccounts.e2e.test.ts +1 -2
- package/tempo/index.ts +1 -3
- package/version.ts +1 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as Address from '../core/Address.js';
|
|
2
2
|
import type * as Bytes from '../core/Bytes.js';
|
|
3
|
-
import * as ContractAddress from '../core/ContractAddress.js';
|
|
4
3
|
import * as Errors from '../core/Errors.js';
|
|
5
4
|
import * as Hash from '../core/Hash.js';
|
|
6
5
|
import * as Hex from '../core/Hex.js';
|
|
@@ -217,9 +216,9 @@ export declare namespace fromUpgrade {
|
|
|
217
216
|
/**
|
|
218
217
|
* Derives the stable configurable account address.
|
|
219
218
|
*
|
|
220
|
-
* The
|
|
221
|
-
* big-endian fields, not RLP
|
|
222
|
-
*
|
|
219
|
+
* The address is the last 20 bytes of the keccak256 hash of the initial
|
|
220
|
+
* config, encoded with fixed-width big-endian fields, not RLP:
|
|
221
|
+
* `keccak256("tempo:configurable-account:account" || salt || uint8(threshold) || uint8(owners.length) || owners)`.
|
|
223
222
|
*
|
|
224
223
|
* The address is derived once from the initial version-0 config. Config
|
|
225
224
|
* updates do not change it.
|
|
@@ -235,22 +234,15 @@ export declare namespace fromUpgrade {
|
|
|
235
234
|
* threshold: 1,
|
|
236
235
|
* })
|
|
237
236
|
*
|
|
238
|
-
* const address = AccountConfig.getAddress(initialConfig
|
|
239
|
-
* factory: '0x7171717171717171717171717171717171717171'
|
|
240
|
-
* })
|
|
237
|
+
* const address = AccountConfig.getAddress(initialConfig)
|
|
241
238
|
* ```
|
|
242
239
|
*
|
|
243
240
|
* @param config - The initial account config.
|
|
244
|
-
* @param options - The recovery factory configured by the chain.
|
|
245
241
|
* @returns The configurable account address.
|
|
246
242
|
*/
|
|
247
|
-
export declare function getAddress(config: Input
|
|
243
|
+
export declare function getAddress(config: Input): Address.Address;
|
|
248
244
|
export declare namespace getAddress {
|
|
249
|
-
type
|
|
250
|
-
/** Recovery factory configured by the chain. */
|
|
251
|
-
factory: Address.Address;
|
|
252
|
-
};
|
|
253
|
-
type ErrorType = assert.ErrorType | ContractAddress.fromCreate2.ErrorType | Hash.keccak256.ErrorType | Hex.concat.ErrorType | Hex.fromNumber.ErrorType | Hex.fromString.ErrorType | Errors.GlobalErrorType;
|
|
245
|
+
type ErrorType = assert.ErrorType | Hash.keccak256.ErrorType | Hex.concat.ErrorType | Hex.fromNumber.ErrorType | Hex.fromString.ErrorType | Hex.slice.ErrorType | Errors.GlobalErrorType;
|
|
254
246
|
}
|
|
255
247
|
/**
|
|
256
248
|
* Computes the commitment for an account configuration.
|
|
@@ -306,9 +298,7 @@ export declare namespace getCommitment {
|
|
|
306
298
|
* })
|
|
307
299
|
*
|
|
308
300
|
* const digest = AccountConfig.getSignPayload({
|
|
309
|
-
* account: AccountConfig.getAddress(config,
|
|
310
|
-
* factory: '0x7171717171717171717171717171717171717171'
|
|
311
|
-
* }),
|
|
301
|
+
* account: AccountConfig.getAddress(config),
|
|
312
302
|
* config,
|
|
313
303
|
* payload: TxEnvelopeTempo.getSignPayload(envelope),
|
|
314
304
|
* })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountConfig.d.ts","sourceRoot":"","sources":["../../tempo/AccountConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAA;AAC7C,OAAO,KAAK,KAAK,KAAK,MAAM,kBAAkB,CAAA;AAC9C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"AccountConfig.d.ts","sourceRoot":"","sources":["../../tempo/AccountConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAA;AAC7C,OAAO,KAAK,KAAK,KAAK,MAAM,kBAAkB,CAAA;AAC9C,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAC3C,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAA;AACvC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAA;AACrC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AAExD,oEAAoE;AACpE,eAAO,MAAM,sBAAsB,OAAO,CAAA;AAE1C,6DAA6D;AAC7D,eAAO,MAAM,SAAS,KAAK,CAAA;AAE3B,6EAA6E;AAC7E,eAAO,MAAM,aAAa,IAAI,CAAA;AAE9B;;;;;GAKG;AACH,eAAO,MAAM,YAAY,MAAO,CAAA;AAEhC,qDAAqD;AACrD,eAAO,MAAM,UAAU,QAAiB,CAAA;AAExC,qEAAqE;AACrE,eAAO,MAAM,iBAAiB,QAAkB,CAAA;AAEhD,gEAAgE;AAChE,eAAO,MAAM,QAAQ,eAAkC,CAAA;AAcvD;;GAEG;AACH,MAAM,MAAM,MAAM,CAAC,UAAU,GAAG,MAAM,EAAE,UAAU,GAAG,MAAM,IAAI,OAAO,CAAC;IACrE,gEAAgE;IAChE,MAAM,EAAE,SAAS,KAAK,CAAC,UAAU,CAAC,EAAE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AAS,GAChB,GAAG,CAAC,UAAU,CAAC,SAAS,GACxB,MAAM,CAAC,eAAe,CAAA;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,KAAK,GAAG,KAAK,CAe5C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,MAAM,CAAC,UAAU,GAAG,MAAM,EACxC,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,EAAE,UAAU,CAAC,EAC1C,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,GAClC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAU5B;AAED,MAAM,CAAC,OAAO,WAAW,MAAM,CAAC;IAC9B,KAAK,OAAO,CAAC,UAAU,GAAG,MAAM,IAAI;QAClC,gEAAgE;QAChE,MAAM,EAAE,SAAS,KAAK,CAAC,UAAU,CAAC,EAAE,CAAA;QACpC,yEAAyE;QACzE,SAAS,EAAE,UAAU,CAAA;KACtB,CAAA;IAED,KAAK,SAAS,GACV,MAAM,CAAC,SAAS,GAChB,kBAAkB,GAClB,MAAM,CAAC,eAAe,CAAA;CAC3B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,KAAK,GAAG,OAAO,CAO/C;AAED,gDAAgD;AAChD,qBAAa,kBAAmB,SAAQ,MAAM,CAAC,SAAS;IACtD,SAAkB,IAAI,sCAAqC;gBAC/C,EAAE,MAAM,EAAE,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE;CAG3C"}
|
|
@@ -105,7 +105,7 @@ export declare namespace getHash {
|
|
|
105
105
|
* The function retains one canonical approval per owner. It selects the
|
|
106
106
|
* smallest deterministic quorum by owner weight, then orders the selected
|
|
107
107
|
* approvals by owner address for serialization. The caller supplies the
|
|
108
|
-
* account and config; the chain validates their
|
|
108
|
+
* account and config; the chain validates their derived identity.
|
|
109
109
|
*
|
|
110
110
|
* @example
|
|
111
111
|
* ```ts twoslash
|
package/_types/tempo/index.d.ts
CHANGED
|
@@ -22,9 +22,7 @@ export type {};
|
|
|
22
22
|
* ],
|
|
23
23
|
* })
|
|
24
24
|
*
|
|
25
|
-
* const account = AccountConfig.getAddress(initialConfig
|
|
26
|
-
* factory: '0x7171717171717171717171717171717171717171'
|
|
27
|
-
* })
|
|
25
|
+
* const account = AccountConfig.getAddress(initialConfig)
|
|
28
26
|
* ```
|
|
29
27
|
*
|
|
30
28
|
* @category Reference
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../tempo/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAEhC,YAAY,EAAE,CAAA;AAEd
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../tempo/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAEhC,YAAY,EAAE,CAAA;AAEd;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AACnD;;;;;;;GAOG;AACH,OAAO,KAAK,gBAAgB,MAAM,uBAAuB,CAAA;AACzD;;;;;;;GAOG;AACH,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAA;AAC3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,KAAK,kBAAkB,MAAM,yBAAyB,CAAA;AAC7D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,OAAO,KAAK,gBAAgB,MAAM,uBAAuB,CAAA;AACzD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,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,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,KAAK,qBAAqB,MAAM,4BAA4B,CAAA"}
|
package/_types/version.d.ts
CHANGED
package/core/AbiEvent.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type * as AbiItem_internal from './internal/abiItem.js'
|
|
|
12
12
|
import * as Cursor from './internal/cursor.js'
|
|
13
13
|
import { prettyPrint } from './internal/errors.js'
|
|
14
14
|
import type { Compute, IsNarrowable } from './internal/types.js'
|
|
15
|
+
import * as Solidity from './Solidity.js'
|
|
15
16
|
|
|
16
17
|
/** Root type for an {@link ox#AbiItem.AbiItem} with an `event` type. */
|
|
17
18
|
export type AbiEvent = abitype.AbiEvent & {
|
|
@@ -136,9 +137,29 @@ export function assertArgs<const abiEvent extends AbiEvent>(
|
|
|
136
137
|
) {
|
|
137
138
|
if (input.type === 'address')
|
|
138
139
|
return Address.isEqual(value as Address.Address, arg as Address.Address)
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
if (input.
|
|
140
|
+
// Indexed `string` and `bytes` topics hold the keccak256 of their contents.
|
|
141
|
+
// Values decoded from data hold the contents.
|
|
142
|
+
if (input.indexed) {
|
|
143
|
+
if (input.type === 'string')
|
|
144
|
+
return (
|
|
145
|
+
Hash.keccak256(Bytes.fromString(value as string), { as: 'Hex' }) ===
|
|
146
|
+
arg
|
|
147
|
+
)
|
|
148
|
+
if (input.type === 'bytes') {
|
|
149
|
+
const hex =
|
|
150
|
+
typeof value === 'string'
|
|
151
|
+
? (value as Hex.Hex)
|
|
152
|
+
: Hex.fromBytes(value as Bytes.Bytes)
|
|
153
|
+
return Hash.keccak256(hex, { as: 'Hex' }) === arg
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
// Decoded `bytes` and `bytesN` are lowercase hex, so match either case.
|
|
157
|
+
if (
|
|
158
|
+
typeof value === 'string' &&
|
|
159
|
+
typeof arg === 'string' &&
|
|
160
|
+
Solidity.bytesRegex.test(input.type)
|
|
161
|
+
)
|
|
162
|
+
return value.toLowerCase() === arg.toLowerCase()
|
|
142
163
|
return value === arg
|
|
143
164
|
}
|
|
144
165
|
|
package/core/Authorization.ts
CHANGED
|
@@ -175,7 +175,11 @@ export declare namespace from {
|
|
|
175
175
|
*/
|
|
176
176
|
export function fromRpc(authorization: Rpc): Signed {
|
|
177
177
|
const { address, chainId, nonce } = authorization
|
|
178
|
-
|
|
178
|
+
// EIP-7702 permits any `y_parity` below 2**8 in an authorization tuple, so
|
|
179
|
+
// check `yParity` against one byte rather than against 0 or 1.
|
|
180
|
+
const signature = Signature.fromRpc(authorization)
|
|
181
|
+
Signature.assert({ r: signature.r, s: signature.s })
|
|
182
|
+
assertYParity(signature.yParity)
|
|
179
183
|
|
|
180
184
|
return {
|
|
181
185
|
address,
|
|
@@ -272,8 +276,18 @@ export function fromTuple<const tuple extends Tuple>(
|
|
|
272
276
|
chainId: chainId === '0x' ? 0 : Number(chainId),
|
|
273
277
|
nonce: nonce === '0x' ? 0n : BigInt(nonce),
|
|
274
278
|
}
|
|
275
|
-
if (yParity && r && s)
|
|
276
|
-
|
|
279
|
+
if (yParity && r && s) {
|
|
280
|
+
// EIP-7702 permits any `y_parity` below 2**8 in an authorization tuple, so
|
|
281
|
+
// check `yParity` against one byte rather than against 0 or 1.
|
|
282
|
+
const signature = {
|
|
283
|
+
r: r === '0x' ? 0n : BigInt(r),
|
|
284
|
+
s: s === '0x' ? 0n : BigInt(s),
|
|
285
|
+
yParity: yParity === '0x' ? 0 : Number(yParity),
|
|
286
|
+
}
|
|
287
|
+
Signature.assert({ r: signature.r, s: signature.s })
|
|
288
|
+
assertYParity(signature.yParity)
|
|
289
|
+
args = { ...args, ...signature }
|
|
290
|
+
}
|
|
277
291
|
return from(args) as never
|
|
278
292
|
}
|
|
279
293
|
|
|
@@ -472,12 +486,16 @@ export declare namespace hash {
|
|
|
472
486
|
*/
|
|
473
487
|
export function toRpc(authorization: Signed): Rpc {
|
|
474
488
|
const { address, chainId, nonce, ...signature } = authorization
|
|
489
|
+
assertYParity(signature.yParity)
|
|
475
490
|
|
|
476
491
|
return {
|
|
477
492
|
address,
|
|
478
493
|
chainId: Hex.fromNumber(chainId),
|
|
479
494
|
nonce: Hex.fromNumber(nonce),
|
|
480
495
|
...Signature.toRpc(signature),
|
|
496
|
+
// EIP-7702 permits any `y_parity` below 2**8 in an authorization tuple, so
|
|
497
|
+
// encode `yParity` as is instead of the 0 or 1 of `Signature.toRpc`.
|
|
498
|
+
yParity: Hex.fromNumber(signature.yParity),
|
|
481
499
|
}
|
|
482
500
|
}
|
|
483
501
|
|
|
@@ -540,13 +558,23 @@ export declare namespace toRpcList {
|
|
|
540
558
|
export function toTuple<const authorization extends Authorization>(
|
|
541
559
|
authorization: authorization,
|
|
542
560
|
): toTuple.ReturnType<authorization> {
|
|
543
|
-
const { address, chainId, nonce } = authorization
|
|
544
|
-
const signature = Signature.extract(
|
|
561
|
+
const { address, chainId, nonce, r, s, yParity } = authorization
|
|
562
|
+
const signature = Signature.extract({ r, s })
|
|
563
|
+
if (signature && typeof yParity !== 'undefined') assertYParity(yParity)
|
|
545
564
|
return [
|
|
546
565
|
chainId ? Hex.fromNumber(chainId) : '0x',
|
|
547
566
|
address,
|
|
548
567
|
nonce ? Hex.fromNumber(nonce) : '0x',
|
|
549
|
-
|
|
568
|
+
// EIP-7702 permits any `y_parity` below 2**8 in an authorization tuple, and a
|
|
569
|
+
// tuple that fails recovery does not invalidate the transaction. Encode
|
|
570
|
+
// `yParity` as is, so that serialization preserves the transaction hash.
|
|
571
|
+
...(signature
|
|
572
|
+
? [
|
|
573
|
+
yParity ? Hex.fromNumber(yParity, { size: 1 }) : '0x',
|
|
574
|
+
signature.r === 0n ? '0x' : Hex.trimLeft(Hex.fromNumber(signature.r)),
|
|
575
|
+
signature.s === 0n ? '0x' : Hex.trimLeft(Hex.fromNumber(signature.s)),
|
|
576
|
+
]
|
|
577
|
+
: []),
|
|
550
578
|
] as never
|
|
551
579
|
}
|
|
552
580
|
|
|
@@ -617,3 +645,15 @@ export declare namespace toTupleList {
|
|
|
617
645
|
|
|
618
646
|
type ErrorType = Errors.GlobalErrorType
|
|
619
647
|
}
|
|
648
|
+
|
|
649
|
+
// Asserts that an EIP-7702 authorization `yParity` fits in one byte.
|
|
650
|
+
function assertYParity(yParity: number) {
|
|
651
|
+
if (Number.isInteger(yParity) && yParity >= 0 && yParity < 256) return
|
|
652
|
+
throw new Hex.IntegerOutOfRangeError({
|
|
653
|
+
max: '255',
|
|
654
|
+
min: '0',
|
|
655
|
+
signed: false,
|
|
656
|
+
size: 1,
|
|
657
|
+
value: `${yParity}`,
|
|
658
|
+
})
|
|
659
|
+
}
|
package/core/Hex.ts
CHANGED
|
@@ -34,17 +34,24 @@ export function assert(
|
|
|
34
34
|
value: unknown,
|
|
35
35
|
options: assert.Options = {},
|
|
36
36
|
): asserts value is Hex {
|
|
37
|
-
const { strict = false } = options
|
|
37
|
+
const { even = false, strict = false } = options
|
|
38
38
|
if (!value) throw new InvalidHexTypeError(value)
|
|
39
39
|
if (typeof value !== 'string') throw new InvalidHexTypeError(value)
|
|
40
40
|
if (strict) {
|
|
41
41
|
if (!/^0x[0-9a-fA-F]*$/.test(value)) throw new InvalidHexValueError(value)
|
|
42
42
|
}
|
|
43
43
|
if (!value.startsWith('0x')) throw new InvalidHexValueError(value)
|
|
44
|
+
if (even && value.length % 2 !== 0) throw new InvalidLengthError(value as Hex)
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
export declare namespace assert {
|
|
47
48
|
type Options = {
|
|
49
|
+
/**
|
|
50
|
+
* Checks if the {@link ox#Hex.Hex} value has an even number of hexadecimal characters (whole bytes).
|
|
51
|
+
* Keep disabled for RPC quantities (e.g. `0x0`, `0x400`).
|
|
52
|
+
* @default false
|
|
53
|
+
*/
|
|
54
|
+
even?: boolean | undefined
|
|
48
55
|
/** Checks if the {@link ox#Hex.Hex} value contains invalid hexadecimal characters. @default false */
|
|
49
56
|
strict?: boolean | undefined
|
|
50
57
|
}
|
|
@@ -52,6 +59,7 @@ export declare namespace assert {
|
|
|
52
59
|
type ErrorType =
|
|
53
60
|
| InvalidHexTypeError
|
|
54
61
|
| InvalidHexValueError
|
|
62
|
+
| InvalidLengthError
|
|
55
63
|
| Errors.GlobalErrorType
|
|
56
64
|
}
|
|
57
65
|
|
|
@@ -741,9 +749,9 @@ export function validate(
|
|
|
741
749
|
value: unknown,
|
|
742
750
|
options: validate.Options = {},
|
|
743
751
|
): value is Hex {
|
|
744
|
-
const { strict = false } = options
|
|
752
|
+
const { even = false, strict = false } = options
|
|
745
753
|
try {
|
|
746
|
-
assert(value, { strict })
|
|
754
|
+
assert(value, { even, strict })
|
|
747
755
|
return true
|
|
748
756
|
} catch {
|
|
749
757
|
return false
|
|
@@ -752,6 +760,12 @@ export function validate(
|
|
|
752
760
|
|
|
753
761
|
export declare namespace validate {
|
|
754
762
|
type Options = {
|
|
763
|
+
/**
|
|
764
|
+
* Checks if the {@link ox#Hex.Hex} value has an even number of hexadecimal characters (whole bytes).
|
|
765
|
+
* Keep disabled for RPC quantities (e.g. `0x0`, `0x400`).
|
|
766
|
+
* @default false
|
|
767
|
+
*/
|
|
768
|
+
even?: boolean | undefined
|
|
755
769
|
/** Checks if the {@link ox#Hex.Hex} value contains invalid hexadecimal characters. @default false */
|
|
756
770
|
strict?: boolean | undefined
|
|
757
771
|
}
|
package/core/RpcTransport.ts
CHANGED
|
@@ -95,8 +95,14 @@ export function fromHttp<
|
|
|
95
95
|
? await fetchOptions_(body_)
|
|
96
96
|
: fetchOptions_
|
|
97
97
|
|
|
98
|
-
const response = await promise.withTimeout(
|
|
99
|
-
({ signal }) => {
|
|
98
|
+
const { data, response } = await promise.withTimeout(
|
|
99
|
+
async ({ signal }) => {
|
|
100
|
+
// Abort on whichever signal fires first, so that a caller's
|
|
101
|
+
// `signal` does not disable the timeout.
|
|
102
|
+
const signals = [
|
|
103
|
+
fetchOptions?.signal,
|
|
104
|
+
timeout > 0 ? signal : null,
|
|
105
|
+
].filter((s): s is AbortSignal => Boolean(s))
|
|
100
106
|
const init: RequestInit = {
|
|
101
107
|
...fetchOptions,
|
|
102
108
|
body,
|
|
@@ -105,10 +111,40 @@ export function fromHttp<
|
|
|
105
111
|
...fetchOptions?.headers,
|
|
106
112
|
},
|
|
107
113
|
method: fetchOptions?.method ?? 'POST',
|
|
108
|
-
signal:
|
|
114
|
+
signal: (() => {
|
|
115
|
+
if (signals.length < 2) return signals[0] ?? null
|
|
116
|
+
// Runtimes without `AbortSignal.any` (e.g. Node < 18.17) keep
|
|
117
|
+
// only the caller's signal, as before.
|
|
118
|
+
if (typeof AbortSignal.any !== 'function') return signals[0]!
|
|
119
|
+
return AbortSignal.any(signals)
|
|
120
|
+
})(),
|
|
109
121
|
}
|
|
110
122
|
const request = new Request(url, init)
|
|
111
|
-
|
|
123
|
+
const response = await fetchFn(request)
|
|
124
|
+
|
|
125
|
+
// Read the body within the timeout too, so a response that stalls
|
|
126
|
+
// after its headers cannot hang the request.
|
|
127
|
+
const data = await (async () => {
|
|
128
|
+
if (
|
|
129
|
+
response.headers
|
|
130
|
+
.get('Content-Type')
|
|
131
|
+
?.startsWith('application/json')
|
|
132
|
+
)
|
|
133
|
+
return response.json()
|
|
134
|
+
return response.text().then((data) => {
|
|
135
|
+
try {
|
|
136
|
+
return JSON.parse(data || '{}')
|
|
137
|
+
} catch (_err) {
|
|
138
|
+
if (response.ok)
|
|
139
|
+
throw new MalformedResponseError({
|
|
140
|
+
response: data,
|
|
141
|
+
})
|
|
142
|
+
return { error: data }
|
|
143
|
+
}
|
|
144
|
+
})
|
|
145
|
+
})()
|
|
146
|
+
|
|
147
|
+
return { data, response }
|
|
112
148
|
},
|
|
113
149
|
{
|
|
114
150
|
timeout,
|
|
@@ -116,24 +152,6 @@ export function fromHttp<
|
|
|
116
152
|
},
|
|
117
153
|
)
|
|
118
154
|
|
|
119
|
-
const data = await (async () => {
|
|
120
|
-
if (
|
|
121
|
-
response.headers.get('Content-Type')?.startsWith('application/json')
|
|
122
|
-
)
|
|
123
|
-
return response.json()
|
|
124
|
-
return response.text().then((data) => {
|
|
125
|
-
try {
|
|
126
|
-
return JSON.parse(data || '{}')
|
|
127
|
-
} catch (_err) {
|
|
128
|
-
if (response.ok)
|
|
129
|
-
throw new MalformedResponseError({
|
|
130
|
-
response: data,
|
|
131
|
-
})
|
|
132
|
-
return { error: data }
|
|
133
|
-
}
|
|
134
|
-
})
|
|
135
|
-
})()
|
|
136
|
-
|
|
137
155
|
if (!response.ok)
|
|
138
156
|
throw new HttpError({
|
|
139
157
|
body,
|
package/core/Siwe.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { ExactPartial } from './internal/types.js'
|
|
|
4
4
|
import { uid } from './internal/uid.js'
|
|
5
5
|
|
|
6
6
|
export const domainRegex =
|
|
7
|
-
/^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}(:[0-9]{1,5})?$/
|
|
7
|
+
/^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+(?:[a-zA-Z]{2,63}|[xX][nN]--[a-zA-Z0-9-]{0,58}[a-zA-Z0-9])(:[0-9]{1,5})?$/
|
|
8
8
|
|
|
9
9
|
export const ipRegex =
|
|
10
10
|
/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(:[0-9]{1,5})?$/
|
package/core/TypedData.ts
CHANGED
|
@@ -393,7 +393,7 @@ export function extractEip712DomainTypes(
|
|
|
393
393
|
): Parameter[] {
|
|
394
394
|
return [
|
|
395
395
|
typeof domain?.name === 'string' && { name: 'name', type: 'string' },
|
|
396
|
-
domain?.version && { name: 'version', type: 'string' },
|
|
396
|
+
typeof domain?.version === 'string' && { name: 'version', type: 'string' },
|
|
397
397
|
(typeof domain?.chainId === 'number' ||
|
|
398
398
|
typeof domain?.chainId === 'bigint') && {
|
|
399
399
|
name: 'chainId',
|
package/core/internal/abiItem.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type * as AbiItem from '../AbiItem.js'
|
|
|
4
4
|
import type * as AbiParameters from '../AbiParameters.js'
|
|
5
5
|
import * as Address from '../Address.js'
|
|
6
6
|
import * as Errors from '../Errors.js'
|
|
7
|
+
import { getArrayComponents } from './abiParameters.js'
|
|
7
8
|
import type {
|
|
8
9
|
Compute,
|
|
9
10
|
IsNever,
|
|
@@ -466,8 +467,9 @@ export function normalizeSignature(signature: string): string {
|
|
|
466
467
|
|
|
467
468
|
// Ignore spaces
|
|
468
469
|
if (char === ' ') {
|
|
469
|
-
//
|
|
470
|
-
|
|
470
|
+
// A space directly after a `(` or `,` separator is leading whitespace.
|
|
471
|
+
// Otherwise, it ends the type, so we want to deactivate.
|
|
472
|
+
if (!current.endsWith(',') && !current.endsWith('(')) {
|
|
471
473
|
current = ''
|
|
472
474
|
active = false
|
|
473
475
|
}
|
|
@@ -508,9 +510,12 @@ export function isArgOfType(
|
|
|
508
510
|
if (abiParameterType === 'tuple' && 'components' in abiParameter)
|
|
509
511
|
return Object.values(abiParameter.components).every(
|
|
510
512
|
(component, index) => {
|
|
511
|
-
return
|
|
512
|
-
|
|
513
|
-
|
|
513
|
+
return (
|
|
514
|
+
argType === 'object' &&
|
|
515
|
+
isArgOfType(
|
|
516
|
+
getComponentValue(arg, component, index),
|
|
517
|
+
component as AbiParameters.Parameter,
|
|
518
|
+
)
|
|
514
519
|
)
|
|
515
520
|
},
|
|
516
521
|
)
|
|
@@ -530,15 +535,16 @@ export function isArgOfType(
|
|
|
530
535
|
return argType === 'string' || arg instanceof Uint8Array
|
|
531
536
|
|
|
532
537
|
// fixed-length (`<type>[M]`) and dynamic (`<type>[]`) arrays
|
|
533
|
-
|
|
534
|
-
if (
|
|
538
|
+
const arrayComponents = getArrayComponents(abiParameterType)
|
|
539
|
+
if (arrayComponents) {
|
|
540
|
+
const [length, type] = arrayComponents
|
|
535
541
|
return (
|
|
536
542
|
Array.isArray(arg) &&
|
|
543
|
+
(length === null || arg.length === length) &&
|
|
537
544
|
arg.every((x: unknown) =>
|
|
538
545
|
isArgOfType(x, {
|
|
539
546
|
...abiParameter,
|
|
540
|
-
|
|
541
|
-
type: abiParameterType.replace(/(\[[0-9]{0,}\])$/, ''),
|
|
547
|
+
type,
|
|
542
548
|
} as AbiParameters.Parameter),
|
|
543
549
|
)
|
|
544
550
|
)
|
|
@@ -557,32 +563,65 @@ export function getAmbiguousTypes(
|
|
|
557
563
|
): AbiParameters.Parameter['type'][] | undefined {
|
|
558
564
|
for (const parameterIndex in sourceParameters) {
|
|
559
565
|
const sourceParameter = sourceParameters[parameterIndex]!
|
|
560
|
-
const targetParameter = targetParameters[parameterIndex]
|
|
566
|
+
const targetParameter = targetParameters[parameterIndex]
|
|
567
|
+
if (!targetParameter) continue
|
|
561
568
|
|
|
562
569
|
if (
|
|
563
570
|
sourceParameter.type === 'tuple' &&
|
|
564
571
|
targetParameter.type === 'tuple' &&
|
|
565
572
|
'components' in sourceParameter &&
|
|
566
573
|
'components' in targetParameter
|
|
567
|
-
)
|
|
568
|
-
|
|
574
|
+
) {
|
|
575
|
+
const value = args[parameterIndex]
|
|
576
|
+
const types = getAmbiguousTypes(
|
|
569
577
|
sourceParameter.components,
|
|
570
578
|
targetParameter.components,
|
|
571
|
-
(
|
|
579
|
+
sourceParameter.components.map((component, index) =>
|
|
580
|
+
getComponentValue(value, component, index),
|
|
581
|
+
),
|
|
572
582
|
)
|
|
583
|
+
if (types) return types
|
|
584
|
+
continue
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
const sourceArray = getArrayComponents(sourceParameter.type)
|
|
588
|
+
const targetArray = getArrayComponents(targetParameter.type)
|
|
589
|
+
if (sourceArray && targetArray) {
|
|
590
|
+
// Every item matches both element types, so the first item (or `undefined` for an empty array) decides.
|
|
591
|
+
const types = getAmbiguousTypes(
|
|
592
|
+
[
|
|
593
|
+
{
|
|
594
|
+
...sourceParameter,
|
|
595
|
+
type: sourceArray[1],
|
|
596
|
+
} as AbiParameters.Parameter,
|
|
597
|
+
],
|
|
598
|
+
[
|
|
599
|
+
{
|
|
600
|
+
...targetParameter,
|
|
601
|
+
type: targetArray[1],
|
|
602
|
+
} as AbiParameters.Parameter,
|
|
603
|
+
],
|
|
604
|
+
[(args[parameterIndex] as readonly unknown[] | undefined)?.[0]],
|
|
605
|
+
)
|
|
606
|
+
if (types) return types
|
|
607
|
+
continue
|
|
608
|
+
}
|
|
573
609
|
|
|
574
610
|
const types = [sourceParameter.type, targetParameter.type]
|
|
575
611
|
|
|
612
|
+
const value = args[parameterIndex]
|
|
613
|
+
|
|
576
614
|
const ambiguous = (() => {
|
|
577
615
|
if (types.includes('address') && types.includes('bytes20')) return true
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
return
|
|
584
|
-
|
|
585
|
-
|
|
616
|
+
// An `undefined` value comes from an empty array, which matches both types.
|
|
617
|
+
if (
|
|
618
|
+
types.includes('address') &&
|
|
619
|
+
(types.includes('string') || types.includes('bytes'))
|
|
620
|
+
)
|
|
621
|
+
return (
|
|
622
|
+
value === undefined ||
|
|
623
|
+
Address.validate(value as Address.Address, { strict: false })
|
|
624
|
+
)
|
|
586
625
|
return false
|
|
587
626
|
})()
|
|
588
627
|
|
|
@@ -591,3 +630,13 @@ export function getAmbiguousTypes(
|
|
|
591
630
|
|
|
592
631
|
return
|
|
593
632
|
}
|
|
633
|
+
|
|
634
|
+
// Reads a tuple component's value by index from arrays and by name from objects, like `AbiParameters.encode`.
|
|
635
|
+
function getComponentValue(
|
|
636
|
+
arg: unknown,
|
|
637
|
+
component: AbiParameters.Parameter,
|
|
638
|
+
index: number,
|
|
639
|
+
): unknown {
|
|
640
|
+
if (Array.isArray(arg)) return arg[index]
|
|
641
|
+
return (arg as Record<string, unknown> | undefined)?.[component.name!]
|
|
642
|
+
}
|