ox 1.7.2 → 1.7.5

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 (142) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/dist/core/AbiEvent.d.ts.map +1 -1
  3. package/dist/core/AbiEvent.js +10 -9
  4. package/dist/core/AbiEvent.js.map +1 -1
  5. package/dist/core/Blobs.d.ts.map +1 -1
  6. package/dist/core/Blobs.js +6 -2
  7. package/dist/core/Blobs.js.map +1 -1
  8. package/dist/core/Signature.d.ts +6 -5
  9. package/dist/core/Signature.d.ts.map +1 -1
  10. package/dist/core/Signature.js +17 -7
  11. package/dist/core/Signature.js.map +1 -1
  12. package/dist/core/Siwe.d.ts.map +1 -1
  13. package/dist/core/Siwe.js +21 -1
  14. package/dist/core/Siwe.js.map +1 -1
  15. package/dist/tempo/KeyAuthorization.d.ts +43 -39
  16. package/dist/tempo/KeyAuthorization.d.ts.map +1 -1
  17. package/dist/tempo/KeyAuthorization.js +24 -4
  18. package/dist/tempo/KeyAuthorization.js.map +1 -1
  19. package/dist/tempo/MultisigConfig.d.ts +18 -15
  20. package/dist/tempo/MultisigConfig.d.ts.map +1 -1
  21. package/dist/tempo/MultisigConfig.js +49 -20
  22. package/dist/tempo/MultisigConfig.js.map +1 -1
  23. package/dist/tempo/MultisigOperation.d.ts +45 -28
  24. package/dist/tempo/MultisigOperation.d.ts.map +1 -1
  25. package/dist/tempo/MultisigOperation.js +81 -131
  26. package/dist/tempo/MultisigOperation.js.map +1 -1
  27. package/dist/tempo/MultisigSimulation.d.ts +85 -0
  28. package/dist/tempo/MultisigSimulation.d.ts.map +1 -0
  29. package/dist/tempo/MultisigSimulation.js +112 -0
  30. package/dist/tempo/MultisigSimulation.js.map +1 -0
  31. package/dist/tempo/RpcSchemaTempo.d.ts +20 -10
  32. package/dist/tempo/RpcSchemaTempo.d.ts.map +1 -1
  33. package/dist/tempo/SignatureEnvelope.d.ts +74 -153
  34. package/dist/tempo/SignatureEnvelope.d.ts.map +1 -1
  35. package/dist/tempo/SignatureEnvelope.js +130 -187
  36. package/dist/tempo/SignatureEnvelope.js.map +1 -1
  37. package/dist/tempo/TransactionRequest.d.ts +9 -7
  38. package/dist/tempo/TransactionRequest.d.ts.map +1 -1
  39. package/dist/tempo/TransactionRequest.js +12 -7
  40. package/dist/tempo/TransactionRequest.js.map +1 -1
  41. package/dist/tempo/index.d.ts +7 -5
  42. package/dist/tempo/index.d.ts.map +1 -1
  43. package/dist/tempo/index.js +7 -5
  44. package/dist/tempo/index.js.map +1 -1
  45. package/dist/zod/tempo/AuthorizationTempo.d.ts +360 -140
  46. package/dist/zod/tempo/AuthorizationTempo.d.ts.map +1 -1
  47. package/dist/zod/tempo/KeyAuthorization.d.ts +247 -487
  48. package/dist/zod/tempo/KeyAuthorization.d.ts.map +1 -1
  49. package/dist/zod/tempo/KeyAuthorization.js +29 -31
  50. package/dist/zod/tempo/KeyAuthorization.js.map +1 -1
  51. package/dist/zod/tempo/MultisigOperation.d.ts +0 -10
  52. package/dist/zod/tempo/MultisigOperation.d.ts.map +1 -1
  53. package/dist/zod/tempo/MultisigOperation.js +0 -3
  54. package/dist/zod/tempo/MultisigOperation.js.map +1 -1
  55. package/dist/zod/tempo/MultisigSimulation.d.ts +52 -0
  56. package/dist/zod/tempo/MultisigSimulation.d.ts.map +1 -0
  57. package/dist/zod/tempo/MultisigSimulation.js +44 -0
  58. package/dist/zod/tempo/MultisigSimulation.js.map +1 -0
  59. package/dist/zod/tempo/RpcSchemaTempo.d.ts +357 -422
  60. package/dist/zod/tempo/RpcSchemaTempo.d.ts.map +1 -1
  61. package/dist/zod/tempo/RpcSchemaTempo.js +19 -10
  62. package/dist/zod/tempo/RpcSchemaTempo.js.map +1 -1
  63. package/dist/zod/tempo/SignatureEnvelope.d.ts +108 -42
  64. package/dist/zod/tempo/SignatureEnvelope.d.ts.map +1 -1
  65. package/dist/zod/tempo/SignatureEnvelope.js +21 -19
  66. package/dist/zod/tempo/SignatureEnvelope.js.map +1 -1
  67. package/dist/zod/tempo/Transaction.d.ts +678 -666
  68. package/dist/zod/tempo/Transaction.d.ts.map +1 -1
  69. package/dist/zod/tempo/TransactionRequest.d.ts +580 -619
  70. package/dist/zod/tempo/TransactionRequest.d.ts.map +1 -1
  71. package/dist/zod/tempo/TransactionRequest.js +18 -10
  72. package/dist/zod/tempo/TransactionRequest.js.map +1 -1
  73. package/dist/zod/tempo/TxEnvelopeTempo.d.ts +327 -213
  74. package/dist/zod/tempo/TxEnvelopeTempo.d.ts.map +1 -1
  75. package/dist/zod/tempo/ZoneRpcAuthentication.d.ts +105 -3
  76. package/dist/zod/tempo/ZoneRpcAuthentication.d.ts.map +1 -1
  77. package/dist/zod/tempo/z.d.ts +1 -1
  78. package/dist/zod/tempo/z.d.ts.map +1 -1
  79. package/dist/zod/tempo/z.js +1 -1
  80. package/dist/zod/tempo/z.js.map +1 -1
  81. package/package.json +9 -9
  82. package/src/core/AbiEvent.ts +11 -9
  83. package/src/core/Blobs.ts +6 -2
  84. package/src/core/Signature.ts +41 -11
  85. package/src/core/Siwe.ts +20 -1
  86. package/src/core/_test/AbiEvent.test.ts +45 -0
  87. package/src/core/_test/Blobs.test.ts +22 -0
  88. package/src/core/_test/Signature.test.ts +166 -0
  89. package/src/core/_test/Siwe.test.ts +100 -1
  90. package/src/tempo/AuthorizationTempo.test.ts +8 -0
  91. package/src/tempo/KeyAuthorization.test-d.ts +16 -74
  92. package/src/tempo/KeyAuthorization.test.ts +113 -14
  93. package/src/tempo/KeyAuthorization.ts +110 -66
  94. package/src/tempo/MultisigConfig.test.ts +44 -20
  95. package/src/tempo/MultisigConfig.ts +65 -23
  96. package/src/tempo/MultisigOperation.test-d.ts +8 -6
  97. package/src/tempo/MultisigOperation.test.ts +187 -591
  98. package/src/tempo/MultisigOperation.ts +129 -205
  99. package/src/tempo/MultisigSimulation.test-d.ts +33 -0
  100. package/src/tempo/MultisigSimulation.test.ts +194 -0
  101. package/src/tempo/MultisigSimulation.ts +192 -0
  102. package/src/tempo/RpcSchemaTempo.test-d.ts +45 -10
  103. package/src/tempo/RpcSchemaTempo.ts +15 -6
  104. package/src/tempo/SignatureEnvelope.test-d.ts +27 -101
  105. package/src/tempo/SignatureEnvelope.test.ts +330 -533
  106. package/src/tempo/SignatureEnvelope.ts +198 -310
  107. package/src/tempo/Transaction.test.ts +61 -0
  108. package/src/tempo/TransactionRequest.test-d.ts +7 -7
  109. package/src/tempo/TransactionRequest.test.ts +81 -223
  110. package/src/tempo/TransactionRequest.ts +34 -13
  111. package/src/tempo/index.ts +7 -5
  112. package/src/tempo/multisig.e2e.test.ts +329 -818
  113. package/src/version.ts +1 -1
  114. package/src/zod/tempo/KeyAuthorization.ts +50 -39
  115. package/src/zod/tempo/MultisigOperation.ts +0 -3
  116. package/src/zod/tempo/MultisigSimulation.ts +53 -0
  117. package/src/zod/tempo/RpcSchemaTempo.ts +20 -10
  118. package/src/zod/tempo/SignatureEnvelope.ts +46 -59
  119. package/src/zod/tempo/TransactionRequest.ts +28 -14
  120. package/src/zod/tempo/_test/KeyAuthorization.test.ts +66 -30
  121. package/src/zod/tempo/_test/MultisigOperation.test.ts +0 -2
  122. package/src/zod/tempo/_test/MultisigSimulation.test-d.ts +13 -0
  123. package/src/zod/tempo/_test/MultisigSimulation.test.ts +53 -0
  124. package/src/zod/tempo/_test/RpcSchemaTempo.test-d.ts +19 -2
  125. package/src/zod/tempo/_test/RpcSchemaTempo.test.ts +46 -4
  126. package/src/zod/tempo/_test/SignatureEnvelope.test.ts +108 -129
  127. package/src/zod/tempo/_test/TransactionRequest.test.ts +17 -168
  128. package/src/zod/tempo/z.ts +1 -1
  129. package/dist/tempo/MultisigWitness.d.ts +0 -106
  130. package/dist/tempo/MultisigWitness.d.ts.map +0 -1
  131. package/dist/tempo/MultisigWitness.js +0 -118
  132. package/dist/tempo/MultisigWitness.js.map +0 -1
  133. package/dist/zod/tempo/MultisigWitness.d.ts +0 -152
  134. package/dist/zod/tempo/MultisigWitness.d.ts.map +0 -1
  135. package/dist/zod/tempo/MultisigWitness.js +0 -76
  136. package/dist/zod/tempo/MultisigWitness.js.map +0 -1
  137. package/src/tempo/MultisigWitness.test-d.ts +0 -42
  138. package/src/tempo/MultisigWitness.test.ts +0 -288
  139. package/src/tempo/MultisigWitness.ts +0 -210
  140. package/src/zod/tempo/MultisigWitness.ts +0 -101
  141. package/src/zod/tempo/_test/MultisigWitness.test-d.ts +0 -13
  142. package/src/zod/tempo/_test/MultisigWitness.test.ts +0 -149
