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.
Files changed (149) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/Frame/package.json +6 -0
  3. package/FrameReceipt/package.json +6 -0
  4. package/FrameSignature/package.json +6 -0
  5. package/TxEnvelopeEip8141/package.json +6 -0
  6. package/_cjs/core/Frame.js +147 -0
  7. package/_cjs/core/Frame.js.map +1 -0
  8. package/_cjs/core/FrameReceipt.js +34 -0
  9. package/_cjs/core/FrameReceipt.js.map +1 -0
  10. package/_cjs/core/FrameSignature.js +203 -0
  11. package/_cjs/core/FrameSignature.js.map +1 -0
  12. package/_cjs/core/Transaction.js +18 -2
  13. package/_cjs/core/Transaction.js.map +1 -1
  14. package/_cjs/core/TransactionReceipt.js +10 -0
  15. package/_cjs/core/TransactionReceipt.js.map +1 -1
  16. package/_cjs/core/TransactionRequest.js +11 -1
  17. package/_cjs/core/TransactionRequest.js.map +1 -1
  18. package/_cjs/core/TxEnvelopeEip8141.js +283 -0
  19. package/_cjs/core/TxEnvelopeEip8141.js.map +1 -0
  20. package/_cjs/core/internal/curves.js +6 -0
  21. package/_cjs/core/internal/curves.js.map +1 -0
  22. package/_cjs/core/internal/quantity.js +10 -0
  23. package/_cjs/core/internal/quantity.js.map +1 -0
  24. package/_cjs/erc4337/UserOperationReceipt.js.map +1 -1
  25. package/_cjs/index.js +6 -2
  26. package/_cjs/index.js.map +1 -1
  27. package/_cjs/tempo/KeyAuthorization.js +43 -10
  28. package/_cjs/tempo/KeyAuthorization.js.map +1 -1
  29. package/_cjs/tempo/MultisigConfig.js +33 -11
  30. package/_cjs/tempo/MultisigConfig.js.map +1 -1
  31. package/_cjs/tempo/MultisigOperation.js +18 -94
  32. package/_cjs/tempo/MultisigOperation.js.map +1 -1
  33. package/_cjs/tempo/MultisigSimulation.js +18 -46
  34. package/_cjs/tempo/MultisigSimulation.js.map +1 -1
  35. package/_cjs/tempo/SignatureEnvelope.js +72 -109
  36. package/_cjs/tempo/SignatureEnvelope.js.map +1 -1
  37. package/_cjs/tempo/TransactionRequest.js +5 -1
  38. package/_cjs/tempo/TransactionRequest.js.map +1 -1
  39. package/_cjs/tempo/index.js.map +1 -1
  40. package/_cjs/version.js +1 -1
  41. package/_esm/core/Frame.js +311 -0
  42. package/_esm/core/Frame.js.map +1 -0
  43. package/_esm/core/FrameReceipt.js +72 -0
  44. package/_esm/core/FrameReceipt.js.map +1 -0
  45. package/_esm/core/FrameSignature.js +422 -0
  46. package/_esm/core/FrameSignature.js.map +1 -0
  47. package/_esm/core/Transaction.js +18 -2
  48. package/_esm/core/Transaction.js.map +1 -1
  49. package/_esm/core/TransactionReceipt.js +10 -0
  50. package/_esm/core/TransactionReceipt.js.map +1 -1
  51. package/_esm/core/TransactionRequest.js +11 -1
  52. package/_esm/core/TransactionRequest.js.map +1 -1
  53. package/_esm/core/TxEnvelopeEip8141.js +490 -0
  54. package/_esm/core/TxEnvelopeEip8141.js.map +1 -0
  55. package/_esm/core/internal/curves.js +19 -0
  56. package/_esm/core/internal/curves.js.map +1 -0
  57. package/_esm/core/internal/quantity.js +14 -0
  58. package/_esm/core/internal/quantity.js.map +1 -0
  59. package/_esm/erc4337/UserOperationReceipt.js.map +1 -1
  60. package/_esm/index.js +73 -0
  61. package/_esm/index.js.map +1 -1
  62. package/_esm/tempo/KeyAuthorization.js +42 -9
  63. package/_esm/tempo/KeyAuthorization.js.map +1 -1
  64. package/_esm/tempo/MultisigConfig.js +41 -22
  65. package/_esm/tempo/MultisigConfig.js.map +1 -1
  66. package/_esm/tempo/MultisigOperation.js +20 -100
  67. package/_esm/tempo/MultisigOperation.js.map +1 -1
  68. package/_esm/tempo/MultisigSimulation.js +18 -46
  69. package/_esm/tempo/MultisigSimulation.js.map +1 -1
  70. package/_esm/tempo/SignatureEnvelope.js +107 -169
  71. package/_esm/tempo/SignatureEnvelope.js.map +1 -1
  72. package/_esm/tempo/TransactionRequest.js +5 -1
  73. package/_esm/tempo/TransactionRequest.js.map +1 -1
  74. package/_esm/tempo/index.js +3 -1
  75. package/_esm/tempo/index.js.map +1 -1
  76. package/_esm/version.js +1 -1
  77. package/_types/core/Frame.d.ts +290 -0
  78. package/_types/core/Frame.d.ts.map +1 -0
  79. package/_types/core/FrameReceipt.d.ts +92 -0
  80. package/_types/core/FrameReceipt.d.ts.map +1 -0
  81. package/_types/core/FrameSignature.d.ts +357 -0
  82. package/_types/core/FrameSignature.d.ts.map +1 -0
  83. package/_types/core/Transaction.d.ts +29 -4
  84. package/_types/core/Transaction.d.ts.map +1 -1
  85. package/_types/core/TransactionReceipt.d.ts +15 -6
  86. package/_types/core/TransactionReceipt.d.ts.map +1 -1
  87. package/_types/core/TransactionRequest.d.ts +10 -4
  88. package/_types/core/TransactionRequest.d.ts.map +1 -1
  89. package/_types/core/TxEnvelopeEip8141.d.ts +343 -0
  90. package/_types/core/TxEnvelopeEip8141.d.ts.map +1 -0
  91. package/_types/core/internal/curves.d.ts +19 -0
  92. package/_types/core/internal/curves.d.ts.map +1 -0
  93. package/_types/core/internal/quantity.d.ts +10 -0
  94. package/_types/core/internal/quantity.d.ts.map +1 -0
  95. package/_types/erc4337/UserOperationReceipt.d.ts +1 -1
  96. package/_types/erc4337/UserOperationReceipt.d.ts.map +1 -1
  97. package/_types/index.d.ts +73 -0
  98. package/_types/index.d.ts.map +1 -1
  99. package/_types/tempo/KeyAuthorization.d.ts +48 -38
  100. package/_types/tempo/KeyAuthorization.d.ts.map +1 -1
  101. package/_types/tempo/MultisigConfig.d.ts +15 -14
  102. package/_types/tempo/MultisigConfig.d.ts.map +1 -1
  103. package/_types/tempo/MultisigOperation.d.ts +3 -2
  104. package/_types/tempo/MultisigOperation.d.ts.map +1 -1
  105. package/_types/tempo/MultisigSimulation.d.ts +2 -49
  106. package/_types/tempo/MultisigSimulation.d.ts.map +1 -1
  107. package/_types/tempo/SignatureEnvelope.d.ts +69 -128
  108. package/_types/tempo/SignatureEnvelope.d.ts.map +1 -1
  109. package/_types/tempo/Transaction.d.ts +2 -0
  110. package/_types/tempo/Transaction.d.ts.map +1 -1
  111. package/_types/tempo/TransactionReceipt.d.ts +2 -0
  112. package/_types/tempo/TransactionReceipt.d.ts.map +1 -1
  113. package/_types/tempo/TransactionRequest.d.ts +5 -2
  114. package/_types/tempo/TransactionRequest.d.ts.map +1 -1
  115. package/_types/tempo/index.d.ts +3 -1
  116. package/_types/tempo/index.d.ts.map +1 -1
  117. package/_types/version.d.ts +1 -1
  118. package/core/Frame.ts +443 -0
  119. package/core/FrameReceipt.ts +117 -0
  120. package/core/FrameSignature.ts +606 -0
  121. package/core/Transaction.ts +73 -4
  122. package/core/TransactionReceipt.ts +41 -4
  123. package/core/TransactionRequest.ts +26 -2
  124. package/core/TxEnvelopeEip8141.ts +717 -0
  125. package/core/internal/curves.ts +22 -0
  126. package/core/internal/quantity.ts +16 -0
  127. package/erc4337/UserOperationReceipt.ts +1 -6
  128. package/index.ts +73 -0
  129. package/package.json +21 -1
  130. package/tempo/AuthorizationTempo.test.ts +8 -4
  131. package/tempo/KeyAuthorization.test-d.ts +68 -33
  132. package/tempo/KeyAuthorization.test.ts +89 -8
  133. package/tempo/KeyAuthorization.ts +124 -61
  134. package/tempo/MultisigConfig.test.ts +34 -26
  135. package/tempo/MultisigConfig.ts +54 -24
  136. package/tempo/MultisigOperation.test.ts +79 -550
  137. package/tempo/MultisigOperation.ts +31 -146
  138. package/tempo/MultisigSimulation.test-d.ts +2 -2
  139. package/tempo/MultisigSimulation.test.ts +21 -110
  140. package/tempo/MultisigSimulation.ts +25 -99
  141. package/tempo/SignatureEnvelope.test-d.ts +29 -67
  142. package/tempo/SignatureEnvelope.test.ts +301 -568
  143. package/tempo/SignatureEnvelope.ts +156 -274
  144. package/tempo/TransactionRequest.test-d.ts +6 -5
  145. package/tempo/TransactionRequest.test.ts +17 -80
  146. package/tempo/TransactionRequest.ts +23 -3
  147. package/tempo/index.ts +3 -1
  148. package/tempo/multisig.e2e.test.ts +322 -861
  149. package/version.ts +1 -1
@@ -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 = 0xff
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
- '0x4b5ff53c5328a10a6ec5224adf16de5e204a47057c98af037ee30b7de660a8a6'
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
- return {
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 canonical recovery factory
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(config: Input): Address.Address {
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: recoveryFactory,
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),