ox 1.7.2 → 1.7.4

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 (103) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/tempo/KeyAuthorization.d.ts +1 -1
  3. package/dist/tempo/KeyAuthorization.d.ts.map +1 -1
  4. package/dist/tempo/MultisigOperation.d.ts +42 -26
  5. package/dist/tempo/MultisigOperation.d.ts.map +1 -1
  6. package/dist/tempo/MultisigOperation.js +78 -48
  7. package/dist/tempo/MultisigOperation.js.map +1 -1
  8. package/dist/tempo/MultisigSimulation.d.ts +132 -0
  9. package/dist/tempo/MultisigSimulation.d.ts.map +1 -0
  10. package/dist/tempo/MultisigSimulation.js +140 -0
  11. package/dist/tempo/MultisigSimulation.js.map +1 -0
  12. package/dist/tempo/RpcSchemaTempo.d.ts +20 -10
  13. package/dist/tempo/RpcSchemaTempo.d.ts.map +1 -1
  14. package/dist/tempo/SignatureEnvelope.d.ts +9 -20
  15. package/dist/tempo/SignatureEnvelope.d.ts.map +1 -1
  16. package/dist/tempo/SignatureEnvelope.js +12 -18
  17. package/dist/tempo/SignatureEnvelope.js.map +1 -1
  18. package/dist/tempo/TransactionRequest.d.ts +6 -6
  19. package/dist/tempo/TransactionRequest.d.ts.map +1 -1
  20. package/dist/tempo/TransactionRequest.js +7 -7
  21. package/dist/tempo/TransactionRequest.js.map +1 -1
  22. package/dist/tempo/index.d.ts +4 -4
  23. package/dist/tempo/index.d.ts.map +1 -1
  24. package/dist/tempo/index.js +4 -4
  25. package/dist/tempo/index.js.map +1 -1
  26. package/dist/zod/tempo/AuthorizationTempo.d.ts +10 -130
  27. package/dist/zod/tempo/AuthorizationTempo.d.ts.map +1 -1
  28. package/dist/zod/tempo/KeyAuthorization.d.ts +5 -65
  29. package/dist/zod/tempo/KeyAuthorization.d.ts.map +1 -1
  30. package/dist/zod/tempo/MultisigOperation.d.ts +0 -10
  31. package/dist/zod/tempo/MultisigOperation.d.ts.map +1 -1
  32. package/dist/zod/tempo/MultisigOperation.js +0 -3
  33. package/dist/zod/tempo/MultisigOperation.js.map +1 -1
  34. package/dist/zod/tempo/{MultisigWitness.d.ts → MultisigSimulation.d.ts} +17 -49
  35. package/dist/zod/tempo/MultisigSimulation.d.ts.map +1 -0
  36. package/dist/zod/tempo/{MultisigWitness.js → MultisigSimulation.js} +26 -24
  37. package/dist/zod/tempo/MultisigSimulation.js.map +1 -0
  38. package/dist/zod/tempo/RpcSchemaTempo.d.ts +83 -204
  39. package/dist/zod/tempo/RpcSchemaTempo.d.ts.map +1 -1
  40. package/dist/zod/tempo/RpcSchemaTempo.js +19 -10
  41. package/dist/zod/tempo/RpcSchemaTempo.js.map +1 -1
  42. package/dist/zod/tempo/SignatureEnvelope.d.ts +3 -39
  43. package/dist/zod/tempo/SignatureEnvelope.d.ts.map +1 -1
  44. package/dist/zod/tempo/SignatureEnvelope.js +4 -14
  45. package/dist/zod/tempo/SignatureEnvelope.js.map +1 -1
  46. package/dist/zod/tempo/Transaction.d.ts +18 -234
  47. package/dist/zod/tempo/Transaction.d.ts.map +1 -1
  48. package/dist/zod/tempo/TransactionRequest.d.ts +36 -192
  49. package/dist/zod/tempo/TransactionRequest.d.ts.map +1 -1
  50. package/dist/zod/tempo/TransactionRequest.js +10 -10
  51. package/dist/zod/tempo/TransactionRequest.js.map +1 -1
  52. package/dist/zod/tempo/z.d.ts +1 -1
  53. package/dist/zod/tempo/z.d.ts.map +1 -1
  54. package/dist/zod/tempo/z.js +1 -1
  55. package/dist/zod/tempo/z.js.map +1 -1
  56. package/package.json +9 -9
  57. package/src/tempo/AuthorizationTempo.test.ts +4 -0
  58. package/src/tempo/KeyAuthorization.test-d.ts +1 -12
  59. package/src/tempo/KeyAuthorization.test.ts +44 -3
  60. package/src/tempo/KeyAuthorization.ts +3 -3
  61. package/src/tempo/MultisigOperation.test-d.ts +8 -6
  62. package/src/tempo/MultisigOperation.test.ts +236 -169
  63. package/src/tempo/MultisigOperation.ts +122 -83
  64. package/src/tempo/MultisigSimulation.test-d.ts +33 -0
  65. package/src/tempo/MultisigSimulation.test.ts +283 -0
  66. package/src/tempo/MultisigSimulation.ts +266 -0
  67. package/src/tempo/RpcSchemaTempo.test-d.ts +45 -10
  68. package/src/tempo/RpcSchemaTempo.ts +15 -6
  69. package/src/tempo/SignatureEnvelope.test-d.ts +3 -59
  70. package/src/tempo/SignatureEnvelope.test.ts +61 -51
  71. package/src/tempo/SignatureEnvelope.ts +27 -44
  72. package/src/tempo/Transaction.test.ts +61 -0
  73. package/src/tempo/TransactionRequest.test-d.ts +7 -7
  74. package/src/tempo/TransactionRequest.test.ts +129 -208
  75. package/src/tempo/TransactionRequest.ts +16 -12
  76. package/src/tempo/index.ts +4 -4
  77. package/src/tempo/multisig.e2e.test.ts +51 -1
  78. package/src/version.ts +1 -1
  79. package/src/zod/tempo/MultisigOperation.ts +0 -3
  80. package/src/zod/tempo/{MultisigWitness.ts → MultisigSimulation.ts} +39 -42
  81. package/src/zod/tempo/RpcSchemaTempo.ts +20 -10
  82. package/src/zod/tempo/SignatureEnvelope.ts +11 -35
  83. package/src/zod/tempo/TransactionRequest.ts +14 -14
  84. package/src/zod/tempo/_test/KeyAuthorization.test.ts +2 -15
  85. package/src/zod/tempo/_test/MultisigOperation.test.ts +0 -2
  86. package/src/zod/tempo/_test/MultisigSimulation.test-d.ts +13 -0
  87. package/src/zod/tempo/_test/MultisigSimulation.test.ts +78 -0
  88. package/src/zod/tempo/_test/RpcSchemaTempo.test-d.ts +19 -2
  89. package/src/zod/tempo/_test/RpcSchemaTempo.test.ts +46 -4
  90. package/src/zod/tempo/_test/SignatureEnvelope.test.ts +58 -112
  91. package/src/zod/tempo/_test/TransactionRequest.test.ts +19 -160
  92. package/src/zod/tempo/z.ts +1 -1
  93. package/dist/tempo/MultisigWitness.d.ts +0 -106
  94. package/dist/tempo/MultisigWitness.d.ts.map +0 -1
  95. package/dist/tempo/MultisigWitness.js +0 -118
  96. package/dist/tempo/MultisigWitness.js.map +0 -1
  97. package/dist/zod/tempo/MultisigWitness.d.ts.map +0 -1
  98. package/dist/zod/tempo/MultisigWitness.js.map +0 -1
  99. package/src/tempo/MultisigWitness.test-d.ts +0 -42
  100. package/src/tempo/MultisigWitness.test.ts +0 -288
  101. package/src/tempo/MultisigWitness.ts +0 -210
  102. package/src/zod/tempo/_test/MultisigWitness.test-d.ts +0 -13
  103. package/src/zod/tempo/_test/MultisigWitness.test.ts +0 -149
