ox 1.7.4 → 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.
- package/CHANGELOG.md +16 -0
- package/dist/core/AbiEvent.d.ts.map +1 -1
- package/dist/core/AbiEvent.js +10 -9
- package/dist/core/AbiEvent.js.map +1 -1
- package/dist/core/Blobs.d.ts.map +1 -1
- package/dist/core/Blobs.js +6 -2
- package/dist/core/Blobs.js.map +1 -1
- package/dist/core/Signature.d.ts +6 -5
- package/dist/core/Signature.d.ts.map +1 -1
- package/dist/core/Signature.js +17 -7
- package/dist/core/Signature.js.map +1 -1
- package/dist/core/Siwe.d.ts.map +1 -1
- package/dist/core/Siwe.js +21 -1
- package/dist/core/Siwe.js.map +1 -1
- package/dist/tempo/KeyAuthorization.d.ts +42 -38
- package/dist/tempo/KeyAuthorization.d.ts.map +1 -1
- package/dist/tempo/KeyAuthorization.js +24 -4
- package/dist/tempo/KeyAuthorization.js.map +1 -1
- package/dist/tempo/MultisigConfig.d.ts +18 -15
- package/dist/tempo/MultisigConfig.d.ts.map +1 -1
- package/dist/tempo/MultisigConfig.js +49 -20
- package/dist/tempo/MultisigConfig.js.map +1 -1
- package/dist/tempo/MultisigOperation.d.ts +3 -2
- package/dist/tempo/MultisigOperation.d.ts.map +1 -1
- package/dist/tempo/MultisigOperation.js +20 -100
- package/dist/tempo/MultisigOperation.js.map +1 -1
- package/dist/tempo/MultisigSimulation.d.ts +2 -49
- package/dist/tempo/MultisigSimulation.d.ts.map +1 -1
- package/dist/tempo/MultisigSimulation.js +18 -46
- package/dist/tempo/MultisigSimulation.js.map +1 -1
- package/dist/tempo/SignatureEnvelope.d.ts +72 -140
- package/dist/tempo/SignatureEnvelope.d.ts.map +1 -1
- package/dist/tempo/SignatureEnvelope.js +130 -181
- package/dist/tempo/SignatureEnvelope.js.map +1 -1
- package/dist/tempo/TransactionRequest.d.ts +4 -2
- package/dist/tempo/TransactionRequest.d.ts.map +1 -1
- package/dist/tempo/TransactionRequest.js +6 -1
- package/dist/tempo/TransactionRequest.js.map +1 -1
- package/dist/tempo/index.d.ts +3 -1
- package/dist/tempo/index.d.ts.map +1 -1
- package/dist/tempo/index.js +3 -1
- package/dist/tempo/index.js.map +1 -1
- package/dist/zod/tempo/AuthorizationTempo.d.ts +350 -10
- package/dist/zod/tempo/AuthorizationTempo.d.ts.map +1 -1
- package/dist/zod/tempo/KeyAuthorization.d.ts +242 -422
- package/dist/zod/tempo/KeyAuthorization.d.ts.map +1 -1
- package/dist/zod/tempo/KeyAuthorization.js +29 -31
- package/dist/zod/tempo/KeyAuthorization.js.map +1 -1
- package/dist/zod/tempo/MultisigSimulation.d.ts +8 -76
- package/dist/zod/tempo/MultisigSimulation.d.ts.map +1 -1
- package/dist/zod/tempo/MultisigSimulation.js +3 -37
- package/dist/zod/tempo/MultisigSimulation.js.map +1 -1
- package/dist/zod/tempo/RpcSchemaTempo.d.ts +284 -228
- package/dist/zod/tempo/RpcSchemaTempo.d.ts.map +1 -1
- package/dist/zod/tempo/SignatureEnvelope.d.ts +105 -3
- package/dist/zod/tempo/SignatureEnvelope.d.ts.map +1 -1
- package/dist/zod/tempo/SignatureEnvelope.js +21 -9
- package/dist/zod/tempo/SignatureEnvelope.js.map +1 -1
- package/dist/zod/tempo/Transaction.d.ts +676 -448
- package/dist/zod/tempo/Transaction.d.ts.map +1 -1
- package/dist/zod/tempo/TransactionRequest.d.ts +590 -473
- package/dist/zod/tempo/TransactionRequest.d.ts.map +1 -1
- package/dist/zod/tempo/TransactionRequest.js +8 -0
- package/dist/zod/tempo/TransactionRequest.js.map +1 -1
- package/dist/zod/tempo/TxEnvelopeTempo.d.ts +327 -213
- package/dist/zod/tempo/TxEnvelopeTempo.d.ts.map +1 -1
- package/dist/zod/tempo/ZoneRpcAuthentication.d.ts +105 -3
- package/dist/zod/tempo/ZoneRpcAuthentication.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/AbiEvent.ts +11 -9
- package/src/core/Blobs.ts +6 -2
- package/src/core/Signature.ts +41 -11
- package/src/core/Siwe.ts +20 -1
- package/src/core/_test/AbiEvent.test.ts +45 -0
- package/src/core/_test/Blobs.test.ts +22 -0
- package/src/core/_test/Signature.test.ts +166 -0
- package/src/core/_test/Siwe.test.ts +100 -1
- package/src/tempo/AuthorizationTempo.test.ts +8 -4
- package/src/tempo/KeyAuthorization.test-d.ts +16 -63
- package/src/tempo/KeyAuthorization.test.ts +69 -11
- package/src/tempo/KeyAuthorization.ts +107 -63
- package/src/tempo/MultisigConfig.test.ts +44 -20
- package/src/tempo/MultisigConfig.ts +65 -23
- package/src/tempo/MultisigOperation.test.ts +79 -550
- package/src/tempo/MultisigOperation.ts +31 -146
- package/src/tempo/MultisigSimulation.test-d.ts +2 -2
- package/src/tempo/MultisigSimulation.test.ts +21 -110
- package/src/tempo/MultisigSimulation.ts +25 -99
- package/src/tempo/SignatureEnvelope.test-d.ts +29 -47
- package/src/tempo/SignatureEnvelope.test.ts +328 -541
- package/src/tempo/SignatureEnvelope.ts +196 -291
- package/src/tempo/Transaction.test.ts +4 -4
- package/src/tempo/TransactionRequest.test.ts +17 -80
- package/src/tempo/TransactionRequest.ts +19 -2
- package/src/tempo/index.ts +3 -1
- package/src/tempo/multisig.e2e.test.ts +321 -860
- package/src/version.ts +1 -1
- package/src/zod/tempo/KeyAuthorization.ts +50 -39
- package/src/zod/tempo/MultisigSimulation.ts +3 -48
- package/src/zod/tempo/SignatureEnvelope.ts +46 -35
- package/src/zod/tempo/TransactionRequest.ts +14 -0
- package/src/zod/tempo/_test/KeyAuthorization.test.ts +69 -20
- package/src/zod/tempo/_test/MultisigSimulation.test.ts +6 -31
- package/src/zod/tempo/_test/SignatureEnvelope.test.ts +118 -85
- package/src/zod/tempo/_test/TransactionRequest.test.ts +9 -19
|
@@ -19,25 +19,37 @@ const p256 = {
|
|
|
19
19
|
type: 'p256',
|
|
20
20
|
} as const
|
|
21
21
|
|
|
22
|
-
const
|
|
23
|
-
'
|
|
24
|
-
|
|
25
|
-
|
|
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,
|
|
35
|
+
],
|
|
36
|
+
})
|
|
37
|
+
const multisig = core_SignatureEnvelope.toRpc(envelope)
|
|
26
38
|
|
|
27
39
|
describe('SignatureEnvelope', () => {
|
|
28
|
-
test('
|
|
40
|
+
test('decodes a secp256k1 envelope', () => {
|
|
29
41
|
expect(z.decode(z_SignatureEnvelope.SignatureEnvelope, secp256k1)).toEqual(
|
|
30
42
|
core_SignatureEnvelope.fromRpc(secp256k1),
|
|
31
43
|
)
|
|
32
44
|
})
|
|
33
45
|
|
|
34
|
-
test('
|
|
46
|
+
test('decodes a p256 envelope', () => {
|
|
35
47
|
expect(z.decode(z_SignatureEnvelope.SignatureEnvelope, p256)).toEqual(
|
|
36
48
|
core_SignatureEnvelope.fromRpc(p256),
|
|
37
49
|
)
|
|
38
50
|
})
|
|
39
51
|
|
|
40
|
-
test('
|
|
52
|
+
test('decodes a recursive keychain envelope', () => {
|
|
41
53
|
const keychain = {
|
|
42
54
|
signature: secp256k1,
|
|
43
55
|
type: 'keychain',
|
|
@@ -48,107 +60,128 @@ describe('SignatureEnvelope', () => {
|
|
|
48
60
|
)
|
|
49
61
|
})
|
|
50
62
|
|
|
51
|
-
test('
|
|
52
|
-
|
|
53
|
-
|
|
63
|
+
test('round-trips versioned multisig RPC bytes', () => {
|
|
64
|
+
const decoded = z.decode(z_SignatureEnvelope.SignatureEnvelope, multisig)
|
|
65
|
+
expect(decoded).toEqual(envelope)
|
|
66
|
+
expect(z.encode(z_SignatureEnvelope.SignatureEnvelope, decoded)).toEqual(
|
|
67
|
+
multisig,
|
|
54
68
|
)
|
|
55
69
|
})
|
|
56
70
|
|
|
57
|
-
test('
|
|
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,
|
|
77
|
+
} as const
|
|
58
78
|
expect(
|
|
59
|
-
z.
|
|
60
|
-
|
|
79
|
+
z.encode(
|
|
80
|
+
z_SignatureEnvelope.SignatureEnvelope,
|
|
81
|
+
z.decode(z_SignatureEnvelope.SignatureEnvelope, rpc),
|
|
82
|
+
),
|
|
83
|
+
).toEqual(rpc)
|
|
61
84
|
})
|
|
62
85
|
|
|
63
|
-
test('
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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')
|
|
68
96
|
})
|
|
69
97
|
|
|
70
|
-
test('
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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')
|
|
75
110
|
})
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
|
118
|
+
expect(
|
|
119
|
+
z.safeDecode(z_SignatureEnvelope.SignatureEnvelope, rpc).success,
|
|
120
|
+
).toMatchInlineSnapshot('false')
|
|
80
121
|
expect(
|
|
81
122
|
z.safeEncode(z_SignatureEnvelope.SignatureEnvelope, {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
},
|
|
89
|
-
],
|
|
90
|
-
} as never).success,
|
|
91
|
-
).toMatchInlineSnapshot(`false`)
|
|
123
|
+
type: 'keychain',
|
|
124
|
+
version: 'v1',
|
|
125
|
+
userAddress: envelope.account,
|
|
126
|
+
inner: envelope,
|
|
127
|
+
}).success,
|
|
128
|
+
).toMatchInlineSnapshot('false')
|
|
92
129
|
})
|
|
93
130
|
|
|
94
|
-
test('
|
|
95
|
-
const
|
|
96
|
-
|
|
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,
|
|
146
|
+
type: 'keychain',
|
|
147
|
+
userAddress: envelope.account,
|
|
148
|
+
version: 'v2',
|
|
149
|
+
} as const
|
|
150
|
+
const value = {
|
|
151
|
+
inner,
|
|
152
|
+
type: 'keychain',
|
|
153
|
+
userAddress: envelope.account,
|
|
154
|
+
version: 'v1',
|
|
155
|
+
} as const
|
|
156
|
+
const rpc = {
|
|
157
|
+
signature: core_SignatureEnvelope.toRpc(inner),
|
|
158
|
+
type: 'keychain',
|
|
159
|
+
userAddress: envelope.account,
|
|
160
|
+
version: 'v1',
|
|
161
|
+
} as const
|
|
97
162
|
expect(
|
|
98
|
-
z.
|
|
99
|
-
...decoded,
|
|
100
|
-
signatures: [],
|
|
101
|
-
} as never).success,
|
|
163
|
+
z.safeParse(z_SignatureEnvelope.Keychain, value).success,
|
|
102
164
|
).toMatchInlineSnapshot(`false`)
|
|
103
165
|
expect(
|
|
104
|
-
z.
|
|
105
|
-
...decoded,
|
|
106
|
-
signatures: Array.from({ length: 9 }, () => decoded.signatures[0]),
|
|
107
|
-
} as never).success,
|
|
166
|
+
z.safeParse(z_SignatureEnvelope.KeychainRpc, rpc).success,
|
|
108
167
|
).toMatchInlineSnapshot(`false`)
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
test('error: rejects excess multisig nesting', () => {
|
|
112
|
-
const nested = core_SignatureEnvelope.fromRpc(nestedMultisig)
|
|
113
|
-
if (nested.type !== 'multisig') throw new Error('unreachable')
|
|
114
168
|
expect(
|
|
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,
|
|
169
|
+
z.safeEncode(z_SignatureEnvelope.SignatureEnvelope, value).success,
|
|
125
170
|
).toMatchInlineSnapshot(`false`)
|
|
126
|
-
})
|
|
127
|
-
|
|
128
|
-
test('error: rejects structured multisig RPC envelopes', () => {
|
|
129
171
|
expect(
|
|
130
|
-
z.safeDecode(z_SignatureEnvelope.SignatureEnvelope,
|
|
131
|
-
account: '0x9dba7f426b711d4893c11611eacf7cc334e7146b',
|
|
132
|
-
config: {},
|
|
133
|
-
signatures: [],
|
|
134
|
-
} as never).success,
|
|
172
|
+
z.safeDecode(z_SignatureEnvelope.SignatureEnvelope, rpc).success,
|
|
135
173
|
).toMatchInlineSnapshot(`false`)
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
test('error: rejects tagged multisig RPC envelopes', () => {
|
|
139
174
|
expect(
|
|
140
|
-
z.
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
).success,
|
|
144
|
-
).toMatchInlineSnapshot(`
|
|
145
|
-
})
|
|
146
|
-
|
|
147
|
-
test('error: rejects an invalid envelope', () => {
|
|
175
|
+
z.safeEncode(z_SignatureEnvelope.SignatureEnvelope, {
|
|
176
|
+
...value,
|
|
177
|
+
version: 'v2',
|
|
178
|
+
}).success,
|
|
179
|
+
).toMatchInlineSnapshot(`true`)
|
|
148
180
|
expect(
|
|
149
181
|
z.safeDecode(z_SignatureEnvelope.SignatureEnvelope, {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
182
|
+
...rpc,
|
|
183
|
+
version: 'v2',
|
|
184
|
+
}).success,
|
|
185
|
+
).toMatchInlineSnapshot(`true`)
|
|
153
186
|
})
|
|
154
187
|
})
|
|
@@ -65,27 +65,11 @@ describe('TransactionRequest', () => {
|
|
|
65
65
|
|
|
66
66
|
test('multisig simulation round-trips', () => {
|
|
67
67
|
const multisigSimulation = {
|
|
68
|
-
account: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
|
|
69
68
|
approvals: [
|
|
70
69
|
{
|
|
71
|
-
keyType: '
|
|
70
|
+
keyType: 'webAuthn',
|
|
71
|
+
keyData: '0x0005',
|
|
72
72
|
owner: '0x1111111111111111111111111111111111111111',
|
|
73
|
-
type: 'primitive',
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
spec: {
|
|
77
|
-
account: '0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
|
|
78
|
-
approvals: [
|
|
79
|
-
{
|
|
80
|
-
keyData: '0x0578',
|
|
81
|
-
keyType: 'webAuthn',
|
|
82
|
-
owner: '0x2222222222222222222222222222222222222222',
|
|
83
|
-
},
|
|
84
|
-
],
|
|
85
|
-
config:
|
|
86
|
-
'0xf83ba022222222222222222222222222222222222222222222222222222222222222220101d7d694222222222222222222222222222222222222222201',
|
|
87
|
-
},
|
|
88
|
-
type: 'multisig',
|
|
89
73
|
},
|
|
90
74
|
],
|
|
91
75
|
config:
|
|
@@ -94,13 +78,19 @@ describe('TransactionRequest', () => {
|
|
|
94
78
|
|
|
95
79
|
const decoded = z.decode(z_TransactionRequest.TransactionRequest, {
|
|
96
80
|
...rpc,
|
|
81
|
+
keyAuthorizationSimulation: multisigSimulation,
|
|
97
82
|
multisigSimulation,
|
|
98
83
|
})
|
|
99
84
|
expect(decoded).toEqual(
|
|
100
|
-
core_TransactionRequest.fromRpc({
|
|
85
|
+
core_TransactionRequest.fromRpc({
|
|
86
|
+
...rpc,
|
|
87
|
+
keyAuthorizationSimulation: multisigSimulation,
|
|
88
|
+
multisigSimulation,
|
|
89
|
+
}),
|
|
101
90
|
)
|
|
102
91
|
|
|
103
92
|
const encoded = z.encode(z_TransactionRequest.TransactionRequest, decoded)
|
|
93
|
+
expect(encoded.keyAuthorizationSimulation).toStrictEqual(multisigSimulation)
|
|
104
94
|
expect(encoded.multisigSimulation).toStrictEqual(multisigSimulation)
|
|
105
95
|
expect(encoded).toEqual(core_TransactionRequest.toRpc(decoded))
|
|
106
96
|
})
|