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
@@ -1,3 +1,5 @@
1
+ import type * as core_Address from '../../../core/Address.js'
2
+ import type * as core_MultisigConfig from '../../../tempo/MultisigConfig.js'
1
3
  import type * as core_MultisigOperation from '../../../tempo/MultisigOperation.js'
2
4
  import type * as z from 'zod/mini'
3
5
  import { expectTypeOf, test } from 'vp/test'
@@ -23,6 +25,9 @@ test('Tempo namespace exposes tempo_simulateV1', () => {
23
25
  })
24
26
 
25
27
  test('multisig methods have the expected method names', () => {
28
+ expectTypeOf<
29
+ typeof z_RpcSchemaTempo.multisig_approveKeyAuthorization.method
30
+ >().toEqualTypeOf<'multisig_approveKeyAuthorization'>()
26
31
  expectTypeOf<
27
32
  typeof z_RpcSchemaTempo.multisig_approveRawTransaction.method
28
33
  >().toEqualTypeOf<'multisig_approveRawTransaction'>()
@@ -30,13 +35,22 @@ test('multisig methods have the expected method names', () => {
30
35
  typeof z_RpcSchemaTempo.multisig_approveRawTransactionSync.method
31
36
  >().toEqualTypeOf<'multisig_approveRawTransactionSync'>()
32
37
  expectTypeOf<
33
- typeof z_RpcSchemaTempo.multisig_approveKeyAuthorization.method
34
- >().toEqualTypeOf<'multisig_approveKeyAuthorization'>()
38
+ typeof z_RpcSchemaTempo.multisig_getConfig.method
39
+ >().toEqualTypeOf<'multisig_getConfig'>()
35
40
  expectTypeOf<
36
41
  typeof z_RpcSchemaTempo.multisig_getOperation.method
37
42
  >().toEqualTypeOf<'multisig_getOperation'>()
38
43
  })
39
44
 
45
+ test('multisig_getConfig has the expected request and return types', () => {
46
+ expectTypeOf<
47
+ z.input<typeof z_RpcSchemaTempo.multisig_getConfig.params>
48
+ >().toEqualTypeOf<[{ address: core_Address.Address }]>()
49
+ expectTypeOf<
50
+ z.output<typeof z_RpcSchemaTempo.multisig_getConfig.returns>
51
+ >().toEqualTypeOf<core_MultisigConfig.Rpc | null>()
52
+ })
53
+
40
54
  test('multisig return schemas decode RPC operations', () => {
41
55
  expectTypeOf<
42
56
  z.output<typeof z_RpcSchemaTempo.multisig_approveRawTransactionSync.returns>
@@ -47,6 +61,9 @@ test('multisig return schemas decode RPC operations', () => {
47
61
  })
48
62
 
49
63
  test('Multisig namespace exposes multisig methods', () => {
64
+ expectTypeOf<
65
+ typeof z_RpcSchemaTempo.Multisig.multisig_getConfig
66
+ >().toEqualTypeOf<typeof z_RpcSchemaTempo.multisig_getConfig>()
50
67
  expectTypeOf<
51
68
  typeof z_RpcSchemaTempo.Multisig.multisig_getOperation
52
69
  >().toEqualTypeOf<typeof z_RpcSchemaTempo.multisig_getOperation>()
@@ -56,6 +56,16 @@ describe('tempo_simulateV1', () => {
56
56
  })
57
57
 
58
58
  describe('multisig methods', () => {
59
+ test('decodes key authorization approval params', () => {
60
+ expect(
61
+ z_RpcSchema.decodeParams(
62
+ z_RpcSchemaTempo.Multisig,
63
+ 'multisig_approveKeyAuthorization',
64
+ [{ hash: '0x01', signature: '0x02' }],
65
+ ),
66
+ ).toEqual([{ hash: '0x01', signature: '0x02' }])
67
+ })
68
+
59
69
  test('decodes raw transaction params', () => {
60
70
  expect(
61
71
  z_RpcSchema.decodeParams(
@@ -66,14 +76,46 @@ describe('multisig methods', () => {
66
76
  ).toEqual(['0x76', 30_000])
67
77
  })
68
78
 
69
- test('decodes key authorization approval params', () => {
79
+ test('decodes config params', () => {
70
80
  expect(
71
81
  z_RpcSchema.decodeParams(
72
82
  z_RpcSchemaTempo.Multisig,
73
- 'multisig_approveKeyAuthorization',
74
- [{ hash: '0x01', signature: '0x02' }],
83
+ 'multisig_getConfig',
84
+ [{ address: '0xcafebabecafebabecafebabecafebabecafebabe' }],
75
85
  ),
76
- ).toEqual([{ hash: '0x01', signature: '0x02' }])
86
+ ).toEqual([{ address: '0xcafebabecafebabecafebabecafebabecafebabe' }])
87
+ })
88
+
89
+ test('decodes config result', () => {
90
+ const config = {
91
+ owners: [
92
+ {
93
+ owner: '0x1111111111111111111111111111111111111111',
94
+ weight: 1,
95
+ },
96
+ ],
97
+ salt: '0x0000000000000000000000000000000000000000000000000000000000000000',
98
+ threshold: 1,
99
+ version: '0x0',
100
+ } as const
101
+
102
+ expect(
103
+ z_RpcSchema.decodeReturns(
104
+ z_RpcSchemaTempo.Multisig,
105
+ 'multisig_getConfig',
106
+ config,
107
+ ),
108
+ ).toEqual(config)
109
+ })
110
+
111
+ test('accepts a missing config result', () => {
112
+ expect(
113
+ z_RpcSchema.decodeReturns(
114
+ z_RpcSchemaTempo.Multisig,
115
+ 'multisig_getConfig',
116
+ null,
117
+ ),
118
+ ).toBeNull()
77
119
  })
78
120
 
79
121
  test('accepts a missing operation result', () => {
@@ -19,38 +19,25 @@ const p256 = {
19
19
  type: 'p256',
20
20
  } as const
21
21
 
22
- const config = {
23
- owners: [
24
- {
25
- owner: '0x7e5f4552091a69125d5dfcb7b8c2659029395bdf',
26
- weight: 1,
27
- },
28
- ],
29
- salt: '0x0000000000000000000000000000000000000000000000000000000000000000',
30
- threshold: 1,
31
- version: '0x0',
32
- } as const
33
-
34
- const multisig = {
35
- account: '0x9dba7f426b711d4893c11611eacf7cc334e7146b',
36
- config,
37
- signatures: [secp256k1],
38
- } as const
22
+ const multisig =
23
+ '0xf897949dba7f426b711d4893c11611eacf7cc334e7146bf83ba000000000000000000000000000000000000000000000000000000000000000008001d7d6947e5f4552091a69125d5dfcb7b8c2659029395bdf01f843b841869437e01f64bebeb78a8a6b30bfd3a993819c8cad82c807515d9b9e9b36f98535dfaa5eebc597715d05f6ce4927747f14fa4cd2acc717fdcd3877146437f8f41b' as const
24
+ const nestedMultisig =
25
+ '0xf8f0949969e2243075b27a8eab61009c59b77ab13b83f6f83ba033333333333333333333333333333333333333333333333333333333333333338001d7d6944f9f5b162a7464bcc260ce44d7ae0d935f9c583701f89cb89a05f897944f9f5b162a7464bcc260ce44d7ae0d935f9c5837f83ba022222222222222222222222222222222222222222222222222222222222222228001d7d6946813eb9362372eef6200f3b1dbc3f819671cba6901f843b841032aa6f3ea7b0b7069720d0f3891983c493d149326c5c957d864ed7371b8475e3e95325079b24491f4b6d68920e4b3bacd7c6094df6ed88b8674864ab559c8fb1b' as const
39
26
 
40
27
  describe('SignatureEnvelope', () => {
41
- test('decodes a secp256k1 envelope', () => {
28
+ test('behavior: decodes a secp256k1 envelope', () => {
42
29
  expect(z.decode(z_SignatureEnvelope.SignatureEnvelope, secp256k1)).toEqual(
43
30
  core_SignatureEnvelope.fromRpc(secp256k1),
44
31
  )
45
32
  })
46
33
 
47
- test('decodes a p256 envelope', () => {
34
+ test('behavior: decodes a p256 envelope', () => {
48
35
  expect(z.decode(z_SignatureEnvelope.SignatureEnvelope, p256)).toEqual(
49
36
  core_SignatureEnvelope.fromRpc(p256),
50
37
  )
51
38
  })
52
39
 
53
- test('decodes a recursive keychain envelope', () => {
40
+ test('behavior: decodes a recursive keychain envelope', () => {
54
41
  const keychain = {
55
42
  signature: secp256k1,
56
43
  type: 'keychain',
@@ -61,144 +48,103 @@ describe('SignatureEnvelope', () => {
61
48
  )
62
49
  })
63
50
 
64
- test('decodes a multisig envelope', () => {
51
+ test('behavior: decodes a multisig envelope', () => {
65
52
  expect(z.decode(z_SignatureEnvelope.SignatureEnvelope, multisig)).toEqual(
66
53
  core_SignatureEnvelope.fromRpc(multisig),
67
54
  )
68
55
  })
69
56
 
70
- test('decodes recursive multisig approvals', () => {
71
- const nested = {
72
- ...multisig,
73
- signatures: [
74
- {
75
- account: '0x1111111111111111111111111111111111111111',
76
- config: {
77
- ...config,
78
- version: '0x1',
79
- },
80
- signatures: [secp256k1],
81
- },
82
- ],
83
- } as const
84
- expect(z.decode(z_SignatureEnvelope.SignatureEnvelope, nested)).toEqual(
85
- core_SignatureEnvelope.fromRpc(nested),
86
- )
57
+ test('behavior: decodes recursive multisig approvals', () => {
58
+ expect(
59
+ z.decode(z_SignatureEnvelope.SignatureEnvelope, nestedMultisig),
60
+ ).toEqual(core_SignatureEnvelope.fromRpc(nestedMultisig))
87
61
  })
88
62
 
89
- test('round-trips secp256k1 via encode', () => {
63
+ test('behavior: round-trips secp256k1 via encode', () => {
90
64
  const decoded = z.decode(z_SignatureEnvelope.SignatureEnvelope, secp256k1)
91
65
  expect(z.encode(z_SignatureEnvelope.SignatureEnvelope, decoded)).toEqual(
92
66
  core_SignatureEnvelope.toRpc(decoded),
93
67
  )
94
68
  })
95
69
 
96
- test('round-trips multisig via encode', () => {
70
+ test('behavior: round-trips multisig via encode', () => {
97
71
  const decoded = z.decode(z_SignatureEnvelope.SignatureEnvelope, multisig)
98
72
  expect(z.encode(z_SignatureEnvelope.SignatureEnvelope, decoded)).toEqual(
99
- core_SignatureEnvelope.toRpc(decoded),
73
+ multisig,
100
74
  )
101
75
  })
102
76
 
103
- test('rejects invalid recursive multisig domains before encode', () => {
104
- const invalid = {
105
- account: multisig.account,
106
- config: { ...config, version: 0n },
107
- signatures: [
108
- {
109
- inner: core_SignatureEnvelope.fromRpc(secp256k1),
110
- type: 'keychain',
111
- userAddress: multisig.account,
112
- },
113
- ],
114
- type: 'multisig',
115
- } as const
116
-
117
- expect(
118
- z.safeEncode(z_SignatureEnvelope.SignatureEnvelope, invalid as never)
119
- .success,
120
- ).toMatchInlineSnapshot(`false`)
121
- })
122
-
123
- test('rejects legacy multisig approval encoding', () => {
77
+ test('error: rejects invalid recursive multisig domains before encode', () => {
78
+ const decoded = core_SignatureEnvelope.fromRpc(multisig)
79
+ if (decoded.type !== 'multisig') throw new Error('unreachable')
124
80
  expect(
125
- z.safeDecode(z_SignatureEnvelope.SignatureEnvelope, {
126
- ...multisig,
81
+ z.safeEncode(z_SignatureEnvelope.SignatureEnvelope, {
82
+ ...decoded,
127
83
  signatures: [
128
- core_SignatureEnvelope.serialize(
129
- core_SignatureEnvelope.fromRpc(secp256k1),
130
- ),
84
+ {
85
+ inner: core_SignatureEnvelope.fromRpc(secp256k1),
86
+ type: 'keychain',
87
+ userAddress: decoded.account,
88
+ },
131
89
  ],
132
90
  } as never).success,
133
91
  ).toMatchInlineSnapshot(`false`)
134
92
  })
135
93
 
136
- test('rejects multisig approval counts outside protocol limits', () => {
94
+ test('error: rejects multisig approval counts outside protocol limits', () => {
95
+ const decoded = core_SignatureEnvelope.fromRpc(multisig)
96
+ if (decoded.type !== 'multisig') throw new Error('unreachable')
137
97
  expect(
138
- z.safeDecode(z_SignatureEnvelope.SignatureEnvelope, {
139
- ...multisig,
98
+ z.safeEncode(z_SignatureEnvelope.SignatureEnvelope, {
99
+ ...decoded,
140
100
  signatures: [],
141
- }).success,
101
+ } as never).success,
142
102
  ).toMatchInlineSnapshot(`false`)
143
103
  expect(
144
- z.safeDecode(z_SignatureEnvelope.SignatureEnvelope, {
145
- ...multisig,
146
- signatures: Array.from({ length: 9 }, () => secp256k1),
147
- }).success,
104
+ z.safeEncode(z_SignatureEnvelope.SignatureEnvelope, {
105
+ ...decoded,
106
+ signatures: Array.from({ length: 9 }, () => decoded.signatures[0]),
107
+ } as never).success,
148
108
  ).toMatchInlineSnapshot(`false`)
149
109
  })
150
110
 
151
- test('rejects invalid recursive multisig approvals', () => {
152
- const keychain = {
153
- signature: secp256k1,
154
- type: 'keychain',
155
- userAddress: multisig.account,
156
- } as const
157
- const depth2 = {
158
- account: '0x1111111111111111111111111111111111111111',
159
- config: { ...config, version: '0x1' },
160
- signatures: [secp256k1],
161
- } as const
162
- const depth3 = {
163
- account: '0x2222222222222222222222222222222222222222',
164
- config: { ...config, version: '0x1' },
165
- signatures: [depth2],
166
- } as const
167
-
168
- expect(
169
- z.safeDecode(z_SignatureEnvelope.SignatureEnvelope, {
170
- ...multisig,
171
- signatures: [keychain],
172
- }).success,
173
- ).toMatchInlineSnapshot(`false`)
111
+ test('error: rejects excess multisig nesting', () => {
112
+ const nested = core_SignatureEnvelope.fromRpc(nestedMultisig)
113
+ if (nested.type !== 'multisig') throw new Error('unreachable')
174
114
  expect(
175
- z.safeDecode(z_SignatureEnvelope.SignatureEnvelope, {
176
- ...multisig,
177
- signatures: [depth3],
178
- }).success,
115
+ z.safeEncode(z_SignatureEnvelope.SignatureEnvelope, {
116
+ account: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
117
+ config: {
118
+ ...nested.config,
119
+ owners: [{ owner: nested.account, weight: 1 }],
120
+ version: 1n,
121
+ },
122
+ signatures: [nested],
123
+ type: 'multisig',
124
+ } as never).success,
179
125
  ).toMatchInlineSnapshot(`false`)
180
126
  })
181
127
 
182
- test('rejects old multisig witness shapes', () => {
128
+ test('error: rejects structured multisig RPC envelopes', () => {
183
129
  expect(
184
130
  z.safeDecode(z_SignatureEnvelope.SignatureEnvelope, {
185
- init: config,
186
- account: multisig.account,
187
- signatures: [secp256k1],
131
+ account: '0x9dba7f426b711d4893c11611eacf7cc334e7146b',
132
+ config: {},
133
+ signatures: [],
188
134
  } as never).success,
189
135
  ).toMatchInlineSnapshot(`false`)
190
136
  })
191
137
 
192
- test('rejects tagged multisig RPC envelopes', () => {
138
+ test('error: rejects tagged multisig RPC envelopes', () => {
193
139
  expect(
194
- z.safeDecode(z_SignatureEnvelope.SignatureEnvelope, {
195
- ...multisig,
196
- type: 'multisig',
197
- } as never).success,
140
+ z.safeDecode(
141
+ z_SignatureEnvelope.SignatureEnvelope,
142
+ `0x05${multisig.slice(2)}`,
143
+ ).success,
198
144
  ).toMatchInlineSnapshot(`false`)
199
145
  })
200
146
 
201
- test('rejects an invalid envelope', () => {
147
+ test('error: rejects an invalid envelope', () => {
202
148
  expect(
203
149
  z.safeDecode(z_SignatureEnvelope.SignatureEnvelope, {
204
150
  type: 'secp256k1',
@@ -63,186 +63,45 @@ describe('TransactionRequest', () => {
63
63
  expect(encoded).toEqual(core_TransactionRequest.toRpc(decoded))
64
64
  })
65
65
 
66
- test('multisig witness round-trips', () => {
67
- const witness = {
68
- account: '0xcccccccccccccccccccccccccccccccccccccccc',
66
+ test('multisig simulation round-trips', () => {
67
+ const multisigSimulation = {
68
+ account: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
69
69
  approvals: [
70
70
  {
71
- keyData: '0x0578',
72
- keyType: 'webAuthn',
73
- owner: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
71
+ keyType: 'secp256k1',
72
+ owner: '0x1111111111111111111111111111111111111111',
74
73
  type: 'primitive',
75
74
  },
76
75
  {
77
- type: 'multisig',
78
- witness: {
76
+ spec: {
79
77
  account: '0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
80
78
  approvals: [
81
79
  {
82
- keyType: 'secp256k1',
83
- owner: '0xdddddddddddddddddddddddddddddddddddddddd',
84
- },
85
- {
86
- owner: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
80
+ keyData: '0x0578',
81
+ keyType: 'webAuthn',
82
+ owner: '0x2222222222222222222222222222222222222222',
87
83
  },
88
84
  ],
89
- config: {
90
- owners: [
91
- {
92
- owner: '0xdddddddddddddddddddddddddddddddddddddddd',
93
- weight: 1,
94
- },
95
- {
96
- owner: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
97
- weight: 1,
98
- },
99
- ],
100
- salt: '0x2222222222222222222222222222222222222222222222222222222222222222',
101
- threshold: 2,
102
- version: 2,
103
- },
85
+ config:
86
+ '0xf83ba022222222222222222222222222222222222222222222222222222222222222220101d7d694222222222222222222222222222222222222222201',
104
87
  },
88
+ type: 'multisig',
105
89
  },
106
90
  ],
107
- config: {
108
- owners: [
109
- {
110
- owner: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
111
- weight: 1,
112
- },
113
- {
114
- owner: '0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
115
- weight: 1,
116
- },
117
- ],
118
- salt: '0x1111111111111111111111111111111111111111111111111111111111111111',
119
- threshold: 2,
120
- version: 1,
121
- },
91
+ config:
92
+ '0xf852a011111111111111111111111111111111111111111111111111111111111111118002eed694111111111111111111111111111111111111111101d694bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb01',
122
93
  } as const
123
94
 
124
95
  const decoded = z.decode(z_TransactionRequest.TransactionRequest, {
125
96
  ...rpc,
126
- multisigWitness: witness,
97
+ multisigSimulation,
127
98
  })
128
- expect(decoded.multisigWitness).toMatchInlineSnapshot(`
129
- {
130
- "account": "0xcccccccccccccccccccccccccccccccccccccccc",
131
- "approvals": [
132
- {
133
- "keyData": "0x0578",
134
- "keyType": "webAuthn",
135
- "owner": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
136
- "type": "primitive",
137
- },
138
- {
139
- "type": "multisig",
140
- "witness": {
141
- "account": "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
142
- "approvals": [
143
- {
144
- "keyType": "secp256k1",
145
- "owner": "0xdddddddddddddddddddddddddddddddddddddddd",
146
- },
147
- {
148
- "owner": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
149
- },
150
- ],
151
- "config": {
152
- "owners": [
153
- {
154
- "owner": "0xdddddddddddddddddddddddddddddddddddddddd",
155
- "weight": 1,
156
- },
157
- {
158
- "owner": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
159
- "weight": 1,
160
- },
161
- ],
162
- "salt": "0x2222222222222222222222222222222222222222222222222222222222222222",
163
- "threshold": 2,
164
- "version": 2n,
165
- },
166
- },
167
- },
168
- ],
169
- "config": {
170
- "owners": [
171
- {
172
- "owner": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
173
- "weight": 1,
174
- },
175
- {
176
- "owner": "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
177
- "weight": 1,
178
- },
179
- ],
180
- "salt": "0x1111111111111111111111111111111111111111111111111111111111111111",
181
- "threshold": 2,
182
- "version": 1n,
183
- },
184
- }
185
- `)
99
+ expect(decoded).toEqual(
100
+ core_TransactionRequest.fromRpc({ ...rpc, multisigSimulation }),
101
+ )
186
102
 
187
103
  const encoded = z.encode(z_TransactionRequest.TransactionRequest, decoded)
188
- expect(encoded.multisigWitness).toMatchInlineSnapshot(`
189
- {
190
- "account": "0xcccccccccccccccccccccccccccccccccccccccc",
191
- "approvals": [
192
- {
193
- "keyData": "0x0578",
194
- "keyType": "webAuthn",
195
- "owner": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
196
- "type": "primitive",
197
- },
198
- {
199
- "type": "multisig",
200
- "witness": {
201
- "account": "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
202
- "approvals": [
203
- {
204
- "keyType": "secp256k1",
205
- "owner": "0xdddddddddddddddddddddddddddddddddddddddd",
206
- },
207
- {
208
- "owner": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
209
- },
210
- ],
211
- "config": {
212
- "owners": [
213
- {
214
- "owner": "0xdddddddddddddddddddddddddddddddddddddddd",
215
- "weight": 1,
216
- },
217
- {
218
- "owner": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
219
- "weight": 1,
220
- },
221
- ],
222
- "salt": "0x2222222222222222222222222222222222222222222222222222222222222222",
223
- "threshold": 2,
224
- "version": 2,
225
- },
226
- },
227
- },
228
- ],
229
- "config": {
230
- "owners": [
231
- {
232
- "owner": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
233
- "weight": 1,
234
- },
235
- {
236
- "owner": "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
237
- "weight": 1,
238
- },
239
- ],
240
- "salt": "0x1111111111111111111111111111111111111111111111111111111111111111",
241
- "threshold": 2,
242
- "version": 1,
243
- },
244
- }
245
- `)
104
+ expect(encoded.multisigSimulation).toStrictEqual(multisigSimulation)
246
105
  expect(encoded).toEqual(core_TransactionRequest.toRpc(decoded))
247
106
  })
248
107
 
@@ -3,7 +3,7 @@ export * as AuthorizationTempo from './AuthorizationTempo.js'
3
3
  export * as KeyAuthorization from './KeyAuthorization.js'
4
4
  export * as MultisigConfig from './MultisigConfig.js'
5
5
  export * as MultisigOperation from './MultisigOperation.js'
6
- export * as MultisigWitness from './MultisigWitness.js'
6
+ export * as MultisigSimulation from './MultisigSimulation.js'
7
7
  export * as PoolId from './PoolId.js'
8
8
  export * as RpcSchemaTempo from './RpcSchemaTempo.js'
9
9
  export * as SignatureEnvelope from './SignatureEnvelope.js'
@@ -1,106 +0,0 @@
1
- import type * as Address from '../core/Address.js';
2
- import * as Errors from '../core/Errors.js';
3
- import * as Hex from '../core/Hex.js';
4
- import type { Compute } from '../core/internal/types.js';
5
- import * as MultisigConfig from './MultisigConfig.js';
6
- import type * as SignatureEnvelope from './SignatureEnvelope.js';
7
- /** Native multisig owner approval used for RPC simulation. */
8
- export type Approval<versionType = bigint> = NestedApproval<versionType> | PrimitiveApproval;
9
- /** Native multisig witness used to construct an RPC simulation signature. */
10
- export type MultisigWitness<versionType = bigint> = Compute<{
11
- /** Account authorized by this witness. */
12
- account: Address.Address;
13
- /** Owner approvals to model. */
14
- approvals: readonly Approval<versionType>[];
15
- /** Complete applicable configuration. */
16
- config: MultisigConfig.Config<versionType>;
17
- }>;
18
- /** Nested native multisig owner approval used for RPC simulation. */
19
- export type NestedApproval<versionType = bigint> = {
20
- /** Approval type. */
21
- type: 'multisig';
22
- /** Depth-2 multisig witness. */
23
- witness: NestedWitness<versionType>;
24
- };
25
- /** Primitive approval in a depth-2 multisig simulation witness. */
26
- export type NestedPrimitiveApproval = {
27
- /** Optional signature-specific gas-estimation data. */
28
- keyData?: Hex.Hex | undefined;
29
- /** Signature type to model. Omission uses a maximum-size WebAuthn signature. */
30
- keyType?: SignatureEnvelope.Type | undefined;
31
- /** Configured owner address. */
32
- owner: Address.Address;
33
- };
34
- /** Depth-2 native multisig witness used for RPC simulation. */
35
- export type NestedWitness<versionType = bigint> = {
36
- /** Nested multisig account. */
37
- account: Address.Address;
38
- /** Primitive owner approvals to model. */
39
- approvals: readonly NestedPrimitiveApproval[];
40
- /** Complete applicable configuration. */
41
- config: MultisigConfig.Config<versionType>;
42
- };
43
- /** Primitive owner approval used for RPC simulation. */
44
- export type PrimitiveApproval = {
45
- /** Optional signature-specific gas-estimation data. */
46
- keyData?: Hex.Hex | undefined;
47
- /** Signature type to model. Omission uses a maximum-size WebAuthn signature. */
48
- keyType?: SignatureEnvelope.Type | undefined;
49
- /** Configured owner address. */
50
- owner: Address.Address;
51
- /** Approval type. */
52
- type: 'primitive';
53
- };
54
- /** JSON-RPC representation of a native multisig simulation witness. */
55
- export type Rpc = MultisigWitness<number>;
56
- /**
57
- * Converts a JSON-RPC multisig witness to its domain representation.
58
- *
59
- * @example
60
- * ```ts twoslash
61
- * // @noErrors
62
- * import { MultisigWitness } from 'ox/tempo'
63
- *
64
- * const witness = MultisigWitness.fromRpc(witnessRpc)
65
- * ```
66
- *
67
- * @param witness - JSON-RPC multisig witness.
68
- * @returns The multisig witness with bigint configuration versions.
69
- */
70
- export declare function fromRpc(witness: Rpc): MultisigWitness;
71
- export declare namespace fromRpc {
72
- /** Error type for `fromRpc`. */
73
- type ErrorType = InvalidWitnessError | MultisigConfig.assert.ErrorType | Errors.GlobalErrorType;
74
- }
75
- /**
76
- * Converts a multisig witness to its JSON-RPC representation.
77
- *
78
- * @example
79
- * ```ts twoslash
80
- * // @noErrors
81
- * import { MultisigWitness } from 'ox/tempo'
82
- *
83
- * const witnessRpc = MultisigWitness.toRpc(witness)
84
- * ```
85
- *
86
- * @param witness - Multisig witness.
87
- * @returns The JSON-RPC multisig witness with numeric configuration versions.
88
- */
89
- export declare function toRpc(witness: MultisigWitness): Rpc;
90
- export declare namespace toRpc {
91
- /** Error type for `toRpc`. */
92
- type ErrorType = Hex.fromNumber.ErrorType | Hex.toNumber.ErrorType | InvalidWitnessError | MultisigConfig.assert.ErrorType | Errors.GlobalErrorType;
93
- }
94
- /** Thrown when a native multisig witness is invalid. */
95
- export declare class InvalidWitnessError extends Errors.BaseError {
96
- readonly name = "MultisigWitness.InvalidWitnessError";
97
- constructor(options: InvalidWitnessError.Options);
98
- }
99
- export declare namespace InvalidWitnessError {
100
- /** Error construction options. */
101
- type Options = {
102
- /** Validation failure. */
103
- reason: string;
104
- };
105
- }
106
- //# sourceMappingURL=MultisigWitness.d.ts.map