@@ -0,0 +1,53 @@
1
+ import { describe, expect, test } from 'vp/test'
2
+ import * as core_MultisigSimulation from '../../../tempo/MultisigSimulation.js'
3
+ import * as z_MultisigSimulation from '../MultisigSimulation.js'
4
+ import * as z from 'zod/mini'
5
+
6
+ const rpc = {
7
+ approvals: [
8
+ {
9
+ keyType: 'webAuthn',
10
+ keyData: '0x0005',
11
+ owner: '0x1111111111111111111111111111111111111111',
12
+ },
13
+ ],
14
+ config:
15
+ '0xf852a011111111111111111111111111111111111111111111111111111111111111110102eed694aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa01d694bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb01',
16
+ } as const satisfies core_MultisigSimulation.Rpc
17
+
18
+ describe('MultisigSimulation', () => {
19
+ test('behavior: converts between RPC and domain specs', () => {
20
+ const spec = z.decode(z_MultisigSimulation.MultisigSimulation, rpc)
21
+
22
+ expect(spec).toEqual(core_MultisigSimulation.fromRpc(rpc))
23
+ expect(
24
+ z.encode(z_MultisigSimulation.MultisigSimulation, spec),
25
+ ).toStrictEqual(rpc)
26
+ })
27
+
28
+ test('error: rejects more than eight root approvals', () => {
29
+ expect(
30
+ z.safeDecode(z_MultisigSimulation.Rpc, {
31
+ ...rpc,
32
+ approvals: Array.from({ length: 9 }, () => rpc.approvals[0]),
33
+ }).success,
34
+ ).toMatchInlineSnapshot(`false`)
35
+ })
36
+ test('error: rejects nested approvals', () => {
37
+ expect(
38
+ z.safeDecode(z_MultisigSimulation.Rpc, {
39
+ ...rpc,
40
+ approvals: [{ type: 'multisig', spec: rpc }],
41
+ } as never).success,
42
+ ).toMatchInlineSnapshot(`false`)
43
+ })
44
+
45
+ test('error: rejects malformed encoded configurations', () => {
46
+ expect(
47
+ z.safeDecode(z_MultisigSimulation.Rpc, {
48
+ ...rpc,
49
+ config: '0x01',
50
+ }).success,
51
+ ).toMatchInlineSnapshot(`false`)
52
+ })
53
+ })
@@ -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,23 +19,22 @@ 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
- },
22
+ const envelope = core_SignatureEnvelope.from({
23
+ account: '0x2222222222222222222222222222222222222222',
24
+ config: {
25
+ version: 2n,
26
+ threshold: 1,
27
+ owners: [
28
+ { owner: '0x1111111111111111111111111111111111111111', weight: 1 },
29
+ ],
30
+ },
31
+ signatures: [
32
+ core_SignatureEnvelope.fromRpc(
33
+ secp256k1,
34
+ ) as core_SignatureEnvelope.Primitive,
28
35
  ],
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
36
+ })
37
+ const multisig = core_SignatureEnvelope.toRpc(envelope)
39
38
 