@@ -126,9 +126,7 @@ export type SignatureEnvelope<numberType = number> =
126
126
  | MultisigOneOf<numberType>
127
127
 
128
128
  /** RPC-formatted signature envelope. */
129
- export type SignatureEnvelopeRpc =
130
- | (NonMultisigRpc & Undefined<Omit<MultisigRpc, 'type'>>)
131
- | MultisigRpcOneOf
129
+ export type SignatureEnvelopeRpc = NonMultisigRpc | MultisigRpc
132
130
 
133
131
  /** Primitive signature envelope accepted by protocol sidecars. */
134
132
  export type Primitive<numberType = number> = OneOf<
@@ -180,7 +178,7 @@ export type KeychainRpc = {
180
178
  export type Multisig<numberType = number> = {
181
179
  /** Native multisig account address. */
182
180
  account: Address.Address
183
- /** Complete applicable multisig configuration witness. */
181
+ /** Complete applicable multisig configuration. */
184
182
  config: MultisigConfig.Config<bigint, numberType>
185
183
  /**
186
184
  * Owner approvals over the multisig owner approval digest. Each approval is
@@ -196,20 +194,8 @@ interface MultisigOneOf<numberType = number>
196
194
  Multisig<numberType>,
197
195
  Undefined<Omit<NonMultisig<numberType>, 'type'>> {}
198
196
 
199
- /** RPC-formatted native multisig signature. */
200
- export type MultisigRpc = {
201
- /** Native multisig account address. */
202
- account: Address.Address
203
- /** Complete applicable multisig configuration witness. */
204
- config: MultisigConfig.Rpc
205
- /** Structured owner approvals. */
206
- signatures: readonly SignatureEnvelopeRpc[]
207
- /** Multisig RPC signatures are untagged. */
208
- type?: undefined
209
- }
210
-
211
- interface MultisigRpcOneOf
212
- extends MultisigRpc, Undefined<Omit<NonMultisigRpc, 'type'>> {}
197
+ /** RPC-formatted native multisig signature without the `0x05` type byte. */
198
+ export type MultisigRpc = Hex.Hex
213
199
 
214
200
  export type P256<numberType = number> = {
215
201
  prehash: boolean
@@ -1040,7 +1026,7 @@ export declare namespace from {
1040
1026
  | {
1041
1027
  /** Initial native multisig account, derived from config when omitted. */
1042
1028
  account?: Address.Address | undefined
1043
- /** Initial version-0 multisig configuration witness. */
1029
+ /** Initial version-0 multisig configuration. */
1044
1030
  config: MultisigConfig.Input<0 | 0n>
1045
1031
  /** Primitive or nested owner approvals. */
1046
1032
  signatures: readonly SignatureEnvelope[]
@@ -1049,7 +1035,7 @@ export declare namespace from {
1049
1035
  | {
1050
1036
  /** Native multisig account. */
1051
1037
  account: Address.Address
1052
- /** Complete applicable multisig configuration witness. */
1038
+ /** Complete applicable multisig configuration. */
1053
1039
  config: MultisigConfig.Input
1054
1040
  /** Primitive or nested owner approvals. */
1055
1041
  signatures: readonly SignatureEnvelope[]
@@ -1103,6 +1089,20 @@ export declare namespace from {
1103
1089
  * @returns The signature envelope with bigint values.
1104
1090
  */
1105
1091
  export function fromRpc(envelope: SignatureEnvelopeRpc): SignatureEnvelope {
1092
+ if (typeof envelope === 'string') {
1093
+ const serialized = Hex.concat(serializedMultisigType, envelope)
1094
+ const result = deserialize(serialized)
1095
+ if (
1096
+ result.type !== 'multisig' ||
1097
+ !Hex.isEqual(serialize(result), serialized)
1098
+ )
1099
+ throw new InvalidSerializedError({
1100
+ reason: 'invalid multisig RPC signature',
1101
+ serialized: envelope,
1102
+ })
1103
+ return result
1104
+ }
1105
+
1106
1106
  if (envelope.type === 'secp256k1')
1107
1107
  return {
1108
1108
  signature: Signature.fromRpc(envelope),
@@ -1185,21 +1185,6 @@ export function fromRpc(envelope: SignatureEnvelopeRpc): SignatureEnvelope {
1185
1185
  }
1186
1186
  }
1187
1187
 
1188
- if (
1189
- (envelope as { type?: string | undefined }).type === 'multisig' ||
1190
- ('config' in envelope && 'signatures' in envelope)
1191
- ) {
1192
- const multisig = envelope as MultisigRpc
1193
- const result = {
1194
- account: multisig.account,
1195
- config: MultisigConfig.fromRpc(multisig.config),
1196
- signatures: multisig.signatures.map((signature) => fromRpc(signature)),
1197
- type: 'multisig',
1198
- } satisfies Multisig
1199
- assert(result)
1200
- return result
1201
- }
1202
-
1203
1188
  throw new CoercionError({ envelope })
1204
1189
  }
1205
1190
 
@@ -1207,8 +1192,10 @@ export declare namespace fromRpc {
1207
1192
  type ErrorType =
1208
1193
  | assert.ErrorType
1209
1194
  | CoercionError
1195
+ | Hex.concat.ErrorType
1196
+ | Hex.isEqual.ErrorType
1210
1197
  | InvalidSerializedError
1211
- | MultisigConfig.fromRpc.ErrorType
1198
+ | serialize.ErrorType
1212
1199
  | Signature.fromRpc.ErrorType
1213
1200
  | Errors.GlobalErrorType
1214
1201
  }
@@ -1510,7 +1497,7 @@ export declare namespace sortMultisigApprovals {
1510
1497
  type Value = {
1511
1498
  /** The native multisig account address. */
1512
1499
  account: Address.Address
1513
- /** Complete applicable multisig configuration witness. */
1500
+ /** Complete applicable multisig configuration. */
1514
1501
  config: MultisigConfig.Input
1515
1502
  /** The inner transaction sign payload (`tx.signature_hash()`). */
1516
1503
  payload: Hex.Hex | Bytes.Bytes
@@ -1599,12 +1586,7 @@ export function toRpc<const envelope extends toRpc.Input>(
1599
1586
 
1600
1587
  if (type === 'multisig') {
1601
1588
  const multisig = envelope as Multisig
1602
- assert(multisig)
1603
- return {
1604
- account: multisig.account,
1605
- config: MultisigConfig.toRpc(multisig.config),
1606
- signatures: multisig.signatures.map((signature) => toRpc(signature)),
1607
- } as never
1589
+ return Hex.slice(serialize(multisig), 1) as never
1608
1590
  }
1609
1591
 
1610
1592
  throw new CoercionError({ envelope })
@@ -1631,7 +1613,8 @@ export declare namespace toRpc {
1631
1613
  type ErrorType =
1632
1614
  | assert.ErrorType
1633
1615
  | CoercionError
1634
- | MultisigConfig.toRpc.ErrorType
1616
+ | Hex.slice.ErrorType
1617
+ | serialize.ErrorType
1635
1618
  | Signature.toRpc.ErrorType
1636
1619
  | Errors.GlobalErrorType
1637
1620
  }
@@ -1,6 +1,9 @@
1
1
  import { Transaction } from 'ox/tempo'
2
2
  import { describe, expect, test } from 'vp/test'
3
3
 
4
+ const multisigRpcSignature =
5
+ '0xf897949dba7f426b711d4893c11611eacf7cc334e7146bf83ba000000000000000000000000000000000000000000000000000000000000000008001d7d6947e5f4552091a69125d5dfcb7b8c2659029395bdf01f843b841869437e01f64bebeb78a8a6b30bfd3a993819c8cad82c807515d9b9e9b36f98535dfaa5eebc597715d05f6ce4927747f14fa4cd2acc717fdcd3877146437f8f41b' as const
6
+
4
7
  describe('fromRpc', () => {
5
8
  test('default', () => {
6
9
  const transaction = Transaction.fromRpc({
@@ -512,3 +515,61 @@ describe('toRpc', () => {
512
515
  `)
513
516
  })
514
517
  })
518
+
519
+ describe('roundtrip', () => {
520
+ test('behavior: multisig RPC signature', () => {
521
+ const rpc = {
522
+ accessList: [],
523
+ blockHash:
524
+ '0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b',
525
+ blockNumber: '0x12f296f',
526
+ calls: [],
527
+ chainId: '0x1',
528
+ feeToken: '0x20c0000000000000000000000000000000000000',
529
+ from: '0x9dba7f426b711d4893c11611eacf7cc334e7146b',
530
+ gas: '0x43f5d',
531
+ hash: '0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0',
532
+ maxFeePerGas: '0x2',
533
+ maxPriorityFeePerGas: '0x1',
534
+ nonce: '0x357',
535
+ signature: multisigRpcSignature,
536
+ transactionIndex: '0x2',
537
+ type: '0x76',
538
+ } as const satisfies Transaction.TempoRpc
539
+ const transaction = Transaction.fromRpc(rpc)
540
+
541
+ expect({
542
+ rpc: Transaction.toRpc(transaction).signature,
543
+ signature: transaction.signature,
544
+ }).toMatchInlineSnapshot(`
545
+ {
546
+ "rpc": "0xf897949dba7f426b711d4893c11611eacf7cc334e7146bf83ba000000000000000000000000000000000000000000000000000000000000000008001d7d6947e5f4552091a69125d5dfcb7b8c2659029395bdf01f843b841869437e01f64bebeb78a8a6b30bfd3a993819c8cad82c807515d9b9e9b36f98535dfaa5eebc597715d05f6ce4927747f14fa4cd2acc717fdcd3877146437f8f41b",
547
+ "signature": {
548
+ "account": "0x9dba7f426b711d4893c11611eacf7cc334e7146b",
549
+ "config": {
550
+ "owners": [
551
+ {
552
+ "owner": "0x7e5f4552091a69125d5dfcb7b8c2659029395bdf",
553
+ "weight": 1,
554
+ },
555
+ ],
556
+ "salt": "0x0000000000000000000000000000000000000000000000000000000000000000",
557
+ "threshold": 1,
558
+ "version": 0n,
559
+ },
560
+ "signatures": [
561
+ {
562
+ "signature": {
563
+ "r": "0x869437e01f64bebeb78a8a6b30bfd3a993819c8cad82c807515d9b9e9b36f985",
564
+ "s": "0x35dfaa5eebc597715d05f6ce4927747f14fa4cd2acc717fdcd3877146437f8f4",
565
+ "yParity": 0,
566
+ },
567
+ "type": "secp256k1",
568
+ },
569
+ ],
570
+ "type": "multisig",
571
+ },
572
+ }
573
+ `)
574
+ })
575
+ })
@@ -1,7 +1,7 @@
1
1
  import type * as ox_TransactionRequest from '../core/TransactionRequest.js'
2
2
  import * as Signature from '../core/Signature.js'
3
3
  import { describe, expectTypeOf, test } from 'vp/test'
4
- import * as MultisigWitness from './MultisigWitness.js'
4
+ import * as MultisigSimulation from './MultisigSimulation.js'
5
5
  import * as SignatureEnvelope from './SignatureEnvelope.js'
6
6
  import * as TransactionRequest from './TransactionRequest.js'
7
7
  import * as TxEnvelopeTempo from './TxEnvelopeTempo.js'
@@ -49,12 +49,12 @@ describe('TransactionRequest type', () => {
49
49
  >()
50
50
  })
51
51
 
52
- test('carries domain and RPC multisig witnesses', () => {
52
+ test('carries domain and RPC multisig simulations', () => {
53
53
  expectTypeOf<
54
- TransactionRequest.TransactionRequest['multisigWitness']
55
- >().toEqualTypeOf<MultisigWitness.MultisigWitness | undefined>()
56
- expectTypeOf<TransactionRequest.Rpc['multisigWitness']>().toEqualTypeOf<
57
- MultisigWitness.Rpc | undefined
54
+ TransactionRequest.TransactionRequest['multisigSimulation']
55
+ >().toEqualTypeOf<MultisigSimulation.Spec | undefined>()
56
+ expectTypeOf<TransactionRequest.Rpc['multisigSimulation']>().toEqualTypeOf<
57
+ MultisigSimulation.Rpc | undefined
58
58
  >()
59
59
  })
60
60
  })
@@ -87,7 +87,7 @@ describe('toEnvelope', () => {
87
87
  keyType: 'secp256k1',
88
88
  maxFeePerGas: 1n,
89
89
  maxPriorityFeePerGas: 1n,
90
- multisigWitness: undefined,
90
+ multisigSimulation: undefined,
91
91
  nonce: 0n,
92
92
  nonceKey: 'random',
93
93
  signature: undefined,
@@ -1,6 +1,77 @@
1
- import { TransactionRequest } from 'ox/tempo'
1
+ import {
2
+ MultisigConfig,
3
+ type MultisigSimulation,
4
+ TransactionRequest,
5
+ } from 'ox/tempo'
2
6
  import { describe, expect, test } from 'vp/test'
3
7
 
8
+ const multisigSimulationRpc = {
9
+ account: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
10
+ approvals: [
11
+ {
12
+ keyType: 'secp256k1',
13
+ owner: '0x1111111111111111111111111111111111111111',
14
+ type: 'primitive',
15
+ },
16
+ {
17
+ spec: {
18
+ account: '0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
19
+ approvals: [
20
+ {
21
+ keyData: '0x0578',
22
+ keyType: 'webAuthn',
23
+ owner: '0x2222222222222222222222222222222222222222',
24
+ },
25
+ ],
26
+ config:
27
+ '0xf83ba022222222222222222222222222222222222222222222222222222222222222220101d7d694222222222222222222222222222222222222222201',
28
+ },
29
+ type: 'multisig',
30
+ },
31
+ ],
32
+ config:
33
+ '0xf852a011111111111111111111111111111111111111111111111111111111111111118002eed694111111111111111111111111111111111111111101d694bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb01',
34
+ } as const satisfies MultisigSimulation.Rpc
35
+
36
+ const multisigSimulation = {
37
+ account: multisigSimulationRpc.account,
38
+ approvals: [
39
+ multisigSimulationRpc.approvals[0],
40
+ {
41
+ spec: {
42
+ account: multisigSimulationRpc.approvals[1].spec.account,
43
+ approvals: multisigSimulationRpc.approvals[1].spec.approvals,
44
+ config: MultisigConfig.from({
45
+ owners: [
46
+ {
47
+ owner: '0x2222222222222222222222222222222222222222',
48
+ weight: 1,
49
+ },
50
+ ],
51
+ salt: `0x${'22'.repeat(32)}`,
52
+ threshold: 1,
53
+ version: 1n,
54
+ }),
55
+ },
56
+ type: 'multisig',
57
+ },
58
+ ],
59
+ config: MultisigConfig.from({
60
+ owners: [
61
+ {
62
+ owner: '0x1111111111111111111111111111111111111111',
63
+ weight: 1,
64
+ },
65
+ {
66
+ owner: '0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
67
+ weight: 1,
68
+ },
69
+ ],
70
+ salt: `0x${'11'.repeat(32)}`,
71
+ threshold: 2,
72
+ }),
73
+ } as const satisfies MultisigSimulation.Spec
74
+
4
75
  describe('fromRpc', () => {
5
76
  test('default', () => {
6
77
  const request = TransactionRequest.fromRpc({
@@ -99,132 +170,62 @@ describe('fromRpc', () => {
99
170
  `)
100
171
  })
101
172
 
102
- test('behavior: multisig witness configs decode from RPC numbers', () => {
173
+ test('behavior: multisig simulation', () => {
103
174
  const request = TransactionRequest.fromRpc({
104
- calls: [{ to: '0xcafebabecafebabecafebabecafebabecafebabe' }],
105
- multisigWitness: {
106
- account: '0xcccccccccccccccccccccccccccccccccccccccc',
107
- approvals: [
175
+ from: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
176
+ multisigSimulation: multisigSimulationRpc,
177
+ type: '0x76',
178
+ })
179
+
180
+ expect(request.multisigSimulation).toMatchInlineSnapshot(`
181
+ {
182
+ "account": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
183
+ "approvals": [
108
184
  {
109
- keyData: '0x0578',
110
- keyType: 'webAuthn',
111
- owner: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
112
- type: 'primitive',
185
+ "keyType": "secp256k1",
186
+ "owner": "0x1111111111111111111111111111111111111111",
187
+ "type": "primitive",
113
188
  },
114
189
  {
115
- type: 'multisig',
116
- witness: {
117
- account: '0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
118
- approvals: [
190
+ "spec": {
191
+ "account": "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
192
+ "approvals": [
119
193
  {
120
- keyType: 'secp256k1',
121
- owner: '0xdddddddddddddddddddddddddddddddddddddddd',
122
- },
123
- {
124
- owner: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
194
+ "keyData": "0x0578",
195
+ "keyType": "webAuthn",
196
+ "owner": "0x2222222222222222222222222222222222222222",
125
197
  },
126
198
  ],
127
- config: {
128
- owners: [
129
- {
130
- owner: '0xdddddddddddddddddddddddddddddddddddddddd',
131
- weight: 1,
132
- },
199
+ "config": {
200
+ "owners": [
133
201
  {
134
- owner: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
135
- weight: 1,
202
+ "owner": "0x2222222222222222222222222222222222222222",
203
+ "weight": 1,
136
204
  },
137
205
  ],
138
- salt: '0x2222222222222222222222222222222222222222222222222222222222222222',
139
- threshold: 2,
140
- version: 2,
206
+ "salt": "0x2222222222222222222222222222222222222222222222222222222222222222",
207
+ "threshold": 1,
208
+ "version": 1n,
141
209
  },
142
210
  },
211
+ "type": "multisig",
143
212
  },
144
213
  ],
145
- config: {
146
- owners: [
214
+ "config": {
215
+ "owners": [
147
216
  {
148
- owner: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
149
- weight: 1,
217
+ "owner": "0x1111111111111111111111111111111111111111",
218
+ "weight": 1,
150
219
  },
151
220
  {
152
- owner: '0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
153
- weight: 1,
221
+ "owner": "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
222
+ "weight": 1,
154
223
  },
155
224
  ],
156
- salt: '0x1111111111111111111111111111111111111111111111111111111111111111',
157
- threshold: 2,
158
- version: 1,
225
+ "salt": "0x1111111111111111111111111111111111111111111111111111111111111111",
226
+ "threshold": 2,
227
+ "version": 0n,
159
228
  },
160
- },
161
- type: '0x76',
162
- })
163
- expect(request).toMatchInlineSnapshot(`
164
- {
165
- "calls": [
166
- {
167
- "data": undefined,
168
- "to": "0xcafebabecafebabecafebabecafebabecafebabe",
169
- },
170
- ],
171
- "multisigWitness": {
172
- "account": "0xcccccccccccccccccccccccccccccccccccccccc",
173
- "approvals": [
174
- {
175
- "keyData": "0x0578",
176
- "keyType": "webAuthn",
177
- "owner": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
178
- "type": "primitive",
179
- },
180
- {
181
- "type": "multisig",
182
- "witness": {
183
- "account": "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
184
- "approvals": [
185
- {
186
- "keyType": "secp256k1",
187
- "owner": "0xdddddddddddddddddddddddddddddddddddddddd",
188
- },
189
- {
190
- "owner": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
191
- },
192
- ],
193
- "config": {
194
- "owners": [
195
- {
196
- "owner": "0xdddddddddddddddddddddddddddddddddddddddd",
197
- "weight": 1,
198
- },
199
- {
200
- "owner": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
201
- "weight": 1,
202
- },
203
- ],
204
- "salt": "0x2222222222222222222222222222222222222222222222222222222222222222",
205
- "threshold": 2,
206
- "version": 2n,
207
- },
208
- },
209
- },
210
- ],
211
- "config": {
212
- "owners": [
213
- {
214
- "owner": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
215
- "weight": 1,
216
- },
217
- {
218
- "owner": "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
219
- "weight": 1,
220
- },
221
- ],
222
- "salt": "0x1111111111111111111111111111111111111111111111111111111111111111",
223
- "threshold": 2,
224
- "version": 1n,
225
- },
226
- },
227
- "type": "tempo",
228
229
  }
229
230
  `)
230
231
  })
@@ -313,130 +314,46 @@ describe('toRpc', () => {
313
314
  `)
314
315
  })
315
316
 
316
- test('behavior: multisig witness configs encode as RPC numbers', () => {
317
+ test('behavior: multisig simulation', () => {
317
318
  const request = TransactionRequest.toRpc({
318
- calls: [{ to: '0xcafebabecafebabecafebabecafebabecafebabe' }],
319
- multisigWitness: {
320
- account: '0xcccccccccccccccccccccccccccccccccccccccc',
321
- approvals: [
322
- {
323
- keyData: '0x0578',
324
- keyType: 'webAuthn',
325
- owner: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
326
- type: 'primitive',
327
- },
328
- {
329
- type: 'multisig',
330
- witness: {
331
- account: '0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
332
- approvals: [
333
- {
334
- keyType: 'secp256k1',
335
- owner: '0xdddddddddddddddddddddddddddddddddddddddd',
336
- },
337
- {
338
- owner: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
339
- },
340
- ],
341
- config: {
342
- owners: [
343
- {
344
- owner: '0xdddddddddddddddddddddddddddddddddddddddd',
345
- weight: 1,
346
- },
347
- {
348
- owner: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
349
- weight: 1,
350
- },
351
- ],
352
- salt: '0x2222222222222222222222222222222222222222222222222222222222222222',
353
- threshold: 2,
354
- version: 2n,
355
- },
356
- },
357
- },
358
- ],
359
- config: {
360
- owners: [
361
- {
362
- owner: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
363
- weight: 1,
364
- },
365
- {
366
- owner: '0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
367
- weight: 1,
368
- },
369
- ],
370
- salt: '0x1111111111111111111111111111111111111111111111111111111111111111',
371
- threshold: 2,
372
- version: 1n,
373
- },
374
- },
319
+ from: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
320
+ multisigSimulation,
375
321
  })
322
+
376
323
  expect(request).toMatchInlineSnapshot(`
377
324
  {
378
325
  "calls": [
379
326
  {
380
327
  "data": "0x",
381
- "to": "0xcafebabecafebabecafebabecafebabecafebabe",
328
+ "to": "0x0000000000000000000000000000000000000000",
382
329
  "value": "0x",
383
330
  },
384
331
  ],
385
- "multisigWitness": {
386
- "account": "0xcccccccccccccccccccccccccccccccccccccccc",
332
+ "from": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
333
+ "multisigSimulation": {
334
+ "account": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
387
335
  "approvals": [
388
336
  {
389
- "keyData": "0x0578",
390
- "keyType": "webAuthn",
391
- "owner": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
337
+ "keyType": "secp256k1",
338
+ "owner": "0x1111111111111111111111111111111111111111",
392
339
  "type": "primitive",
393
340
  },
394
341
  {
395
- "type": "multisig",
396
- "witness": {
342
+ "spec": {
397
343
  "account": "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
398
344
  "approvals": [
399
345
  {
400
- "keyType": "secp256k1",
401
- "owner": "0xdddddddddddddddddddddddddddddddddddddddd",
402
- },
403
- {
404
- "owner": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
346
+ "keyData": "0x0578",
347
+ "keyType": "webAuthn",
348
+ "owner": "0x2222222222222222222222222222222222222222",
405
349
  },
406
350
  ],
407
- "config": {
408
- "owners": [
409
- {
410
- "owner": "0xdddddddddddddddddddddddddddddddddddddddd",
411
- "weight": 1,
412
- },
413
- {
414
- "owner": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
415
- "weight": 1,
416
- },
417
- ],
418
- "salt": "0x2222222222222222222222222222222222222222222222222222222222222222",
419
- "threshold": 2,
420
- "version": 2,
421
- },
351
+ "config": "0xf83ba022222222222222222222222222222222222222222222222222222222222222220101d7d694222222222222222222222222222222222222222201",
422
352
  },
353
+ "type": "multisig",
423
354
  },
424
355
  ],
425
- "config": {
426
- "owners": [
427
- {
428
- "owner": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
429
- "weight": 1,
430
- },
431
- {
432
- "owner": "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
433
- "weight": 1,
434
- },
435
- ],
436
- "salt": "0x1111111111111111111111111111111111111111111111111111111111111111",
437
- "threshold": 2,
438
- "version": 1,
439
- },
356
+ "config": "0xf852a011111111111111111111111111111111111111111111111111111111111111118002eed694111111111111111111111111111111111111111101d694bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb01",
440
357
  },
441
358
  "type": "0x76",
442
359
  }
@@ -540,6 +457,7 @@ describe('roundtrip', () => {
540
457
  nonceKey: 255n,
541
458
  gas: 100000n,
542
459
  maxFeePerGas: 1000000000n,
460
+ multisigSimulation,
543
461
  }
544
462
 
545
463
  const rpc = TransactionRequest.toRpc(original)
@@ -560,6 +478,7 @@ describe('roundtrip', () => {
560
478
  expect(converted.nonceKey).toBe(original.nonceKey)
561
479
  expect(converted.gas).toBe(original.gas)
562
480
  expect(converted.maxFeePerGas).toBe(original.maxFeePerGas)
481
+ expect(converted.multisigSimulation).toEqual(original.multisigSimulation)
563
482
  expect(converted.type).toBe('tempo')
564
483
  })
565
484
 
@@ -577,6 +496,7 @@ describe('roundtrip', () => {
577
496
  validAfter: '0x32',
578
497
  nonceKey: '0xff',
579
498
  gas: '0x186a0',
499
+ multisigSimulation: multisigSimulationRpc,
580
500
  type: '0x76',
581
501
  }
582
502
 
@@ -589,6 +509,7 @@ describe('roundtrip', () => {
589
509
  expect(rpc.validAfter).toBe(original.validAfter)
590
510
  expect(rpc.nonceKey).toBe(original.nonceKey)
591
511
  expect(rpc.gas).toBe(original.gas)
512
+ expect(rpc.multisigSimulation).toEqual(original.multisigSimulation)
592
513
  expect(rpc.type).toBe('0x76')
593
514
  })
594
515
  })