ox 1.8.8 → 1.8.9

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 (52) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/tempo/AccountConfig.d.ts +46 -3
  3. package/dist/tempo/AccountConfig.d.ts.map +1 -1
  4. package/dist/tempo/AccountConfig.js +58 -9
  5. package/dist/tempo/AccountConfig.js.map +1 -1
  6. package/dist/tempo/AccountSimulation.d.ts +6 -2
  7. package/dist/tempo/AccountSimulation.d.ts.map +1 -1
  8. package/dist/tempo/AccountSimulation.js +15 -5
  9. package/dist/tempo/AccountSimulation.js.map +1 -1
  10. package/dist/tempo/KeyAuthorization.d.ts +14 -9
  11. package/dist/tempo/KeyAuthorization.d.ts.map +1 -1
  12. package/dist/tempo/KeyAuthorization.js +8 -12
  13. package/dist/tempo/KeyAuthorization.js.map +1 -1
  14. package/dist/tempo/TransactionRequest.d.ts +3 -3
  15. package/dist/tempo/TransactionRequest.d.ts.map +1 -1
  16. package/dist/tempo/TransactionRequest.js +10 -6
  17. package/dist/tempo/TransactionRequest.js.map +1 -1
  18. package/dist/zod/tempo/AccountSimulation.d.ts +4 -0
  19. package/dist/zod/tempo/AccountSimulation.d.ts.map +1 -1
  20. package/dist/zod/tempo/AccountSimulation.js +2 -0
  21. package/dist/zod/tempo/AccountSimulation.js.map +1 -1
  22. package/dist/zod/tempo/KeyAuthorization.d.ts +5 -5
  23. package/dist/zod/tempo/KeyAuthorization.d.ts.map +1 -1
  24. package/dist/zod/tempo/KeyAuthorization.js +10 -13
  25. package/dist/zod/tempo/KeyAuthorization.js.map +1 -1
  26. package/dist/zod/tempo/RpcSchemaTempo.d.ts +16 -8
  27. package/dist/zod/tempo/RpcSchemaTempo.d.ts.map +1 -1
  28. package/dist/zod/tempo/Transaction.d.ts +6 -6
  29. package/dist/zod/tempo/TransactionRequest.d.ts +23 -9
  30. package/dist/zod/tempo/TransactionRequest.d.ts.map +1 -1
  31. package/dist/zod/tempo/TransactionRequest.js +13 -9
  32. package/dist/zod/tempo/TransactionRequest.js.map +1 -1
  33. package/package.json +1 -1
  34. package/src/tempo/AccountConfig.test-d.ts +10 -0
  35. package/src/tempo/AccountConfig.test.ts +143 -10
  36. package/src/tempo/AccountConfig.ts +80 -9
  37. package/src/tempo/AccountOperation.test.ts +32 -32
  38. package/src/tempo/AccountSimulation.test.ts +43 -0
  39. package/src/tempo/AccountSimulation.ts +19 -5
  40. package/src/tempo/KeyAuthorization.test.ts +91 -32
  41. package/src/tempo/KeyAuthorization.ts +16 -39
  42. package/src/tempo/RpcSchemaTempo.test-d.ts +2 -2
  43. package/src/tempo/TransactionRequest.test-d.ts +5 -5
  44. package/src/tempo/TransactionRequest.test.ts +11 -9
  45. package/src/tempo/TransactionRequest.ts +13 -9
  46. package/src/version.ts +1 -1
  47. package/src/zod/tempo/AccountSimulation.ts +2 -0
  48. package/src/zod/tempo/KeyAuthorization.ts +28 -46
  49. package/src/zod/tempo/TransactionRequest.ts +17 -9
  50. package/src/zod/tempo/_test/AccountOperation.test.ts +1 -1
  51. package/src/zod/tempo/_test/KeyAuthorization.test.ts +5 -5
  52. package/src/zod/tempo/_test/TransactionRequest.test.ts +12 -7
@@ -33,17 +33,25 @@ export const signatureTypeByte = '0x05' as const
33
33
  export const zeroSalt = `0x${'00'.repeat(32)}` as const
34
34
 
35
35
  /** Domain prefix for the configurable account address derivation. */
36
- const accountDomain = 'tempo:multisig:account'
36
+ const accountDomain = 'tempo:configurable-account:account'
37
37
 
38
38
  /** Domain prefix for account configuration commitments. */