40
39
  describe('SignatureEnvelope', () => {
41
40
  test('decodes a secp256k1 envelope', () => {
@@ -61,148 +60,128 @@ describe('SignatureEnvelope', () => {
61
60
  )
62
61
  })
63
62
 
64
- test('decodes a multisig envelope', () => {
65
- expect(z.decode(z_SignatureEnvelope.SignatureEnvelope, multisig)).toEqual(
66
- core_SignatureEnvelope.fromRpc(multisig),
67
- )
68
- })
69
-
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
- )
87
- })
88
-
89
- test('round-trips secp256k1 via encode', () => {
90
- const decoded = z.decode(z_SignatureEnvelope.SignatureEnvelope, secp256k1)
91
- expect(z.encode(z_SignatureEnvelope.SignatureEnvelope, decoded)).toEqual(
92
- core_SignatureEnvelope.toRpc(decoded),
93
- )
94
- })
95
-
96
- test('round-trips multisig via encode', () => {
63
+ test('round-trips versioned multisig RPC bytes', () => {
97
64
  const decoded = z.decode(z_SignatureEnvelope.SignatureEnvelope, multisig)
65
+ expect(decoded).toEqual(envelope)
98
66
  expect(z.encode(z_SignatureEnvelope.SignatureEnvelope, decoded)).toEqual(
99
- core_SignatureEnvelope.toRpc(decoded),
67
+ multisig,
100
68
  )
101
69
  })
102
70
 
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',
71
+ test('round-trips a multisig delegate in a keychain', () => {
72
+ const rpc = {
73
+ type: 'keychain',
74
+ version: 'v2',
75
+ userAddress: '0x3333333333333333333333333333333333333333',
76
+ signature: multisig,
115
77
  } as const
116
-
117
78
  expect(
118
- z.safeEncode(z_SignatureEnvelope.SignatureEnvelope, invalid as never)
119
- .success,
120
- ).toMatchInlineSnapshot(`false`)
79
+ z.encode(
80
+ z_SignatureEnvelope.SignatureEnvelope,
81
+ z.decode(z_SignatureEnvelope.SignatureEnvelope, rpc),
82
+ ),
83
+ ).toEqual(rpc)
121
84
  })
122
85
 
123
- test('rejects legacy multisig approval encoding', () => {
124
- expect(
125
- z.safeDecode(z_SignatureEnvelope.SignatureEnvelope, {
126
- ...multisig,
127
- signatures: [
128
- core_SignatureEnvelope.serialize(
129
- core_SignatureEnvelope.fromRpc(secp256k1),
130
- ),
131
- ],
132
- } as never).success,
133
- ).toMatchInlineSnapshot(`false`)
86
+ test('rejects legacy RPC shapes and malformed bytes', () => {
87
+ for (const rpc of [
88
+ { account: envelope.account, signatures: [secp256k1] },
89
+ '0xc0',
90
+ '0x',
91
+ ])
92
+ expect(
93
+ z.safeDecode(z_SignatureEnvelope.SignatureEnvelope, rpc as never)
94
+ .success,
95
+ ).toMatchInlineSnapshot('false')
134
96
  })
135
97
 
136
- test('rejects multisig approval counts outside protocol limits', () => {
98
+ test('rejects recursive and empty owner approvals', () => {
99
+ for (const signatures of [
100
+ [],
101
+ [envelope],
102
+ [{ type: 'keychain', userAddress: envelope.account, inner: envelope }],
103
+ ])
104
+ expect(
105
+ z.safeEncode(z_SignatureEnvelope.SignatureEnvelope, {
106
+ ...envelope,
107
+ signatures,
108
+ } as never).success,
109
+ ).toMatchInlineSnapshot('false')
110
+ })
111
+ test('rejects keychain V1 multisig delegates', () => {
112
+ const rpc = {
113
+ type: 'keychain',
114
+ version: 'v1',
115
+ userAddress: envelope.account,
116
+ signature: multisig,
117
+ } as const
137
118
  expect(
138
- z.safeDecode(z_SignatureEnvelope.SignatureEnvelope, {
139
- ...multisig,
140
- signatures: [],
141
- }).success,
142
- ).toMatchInlineSnapshot(`false`)
119
+ z.safeDecode(z_SignatureEnvelope.SignatureEnvelope, rpc).success,
120
+ ).toMatchInlineSnapshot('false')
143
121
  expect(
144
- z.safeDecode(z_SignatureEnvelope.SignatureEnvelope, {
145
- ...multisig,
146
- signatures: Array.from({ length: 9 }, () => secp256k1),
122
+ z.safeEncode(z_SignatureEnvelope.SignatureEnvelope, {
123
+ type: 'keychain',
124
+ version: 'v1',
125
+ userAddress: envelope.account,
126
+ inner: envelope,
147
127
  }).success,
148
- ).toMatchInlineSnapshot(`false`)
128
+ ).toMatchInlineSnapshot('false')
149
129
  })
150
130
 
151
- test('rejects invalid recursive multisig approvals', () => {
152
- const keychain = {
153
- signature: secp256k1,
131
+ test('round-trips primitive RPC envelopes', () => {
132
+ for (const rpc of [secp256k1, p256])
133
+ expect(
134
+ z.encode(
135
+ z_SignatureEnvelope.SignatureEnvelope,
136
+ z.decode(z_SignatureEnvelope.SignatureEnvelope, rpc),
137
+ ),
138
+ ).toEqual(rpc)
139
+ })
140
+ })
141
+
142
+ describe('Keychain', () => {
143
+ test('rejects V1 wrappers with nested multisig delegates', () => {
144
+ const inner = {
145
+ inner: envelope,
154
146
  type: 'keychain',
155
- userAddress: multisig.account,
147
+ userAddress: envelope.account,
148
+ version: 'v2',
156
149
  } as const
157
- const depth2 = {
158
- account: '0x1111111111111111111111111111111111111111',
159
- config: { ...config, version: '0x1' },
160
- signatures: [secp256k1],
150
+ const value = {
151
+ inner,
152
+ type: 'keychain',
153
+ userAddress: envelope.account,
154
+ version: 'v1',
161
155
  } as const
162
- const depth3 = {
163
- account: '0x2222222222222222222222222222222222222222',
164
- config: { ...config, version: '0x1' },
165
- signatures: [depth2],
156
+ const rpc = {
157
+ signature: core_SignatureEnvelope.toRpc(inner),
158
+ type: 'keychain',
159
+ userAddress: envelope.account,
160
+ version: 'v1',
166
161
  } as const
167
-
168
162
  expect(
169
- z.safeDecode(z_SignatureEnvelope.SignatureEnvelope, {
170
- ...multisig,
171
- signatures: [keychain],
172
- }).success,
163
+ z.safeParse(z_SignatureEnvelope.Keychain, value).success,
173
164
  ).toMatchInlineSnapshot(`false`)
174
165
  expect(
175
- z.safeDecode(z_SignatureEnvelope.SignatureEnvelope, {
176
- ...multisig,
177
- signatures: [depth3],
178
- }).success,
166
+ z.safeParse(z_SignatureEnvelope.KeychainRpc, rpc).success,
179
167
  ).toMatchInlineSnapshot(`false`)
180
- })
181
-
182
- test('rejects old multisig witness shapes', () => {
183
168
  expect(
184
- z.safeDecode(z_SignatureEnvelope.SignatureEnvelope, {
185
- init: config,
186
- account: multisig.account,
187
- signatures: [secp256k1],
188
- } as never).success,
169
+ z.safeEncode(z_SignatureEnvelope.SignatureEnvelope, value).success,
189
170
  ).toMatchInlineSnapshot(`false`)
190
- })
191
-
192
- test('rejects tagged multisig RPC envelopes', () => {
193
171
  expect(
194
- z.safeDecode(z_SignatureEnvelope.SignatureEnvelope, {
195
- ...multisig,
196
- type: 'multisig',
197
- } as never).success,
172
+ z.safeDecode(z_SignatureEnvelope.SignatureEnvelope, rpc).success,
198
173
  ).toMatchInlineSnapshot(`false`)
199
- })
200
-
201
- test('rejects an invalid envelope', () => {
174
+ expect(
175
+ z.safeEncode(z_SignatureEnvelope.SignatureEnvelope, {
176
+ ...value,
177
+ version: 'v2',
178
+ }).success,
179
+ ).toMatchInlineSnapshot(`true`)
202
180
  expect(
203
181
  z.safeDecode(z_SignatureEnvelope.SignatureEnvelope, {
204
- type: 'secp256k1',
205
- } as never).success,
206
- ).toBe(false)
182
+ ...rpc,
183
+ version: 'v2',
184
+ }).success,
185
+ ).toMatchInlineSnapshot(`true`)
207
186
  })
208
187
  })
@@ -63,186 +63,35 @@ 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 = {
69
68
  approvals: [
70
69
  {
71
- keyData: '0x0578',
72
70
  keyType: 'webAuthn',
73
- owner: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
74
- type: 'primitive',
75
- },
76
- {
77
- type: 'multisig',
78
- witness: {
79
- account: '0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
80
- approvals: [
81
- {
82
- keyType: 'secp256k1',
83
- owner: '0xdddddddddddddddddddddddddddddddddddddddd',
84
- },
85
- {
86
- owner: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
87
- },
88
- ],
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
- },
104
- },
71
+ keyData: '0x0005',
72
+ owner: '0x1111111111111111111111111111111111111111',
105
73
  },
106
74
  ],
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
- },
75
+ config:
76
+ '0xf852a011111111111111111111111111111111111111111111111111111111111111118002eed694111111111111111111111111111111111111111101d694bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb01',
122
77
  } as const
123
78
 
124
79
  const decoded = z.decode(z_TransactionRequest.TransactionRequest, {
125
80
  ...rpc,
126
- multisigWitness: witness,
81
+ keyAuthorizationSimulation: multisigSimulation,
82
+ multisigSimulation,
127
83
  })
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
- `)
84
+ expect(decoded).toEqual(
85
+ core_TransactionRequest.fromRpc({
86
+ ...rpc,
87
+ keyAuthorizationSimulation: multisigSimulation,
88
+ multisigSimulation,
89
+ }),
90
+ )
186
91
 
187
92
  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
- `)
93
+ expect(encoded.keyAuthorizationSimulation).toStrictEqual(multisigSimulation)
94
+ expect(encoded.multisigSimulation).toStrictEqual(multisigSimulation)
246
95
  expect(encoded).toEqual(core_TransactionRequest.toRpc(decoded))
247
96
  })
248
97
 
@@ -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'