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.
- package/CHANGELOG.md +27 -0
- package/dist/tempo/KeyAuthorization.d.ts +1 -1
- package/dist/tempo/KeyAuthorization.d.ts.map +1 -1
- package/dist/tempo/MultisigOperation.d.ts +42 -26
- package/dist/tempo/MultisigOperation.d.ts.map +1 -1
- package/dist/tempo/MultisigOperation.js +78 -48
- package/dist/tempo/MultisigOperation.js.map +1 -1
- package/dist/tempo/MultisigSimulation.d.ts +132 -0
- package/dist/tempo/MultisigSimulation.d.ts.map +1 -0
- package/dist/tempo/MultisigSimulation.js +140 -0
- package/dist/tempo/MultisigSimulation.js.map +1 -0
- package/dist/tempo/RpcSchemaTempo.d.ts +20 -10
- package/dist/tempo/RpcSchemaTempo.d.ts.map +1 -1
- package/dist/tempo/SignatureEnvelope.d.ts +9 -20
- package/dist/tempo/SignatureEnvelope.d.ts.map +1 -1
- package/dist/tempo/SignatureEnvelope.js +12 -18
- package/dist/tempo/SignatureEnvelope.js.map +1 -1
- package/dist/tempo/TransactionRequest.d.ts +6 -6
- package/dist/tempo/TransactionRequest.d.ts.map +1 -1
- package/dist/tempo/TransactionRequest.js +7 -7
- package/dist/tempo/TransactionRequest.js.map +1 -1
- package/dist/tempo/index.d.ts +4 -4
- package/dist/tempo/index.d.ts.map +1 -1
- package/dist/tempo/index.js +4 -4
- package/dist/tempo/index.js.map +1 -1
- package/dist/zod/tempo/AuthorizationTempo.d.ts +10 -130
- package/dist/zod/tempo/AuthorizationTempo.d.ts.map +1 -1
- package/dist/zod/tempo/KeyAuthorization.d.ts +5 -65
- package/dist/zod/tempo/KeyAuthorization.d.ts.map +1 -1
- package/dist/zod/tempo/MultisigOperation.d.ts +0 -10
- package/dist/zod/tempo/MultisigOperation.d.ts.map +1 -1
- package/dist/zod/tempo/MultisigOperation.js +0 -3
- package/dist/zod/tempo/MultisigOperation.js.map +1 -1
- package/dist/zod/tempo/{MultisigWitness.d.ts → MultisigSimulation.d.ts} +17 -49
- package/dist/zod/tempo/MultisigSimulation.d.ts.map +1 -0
- package/dist/zod/tempo/{MultisigWitness.js → MultisigSimulation.js} +26 -24
- package/dist/zod/tempo/MultisigSimulation.js.map +1 -0
- package/dist/zod/tempo/RpcSchemaTempo.d.ts +83 -204
- package/dist/zod/tempo/RpcSchemaTempo.d.ts.map +1 -1
- package/dist/zod/tempo/RpcSchemaTempo.js +19 -10
- package/dist/zod/tempo/RpcSchemaTempo.js.map +1 -1
- package/dist/zod/tempo/SignatureEnvelope.d.ts +3 -39
- package/dist/zod/tempo/SignatureEnvelope.d.ts.map +1 -1
- package/dist/zod/tempo/SignatureEnvelope.js +4 -14
- package/dist/zod/tempo/SignatureEnvelope.js.map +1 -1
- package/dist/zod/tempo/Transaction.d.ts +18 -234
- package/dist/zod/tempo/Transaction.d.ts.map +1 -1
- package/dist/zod/tempo/TransactionRequest.d.ts +36 -192
- package/dist/zod/tempo/TransactionRequest.d.ts.map +1 -1
- package/dist/zod/tempo/TransactionRequest.js +10 -10
- package/dist/zod/tempo/TransactionRequest.js.map +1 -1
- package/dist/zod/tempo/z.d.ts +1 -1
- package/dist/zod/tempo/z.d.ts.map +1 -1
- package/dist/zod/tempo/z.js +1 -1
- package/dist/zod/tempo/z.js.map +1 -1
- package/package.json +9 -9
- package/src/tempo/AuthorizationTempo.test.ts +4 -0
- package/src/tempo/KeyAuthorization.test-d.ts +1 -12
- package/src/tempo/KeyAuthorization.test.ts +44 -3
- package/src/tempo/KeyAuthorization.ts +3 -3
- package/src/tempo/MultisigOperation.test-d.ts +8 -6
- package/src/tempo/MultisigOperation.test.ts +236 -169
- package/src/tempo/MultisigOperation.ts +122 -83
- package/src/tempo/MultisigSimulation.test-d.ts +33 -0
- package/src/tempo/MultisigSimulation.test.ts +283 -0
- package/src/tempo/MultisigSimulation.ts +266 -0
- package/src/tempo/RpcSchemaTempo.test-d.ts +45 -10
- package/src/tempo/RpcSchemaTempo.ts +15 -6
- package/src/tempo/SignatureEnvelope.test-d.ts +3 -59
- package/src/tempo/SignatureEnvelope.test.ts +61 -51
- package/src/tempo/SignatureEnvelope.ts +27 -44
- package/src/tempo/Transaction.test.ts +61 -0
- package/src/tempo/TransactionRequest.test-d.ts +7 -7
- package/src/tempo/TransactionRequest.test.ts +129 -208
- package/src/tempo/TransactionRequest.ts +16 -12
- package/src/tempo/index.ts +4 -4
- package/src/tempo/multisig.e2e.test.ts +51 -1
- package/src/version.ts +1 -1
- package/src/zod/tempo/MultisigOperation.ts +0 -3
- package/src/zod/tempo/{MultisigWitness.ts → MultisigSimulation.ts} +39 -42
- package/src/zod/tempo/RpcSchemaTempo.ts +20 -10
- package/src/zod/tempo/SignatureEnvelope.ts +11 -35
- package/src/zod/tempo/TransactionRequest.ts +14 -14
- package/src/zod/tempo/_test/KeyAuthorization.test.ts +2 -15
- package/src/zod/tempo/_test/MultisigOperation.test.ts +0 -2
- package/src/zod/tempo/_test/MultisigSimulation.test-d.ts +13 -0
- package/src/zod/tempo/_test/MultisigSimulation.test.ts +78 -0
- package/src/zod/tempo/_test/RpcSchemaTempo.test-d.ts +19 -2
- package/src/zod/tempo/_test/RpcSchemaTempo.test.ts +46 -4
- package/src/zod/tempo/_test/SignatureEnvelope.test.ts +58 -112
- package/src/zod/tempo/_test/TransactionRequest.test.ts +19 -160
- package/src/zod/tempo/z.ts +1 -1
- package/dist/tempo/MultisigWitness.d.ts +0 -106
- package/dist/tempo/MultisigWitness.d.ts.map +0 -1
- package/dist/tempo/MultisigWitness.js +0 -118
- package/dist/tempo/MultisigWitness.js.map +0 -1
- package/dist/zod/tempo/MultisigWitness.d.ts.map +0 -1
- package/dist/zod/tempo/MultisigWitness.js.map +0 -1
- package/src/tempo/MultisigWitness.test-d.ts +0 -42
- package/src/tempo/MultisigWitness.test.ts +0 -288
- package/src/tempo/MultisigWitness.ts +0 -210
- package/src/zod/tempo/_test/MultisigWitness.test-d.ts +0 -13
- 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.
|
|
34
|
-
>().toEqualTypeOf<'
|
|
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
|
|
79
|
+
test('decodes config params', () => {
|
|
70
80
|
expect(
|
|
71
81
|
z_RpcSchema.decodeParams(
|
|
72
82
|
z_RpcSchemaTempo.Multisig,
|
|
73
|
-
'
|
|
74
|
-
[{
|
|
83
|
+
'multisig_getConfig',
|
|
84
|
+
[{ address: '0xcafebabecafebabecafebabecafebabecafebabe' }],
|
|
75
85
|
),
|
|
76
|
-
).toEqual([{
|
|
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
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
|
|
73
|
+
multisig,
|
|
100
74
|
)
|
|
101
75
|
})
|
|
102
76
|
|
|
103
|
-
test('rejects invalid recursive multisig domains before encode', () => {
|
|
104
|
-
const
|
|
105
|
-
|
|
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.
|
|
126
|
-
...
|
|
81
|
+
z.safeEncode(z_SignatureEnvelope.SignatureEnvelope, {
|
|
82
|
+
...decoded,
|
|
127
83
|
signatures: [
|
|
128
|
-
|
|
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.
|
|
139
|
-
...
|
|
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.
|
|
145
|
-
...
|
|
146
|
-
signatures: Array.from({ length: 9 }, () =>
|
|
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
|
|
152
|
-
const
|
|
153
|
-
|
|
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.
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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
|
|
128
|
+
test('error: rejects structured multisig RPC envelopes', () => {
|
|
183
129
|
expect(
|
|
184
130
|
z.safeDecode(z_SignatureEnvelope.SignatureEnvelope, {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
signatures: [
|
|
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(
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
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
|
|
67
|
-
const
|
|
68
|
-
account: '
|
|
66
|
+
test('multisig simulation round-trips', () => {
|
|
67
|
+
const multisigSimulation = {
|
|
68
|
+
account: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
|
|
69
69
|
approvals: [
|
|
70
70
|
{
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
owner: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
|
|
71
|
+
keyType: 'secp256k1',
|
|
72
|
+
owner: '0x1111111111111111111111111111111111111111',
|
|
74
73
|
type: 'primitive',
|
|
75
74
|
},
|
|
76
75
|
{
|
|
77
|
-
|
|
78
|
-
witness: {
|
|
76
|
+
spec: {
|
|
79
77
|
account: '0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
|
|
80
78
|
approvals: [
|
|
81
79
|
{
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
{
|
|
86
|
-
owner: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
|
|
80
|
+
keyData: '0x0578',
|
|
81
|
+
keyType: 'webAuthn',
|
|
82
|
+
owner: '0x2222222222222222222222222222222222222222',
|
|
87
83
|
},
|
|
88
84
|
],
|
|
89
|
-
config:
|
|
90
|
-
|
|
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
|
-
|
|
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
|
-
|
|
97
|
+
multisigSimulation,
|
|
127
98
|
})
|
|
128
|
-
expect(decoded
|
|
129
|
-
{
|
|
130
|
-
|
|
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.
|
|
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
|
|
package/src/zod/tempo/z.ts
CHANGED
|
@@ -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
|
|
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
|