39
- const configDomain = 'tempo:multisig:config'
39
+ const configDomain = 'tempo:configurable-account:config'
40
40
 
41
- /** Keccak-256 of the canonical recovery wallet creation code. */
42
- const recoveryWalletInitCodeHash =
41
+ /**
42
+ * Keccak-256 of the account proxy creation code.
43
+ *
44
+ * Placeholder until [TIP-1110](https://tips.sh/1110) fixes the canonical
45
+ * account proxy, which will change every derived address.
46
+ */
47
+ const accountProxyInitCodeHash =
43
48
  '0x583cc63a2e37f645b43eac911b1a6d6de08b83abdc308c61364edda8cfc3bd37'
44
49
 
45
50
  /** Domain prefix for configurable account owner approvals. */
46
- const signatureDomain = 'tempo:multisig:signature'
51
+ const signatureDomain = 'tempo:configurable-account:signature'
52
+
53
+ /** Domain prefix for the salt of an account migrated in place. */
54
+ const upgradeDomain = 'tempo:configurable-account:upgrade'
47
55
 
48
56
  /**
49
57
  * Complete account configuration witness.
@@ -347,12 +355,75 @@ export function fromTuple(tuple: Tuple): Config {
347
355
  return config
348
356
  }
349
357
 
358
+ /**
359
+ * Derives the configuration an existing account installs when it migrates in
360
+ * place with the `upgradeAccount` precompile call
361
+ * ([TIP-1113](https://tips.sh/1113)).
362
+ *
363
+ * The account keeps its address. Its salt is
364
+ * `keccak256("tempo:configurable-account:upgrade" || account)` and its version
365
+ * is `1n`. Owners are sorted into canonical order and the config is validated.
366
+ * The account itself may be listed as an owner.
367
+ *
368
+ * @example
369
+ * ```ts twoslash
370
+ * import { AccountConfig } from 'ox/tempo'
371
+ *
372
+ * const config = AccountConfig.fromUpgrade(
373
+ * '0x3333333333333333333333333333333333333333',
374
+ * {
375
+ * owners: [
376
+ * {
377
+ * owner: '0x1111111111111111111111111111111111111111',
378
+ * weight: 1
379
+ * }
380
+ * ],
381
+ * threshold: 1
382
+ * }
383
+ * )
384
+ * // config.version === 1n
385
+ * ```
386
+ *
387
+ * @param account - The account migrating in place.
388
+ * @param options - The owners and threshold to install.
389
+ * @returns The installed account config.
390
+ */
391
+ export function fromUpgrade<numberType = number>(
392
+ account: Address.Address,
393
+ options: fromUpgrade.Options<numberType>,
394
+ ): Config<1n, numberType> {
395
+ Address.assert(account)
396
+ return from({
397
+ owners: options.owners,
398
+ salt: Hash.keccak256(Hex.concat(Hex.fromString(upgradeDomain), account)),
399
+ threshold: options.threshold,
400
+ version: 1n,
401
+ })
402
+ }
403
+
404
+ export declare namespace fromUpgrade {
405
+ type Options<numberType = number> = {
406
+ /** Weighted owners to install. Sorted into canonical order. */
407
+ owners: readonly Owner<numberType>[]
408
+ /** Minimum total owner weight required for authorization. */
409
+ threshold: numberType
410
+ }
411
+
412
+ type ErrorType =
413
+ | Address.assert.ErrorType
414
+ | assert.ErrorType
415
+ | Hash.keccak256.ErrorType
416
+ | Hex.concat.ErrorType
417
+ | Hex.fromString.ErrorType
418
+ | Errors.GlobalErrorType
419
+ }
420
+
350
421
  /**
351
422
  * Derives the stable configurable account address.
352
423
  *
353
424
  * The initial config is hashed into a CREATE2 salt using fixed-width
354
425
  * big-endian fields, not RLP. The account uses the chain-configured recovery
355
- * factory and wallet init-code hash.
426
+ * factory and account proxy init-code hash.
356
427
  *
357
428
  * The address is derived once from the initial version-0 config. Config
358
429
  * updates do not change it.
@@ -403,7 +474,7 @@ export function getAddress(
403
474
  ),
404
475
  )
405
476
  const account = ContractAddress.fromCreate2({
406
- bytecodeHash: recoveryWalletInitCodeHash,
477
+ bytecodeHash: accountProxyInitCodeHash,
407
478
  from: options.factory,
408
479
  salt: accountSalt,
409
480
  })
@@ -436,7 +507,7 @@ export declare namespace getAddress {
436
507
  * Computes the commitment for an account configuration.
437
508
  *
438
509
  * The commitment uses raw fixed-width fields, not RLP or ABI encoding:
439
- * `keccak256("tempo:multisig:config" || salt || uint64be(version) || uint8(threshold) || uint8(owners.length) || owners)`.
510
+ * `keccak256("tempo:configurable-account:config" || salt || uint64be(version) || uint8(threshold) || uint8(owners.length) || owners)`.
440
511
  *
441
512
  * @example
442
513
  * ```ts twoslash
@@ -487,7 +558,7 @@ export declare namespace getCommitment {
487
558
  /**
488
559
  * Computes the digest a configurable account owner approves (signs).
489
560
  *
490
- * `keccak256("tempo:multisig:signature" || inner_digest || account || uint64be(version))`,
561
+ * `keccak256("tempo:configurable-account:signature" || inner_digest || account || uint64be(version))`,
491
562
  * where `inner_digest` is the transaction sign payload
492
563
  * ({@link ox#TxEnvelopeTempo.(getSignPayload:function)}).
493
564
  *
@@ -153,8 +153,8 @@ describe('getHash', () => {
153
153
  }),
154
154
  }).toMatchInlineSnapshot(`
155
155
  {
156
- "keyAuthorization": "0xa83016f0e94c4a6125483ffeba3abb0a8df1bc0f5a503f63639e806b793520bb",
157
- "transaction": "0x2d7e3c7c38a9acf85f0a9d70a39b0e9e5a05d92c7a73b633a47a45be4a112b3b",
156
+ "keyAuthorization": "0xd18f389ae23bdc81939861c9a1079201968a2ec5fbd67ad1063556b46af8914f",
157
+ "transaction": "0x246027f7c6940fb4b68a746c49819c1c45737aa6c975aafcce721b4a619a9ab1",
158
158
  }
159
159
  `)
160
160
  })
@@ -345,14 +345,14 @@ describe('serializeKeyAuthorization', () => {
345
345
  expect(results).toMatchInlineSnapshot(`
346
346
  [
347
347
  {
348
- "account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
349
- "hash": "0xcd4283709cc1853dc8ed9cc4dd8c3b6a22e1b01f19ad3f6348f4bebe79590408",
348
+ "account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
349
+ "hash": "0x8d72c92f8aca5cf651ff914a928a32b1717e51b70fce97e305aaab02617474f5",
350
350
  "signatureCount": 2,
351
351
  "version": 1n,
352
352
  },
353
353
  {
354
- "account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
355
- "hash": "0x1f66e6adc4ddf8ac9d4575f518be11509ca616ac13d4e0a286b4eef7b96959f2",
354
+ "account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
355
+ "hash": "0x1dce79ae000bb60526cbe3b18be29d517319ee0958b01e5e3e89608e19c13459",
356
356
  "signatureCount": 2,
357
357
  "version": 0n,
358
358
  },
@@ -446,15 +446,15 @@ describe('serializeTransaction', () => {
446
446
  expect(results).toMatchInlineSnapshot(`
447
447
  [
448
448
  {
449
- "account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
450
- "hash": "0x6a034f208339f7eaa4a42b3fa03aad5df77ebe83659dac2e4d2b11226d221928",
449
+ "account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
450
+ "hash": "0x75106153400c34efbeb7380828e3fef939340eb0a3a42dda6a22f798f94665d0",
451
451
  "signatureCount": 2,
452
452
  "type": "0x76",
453
453
  "version": 1n,
454
454
  },
455
455
  {
456
- "account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
457
- "hash": "0x04d36e54d7a816b080dfa03370da6fbeb3523ce3eff5211d7f22a3c7e87476ee",
456
+ "account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
457
+ "hash": "0x2718b956492b1f8ff4e25165ac425e9e7064580b76eb087ce764e263723152bc",
458
458
  "signatureCount": 2,
459
459
  "type": "0x76",
460
460
  "version": 0n,
@@ -535,7 +535,7 @@ describe('serializeTransaction', () => {
535
535
  [
536
536
  {
537
537
  "feePayerSignature": null,
538
- "from": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
538
+ "from": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
539
539
  "signatureCount": 2,
540
540
  "type": "0x78",
541
541
  },
@@ -545,7 +545,7 @@ describe('serializeTransaction', () => {
545
545
  "s": "0x0000000000000000000000000000000000000000000000000000000000000006",
546
546
  "yParity": 0,
547
547
  },
548
- "from": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
548
+ "from": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
549
549
  "signatureCount": 2,
550
550
  "type": "0x78",
551
551
  },
@@ -617,7 +617,7 @@ describe('from', () => {
617
617
  expect({ pending, submitting, success }).toMatchInlineSnapshot(`
618
618
  {
619
619
  "pending": {
620
- "account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
620
+ "account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
621
621
  "approvals": [
622
622
  "0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
623
623
  ],
@@ -637,7 +637,7 @@ describe('from', () => {
637
637
  "version": 1n,
638
638
  },
639
639
  "createdAt": 1,
640
- "hash": "0x2d7e3c7c38a9acf85f0a9d70a39b0e9e5a05d92c7a73b633a47a45be4a112b3b",
640
+ "hash": "0x246027f7c6940fb4b68a746c49819c1c45737aa6c975aafcce721b4a619a9ab1",
641
641
  "signatureCount": 1,
642
642
  "status": "pending",
643
643
  "threshold": 2,
@@ -647,7 +647,7 @@ describe('from', () => {
647
647
  "weight": 1,
648
648
  },
649
649
  "submitting": {
650
- "account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
650
+ "account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
651
651
  "approvals": [
652
652
  "0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
653
653
  "0x01000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
@@ -669,7 +669,7 @@ describe('from', () => {
669
669
  },
670
670
  "createdAt": 1,
671
671
  "expiresAt": 10,
672
- "hash": "0x2d7e3c7c38a9acf85f0a9d70a39b0e9e5a05d92c7a73b633a47a45be4a112b3b",
672
+ "hash": "0x246027f7c6940fb4b68a746c49819c1c45737aa6c975aafcce721b4a619a9ab1",
673
673
  "signatureCount": 2,
674
674
  "status": "submitting",
675
675
  "submissionId": "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
@@ -680,7 +680,7 @@ describe('from', () => {
680
680
  "weight": 2,
681
681
  },
682
682
  "success": {
683
- "account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
683
+ "account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
684
684
  "approvals": [
685
685
  "0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
686
686
  "0x01000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
@@ -701,7 +701,7 @@ describe('from', () => {
701
701
  "version": 1n,
702
702
  },
703
703
  "createdAt": 1,
704
- "hash": "0x2d7e3c7c38a9acf85f0a9d70a39b0e9e5a05d92c7a73b633a47a45be4a112b3b",
704
+ "hash": "0x246027f7c6940fb4b68a746c49819c1c45737aa6c975aafcce721b4a619a9ab1",
705
705
  "signatureCount": 2,
706
706
  "status": "success",
707
707
  "threshold": 2,
@@ -747,7 +747,7 @@ describe('from', () => {
747
747
  },
748
748
  `
749
749
  {
750
- "account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
750
+ "account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
751
751
  "approvals": [
752
752
  "0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
753
753
  ],
@@ -833,7 +833,7 @@ describe('from', () => {
833
833
  },
834
834
  `
835
835
  {
836
- "account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
836
+ "account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
837
837
  "approvals": [
838
838
  "0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
839
839
  ],
@@ -890,7 +890,7 @@ describe('from', () => {
890
890
  expect({ pending, success }).toMatchInlineSnapshot(`
891
891
  {
892
892
  "pending": {
893
- "account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
893
+ "account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
894
894
  "approvals": [
895
895
  "0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
896
896
  ],
@@ -910,8 +910,8 @@ describe('from', () => {
910
910
  "version": 1n,
911
911
  },
912
912
  "createdAt": 1,
913
- "hash": "0xa83016f0e94c4a6125483ffeba3abb0a8df1bc0f5a503f63639e806b793520bb",
914
- "keyAuthorization": "0xf838f782107980943333333333333333333333333333333333333333846b49d2008080808094ef6b17836e1b3647105c3084124485e3e1b0ab7f",
913
+ "hash": "0xd18f389ae23bdc81939861c9a1079201968a2ec5fbd67ad1063556b46af8914f",
914
+ "keyAuthorization": "0xf838f782107980943333333333333333333333333333333333333333846b49d20080808080940f8659dd87410f00a1668211ecda7ac7f9c9fd13",
915
915
  "signatureCount": 1,
916
916
  "status": "pending",
917
917
  "threshold": 2,
@@ -920,7 +920,7 @@ describe('from', () => {
920
920
  "weight": 1,
921
921
  },
922
922
  "success": {
923
- "account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
923
+ "account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
924
924
  "approvals": [
925
925
  "0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
926
926
  "0x01000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
@@ -941,8 +941,8 @@ describe('from', () => {
941
941
  "version": 1n,
942
942
  },
943
943
  "createdAt": 1,
944
- "hash": "0xa83016f0e94c4a6125483ffeba3abb0a8df1bc0f5a503f63639e806b793520bb",
945
- "keyAuthorization": "0xf901b3f782107980943333333333333333333333333333333333333333846b49d2008080808094ef6b17836e1b3647105c3084124485e3e1b0ab7fb9017805f9017494ef6b17836e1b3647105c3084124485e3e1b0ab7ff852a000000000000000000000000000000000000000000000000000000000000000000102eed69407e1ed8ea0e9601e5546b0a03aed683df360140701d694288f0cd85005f34168f731a468aef268c2f9456f01f90108b88201000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200b88201000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
944
+ "hash": "0xd18f389ae23bdc81939861c9a1079201968a2ec5fbd67ad1063556b46af8914f",
945
+ "keyAuthorization": "0xf901b3f782107980943333333333333333333333333333333333333333846b49d20080808080940f8659dd87410f00a1668211ecda7ac7f9c9fd13b9017805f90174940f8659dd87410f00a1668211ecda7ac7f9c9fd13f852a000000000000000000000000000000000000000000000000000000000000000000102eed69407e1ed8ea0e9601e5546b0a03aed683df360140701d694288f0cd85005f34168f731a468aef268c2f9456f01f90108b88201000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200b88201000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
946
946
  "signatureCount": 2,
947
947
  "status": "success",
948
948
  "threshold": 2,
@@ -988,7 +988,7 @@ describe('from', () => {
988
988
  },
989
989
  `
990
990
  {
991
- "account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
991
+ "account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
992
992
  "approvals": [
993
993
  "0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
994
994
  "0x01000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
@@ -1034,7 +1034,7 @@ describe('RPC conversion', () => {
1034
1034
  expect({ keyAuthorizationRpc, transactionRpc }).toMatchInlineSnapshot(`
1035
1035
  {
1036
1036
  "keyAuthorizationRpc": {
1037
- "account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
1037
+ "account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
1038
1038
  "approvals": [
1039
1039
  "0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
1040
1040
  ],
@@ -1054,8 +1054,8 @@ describe('RPC conversion', () => {
1054
1054
  "version": "0x1",
1055
1055
  },
1056
1056
  "createdAt": 1,
1057
- "hash": "0xa83016f0e94c4a6125483ffeba3abb0a8df1bc0f5a503f63639e806b793520bb",
1058
- "keyAuthorization": "0xf838f782107980943333333333333333333333333333333333333333846b49d2008080808094ef6b17836e1b3647105c3084124485e3e1b0ab7f",
1057
+ "hash": "0xd18f389ae23bdc81939861c9a1079201968a2ec5fbd67ad1063556b46af8914f",
1058
+ "keyAuthorization": "0xf838f782107980943333333333333333333333333333333333333333846b49d20080808080940f8659dd87410f00a1668211ecda7ac7f9c9fd13",
1059
1059
  "signatureCount": 1,
1060
1060
  "status": "pending",
1061
1061
  "threshold": 2,
@@ -1064,7 +1064,7 @@ describe('RPC conversion', () => {
1064
1064
  "weight": 1,
1065
1065
  },
1066
1066
  "transactionRpc": {
1067
- "account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
1067
+ "account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
1068
1068
  "approvals": [
1069
1069
  "0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
1070
1070
  ],
@@ -1084,7 +1084,7 @@ describe('RPC conversion', () => {
1084
1084
  "version": "0x1",
1085
1085
  },
1086
1086
  "createdAt": 1,
1087
- "hash": "0x2d7e3c7c38a9acf85f0a9d70a39b0e9e5a05d92c7a73b633a47a45be4a112b3b",
1087
+ "hash": "0x246027f7c6940fb4b68a746c49819c1c45737aa6c975aafcce721b4a619a9ab1",
1088
1088
  "signatureCount": 1,
1089
1089
  "status": "pending",
1090
1090
  "threshold": 2,
@@ -113,6 +113,25 @@ describe('fromRpc', () => {
113
113
  })
114
114
 
115
115
  describe('toRpc', () => {
116
+ test('behavior: round-trips the grant signer', () => {
117
+ const signer = '0x2222222222222222222222222222222222222222'
118
+ const spec = AccountSimulation.fromRpc({ ...rpc, signer })
119
+ expect(spec.signer).toBe(signer)
120
+ expect(AccountSimulation.toRpc(spec).signer).toBe(signer)
121
+ expect(
122
+ 'signer' in AccountSimulation.toRpc(AccountSimulation.fromRpc(rpc)),
123
+ ).toBe(false)
124
+ })
125
+
126
+ test('error: rejects an invalid grant signer', () => {
127
+ expect(() => AccountSimulation.fromRpc({ ...rpc, signer: '0x1234' }))
128
+ .toThrowErrorMatchingInlineSnapshot(`
129
+ [Address.InvalidAddressError: Address "0x1234" is invalid.
130
+
131
+ Details: Address is not a 20 byte (40 hexadecimal character) value.]
132
+ `)
133
+ })
134
+
116
135
  test('behavior: encodes configurations and shims long key data', () => {
117
136
  expect(AccountSimulation.toRpc(AccountSimulation.fromRpc(rpc)))
118
137
  .toMatchInlineSnapshot(`
@@ -146,6 +165,30 @@ describe('toRpc', () => {
146
165
  `)
147
166
  })
148
167
 
168
+ test('behavior: shims key data that is not a valid length hint', () => {
169
+ const keyData = (keyData: `0x${string}`) =>
170
+ AccountSimulation.toRpc(
171
+ AccountSimulation.fromRpc({
172
+ ...rpc,
173
+ approvals: [{ ...rpc.approvals[0], keyData }],
174
+ }),
175
+ ).approvals[0]?.keyData
176
+
177
+ expect({
178
+ empty: keyData('0x'),
179
+ four: keyData('0x01020304'),
180
+ one: keyData('0x01'),
181
+ three: keyData('0x010203'),
182
+ }).toMatchInlineSnapshot(`
183
+ {
184
+ "empty": "0x0000",
185
+ "four": "0x01020304",
186
+ "one": "0x01",
187
+ "three": "0x0003",
188
+ }
189
+ `)
190
+ })
191
+
149
192
  test('behavior: encodes the maximum uint64 configuration version', () => {
150
193
  const spec = AccountSimulation.fromRpc(rpc)
151
194
 
@@ -28,6 +28,8 @@ export type Rpc = Compute<{
28
28
  approvals: readonly ApprovalRpc[]
29
29
  /** Canonical RLP-encoded applicable configuration. */
