ox 0.14.44 → 0.14.46
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 +12 -0
- package/Frame/package.json +6 -0
- package/FrameReceipt/package.json +6 -0
- package/FrameSignature/package.json +6 -0
- package/TxEnvelopeEip8141/package.json +6 -0
- package/_cjs/core/Frame.js +147 -0
- package/_cjs/core/Frame.js.map +1 -0
- package/_cjs/core/FrameReceipt.js +34 -0
- package/_cjs/core/FrameReceipt.js.map +1 -0
- package/_cjs/core/FrameSignature.js +203 -0
- package/_cjs/core/FrameSignature.js.map +1 -0
- package/_cjs/core/Transaction.js +18 -2
- package/_cjs/core/Transaction.js.map +1 -1
- package/_cjs/core/TransactionReceipt.js +10 -0
- package/_cjs/core/TransactionReceipt.js.map +1 -1
- package/_cjs/core/TransactionRequest.js +11 -1
- package/_cjs/core/TransactionRequest.js.map +1 -1
- package/_cjs/core/TxEnvelopeEip8141.js +283 -0
- package/_cjs/core/TxEnvelopeEip8141.js.map +1 -0
- package/_cjs/core/internal/curves.js +6 -0
- package/_cjs/core/internal/curves.js.map +1 -0
- package/_cjs/core/internal/quantity.js +10 -0
- package/_cjs/core/internal/quantity.js.map +1 -0
- package/_cjs/erc4337/UserOperationReceipt.js.map +1 -1
- package/_cjs/index.js +6 -2
- package/_cjs/index.js.map +1 -1
- package/_cjs/tempo/KeyAuthorization.js +43 -10
- package/_cjs/tempo/KeyAuthorization.js.map +1 -1
- package/_cjs/tempo/MultisigConfig.js +33 -11
- package/_cjs/tempo/MultisigConfig.js.map +1 -1
- package/_cjs/tempo/MultisigOperation.js +18 -94
- package/_cjs/tempo/MultisigOperation.js.map +1 -1
- package/_cjs/tempo/MultisigSimulation.js +18 -46
- package/_cjs/tempo/MultisigSimulation.js.map +1 -1
- package/_cjs/tempo/SignatureEnvelope.js +72 -109
- package/_cjs/tempo/SignatureEnvelope.js.map +1 -1
- package/_cjs/tempo/TransactionRequest.js +5 -1
- package/_cjs/tempo/TransactionRequest.js.map +1 -1
- package/_cjs/tempo/index.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/core/Frame.js +311 -0
- package/_esm/core/Frame.js.map +1 -0
- package/_esm/core/FrameReceipt.js +72 -0
- package/_esm/core/FrameReceipt.js.map +1 -0
- package/_esm/core/FrameSignature.js +422 -0
- package/_esm/core/FrameSignature.js.map +1 -0
- package/_esm/core/Transaction.js +18 -2
- package/_esm/core/Transaction.js.map +1 -1
- package/_esm/core/TransactionReceipt.js +10 -0
- package/_esm/core/TransactionReceipt.js.map +1 -1
- package/_esm/core/TransactionRequest.js +11 -1
- package/_esm/core/TransactionRequest.js.map +1 -1
- package/_esm/core/TxEnvelopeEip8141.js +490 -0
- package/_esm/core/TxEnvelopeEip8141.js.map +1 -0
- package/_esm/core/internal/curves.js +19 -0
- package/_esm/core/internal/curves.js.map +1 -0
- package/_esm/core/internal/quantity.js +14 -0
- package/_esm/core/internal/quantity.js.map +1 -0
- package/_esm/erc4337/UserOperationReceipt.js.map +1 -1
- package/_esm/index.js +73 -0
- package/_esm/index.js.map +1 -1
- package/_esm/tempo/KeyAuthorization.js +42 -9
- package/_esm/tempo/KeyAuthorization.js.map +1 -1
- package/_esm/tempo/MultisigConfig.js +41 -22
- package/_esm/tempo/MultisigConfig.js.map +1 -1
- package/_esm/tempo/MultisigOperation.js +20 -100
- package/_esm/tempo/MultisigOperation.js.map +1 -1
- package/_esm/tempo/MultisigSimulation.js +18 -46
- package/_esm/tempo/MultisigSimulation.js.map +1 -1
- package/_esm/tempo/SignatureEnvelope.js +107 -169
- package/_esm/tempo/SignatureEnvelope.js.map +1 -1
- package/_esm/tempo/TransactionRequest.js +5 -1
- package/_esm/tempo/TransactionRequest.js.map +1 -1
- package/_esm/tempo/index.js +3 -1
- package/_esm/tempo/index.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/core/Frame.d.ts +290 -0
- package/_types/core/Frame.d.ts.map +1 -0
- package/_types/core/FrameReceipt.d.ts +92 -0
- package/_types/core/FrameReceipt.d.ts.map +1 -0
- package/_types/core/FrameSignature.d.ts +357 -0
- package/_types/core/FrameSignature.d.ts.map +1 -0
- package/_types/core/Transaction.d.ts +29 -4
- package/_types/core/Transaction.d.ts.map +1 -1
- package/_types/core/TransactionReceipt.d.ts +15 -6
- package/_types/core/TransactionReceipt.d.ts.map +1 -1
- package/_types/core/TransactionRequest.d.ts +10 -4
- package/_types/core/TransactionRequest.d.ts.map +1 -1
- package/_types/core/TxEnvelopeEip8141.d.ts +343 -0
- package/_types/core/TxEnvelopeEip8141.d.ts.map +1 -0
- package/_types/core/internal/curves.d.ts +19 -0
- package/_types/core/internal/curves.d.ts.map +1 -0
- package/_types/core/internal/quantity.d.ts +10 -0
- package/_types/core/internal/quantity.d.ts.map +1 -0
- package/_types/erc4337/UserOperationReceipt.d.ts +1 -1
- package/_types/erc4337/UserOperationReceipt.d.ts.map +1 -1
- package/_types/index.d.ts +73 -0
- package/_types/index.d.ts.map +1 -1
- package/_types/tempo/KeyAuthorization.d.ts +48 -38
- package/_types/tempo/KeyAuthorization.d.ts.map +1 -1
- package/_types/tempo/MultisigConfig.d.ts +15 -14
- package/_types/tempo/MultisigConfig.d.ts.map +1 -1
- package/_types/tempo/MultisigOperation.d.ts +3 -2
- package/_types/tempo/MultisigOperation.d.ts.map +1 -1
- package/_types/tempo/MultisigSimulation.d.ts +2 -49
- package/_types/tempo/MultisigSimulation.d.ts.map +1 -1
- package/_types/tempo/SignatureEnvelope.d.ts +69 -128
- package/_types/tempo/SignatureEnvelope.d.ts.map +1 -1
- package/_types/tempo/Transaction.d.ts +2 -0
- package/_types/tempo/Transaction.d.ts.map +1 -1
- package/_types/tempo/TransactionReceipt.d.ts +2 -0
- package/_types/tempo/TransactionReceipt.d.ts.map +1 -1
- package/_types/tempo/TransactionRequest.d.ts +5 -2
- package/_types/tempo/TransactionRequest.d.ts.map +1 -1
- package/_types/tempo/index.d.ts +3 -1
- package/_types/tempo/index.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/core/Frame.ts +443 -0
- package/core/FrameReceipt.ts +117 -0
- package/core/FrameSignature.ts +606 -0
- package/core/Transaction.ts +73 -4
- package/core/TransactionReceipt.ts +41 -4
- package/core/TransactionRequest.ts +26 -2
- package/core/TxEnvelopeEip8141.ts +717 -0
- package/core/internal/curves.ts +22 -0
- package/core/internal/quantity.ts +16 -0
- package/erc4337/UserOperationReceipt.ts +1 -6
- package/index.ts +73 -0
- package/package.json +21 -1
- package/tempo/AuthorizationTempo.test.ts +8 -4
- package/tempo/KeyAuthorization.test-d.ts +68 -33
- package/tempo/KeyAuthorization.test.ts +89 -8
- package/tempo/KeyAuthorization.ts +124 -61
- package/tempo/MultisigConfig.test.ts +34 -26
- package/tempo/MultisigConfig.ts +54 -24
- package/tempo/MultisigOperation.test.ts +79 -550
- package/tempo/MultisigOperation.ts +31 -146
- package/tempo/MultisigSimulation.test-d.ts +2 -2
- package/tempo/MultisigSimulation.test.ts +21 -110
- package/tempo/MultisigSimulation.ts +25 -99
- package/tempo/SignatureEnvelope.test-d.ts +29 -67
- package/tempo/SignatureEnvelope.test.ts +301 -568
- package/tempo/SignatureEnvelope.ts +156 -274
- package/tempo/TransactionRequest.test-d.ts +6 -5
- package/tempo/TransactionRequest.test.ts +17 -80
- package/tempo/TransactionRequest.ts +23 -3
- package/tempo/index.ts +3 -1
- package/tempo/multisig.e2e.test.ts +322 -861
- package/version.ts +1 -1
package/tempo/MultisigConfig.ts
CHANGED
|
@@ -6,12 +6,6 @@ import * as Hash from '../core/Hash.js'
|
|
|
6
6
|
import * as Hex from '../core/Hex.js'
|
|
7
7
|
import type { Compute } from '../core/internal/types.js'
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* Maximum number of native multisig signatures in one nested authorization
|
|
11
|
-
* path, including the top-level transaction signature.
|
|
12
|
-
*/
|
|
13
|
-
export const maxNestingDepth = 2
|
|
14
|
-
|
|
15
9
|
/** Maximum encoded byte length for one primitive owner approval. */
|
|
16
10
|
export const maxOwnerSignatureBytes = 2049
|
|
17
11
|
|
|
@@ -22,7 +16,7 @@ export const maxOwners = 48
|
|
|
22
16
|
export const maxSignatures = 8
|
|
23
17
|
|
|
24
18
|
/** Maximum threshold accepted by a native multisig config. */
|
|
25
|
-
export const maxThreshold =
|
|
19
|
+
export const maxThreshold = 8
|
|
26
20
|
|
|
27
21
|
/** Maximum version accepted by a native multisig config. */
|
|
28
22
|
export const maxVersion = 2n ** 64n - 1n
|
|
@@ -39,12 +33,9 @@ const accountDomain = 'tempo:multisig:account'
|
|
|
39
33
|
/** Domain prefix for native multisig configuration commitments. */
|
|
40
34
|
const configDomain = 'tempo:multisig:config'
|
|
41
35
|
|
|
42
|
-
/** Canonical CREATE2 factory for multisig recovery wallets. */
|
|
43
|
-
const recoveryFactory = '0x8a196A227C48Ae8A3E36EebD4E106675CC0f6E64'
|
|
44
|
-
|
|
45
36
|
/** Keccak-256 of the canonical recovery wallet creation code. */
|
|
46
37
|
const recoveryWalletInitCodeHash =
|
|
47
|
-
'
|
|
38
|
+
'0x583cc63a2e37f645b43eac911b1a6d6de08b83abdc308c61364edda8cfc3bd37'
|
|
48
39
|
|
|
49
40
|
/** Domain prefix for native multisig owner approvals. */
|
|
50
41
|
const signatureDomain = 'tempo:multisig:signature'
|
|
@@ -300,7 +291,33 @@ export declare namespace fromRpc {
|
|
|
300
291
|
*/
|
|
301
292
|
export function fromTuple(tuple: Tuple): Config {
|
|
302
293
|
const [salt, version, threshold, owners] = tuple
|
|
303
|
-
|
|
294
|
+
if (
|
|
295
|
+
tuple.length !== 4 ||
|
|
296
|
+
typeof salt !== 'string' ||
|
|
297
|
+
Hex.size(salt) !== 32 ||
|
|
298
|
+
typeof version !== 'string' ||
|
|
299
|
+
Hex.size(version) > 8 ||
|
|
300
|
+
version.startsWith('0x00') ||
|
|
301
|
+
typeof threshold !== 'string' ||
|
|
302
|
+
Hex.size(threshold) > 1 ||
|
|
303
|
+
threshold.startsWith('0x00') ||
|
|
304
|
+
!Array.isArray(owners) ||
|
|
305
|
+
owners.some(
|
|
306
|
+
(owner) =>
|
|
307
|
+
!Array.isArray(owner) ||
|
|
308
|
+
owner.length !== 2 ||
|
|
309
|
+
typeof owner[0] !== 'string' ||
|
|
310
|
+
!Address.validate(owner[0]) ||
|
|
311
|
+
typeof owner[1] !== 'string' ||
|
|
312
|
+
Hex.size(owner[1] as Hex.Hex) > 1 ||
|
|
313
|
+
owner[1].startsWith('0x00'),
|
|
314
|
+
)
|
|
315
|
+
)
|
|
316
|
+
throw new InvalidConfigError({ reason: 'invalid config RLP tuple' })
|
|
317
|
+
const config = {
|
|
318
|
+
salt: salt && salt !== '0x' ? Hex.padLeft(salt, 32) : zeroSalt,
|
|
319
|
+
version: version === '0x' ? 0n : Hex.toBigInt(version),
|
|
320
|
+
threshold: threshold === '0x' ? 0 : Hex.toNumber(threshold),
|
|
304
321
|
owners: owners.map((owner) => {
|
|
305
322
|
const [ownerAddress, weight] = owner as readonly Hex.Hex[]
|
|
306
323
|
return {
|
|
@@ -308,18 +325,17 @@ export function fromTuple(tuple: Tuple): Config {
|
|
|
308
325
|
weight: !weight || weight === '0x' ? 0 : Hex.toNumber(weight),
|
|
309
326
|
}
|
|
310
327
|
}),
|
|
311
|
-
salt: salt && salt !== '0x' ? Hex.padLeft(salt, 32) : zeroSalt,
|
|
312
|
-
threshold: threshold === '0x' ? 0 : Hex.toNumber(threshold),
|
|
313
|
-
version: version === '0x' ? 0n : Hex.toBigInt(version),
|
|
314
328
|
}
|
|
329
|
+
assert(config)
|
|
330
|
+
return config
|
|
315
331
|
}
|
|
316
332
|
|
|
317
333
|
/**
|
|
318
334
|
* Derives the stable native multisig account address.
|
|
319
335
|
*
|
|
320
336
|
* The initial config is hashed into a CREATE2 salt using fixed-width
|
|
321
|
-
* big-endian fields, not RLP. The account uses the
|
|
322
|
-
* and wallet init-code hash.
|
|
337
|
+
* big-endian fields, not RLP. The account uses the chain-configured recovery
|
|
338
|
+
* factory and wallet init-code hash.
|
|
323
339
|
*
|
|
324
340
|
* The address is derived once from the initial version-0 config. Config
|
|
325
341
|
* updates do not change it.
|
|
@@ -335,13 +351,20 @@ export function fromTuple(tuple: Tuple): Config {
|
|
|
335
351
|
* threshold: 1,
|
|
336
352
|
* })
|
|
337
353
|
*
|
|
338
|
-
* const address = MultisigConfig.getAddress(initialConfig
|
|
354
|
+
* const address = MultisigConfig.getAddress(initialConfig, {
|
|
355
|
+
* factory: '0x7171717171717171717171717171717171717171'
|
|
356
|
+
* })
|
|
339
357
|
* ```
|
|
340
358
|
*
|
|
341
359
|
* @param config - The initial multisig config.
|
|
360
|
+
* @param options - The recovery factory configured by the chain.
|
|
342
361
|
* @returns The multisig account address.
|
|
343
362
|
*/
|
|
344
|
-
export function getAddress(
|
|
363
|
+
export function getAddress(
|
|
364
|
+
config: Input,
|
|
365
|
+
options: getAddress.Options,
|
|
366
|
+
): Address.Address {
|
|
367
|
+
Address.assert(options.factory)
|
|
345
368
|
assert(config)
|
|
346
369
|
if (BigInt(config.version ?? 0) !== 0n)
|
|
347
370
|
throw new InvalidConfigError({
|
|
@@ -361,7 +384,7 @@ export function getAddress(config: Input): Address.Address {
|
|
|
361
384
|
)
|
|
362
385
|
const account = ContractAddress.fromCreate2({
|
|
363
386
|
bytecodeHash: recoveryWalletInitCodeHash,
|
|
364
|
-
from:
|
|
387
|
+
from: options.factory,
|
|
365
388
|
salt: accountSalt,
|
|
366
389
|
})
|
|
367
390
|
if (Hex.toBigInt(account) === 0n)
|
|
@@ -374,6 +397,11 @@ export function getAddress(config: Input): Address.Address {
|
|
|
374
397
|
}
|
|
375
398
|
|
|
376
399
|
export declare namespace getAddress {
|
|
400
|
+
type Options = {
|
|
401
|
+
/** Recovery factory configured by the chain. */
|
|
402
|
+
factory: Address.Address
|
|
403
|
+
}
|
|
404
|
+
|
|
377
405
|
type ErrorType =
|
|
378
406
|
| assert.ErrorType
|
|
379
407
|
| ContractAddress.fromCreate2.ErrorType
|
|
@@ -444,9 +472,6 @@ export declare namespace getCommitment {
|
|
|
444
472
|
* version. Initial approvals use version `0n`; each config update increments
|
|
445
473
|
* it.
|
|
446
474
|
*
|
|
447
|
-
* For a nested multisig owner approval, the parent digest becomes the nested
|
|
448
|
-
* approval's `payload`, with the nested multisig `account`.
|
|
449
|
-
*
|
|
450
475
|
* @example
|
|
451
476
|
* ```ts twoslash
|
|
452
477
|
* import { MultisigConfig, TxEnvelopeTempo } from 'ox/tempo'
|
|
@@ -464,7 +489,9 @@ export declare namespace getCommitment {
|
|
|
464
489
|
* })
|
|
465
490
|
*
|
|
466
491
|
* const digest = MultisigConfig.getSignPayload({
|
|
467
|
-
* account: MultisigConfig.getAddress(config
|
|
492
|
+
* account: MultisigConfig.getAddress(config, {
|
|
493
|
+
* factory: '0x7171717171717171717171717171717171717171'
|
|
494
|
+
* }),
|
|
468
495
|
* config,
|
|
469
496
|
* payload: TxEnvelopeTempo.getSignPayload(envelope),
|
|
470
497
|
* })
|
|
@@ -476,6 +503,9 @@ export declare namespace getCommitment {
|
|
|
476
503
|
export function getSignPayload(value: getSignPayload.Value): Hex.Hex {
|
|
477
504
|
const { account, config, payload } = value
|
|
478
505
|
assertVersion(config.version)
|
|
506
|
+
Address.assert(account)
|
|
507
|
+
if (Hex.size(Hex.from(payload)) !== 32)
|
|
508
|
+
throw new InvalidConfigError({ reason: 'payload must be 32 bytes' })
|
|
479
509
|
return Hash.keccak256(
|
|
480
510
|
Hex.concat(
|
|
481
511
|
Hex.fromString(signatureDomain),
|