ox 1.7.4 → 1.8.0
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 +22 -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/Frame.d.ts +290 -0
- package/dist/core/Frame.d.ts.map +1 -0
- package/dist/core/Frame.js +306 -0
- package/dist/core/Frame.js.map +1 -0
- package/dist/core/FrameReceipt.d.ts +92 -0
- package/dist/core/FrameReceipt.d.ts.map +1 -0
- package/dist/core/FrameReceipt.js +72 -0
- package/dist/core/FrameReceipt.js.map +1 -0
- package/dist/core/FrameSignature.d.ts +357 -0
- package/dist/core/FrameSignature.d.ts.map +1 -0
- package/dist/core/FrameSignature.js +411 -0
- package/dist/core/FrameSignature.js.map +1 -0
- 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/core/Transaction.d.ts +29 -4
- package/dist/core/Transaction.d.ts.map +1 -1
- package/dist/core/Transaction.js +25 -4
- package/dist/core/Transaction.js.map +1 -1
- package/dist/core/TransactionReceipt.d.ts +13 -4
- package/dist/core/TransactionReceipt.d.ts.map +1 -1
- package/dist/core/TransactionReceipt.js +14 -0
- package/dist/core/TransactionReceipt.js.map +1 -1
- package/dist/core/TransactionRequest.d.ts +15 -7
- package/dist/core/TransactionRequest.d.ts.map +1 -1
- package/dist/core/TransactionRequest.js +47 -1
- package/dist/core/TransactionRequest.js.map +1 -1
- package/dist/core/TxEnvelope.d.ts +35 -21
- package/dist/core/TxEnvelope.d.ts.map +1 -1
- package/dist/core/TxEnvelope.js +46 -6
- package/dist/core/TxEnvelope.js.map +1 -1
- package/dist/core/TxEnvelopeEip8141.d.ts +341 -0
- package/dist/core/TxEnvelopeEip8141.d.ts.map +1 -0
- package/dist/core/TxEnvelopeEip8141.js +485 -0
- package/dist/core/TxEnvelopeEip8141.js.map +1 -0
- package/dist/core/internal/curves.d.ts +2 -0
- package/dist/core/internal/curves.d.ts.map +1 -1
- package/dist/core/internal/curves.js +2 -0
- package/dist/core/internal/curves.js.map +1 -1
- package/dist/index.d.ts +73 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +73 -0
- package/dist/index.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/Transaction.d.ts +2 -0
- package/dist/tempo/Transaction.d.ts.map +1 -1
- package/dist/tempo/TransactionReceipt.d.ts +2 -0
- package/dist/tempo/TransactionReceipt.d.ts.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/Block.d.ts +123 -0
- package/dist/zod/Block.d.ts.map +1 -1
- package/dist/zod/Frame.d.ts +73 -0
- package/dist/zod/Frame.d.ts.map +1 -0
- package/dist/zod/Frame.js +74 -0
- package/dist/zod/Frame.js.map +1 -0
- package/dist/zod/FrameReceipt.d.ts +50 -0
- package/dist/zod/FrameReceipt.d.ts.map +1 -0
- package/dist/zod/FrameReceipt.js +37 -0
- package/dist/zod/FrameReceipt.js.map +1 -0
- package/dist/zod/FrameSignature.d.ts +63 -0
- package/dist/zod/FrameSignature.d.ts.map +1 -0
- package/dist/zod/FrameSignature.js +66 -0
- package/dist/zod/FrameSignature.js.map +1 -0
- package/dist/zod/RpcSchema.d.ts +806 -11
- package/dist/zod/RpcSchema.d.ts.map +1 -1
- package/dist/zod/Transaction.d.ts +252 -0
- package/dist/zod/Transaction.d.ts.map +1 -1
- package/dist/zod/Transaction.js +54 -0
- package/dist/zod/Transaction.js.map +1 -1
- package/dist/zod/TransactionEnvelope.d.ts +233 -4
- package/dist/zod/TransactionEnvelope.d.ts.map +1 -1
- package/dist/zod/TransactionEnvelope.js +9 -0
- package/dist/zod/TransactionEnvelope.js.map +1 -1
- package/dist/zod/TransactionReceipt.d.ts +48 -0
- package/dist/zod/TransactionReceipt.d.ts.map +1 -1
- package/dist/zod/TransactionReceipt.js +8 -3
- package/dist/zod/TransactionReceipt.js.map +1 -1
- package/dist/zod/TransactionRequest.d.ts +50 -2
- package/dist/zod/TransactionRequest.d.ts.map +1 -1
- package/dist/zod/TransactionRequest.js +10 -4
- package/dist/zod/TransactionRequest.js.map +1 -1
- package/dist/zod/TxEnvelopeEip8141.d.ts +166 -0
- package/dist/zod/TxEnvelopeEip8141.d.ts.map +1 -0
- package/dist/zod/TxEnvelopeEip8141.js +76 -0
- package/dist/zod/TxEnvelopeEip8141.js.map +1 -0
- package/dist/zod/internal/Frame.d.ts +4 -0
- package/dist/zod/internal/Frame.d.ts.map +1 -0
- package/dist/zod/internal/Frame.js +17 -0
- package/dist/zod/internal/Frame.js.map +1 -0
- package/dist/zod/internal/rpcSchemas/Eth.d.ts +842 -11
- package/dist/zod/internal/rpcSchemas/Eth.d.ts.map +1 -1
- package/dist/zod/internal/rpcSchemas/Wallet.d.ts +56 -2
- package/dist/zod/internal/rpcSchemas/Wallet.d.ts.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 +424 -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 +783 -432
- 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/dist/zod/z.d.ts +4 -0
- package/dist/zod/z.d.ts.map +1 -1
- package/dist/zod/z.js +4 -0
- package/dist/zod/z.js.map +1 -1
- package/package.json +41 -1
- package/src/core/AbiEvent.ts +11 -9
- package/src/core/Blobs.ts +6 -2
- package/src/core/Frame.ts +443 -0
- package/src/core/FrameReceipt.ts +117 -0
- package/src/core/FrameSignature.ts +593 -0
- package/src/core/Signature.ts +41 -11
- package/src/core/Siwe.ts +20 -1
- package/src/core/Transaction.ts +82 -5
- package/src/core/TransactionReceipt.ts +41 -3
- package/src/core/TransactionRequest.ts +71 -4
- package/src/core/TxEnvelope.ts +159 -90
- package/src/core/TxEnvelopeEip8141.ts +715 -0
- package/src/core/_test/AbiEvent.test.ts +45 -0
- package/src/core/_test/Blobs.test.ts +22 -0
- package/src/core/_test/Frame.test-d.ts +96 -0
- package/src/core/_test/Frame.test.ts +267 -0
- package/src/core/_test/FrameReceipt.test.ts +86 -0
- package/src/core/_test/FrameSignature.test-d.ts +93 -0
- package/src/core/_test/FrameSignature.test.ts +554 -0
- package/src/core/_test/Signature.test.ts +166 -0
- package/src/core/_test/Siwe.test.ts +100 -1
- package/src/core/_test/Transaction.test.ts +33 -0
- package/src/core/_test/TransactionEnvelope.test-d.ts +74 -0
- package/src/core/_test/TransactionEnvelope.test.ts +107 -0
- package/src/core/_test/TransactionReceipt.test.ts +59 -0
- package/src/core/_test/TransactionRequest.test-d.ts +50 -0
- package/src/core/_test/TransactionRequest.test.ts +88 -1
- package/src/core/_test/TxEnvelopeEip8141.test-d.ts +44 -0
- package/src/core/_test/TxEnvelopeEip8141.test.ts +1775 -0
- package/src/core/_test/curves.test.ts +6 -1
- package/src/core/_test/index.test.ts +4 -0
- package/src/core/internal/curves.ts +4 -0
- package/src/index.ts +77 -0
- 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/Frame.ts +82 -0
- package/src/zod/FrameReceipt.ts +48 -0
- package/src/zod/FrameSignature.ts +78 -0
- package/src/zod/Transaction.ts +63 -0
- package/src/zod/TransactionEnvelope.ts +33 -0
- package/src/zod/TransactionReceipt.ts +14 -3
- package/src/zod/TransactionRequest.ts +18 -3
- package/src/zod/TxEnvelopeEip8141.ts +102 -0
- package/src/zod/_test/Frame.test-d.ts +41 -0
- package/src/zod/_test/Frame.test.ts +54 -0
- package/src/zod/_test/FrameReceipt.test.ts +75 -0
- package/src/zod/_test/FrameSignature.test.ts +94 -0
- package/src/zod/_test/TxEnvelopeEip8141.test.ts +116 -0
- package/src/zod/internal/Frame.ts +26 -0
- 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
- package/src/zod/z.ts +4 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { factory } from '../../test/tempo/multisig.js'
|
|
1
2
|
import { Address, Hash, Hex, P256 } from 'ox'
|
|
2
3
|
import {
|
|
3
4
|
KeyAuthorization,
|
|
@@ -40,7 +41,7 @@ const config = MultisigConfig.from({
|
|
|
40
41
|
threshold: 2,
|
|
41
42
|
})
|
|
42
43
|
const currentConfig = MultisigConfig.from({ ...config, version: 1n })
|
|
43
|
-
const account = MultisigConfig.getAddress(config)
|
|
44
|
+
const account = MultisigConfig.getAddress(config, { factory })
|
|
44
45
|
const ownerSignature_1 = owners[0]!.signature
|
|
45
46
|
const approval_1 = SignatureEnvelope.serialize(ownerSignature_1)
|
|
46
47
|
const approval_2 = SignatureEnvelope.serialize(owners[1]!.signature)
|
|
@@ -152,8 +153,8 @@ describe('getHash', () => {
|
|
|
152
153
|
}),
|
|
153
154
|
}).toMatchInlineSnapshot(`
|
|
154
155
|
{
|
|
155
|
-
"keyAuthorization": "
|
|
156
|
-
"transaction": "
|
|
156
|
+
"keyAuthorization": "0xa83016f0e94c4a6125483ffeba3abb0a8df1bc0f5a503f63639e806b793520bb",
|
|
157
|
+
"transaction": "0x2d7e3c7c38a9acf85f0a9d70a39b0e9e5a05d92c7a73b633a47a45be4a112b3b",
|
|
157
158
|
}
|
|
158
159
|
`)
|
|
159
160
|
})
|
|
@@ -169,7 +170,7 @@ describe('selectApprovals', () => {
|
|
|
169
170
|
],
|
|
170
171
|
threshold: 3,
|
|
171
172
|
})
|
|
172
|
-
const account = MultisigConfig.getAddress(config)
|
|
173
|
+
const account = MultisigConfig.getAddress(config, { factory })
|
|
173
174
|
const hash = MultisigOperation.getHash({
|
|
174
175
|
account,
|
|
175
176
|
config: { ...config, version: 1n },
|
|
@@ -225,195 +226,39 @@ describe('selectApprovals', () => {
|
|
|
225
226
|
}
|
|
226
227
|
`)
|
|
227
228
|
})
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
const childConfig = MultisigConfig.from({
|
|
231
|
-
owners: [
|
|
232
|
-
{ owner: owners[1]!.address, weight: 1 },
|
|
233
|
-
{ owner: owners[2]!.address, weight: 1 },
|
|
234
|
-
],
|
|
235
|
-
threshold: 2,
|
|
236
|
-
})
|
|
237
|
-
const child = MultisigConfig.getAddress(childConfig)
|
|
238
|
-
const config = MultisigConfig.from({
|
|
239
|
-
owners: [
|
|
240
|
-
{ owner: owners[0]!.address, weight: 1 },
|
|
241
|
-
{ owner: child, weight: 2 },
|
|
242
|
-
],
|
|
243
|
-
threshold: 2,
|
|
244
|
-
})
|
|
245
|
-
const account = MultisigConfig.getAddress(config)
|
|
246
|
-
const hash = MultisigOperation.getHash({
|
|
247
|
-
account,
|
|
248
|
-
config: { ...config, version: 1n },
|
|
249
|
-
transaction,
|
|
250
|
-
type: 'transaction',
|
|
251
|
-
})
|
|
252
|
-
const childHash = MultisigConfig.getSignPayload({
|
|
253
|
-
account: child,
|
|
254
|
-
config: { ...childConfig, version: 2n },
|
|
255
|
-
payload: hash,
|
|
256
|
-
})
|
|
257
|
-
const childApprovals = [
|
|
258
|
-
signApproval(owners[1]!, childHash),
|
|
259
|
-
signApproval(owners[2]!, childHash),
|
|
260
|
-
]
|
|
261
|
-
const rootApproval = signApproval(owners[0]!, hash)
|
|
262
|
-
const partial = await MultisigOperation.selectApprovals({
|
|
229
|
+
test('accepts an explicit account from a chain-configured factory', async () => {
|
|
230
|
+
const selected = await MultisigOperation.selectApprovals({
|
|
263
231
|
account,
|
|
264
|
-
approvals: [
|
|
265
|
-
rootApproval,
|
|
266
|
-
SignatureEnvelope.serialize({
|
|
267
|
-
account: child,
|
|
268
|
-
config: MultisigConfig.from({ ...childConfig, version: 2n }),
|
|
269
|
-
signatures: [SignatureEnvelope.deserialize(childApprovals[0]!)],
|
|
270
|
-
type: 'multisig',
|
|
271
|
-
}),
|
|
272
|
-
],
|
|
232
|
+
approvals: [],
|
|
273
233
|
config,
|
|
274
|
-
hash,
|
|
234
|
+
hash: transactionHash_,
|
|
275
235
|
})
|
|
276
|
-
|
|
277
|
-
account,
|
|
278
|
-
approvals: [
|
|
279
|
-
rootApproval,
|
|
280
|
-
SignatureEnvelope.serialize({
|
|
281
|
-
account: child,
|
|
282
|
-
config: MultisigConfig.from({ ...childConfig, version: 2n }),
|
|
283
|
-
signatures: childApprovals.map((approval) =>
|
|
284
|
-
SignatureEnvelope.deserialize(approval),
|
|
285
|
-
),
|
|
286
|
-
type: 'multisig',
|
|
287
|
-
}),
|
|
288
|
-
],
|
|
289
|
-
config,
|
|
290
|
-
hash,
|
|
291
|
-
})
|
|
292
|
-
|
|
293
|
-
expect({
|
|
294
|
-
complete: {
|
|
295
|
-
...complete,
|
|
296
|
-
approvals: approvalAddresses(complete.approvals, hash),
|
|
297
|
-
selectedApprovals: approvalAddresses(complete.selectedApprovals, hash),
|
|
298
|
-
},
|
|
299
|
-
partial: {
|
|
300
|
-
...partial,
|
|
301
|
-
approvals: approvalAddresses(partial.approvals, hash),
|
|
302
|
-
selectedApprovals: approvalAddresses(partial.selectedApprovals, hash),
|
|
303
|
-
},
|
|
304
|
-
}).toMatchInlineSnapshot(`
|
|
305
|
-
{
|
|
306
|
-
"complete": {
|
|
307
|
-
"approvals": [
|
|
308
|
-
"0x07e1ed8ea0e9601e5546b0a03aed683df3601407",
|
|
309
|
-
"0xe2d2c3c2fc4b17af341cc5c1a459af9606167e8a",
|
|
310
|
-
],
|
|
311
|
-
"selectedApprovals": [
|
|
312
|
-
"0xe2d2c3c2fc4b17af341cc5c1a459af9606167e8a",
|
|
313
|
-
],
|
|
314
|
-
"signatureCount": 1,
|
|
315
|
-
"threshold": 2,
|
|
316
|
-
"weight": 2,
|
|
317
|
-
},
|
|
318
|
-
"partial": {
|
|
319
|
-
"approvals": [
|
|
320
|
-
"0x07e1ed8ea0e9601e5546b0a03aed683df3601407",
|
|
321
|
-
"0xe2d2c3c2fc4b17af341cc5c1a459af9606167e8a",
|
|
322
|
-
],
|
|
323
|
-
"selectedApprovals": [
|
|
324
|
-
"0x07e1ed8ea0e9601e5546b0a03aed683df3601407",
|
|
325
|
-
],
|
|
326
|
-
"signatureCount": 1,
|
|
327
|
-
"threshold": 2,
|
|
328
|
-
"weight": 1,
|
|
329
|
-
},
|
|
330
|
-
}
|
|
331
|
-
`)
|
|
236
|
+
expect(selected.weight).toMatchInlineSnapshot(`0`)
|
|
332
237
|
})
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
threshold: 1,
|
|
343
|
-
})
|
|
344
|
-
const account = MultisigConfig.getAddress(config)
|
|
345
|
-
const hash = MultisigOperation.getHash({
|
|
346
|
-
account,
|
|
347
|
-
config: { ...config, version: 1n },
|
|
348
|
-
transaction,
|
|
349
|
-
type: 'transaction',
|
|
350
|
-
})
|
|
351
|
-
const config_2 = MultisigConfig.from({
|
|
352
|
-
...childConfig,
|
|
353
|
-
version: 2n,
|
|
354
|
-
})
|
|
355
|
-
const config_3 = MultisigConfig.from({
|
|
356
|
-
...childConfig,
|
|
357
|
-
version: 3n,
|
|
358
|
-
})
|
|
359
|
-
const childHash_2 = MultisigConfig.getSignPayload({
|
|
360
|
-
account: child,
|
|
361
|
-
config: config_2,
|
|
362
|
-
payload: hash,
|
|
363
|
-
})
|
|
364
|
-
const childHash_3 = MultisigConfig.getSignPayload({
|
|
365
|
-
account: child,
|
|
366
|
-
config: config_3,
|
|
367
|
-
payload: hash,
|
|
368
|
-
})
|
|
369
|
-
|
|
370
|
-
await expect(
|
|
371
|
-
MultisigOperation.selectApprovals({
|
|
238
|
+
test('rejects keychain and multisig owner approvals', async () => {
|
|
239
|
+
for (const signature of [
|
|
240
|
+
SignatureEnvelope.from({
|
|
241
|
+
inner: ownerSignature_1,
|
|
242
|
+
type: 'keychain',
|
|
243
|
+
userAddress: account,
|
|
244
|
+
version: 'v2',
|
|
245
|
+
}),
|
|
246
|
+
SignatureEnvelope.from({
|
|
372
247
|
account,
|
|
373
|
-
approvals: [
|
|
374
|
-
SignatureEnvelope.serialize({
|
|
375
|
-
account: child,
|
|
376
|
-
config: config_2,
|
|
377
|
-
signatures: [
|
|
378
|
-
SignatureEnvelope.deserialize(
|
|
379
|
-
signApproval(owners[1]!, childHash_2),
|
|
380
|
-
),
|
|
381
|
-
],
|
|
382
|
-
type: 'multisig',
|
|
383
|
-
}),
|
|
384
|
-
SignatureEnvelope.serialize({
|
|
385
|
-
account: child,
|
|
386
|
-
config: config_3,
|
|
387
|
-
signatures: [
|
|
388
|
-
SignatureEnvelope.deserialize(
|
|
389
|
-
signApproval(owners[1]!, childHash_3),
|
|
390
|
-
),
|
|
391
|
-
],
|
|
392
|
-
type: 'multisig',
|
|
393
|
-
}),
|
|
394
|
-
],
|
|
395
248
|
config,
|
|
396
|
-
|
|
249
|
+
signatures: [ownerSignature_1],
|
|
397
250
|
}),
|
|
398
|
-
)
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
MultisigOperation.selectApprovals({
|
|
406
|
-
account,
|
|
407
|
-
approvals: [],
|
|
408
|
-
config: MultisigConfig.from({
|
|
409
|
-
...config,
|
|
410
|
-
salt: `0x${'ff'.repeat(32)}`,
|
|
251
|
+
])
|
|
252
|
+
await expect(
|
|
253
|
+
MultisigOperation.selectApprovals({
|
|
254
|
+
account,
|
|
255
|
+
approvals: [SignatureEnvelope.serialize(signature)],
|
|
256
|
+
config,
|
|
257
|
+
hash: transactionHash_,
|
|
411
258
|
}),
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
`[MultisigOperation.InvalidApprovalError: Invalid multisig approval: initial config does not derive the root multisig account.]`,
|
|
416
|
-
)
|
|
259
|
+
).rejects.toThrowErrorMatchingInlineSnapshot(
|
|
260
|
+
`[MultisigOperation.InvalidApprovalError: Invalid multisig approval: only primitive signatures can approve a multisig operation.]`,
|
|
261
|
+
)
|
|
417
262
|
})
|
|
418
263
|
|
|
419
264
|
test('rejects invalid and non-owner approvals', async () => {
|
|
@@ -450,234 +295,6 @@ describe('selectApprovals', () => {
|
|
|
450
295
|
`[MultisigOperation.InvalidApprovalError: Invalid multisig approval: signature is from non-owner 0xd3a9f047ad43d7e2e4e7e491f1fe2e657a2651b6.]`,
|
|
451
296
|
)
|
|
452
297
|
})
|
|
453
|
-
|
|
454
|
-
test('reads current nested config witnesses from approvals', async () => {
|
|
455
|
-
const childConfig = MultisigConfig.from({
|
|
456
|
-
owners: [{ owner: owners[1]!.address, weight: 1 }],
|
|
457
|
-
threshold: 1,
|
|
458
|
-
})
|
|
459
|
-
const child = MultisigConfig.getAddress(childConfig)
|
|
460
|
-
const config = MultisigConfig.from({
|
|
461
|
-
owners: [{ owner: child, weight: 1 }],
|
|
462
|
-
threshold: 1,
|
|
463
|
-
})
|
|
464
|
-
const account = MultisigConfig.getAddress(config)
|
|
465
|
-
const hash = MultisigOperation.getHash({
|
|
466
|
-
account,
|
|
467
|
-
config: { ...config, version: 1n },
|
|
468
|
-
transaction,
|
|
469
|
-
type: 'transaction',
|
|
470
|
-
})
|
|
471
|
-
const childHash = MultisigConfig.getSignPayload({
|
|
472
|
-
account: child,
|
|
473
|
-
config: { ...childConfig, version: 1n },
|
|
474
|
-
payload: hash,
|
|
475
|
-
})
|
|
476
|
-
|
|
477
|
-
const selection = await MultisigOperation.selectApprovals({
|
|
478
|
-
account,
|
|
479
|
-
approvals: [
|
|
480
|
-
SignatureEnvelope.serialize({
|
|
481
|
-
account: child,
|
|
482
|
-
config: MultisigConfig.from({ ...childConfig, version: 1n }),
|
|
483
|
-
signatures: [
|
|
484
|
-
SignatureEnvelope.deserialize(signApproval(owners[1]!, childHash)),
|
|
485
|
-
],
|
|
486
|
-
type: 'multisig',
|
|
487
|
-
}),
|
|
488
|
-
],
|
|
489
|
-
config,
|
|
490
|
-
hash,
|
|
491
|
-
})
|
|
492
|
-
expect(selection).toMatchInlineSnapshot(
|
|
493
|
-
{
|
|
494
|
-
approvals: [expect.any(String)],
|
|
495
|
-
selectedApprovals: [expect.any(String)],
|
|
496
|
-
},
|
|
497
|
-
`
|
|
498
|
-
{
|
|
499
|
-
"approvals": [
|
|
500
|
-
Any<String>,
|
|
501
|
-
],
|
|
502
|
-
"selectedApprovals": [
|
|
503
|
-
Any<String>,
|
|
504
|
-
],
|
|
505
|
-
"signatureCount": 1,
|
|
506
|
-
"threshold": 1,
|
|
507
|
-
"weight": 1,
|
|
508
|
-
}
|
|
509
|
-
`,
|
|
510
|
-
)
|
|
511
|
-
})
|
|
512
|
-
|
|
513
|
-
test('rejects keychain and accepts initial nested approvals', async () => {
|
|
514
|
-
const childConfig = MultisigConfig.from({
|
|
515
|
-
owners: [{ owner: owners[1]!.address, weight: 1 }],
|
|
516
|
-
threshold: 1,
|
|
517
|
-
})
|
|
518
|
-
const child = MultisigConfig.getAddress(childConfig)
|
|
519
|
-
const config = MultisigConfig.from({
|
|
520
|
-
owners: [
|
|
521
|
-
{ owner: owners[0]!.address, weight: 1 },
|
|
522
|
-
{ owner: child, weight: 1 },
|
|
523
|
-
],
|
|
524
|
-
threshold: 1,
|
|
525
|
-
})
|
|
526
|
-
const account = MultisigConfig.getAddress(config)
|
|
527
|
-
const hash = MultisigOperation.getHash({
|
|
528
|
-
account,
|
|
529
|
-
config: { ...config, version: 1n },
|
|
530
|
-
transaction,
|
|
531
|
-
type: 'transaction',
|
|
532
|
-
})
|
|
533
|
-
const childHash = MultisigConfig.getSignPayload({
|
|
534
|
-
account: child,
|
|
535
|
-
config: childConfig,
|
|
536
|
-
payload: hash,
|
|
537
|
-
})
|
|
538
|
-
|
|
539
|
-
await expect(
|
|
540
|
-
MultisigOperation.selectApprovals({
|
|
541
|
-
account,
|
|
542
|
-
approvals: [
|
|
543
|
-
SignatureEnvelope.serialize({
|
|
544
|
-
inner: SignatureEnvelope.deserialize(
|
|
545
|
-
signApproval(owners[0]!, hash),
|
|
546
|
-
),
|
|
547
|
-
type: 'keychain',
|
|
548
|
-
userAddress: owners[0]!.address,
|
|
549
|
-
}),
|
|
550
|
-
],
|
|
551
|
-
config,
|
|
552
|
-
hash,
|
|
553
|
-
}),
|
|
554
|
-
).rejects.toThrowErrorMatchingInlineSnapshot(
|
|
555
|
-
`[MultisigOperation.InvalidApprovalError: Invalid multisig approval: keychain signatures cannot approve a multisig operation.]`,
|
|
556
|
-
)
|
|
557
|
-
const selection = await MultisigOperation.selectApprovals({
|
|
558
|
-
account,
|
|
559
|
-
approvals: [
|
|
560
|
-
SignatureEnvelope.serialize({
|
|
561
|
-
account: child,
|
|
562
|
-
config: childConfig,
|
|
563
|
-
signatures: [
|
|
564
|
-
SignatureEnvelope.deserialize(signApproval(owners[1]!, childHash)),
|
|
565
|
-
],
|
|
566
|
-
type: 'multisig',
|
|
567
|
-
}),
|
|
568
|
-
],
|
|
569
|
-
config,
|
|
570
|
-
hash,
|
|
571
|
-
})
|
|
572
|
-
expect({
|
|
573
|
-
signatureCount: selection.signatureCount,
|
|
574
|
-
threshold: selection.threshold,
|
|
575
|
-
weight: selection.weight,
|
|
576
|
-
}).toMatchInlineSnapshot(`
|
|
577
|
-
{
|
|
578
|
-
"signatureCount": 1,
|
|
579
|
-
"threshold": 1,
|
|
580
|
-
"weight": 1,
|
|
581
|
-
}
|
|
582
|
-
`)
|
|
583
|
-
})
|
|
584
|
-
|
|
585
|
-
test('rejects nested account cycles while serializing', () => {
|
|
586
|
-
const config = MultisigConfig.from({
|
|
587
|
-
owners: [{ owner: account, weight: 1 }],
|
|
588
|
-
threshold: 1,
|
|
589
|
-
})
|
|
590
|
-
const hash = MultisigOperation.getHash({
|
|
591
|
-
account,
|
|
592
|
-
config: { ...config, version: 2n },
|
|
593
|
-
transaction,
|
|
594
|
-
type: 'transaction',
|
|
595
|
-
})
|
|
596
|
-
const nestedHash = MultisigConfig.getSignPayload({
|
|
597
|
-
account,
|
|
598
|
-
config: { version: 2n },
|
|
599
|
-
payload: hash,
|
|
600
|
-
})
|
|
601
|
-
|
|
602
|
-
expect(() =>
|
|
603
|
-
SignatureEnvelope.serialize({
|
|
604
|
-
account,
|
|
605
|
-
config: MultisigConfig.from({ ...config, version: 2n }),
|
|
606
|
-
signatures: [
|
|
607
|
-
SignatureEnvelope.deserialize(signApproval(owners[0]!, nestedHash)),
|
|
608
|
-
],
|
|
609
|
-
type: 'multisig',
|
|
610
|
-
}),
|
|
611
|
-
).toThrowErrorMatchingInlineSnapshot(
|
|
612
|
-
`[SignatureEnvelope.InvalidMultisigApprovalError: Invalid native multisig owner approval: multisig account cannot be an owner.]`,
|
|
613
|
-
)
|
|
614
|
-
})
|
|
615
|
-
|
|
616
|
-
test('rejects excess nesting depth', async () => {
|
|
617
|
-
const grandchildConfig = MultisigConfig.from({
|
|
618
|
-
owners: [{ owner: owners[2]!.address, weight: 1 }],
|
|
619
|
-
threshold: 1,
|
|
620
|
-
})
|
|
621
|
-
const grandchild = MultisigConfig.getAddress(grandchildConfig)
|
|
622
|
-
const childConfig = MultisigConfig.from({
|
|
623
|
-
owners: [{ owner: grandchild, weight: 1 }],
|
|
624
|
-
threshold: 1,
|
|
625
|
-
})
|
|
626
|
-
const child = MultisigConfig.getAddress(childConfig)
|
|
627
|
-
const config = MultisigConfig.from({
|
|
628
|
-
owners: [{ owner: child, weight: 1 }],
|
|
629
|
-
threshold: 1,
|
|
630
|
-
})
|
|
631
|
-
const account = MultisigConfig.getAddress(config)
|
|
632
|
-
const hash = MultisigOperation.getHash({
|
|
633
|
-
account,
|
|
634
|
-
config: { ...config, version: 1n },
|
|
635
|
-
transaction,
|
|
636
|
-
type: 'transaction',
|
|
637
|
-
})
|
|
638
|
-
const childHash = MultisigConfig.getSignPayload({
|
|
639
|
-
account: child,
|
|
640
|
-
config: { ...childConfig, version: 1n },
|
|
641
|
-
payload: hash,
|
|
642
|
-
})
|
|
643
|
-
const grandchildHash = MultisigConfig.getSignPayload({
|
|
644
|
-
account: grandchild,
|
|
645
|
-
config: { ...grandchildConfig, version: 1n },
|
|
646
|
-
payload: childHash,
|
|
647
|
-
})
|
|
648
|
-
|
|
649
|
-
await expect(
|
|
650
|
-
MultisigOperation.selectApprovals({
|
|
651
|
-
account,
|
|
652
|
-
approvals: [
|
|
653
|
-
SignatureEnvelope.serialize({
|
|
654
|
-
account: child,
|
|
655
|
-
config: MultisigConfig.from({ ...childConfig, version: 1n }),
|
|
656
|
-
signatures: [
|
|
657
|
-
{
|
|
658
|
-
account: grandchild,
|
|
659
|
-
config: MultisigConfig.from({
|
|
660
|
-
...grandchildConfig,
|
|
661
|
-
version: 1n,
|
|
662
|
-
}),
|
|
663
|
-
signatures: [
|
|
664
|
-
SignatureEnvelope.deserialize(
|
|
665
|
-
signApproval(owners[2]!, grandchildHash),
|
|
666
|
-
),
|
|
667
|
-
],
|
|
668
|
-
type: 'multisig',
|
|
669
|
-
},
|
|
670
|
-
],
|
|
671
|
-
type: 'multisig',
|
|
672
|
-
}),
|
|
673
|
-
],
|
|
674
|
-
config,
|
|
675
|
-
hash,
|
|
676
|
-
}),
|
|
677
|
-
).rejects.toThrowErrorMatchingInlineSnapshot(
|
|
678
|
-
`[MultisigOperation.InvalidApprovalError: Invalid multisig approval: nested multisig owner 0xf529c8f6b2b4c72102af4cfe5eeb55b7d45dede2 is invalid.]`,
|
|
679
|
-
)
|
|
680
|
-
})
|
|
681
298
|
})
|
|
682
299
|
|
|
683
300
|
describe('serializeKeyAuthorization', () => {
|
|
@@ -728,14 +345,14 @@ describe('serializeKeyAuthorization', () => {
|
|
|
728
345
|
expect(results).toMatchInlineSnapshot(`
|
|
729
346
|
[
|
|
730
347
|
{
|
|
731
|
-
"account": "
|
|
732
|
-
"hash": "
|
|
348
|
+
"account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
349
|
+
"hash": "0xcd4283709cc1853dc8ed9cc4dd8c3b6a22e1b01f19ad3f6348f4bebe79590408",
|
|
733
350
|
"signatureCount": 2,
|
|
734
351
|
"version": 1n,
|
|
735
352
|
},
|
|
736
353
|
{
|
|
737
|
-
"account": "
|
|
738
|
-
"hash": "
|
|
354
|
+
"account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
355
|
+
"hash": "0x1f66e6adc4ddf8ac9d4575f518be11509ca616ac13d4e0a286b4eef7b96959f2",
|
|
739
356
|
"signatureCount": 2,
|
|
740
357
|
"version": 0n,
|
|
741
358
|
},
|
|
@@ -829,15 +446,15 @@ describe('serializeTransaction', () => {
|
|
|
829
446
|
expect(results).toMatchInlineSnapshot(`
|
|
830
447
|
[
|
|
831
448
|
{
|
|
832
|
-
"account": "
|
|
833
|
-
"hash": "
|
|
449
|
+
"account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
450
|
+
"hash": "0x6a034f208339f7eaa4a42b3fa03aad5df77ebe83659dac2e4d2b11226d221928",
|
|
834
451
|
"signatureCount": 2,
|
|
835
452
|
"type": "0x76",
|
|
836
453
|
"version": 1n,
|
|
837
454
|
},
|
|
838
455
|
{
|
|
839
|
-
"account": "
|
|
840
|
-
"hash": "
|
|
456
|
+
"account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
457
|
+
"hash": "0x04d36e54d7a816b080dfa03370da6fbeb3523ce3eff5211d7f22a3c7e87476ee",
|
|
841
458
|
"signatureCount": 2,
|
|
842
459
|
"type": "0x76",
|
|
843
460
|
"version": 0n,
|
|
@@ -918,7 +535,7 @@ describe('serializeTransaction', () => {
|
|
|
918
535
|
[
|
|
919
536
|
{
|
|
920
537
|
"feePayerSignature": null,
|
|
921
|
-
"from": "
|
|
538
|
+
"from": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
922
539
|
"signatureCount": 2,
|
|
923
540
|
"type": "0x78",
|
|
924
541
|
},
|
|
@@ -928,7 +545,7 @@ describe('serializeTransaction', () => {
|
|
|
928
545
|
"s": "0x0000000000000000000000000000000000000000000000000000000000000006",
|
|
929
546
|
"yParity": 0,
|
|
930
547
|
},
|
|
931
|
-
"from": "
|
|
548
|
+
"from": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
932
549
|
"signatureCount": 2,
|
|
933
550
|
"type": "0x78",
|
|
934
551
|
},
|
|
@@ -1000,7 +617,7 @@ describe('from', () => {
|
|
|
1000
617
|
expect({ pending, submitting, success }).toMatchInlineSnapshot(`
|
|
1001
618
|
{
|
|
1002
619
|
"pending": {
|
|
1003
|
-
"account": "
|
|
620
|
+
"account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
1004
621
|
"approvals": [
|
|
1005
622
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
1006
623
|
],
|
|
@@ -1020,7 +637,7 @@ describe('from', () => {
|
|
|
1020
637
|
"version": 1n,
|
|
1021
638
|
},
|
|
1022
639
|
"createdAt": 1,
|
|
1023
|
-
"hash": "
|
|
640
|
+
"hash": "0x2d7e3c7c38a9acf85f0a9d70a39b0e9e5a05d92c7a73b633a47a45be4a112b3b",
|
|
1024
641
|
"signatureCount": 1,
|
|
1025
642
|
"status": "pending",
|
|
1026
643
|
"threshold": 2,
|
|
@@ -1030,7 +647,7 @@ describe('from', () => {
|
|
|
1030
647
|
"weight": 1,
|
|
1031
648
|
},
|
|
1032
649
|
"submitting": {
|
|
1033
|
-
"account": "
|
|
650
|
+
"account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
1034
651
|
"approvals": [
|
|
1035
652
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
1036
653
|
"0x01000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
|
|
@@ -1052,7 +669,7 @@ describe('from', () => {
|
|
|
1052
669
|
},
|
|
1053
670
|
"createdAt": 1,
|
|
1054
671
|
"expiresAt": 10,
|
|
1055
|
-
"hash": "
|
|
672
|
+
"hash": "0x2d7e3c7c38a9acf85f0a9d70a39b0e9e5a05d92c7a73b633a47a45be4a112b3b",
|
|
1056
673
|
"signatureCount": 2,
|
|
1057
674
|
"status": "submitting",
|
|
1058
675
|
"submissionId": "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
|
@@ -1063,7 +680,7 @@ describe('from', () => {
|
|
|
1063
680
|
"weight": 2,
|
|
1064
681
|
},
|
|
1065
682
|
"success": {
|
|
1066
|
-
"account": "
|
|
683
|
+
"account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
1067
684
|
"approvals": [
|
|
1068
685
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
1069
686
|
"0x01000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
|
|
@@ -1084,7 +701,7 @@ describe('from', () => {
|
|
|
1084
701
|
"version": 1n,
|
|
1085
702
|
},
|
|
1086
703
|
"createdAt": 1,
|
|
1087
|
-
"hash": "
|
|
704
|
+
"hash": "0x2d7e3c7c38a9acf85f0a9d70a39b0e9e5a05d92c7a73b633a47a45be4a112b3b",
|
|
1088
705
|
"signatureCount": 2,
|
|
1089
706
|
"status": "success",
|
|
1090
707
|
"threshold": 2,
|
|
@@ -1130,7 +747,7 @@ describe('from', () => {
|
|
|
1130
747
|
},
|
|
1131
748
|
`
|
|
1132
749
|
{
|
|
1133
|
-
"account": "
|
|
750
|
+
"account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
1134
751
|
"approvals": [
|
|
1135
752
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
1136
753
|
],
|
|
@@ -1216,7 +833,7 @@ describe('from', () => {
|
|
|
1216
833
|
},
|
|
1217
834
|
`
|
|
1218
835
|
{
|
|
1219
|
-
"account": "
|
|
836
|
+
"account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
1220
837
|
"approvals": [
|
|
1221
838
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
1222
839
|
],
|
|
@@ -1260,10 +877,7 @@ describe('from', () => {
|
|
|
1260
877
|
signature: {
|
|
1261
878
|
account,
|
|
1262
879
|
config: currentConfig,
|
|
1263
|
-
signatures: [
|
|
1264
|
-
SignatureEnvelope.deserialize(approval_1),
|
|
1265
|
-
SignatureEnvelope.deserialize(approval_2),
|
|
1266
|
-
],
|
|
880
|
+
signatures: [ownerSignature_1, owners[1]!.signature],
|
|
1267
881
|
type: 'multisig',
|
|
1268
882
|
},
|
|
1269
883
|
}),
|
|
@@ -1276,7 +890,7 @@ describe('from', () => {
|
|
|
1276
890
|
expect({ pending, success }).toMatchInlineSnapshot(`
|
|
1277
891
|
{
|
|
1278
892
|
"pending": {
|
|
1279
|
-
"account": "
|
|
893
|
+
"account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
1280
894
|
"approvals": [
|
|
1281
895
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
1282
896
|
],
|
|
@@ -1296,8 +910,8 @@ describe('from', () => {
|
|
|
1296
910
|
"version": 1n,
|
|
1297
911
|
},
|
|
1298
912
|
"createdAt": 1,
|
|
1299
|
-
"hash": "
|
|
1300
|
-
"keyAuthorization": "
|
|
913
|
+
"hash": "0xa83016f0e94c4a6125483ffeba3abb0a8df1bc0f5a503f63639e806b793520bb",
|
|
914
|
+
"keyAuthorization": "0xf838f782107980943333333333333333333333333333333333333333846b49d2008080808094ef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
1301
915
|
"signatureCount": 1,
|
|
1302
916
|
"status": "pending",
|
|
1303
917
|
"threshold": 2,
|
|
@@ -1306,7 +920,7 @@ describe('from', () => {
|
|
|
1306
920
|
"weight": 1,
|
|
1307
921
|
},
|
|
1308
922
|
"success": {
|
|
1309
|
-
"account": "
|
|
923
|
+
"account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
1310
924
|
"approvals": [
|
|
1311
925
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
1312
926
|
"0x01000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
|
|
@@ -1327,8 +941,8 @@ describe('from', () => {
|
|
|
1327
941
|
"version": 1n,
|
|
1328
942
|
},
|
|
1329
943
|
"createdAt": 1,
|
|
1330
|
-
"hash": "
|
|
1331
|
-
"keyAuthorization": "
|
|
944
|
+
"hash": "0xa83016f0e94c4a6125483ffeba3abb0a8df1bc0f5a503f63639e806b793520bb",
|
|
945
|
+
"keyAuthorization": "0xf901b3f782107980943333333333333333333333333333333333333333846b49d2008080808094ef6b17836e1b3647105c3084124485e3e1b0ab7fb9017805f9017494ef6b17836e1b3647105c3084124485e3e1b0ab7ff852a000000000000000000000000000000000000000000000000000000000000000000102eed69407e1ed8ea0e9601e5546b0a03aed683df360140701d694288f0cd85005f34168f731a468aef268c2f9456f01f90108b88201000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200b88201000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
|
|
1332
946
|
"signatureCount": 2,
|
|
1333
947
|
"status": "success",
|
|
1334
948
|
"threshold": 2,
|
|
@@ -1347,10 +961,7 @@ describe('from', () => {
|
|
|
1347
961
|
signature: {
|
|
1348
962
|
account,
|
|
1349
963
|
config,
|
|
1350
|
-
signatures: [
|
|
1351
|
-
SignatureEnvelope.deserialize(approval_1),
|
|
1352
|
-
SignatureEnvelope.deserialize(approval_2),
|
|
1353
|
-
],
|
|
964
|
+
signatures: [ownerSignature_1, owners[1]!.signature],
|
|
1354
965
|
type: 'multisig',
|
|
1355
966
|
},
|
|
1356
967
|
}),
|
|
@@ -1377,7 +988,7 @@ describe('from', () => {
|
|
|
1377
988
|
},
|
|
1378
989
|
`
|
|
1379
990
|
{
|
|
1380
|
-
"account": "
|
|
991
|
+
"account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
1381
992
|
"approvals": [
|
|
1382
993
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
1383
994
|
"0x01000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
|
|
@@ -1423,7 +1034,7 @@ describe('RPC conversion', () => {
|
|
|
1423
1034
|
expect({ keyAuthorizationRpc, transactionRpc }).toMatchInlineSnapshot(`
|
|
1424
1035
|
{
|
|
1425
1036
|
"keyAuthorizationRpc": {
|
|
1426
|
-
"account": "
|
|
1037
|
+
"account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
1427
1038
|
"approvals": [
|
|
1428
1039
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
1429
1040
|
],
|
|
@@ -1443,8 +1054,8 @@ describe('RPC conversion', () => {
|
|
|
1443
1054
|
"version": "0x1",
|
|
1444
1055
|
},
|
|
1445
1056
|
"createdAt": 1,
|
|
1446
|
-
"hash": "
|
|
1447
|
-
"keyAuthorization": "
|
|
1057
|
+
"hash": "0xa83016f0e94c4a6125483ffeba3abb0a8df1bc0f5a503f63639e806b793520bb",
|
|
1058
|
+
"keyAuthorization": "0xf838f782107980943333333333333333333333333333333333333333846b49d2008080808094ef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
1448
1059
|
"signatureCount": 1,
|
|
1449
1060
|
"status": "pending",
|
|
1450
1061
|
"threshold": 2,
|
|
@@ -1453,7 +1064,7 @@ describe('RPC conversion', () => {
|
|
|
1453
1064
|
"weight": 1,
|
|
1454
1065
|
},
|
|
1455
1066
|
"transactionRpc": {
|
|
1456
|
-
"account": "
|
|
1067
|
+
"account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
1457
1068
|
"approvals": [
|
|
1458
1069
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
1459
1070
|
],
|
|
@@ -1473,7 +1084,7 @@ describe('RPC conversion', () => {
|
|
|
1473
1084
|
"version": "0x1",
|
|
1474
1085
|
},
|
|
1475
1086
|
"createdAt": 1,
|
|
1476
|
-
"hash": "
|
|
1087
|
+
"hash": "0x2d7e3c7c38a9acf85f0a9d70a39b0e9e5a05d92c7a73b633a47a45be4a112b3b",
|
|
1477
1088
|
"signatureCount": 1,
|
|
1478
1089
|
"status": "pending",
|
|
1479
1090
|
"threshold": 2,
|
|
@@ -1505,7 +1116,7 @@ describe('validation', () => {
|
|
|
1505
1116
|
...transactionPending,
|
|
1506
1117
|
transaction: TxEnvelopeTempo.serialize(
|
|
1507
1118
|
TxEnvelopeTempo.deserialize(transaction),
|
|
1508
|
-
{ signature:
|
|
1119
|
+
{ signature: ownerSignature_1 },
|
|
1509
1120
|
),
|
|
1510
1121
|
},
|
|
1511
1122
|
},
|
|
@@ -1691,32 +1302,19 @@ describe('validation', () => {
|
|
|
1691
1302
|
MultisigOperation.from(operation as MultisigOperation.Operation),
|
|
1692
1303
|
).toThrowError(MultisigOperation.InvalidOperationError)
|
|
1693
1304
|
})
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
})
|
|
1701
|
-
expect(() =>
|
|
1702
|
-
MultisigOperation.from({
|
|
1703
|
-
...transactionPending,
|
|
1305
|
+
test('accepts initial accounts validated by the chain', () => {
|
|
1306
|
+
const value = MultisigOperation.from({
|
|
1307
|
+
...transactionPending,
|
|
1308
|
+
config,
|
|
1309
|
+
hash: MultisigOperation.getHash({
|
|
1310
|
+
account,
|
|
1704
1311
|
config,
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
config,
|
|
1708
|
-
payload: TxEnvelopeTempo.getSignPayload(
|
|
1709
|
-
TxEnvelopeTempo.deserialize(transaction),
|
|
1710
|
-
),
|
|
1711
|
-
}),
|
|
1312
|
+
transaction,
|
|
1313
|
+
type: 'transaction',
|
|
1712
1314
|
}),
|
|
1713
|
-
)
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
Details: Invalid native multisig owner approval: initial multisig config does not derive account.]
|
|
1718
|
-
`,
|
|
1719
|
-
)
|
|
1315
|
+
})
|
|
1316
|
+
expect(value.account).toBe(account)
|
|
1317
|
+
expect(value.config).toEqual(config)
|
|
1720
1318
|
})
|
|
1721
1319
|
|
|
1722
1320
|
test('rejects noncanonical RPC quantities', () => {
|
|
@@ -1741,10 +1339,7 @@ describe('validation', () => {
|
|
|
1741
1339
|
signature: {
|
|
1742
1340
|
account,
|
|
1743
1341
|
config: currentConfig,
|
|
1744
|
-
signatures: [
|
|
1745
|
-
SignatureEnvelope.deserialize(approval_1),
|
|
1746
|
-
SignatureEnvelope.deserialize(approval_3),
|
|
1747
|
-
],
|
|
1342
|
+
signatures: [ownerSignature_1, owners[2]!.signature],
|
|
1748
1343
|
type: 'multisig',
|
|
1749
1344
|
},
|
|
1750
1345
|
}),
|
|
@@ -1766,10 +1361,7 @@ describe('validation', () => {
|
|
|
1766
1361
|
account,
|
|
1767
1362
|
config: currentConfig,
|
|
1768
1363
|
payload: KeyAuthorization.getSignPayload(authorization),
|
|
1769
|
-
signatures: [
|
|
1770
|
-
SignatureEnvelope.deserialize(approval_1),
|
|
1771
|
-
SignatureEnvelope.deserialize(approval_2),
|
|
1772
|
-
],
|
|
1364
|
+
signatures: [ownerSignature_1, owners[1]!.signature],
|
|
1773
1365
|
}),
|
|
1774
1366
|
].reverse()
|
|
1775
1367
|
const operation = {
|
|
@@ -1805,10 +1397,7 @@ describe('validation', () => {
|
|
|
1805
1397
|
signature: {
|
|
1806
1398
|
account,
|
|
1807
1399
|
config: currentConfig,
|
|
1808
|
-
signatures: [
|
|
1809
|
-
SignatureEnvelope.deserialize(approval_1),
|
|
1810
|
-
SignatureEnvelope.deserialize(approval_1),
|
|
1811
|
-
],
|
|
1400
|
+
signatures: [ownerSignature_1, ownerSignature_1],
|
|
1812
1401
|
type: 'multisig',
|
|
1813
1402
|
},
|
|
1814
1403
|
}),
|
|
@@ -1823,63 +1412,6 @@ describe('validation', () => {
|
|
|
1823
1412
|
)
|
|
1824
1413
|
})
|
|
1825
1414
|
|
|
1826
|
-
test('rejects reordered nested key authorization approvals', () => {
|
|
1827
|
-
const authorization = KeyAuthorization.deserialize(keyAuthorization)
|
|
1828
|
-
const nestedConfig = MultisigConfig.from({
|
|
1829
|
-
owners: [{ owner: owner_2, weight: 1 }],
|
|
1830
|
-
threshold: 1,
|
|
1831
|
-
version: 1n,
|
|
1832
|
-
})
|
|
1833
|
-
const childSignatures = SignatureEnvelope.sortMultisigApprovals({
|
|
1834
|
-
account: owner_1,
|
|
1835
|
-
config: nestedConfig,
|
|
1836
|
-
payload: keyAuthorizationHash,
|
|
1837
|
-
signatures: [
|
|
1838
|
-
SignatureEnvelope.deserialize(approval_1),
|
|
1839
|
-
SignatureEnvelope.deserialize(approval_2),
|
|
1840
|
-
],
|
|
1841
|
-
})
|
|
1842
|
-
const retainedNested = SignatureEnvelope.from({
|
|
1843
|
-
account: owner_1,
|
|
1844
|
-
config: nestedConfig,
|
|
1845
|
-
signatures: childSignatures,
|
|
1846
|
-
type: 'multisig',
|
|
1847
|
-
})
|
|
1848
|
-
const selectedNested = SignatureEnvelope.from({
|
|
1849
|
-
account: owner_1,
|
|
1850
|
-
config: nestedConfig,
|
|
1851
|
-
signatures: [...childSignatures].reverse(),
|
|
1852
|
-
type: 'multisig',
|
|
1853
|
-
})
|
|
1854
|
-
const selected = SignatureEnvelope.sortMultisigApprovals({
|
|
1855
|
-
account,
|
|
1856
|
-
config: currentConfig,
|
|
1857
|
-
payload: KeyAuthorization.getSignPayload(authorization),
|
|
1858
|
-
signatures: [selectedNested, SignatureEnvelope.deserialize(approval_2)],
|
|
1859
|
-
})
|
|
1860
|
-
const operation = {
|
|
1861
|
-
...keyAuthorizationPending,
|
|
1862
|
-
approvals: [SignatureEnvelope.serialize(retainedNested), approval_2],
|
|
1863
|
-
keyAuthorization: KeyAuthorization.serialize(
|
|
1864
|
-
KeyAuthorization.from(authorization, {
|
|
1865
|
-
signature: {
|
|
1866
|
-
account,
|
|
1867
|
-
config: currentConfig,
|
|
1868
|
-
signatures: selected,
|
|
1869
|
-
type: 'multisig',
|
|
1870
|
-
},
|
|
1871
|
-
}),
|
|
1872
|
-
),
|
|
1873
|
-
signatureCount: 2,
|
|
1874
|
-
status: 'success',
|
|
1875
|
-
weight: 2,
|
|
1876
|
-
} as const
|
|
1877
|
-
|
|
1878
|
-
expect(() => MultisigOperation.from(operation)).toThrowError(
|
|
1879
|
-
'Invalid multisig operation: key authorization signature is not a retained approval.',
|
|
1880
|
-
)
|
|
1881
|
-
})
|
|
1882
|
-
|
|
1883
1415
|
test('accepts case-insensitive initial configs', () => {
|
|
1884
1416
|
const config = MultisigConfig.from({
|
|
1885
1417
|
owners: [
|
|
@@ -1895,7 +1427,7 @@ describe('validation', () => {
|
|
|
1895
1427
|
salt: `0x${'AB'.repeat(32)}`,
|
|
1896
1428
|
threshold: 2,
|
|
1897
1429
|
})
|
|
1898
|
-
const account = MultisigConfig.getAddress(config)
|
|
1430
|
+
const account = MultisigConfig.getAddress(config, { factory })
|
|
1899
1431
|
const authorization = KeyAuthorization.from({
|
|
1900
1432
|
account,
|
|
1901
1433
|
address: '0x3333333333333333333333333333333333333333',
|
|
@@ -1908,10 +1440,7 @@ describe('validation', () => {
|
|
|
1908
1440
|
account,
|
|
1909
1441
|
config,
|
|
1910
1442
|
payload: KeyAuthorization.getSignPayload(authorization),
|
|
1911
|
-
signatures: [
|
|
1912
|
-
SignatureEnvelope.deserialize(approval_1),
|
|
1913
|
-
SignatureEnvelope.deserialize(approval_2),
|
|
1914
|
-
],
|
|
1443
|
+
signatures: [ownerSignature_1, owners[1]!.signature],
|
|
1915
1444
|
})
|
|
1916
1445
|
const approvals = signatures.map((signature) =>
|
|
1917
1446
|
SignatureEnvelope.serialize(signature),
|