30
30
  config: Hex.Hex
31
+ /** Account that signs the modeled key authorization. Omitted for a direct signature. */
32
+ signer?: Address.Address | undefined
31
33
  }>
32
34
 
33
35
  /** Account simulation spec used to construct an RPC simulation signature. */
@@ -36,6 +38,8 @@ export type Spec = Compute<{
36
38
  approvals: readonly Approval[]
37
39
  /** Complete applicable configuration. */
38
40
  config: AccountConfig.Config
41
+ /** Account that signs the modeled key authorization. Omitted for a direct signature. */
42
+ signer?: Address.Address | undefined
39
43
  }>
40
44
 
41
45
  /**
@@ -53,14 +57,20 @@ export type Spec = Compute<{
53
57
  * @returns The account simulation spec with decoded configurations.
54
58
  */
55
59
  export function fromRpc(spec: Rpc): Spec {
56
- const { approvals, config } = spec
60
+ const { approvals, config, signer } = spec
57
61
  assertApprovals(approvals)
58
- return { approvals, config: deserializeConfig(config) }
62
+ if (signer !== undefined) Address.assert(signer)
63
+ return {
64
+ approvals,
65
+ config: deserializeConfig(config),
66
+ ...(signer !== undefined ? { signer } : {}),
67
+ }
59
68
  }
60
69
 
61
70
  export declare namespace fromRpc {
62
71
  /** Error type for `fromRpc`. */
63
72
  export type ErrorType =
73
+ | Address.assert.ErrorType
64
74
  | Hex.isEqual.ErrorType
65
75
  | InvalidSimulationError
66
76
  | AccountConfig.assert.ErrorType
@@ -84,8 +94,9 @@ export declare namespace fromRpc {
84
94
  * @returns The JSON-RPC account simulation spec with encoded configurations.
85
95
  */
86
96
  export function toRpc(spec: Spec): Rpc {
87
- const { approvals, config } = spec
97
+ const { approvals, config, signer } = spec
88
98
  assertApprovals(approvals)
99
+ if (signer !== undefined) Address.assert(signer)
89
100
  return {
90
101
  approvals: approvals.map(({ keyData, keyType, owner }) => ({
91
102
  ...(keyData !== undefined ? { keyData: shimKeyData(keyData) } : {}),
@@ -93,12 +104,14 @@ export function toRpc(spec: Spec): Rpc {
93
104
  owner,
94
105
  })),
95
106
  config: serializeConfig(config),
107
+ ...(signer !== undefined ? { signer } : {}),
96
108
  }
97
109
  }
98
110
 
99
111
  export declare namespace toRpc {
100
112
  /** Error type for `toRpc`. */
101
113
  export type ErrorType =
114
+ | Address.assert.ErrorType
102
115
  | Hex.fromNumber.ErrorType
103
116
  | InvalidSimulationError
104
117
  | AccountConfig.assert.ErrorType
@@ -164,12 +177,13 @@ function serializeConfig(config: AccountConfig.Input): Hex.Hex {
164
177
  }
165
178
 
166
179
  /**
167
- * Shims long key data into the length hint accepted by Tempo's gas estimator.
180
+ * Shims key data into the 1-, 2-, or 4-byte length hint accepted by Tempo's
181
+ * gas estimator. Other sizes are replaced by a 2-byte hint of their length.
168
182
  * @internal
169
183
  */
170
184
  function shimKeyData(data: Hex.Hex): Hex.Hex {
171
185
  const size = Hex.size(data)
172
- if (size <= 4) return data
186
+ if (size === 1 || size === 2 || size === 4) return data
173
187
  return Hex.fromNumber(size, { size: 2 })
174
188
  }
175
189
 
@@ -96,42 +96,80 @@ const signature_keychain = {
96
96
  } as const satisfies SignatureEnvelope.Keychain
97
97
 
98
98
  describe('configurable account binding', () => {
99
- test('rejects unbound grants before signing or encoding', () => {
100
- const authorization = {
101
- address,
102
- chainId: 1n,
103
- type: 'configurable',
104
- } as const
105
- const signed = {
106
- ...authorization,
107
- signature: SignatureEnvelope.from(signature_secp256k1),
108
- }
109
- for (const encode of [
110
- () => KeyAuthorization.from(authorization),
111
- () => KeyAuthorization.toTuple(authorization),
112
- () => KeyAuthorization.getSignPayload(authorization),
113
- () => KeyAuthorization.serialize(authorization),
114
- () => KeyAuthorization.toRpc(signed),
115
- ])
116
- expect(encode).toThrowErrorMatchingInlineSnapshot(
117
- `[KeyAuthorization.MissingAccountError: Configurable account key grants require a parent account binding.]`,
118
- )
99
+ test('behavior: accepts unbound configurable grants', () => {
100
+ // The node binds a root-signed grant to its signer, so only admin-signed
101
+ // grants need `account` (TIP-1049).
102
+ const signed = KeyAuthorization.from(
103
+ { address, chainId: 1n, type: 'configurable' },
104
+ { signature: signature_secp256k1 },
105
+ )
106
+ const rpc = KeyAuthorization.toRpc(signed)
107
+ expect({
108
+ deserialized: KeyAuthorization.deserialize(
109
+ KeyAuthorization.serialize(signed),
110
+ ),
111
+ fromRpc: KeyAuthorization.fromRpc(rpc),
112
+ fromTuple: KeyAuthorization.fromTuple([['0x01', '0x03', address]]),
113
+ rpc,
114
+ }).toMatchInlineSnapshot(`
115
+ {
116
+ "deserialized": {
117
+ "address": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
118
+ "chainId": 1n,
119
+ "signature": {
120
+ "signature": {
121
+ "r": "0xfa78c5905fb0b9d6066ef531f962a62bc6ef0d5eb59ecb134056d206f75aaed7",
122
+ "s": "0x780926ff2601a935c2c79707d9e1799948c9f19dcdde1e090e903b19a07923d0",
123
+ "yParity": 1,
124
+ },
125
+ "type": "secp256k1",
126
+ },
127
+ "type": "configurable",
128
+ },
129
+ "fromRpc": {
130
+ "address": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
131
+ "chainId": 1n,
132
+ "limits": undefined,
133
+ "signature": {
134
+ "signature": {
135
+ "r": "0xfa78c5905fb0b9d6066ef531f962a62bc6ef0d5eb59ecb134056d206f75aaed7",
136
+ "s": "0x780926ff2601a935c2c79707d9e1799948c9f19dcdde1e090e903b19a07923d0",
137
+ "yParity": 1,
138
+ },
139
+ "type": "secp256k1",
140
+ },
141
+ "type": "configurable",
142
+ },
143
+ "fromTuple": {
144
+ "address": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
145
+ "chainId": 1n,
146
+ "type": "configurable",
147
+ },
148
+ "rpc": {
149
+ "chainId": "0x1",
150
+ "expiry": null,
151
+ "keyId": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
152
+ "keyType": "configurableAccount",
153
+ "limits": undefined,
154
+ "signature": {
155
+ "r": "0xfa78c5905fb0b9d6066ef531f962a62bc6ef0d5eb59ecb134056d206f75aaed7",
156
+ "s": "0x780926ff2601a935c2c79707d9e1799948c9f19dcdde1e090e903b19a07923d0",
157
+ "type": "secp256k1",
158
+ "yParity": "0x1",
159
+ },
160
+ },
161
+ }
162
+ `)
119
163
  })
120
164
 
121
- test('rejects unbound RPC and RLP grants', () => {
165
+ test('behavior: preserves a bound account', () => {
122
166
  const signed = KeyAuthorization.from(
123
167
  { account: address, address, chainId: 1n, type: 'configurable' },
124
168
  { signature: signature_secp256k1 },
125
169
  )
126
- const rpc = KeyAuthorization.toRpc(signed)
127
- for (const account of [undefined, null])
128
- expect(() => KeyAuthorization.fromRpc({ ...rpc, account })).toThrowError(
129
- KeyAuthorization.MissingAccountError,
130
- )
131
- expect(() =>
132
- KeyAuthorization.fromTuple([['0x01', '0x03', address]]),
133
- ).toThrowError(KeyAuthorization.MissingAccountError)
134
- expect(KeyAuthorization.fromRpc(rpc).account).toBe(address)
170
+ expect(
171
+ KeyAuthorization.fromRpc(KeyAuthorization.toRpc(signed)).account,
172
+ ).toBe(address)
135
173
  expect(
136
174
  KeyAuthorization.deserialize(KeyAuthorization.serialize(signed)).account,
137
175
  ).toBe(address)
@@ -1450,13 +1488,13 @@ describe('serialize', () => {
1450
1488
  })
1451
1489
 
1452
1490
  describe('toRpc', () => {
1453
- test('behavior: configurable key type uses the RPC multisig key type', () => {
1491
+ test('behavior: configurable key type uses the RPC configurableAccount key type', () => {
1454
1492
  const authorization = KeyAuthorization.from(
1455
1493
  { account: address, address, chainId: 1n, type: 'configurable' },
1456
1494
  { signature: signature_secp256k1 },
1457
1495
  )
1458
1496
  const rpc = KeyAuthorization.toRpc(authorization)
1459
- expect(rpc.keyType).toMatchInlineSnapshot(`"multisig"`)
1497
+ expect(rpc.keyType).toMatchInlineSnapshot(`"configurableAccount"`)
1460
1498
  expect(KeyAuthorization.fromRpc(rpc).type).toMatchInlineSnapshot(
1461
1499
  `"configurable"`,
1462
1500
  )
@@ -2818,4 +2856,25 @@ describe('admin keys (TIP-1049)', () => {
2818
2856
  })
2819
2857
  expect(KeyAuthorization.hash(a)).not.toBe(KeyAuthorization.hash(b))
2820
2858
  })
2859
+
2860
+ describe('configurable admin keys', () => {
2861
+ test('behavior: a configurable account may sign or be granted an admin key', () => {
2862
+ const signed = KeyAuthorization.from(
2863
+ {
2864
+ account: signature_configurable.account,
2865
+ address,
2866
+ chainId: 1n,
2867
+ isAdmin: true,
2868
+ type: 'configurable',
2869
+ },
2870
+ { signature: signature_configurable },
2871
+ )
2872
+ expect(
2873
+ KeyAuthorization.deserialize(KeyAuthorization.serialize(signed)),
2874
+ ).toEqual(signed)
2875
+ expect(
2876
+ KeyAuthorization.fromRpc(KeyAuthorization.toRpc(signed)),
2877
+ ).toMatchObject({ isAdmin: true, type: 'configurable' })
2878
+ })
2879
+ })
2821
2880
  })