ox 0.14.44 → 0.14.45
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 +6 -0
- package/_cjs/tempo/KeyAuthorization.js +43 -10
- package/_cjs/tempo/KeyAuthorization.js.map +1 -1
- package/_cjs/tempo/MultisigConfig.js +33 -11
- package/_cjs/tempo/MultisigConfig.js.map +1 -1
- package/_cjs/tempo/MultisigOperation.js +18 -94
- package/_cjs/tempo/MultisigOperation.js.map +1 -1
- package/_cjs/tempo/MultisigSimulation.js +18 -46
- package/_cjs/tempo/MultisigSimulation.js.map +1 -1
- package/_cjs/tempo/SignatureEnvelope.js +72 -109
- package/_cjs/tempo/SignatureEnvelope.js.map +1 -1
- package/_cjs/tempo/TransactionRequest.js +5 -1
- package/_cjs/tempo/TransactionRequest.js.map +1 -1
- package/_cjs/tempo/index.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/tempo/KeyAuthorization.js +42 -9
- package/_esm/tempo/KeyAuthorization.js.map +1 -1
- package/_esm/tempo/MultisigConfig.js +41 -22
- package/_esm/tempo/MultisigConfig.js.map +1 -1
- package/_esm/tempo/MultisigOperation.js +20 -100
- package/_esm/tempo/MultisigOperation.js.map +1 -1
- package/_esm/tempo/MultisigSimulation.js +18 -46
- package/_esm/tempo/MultisigSimulation.js.map +1 -1
- package/_esm/tempo/SignatureEnvelope.js +107 -169
- package/_esm/tempo/SignatureEnvelope.js.map +1 -1
- package/_esm/tempo/TransactionRequest.js +5 -1
- package/_esm/tempo/TransactionRequest.js.map +1 -1
- package/_esm/tempo/index.js +3 -1
- package/_esm/tempo/index.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/tempo/KeyAuthorization.d.ts +48 -38
- package/_types/tempo/KeyAuthorization.d.ts.map +1 -1
- package/_types/tempo/MultisigConfig.d.ts +15 -14
- package/_types/tempo/MultisigConfig.d.ts.map +1 -1
- package/_types/tempo/MultisigOperation.d.ts +3 -2
- package/_types/tempo/MultisigOperation.d.ts.map +1 -1
- package/_types/tempo/MultisigSimulation.d.ts +2 -49
- package/_types/tempo/MultisigSimulation.d.ts.map +1 -1
- package/_types/tempo/SignatureEnvelope.d.ts +69 -128
- package/_types/tempo/SignatureEnvelope.d.ts.map +1 -1
- package/_types/tempo/TransactionRequest.d.ts +5 -2
- package/_types/tempo/TransactionRequest.d.ts.map +1 -1
- package/_types/tempo/index.d.ts +3 -1
- package/_types/tempo/index.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/package.json +1 -1
- package/tempo/AuthorizationTempo.test.ts +8 -4
- package/tempo/KeyAuthorization.test-d.ts +68 -33
- package/tempo/KeyAuthorization.test.ts +89 -8
- package/tempo/KeyAuthorization.ts +124 -61
- package/tempo/MultisigConfig.test.ts +34 -26
- package/tempo/MultisigConfig.ts +54 -24
- package/tempo/MultisigOperation.test.ts +79 -550
- package/tempo/MultisigOperation.ts +31 -146
- package/tempo/MultisigSimulation.test-d.ts +2 -2
- package/tempo/MultisigSimulation.test.ts +21 -110
- package/tempo/MultisigSimulation.ts +25 -99
- package/tempo/SignatureEnvelope.test-d.ts +29 -67
- package/tempo/SignatureEnvelope.test.ts +301 -568
- package/tempo/SignatureEnvelope.ts +156 -274
- package/tempo/TransactionRequest.test-d.ts +6 -5
- package/tempo/TransactionRequest.test.ts +17 -80
- package/tempo/TransactionRequest.ts +23 -3
- package/tempo/index.ts +3 -1
- package/tempo/multisig.e2e.test.ts +322 -861
- package/version.ts +1 -1
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
TxEnvelopeTempo,
|
|
8
8
|
} from 'ox/tempo'
|
|
9
9
|
import { describe, expect, test } from 'vitest'
|
|
10
|
+
import { factory } from '../../test/tempo/multisig.js'
|
|
10
11
|
|
|
11
12
|
const owners = [1n, 2n, 3n]
|
|
12
13
|
.map((value, index) => {
|
|
@@ -37,7 +38,7 @@ const config = MultisigConfig.from({
|
|
|
37
38
|
threshold: 2,
|
|
38
39
|
})
|
|
39
40
|
const currentConfig = MultisigConfig.from({ ...config, version: 1n })
|
|
40
|
-
const account = MultisigConfig.getAddress(config)
|
|
41
|
+
const account = MultisigConfig.getAddress(config, { factory })
|
|
41
42
|
const ownerSignature_1 = owners[0]!.signature
|
|
42
43
|
const approval_1 = SignatureEnvelope.serialize(ownerSignature_1)
|
|
43
44
|
const approval_2 = SignatureEnvelope.serialize(owners[1]!.signature)
|
|
@@ -149,8 +150,8 @@ describe('getHash', () => {
|
|
|
149
150
|
}),
|
|
150
151
|
}).toMatchInlineSnapshot(`
|
|
151
152
|
{
|
|
152
|
-
"keyAuthorization": "
|
|
153
|
-
"transaction": "
|
|
153
|
+
"keyAuthorization": "0xa83016f0e94c4a6125483ffeba3abb0a8df1bc0f5a503f63639e806b793520bb",
|
|
154
|
+
"transaction": "0x2d7e3c7c38a9acf85f0a9d70a39b0e9e5a05d92c7a73b633a47a45be4a112b3b",
|
|
154
155
|
}
|
|
155
156
|
`)
|
|
156
157
|
})
|
|
@@ -166,7 +167,7 @@ describe('selectApprovals', () => {
|
|
|
166
167
|
],
|
|
167
168
|
threshold: 3,
|
|
168
169
|
})
|
|
169
|
-
const account = MultisigConfig.getAddress(config)
|
|
170
|
+
const account = MultisigConfig.getAddress(config, { factory })
|
|
170
171
|
const hash = MultisigOperation.getHash({
|
|
171
172
|
account,
|
|
172
173
|
config: { ...config, version: 1n },
|
|
@@ -222,195 +223,39 @@ describe('selectApprovals', () => {
|
|
|
222
223
|
}
|
|
223
224
|
`)
|
|
224
225
|
})
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
const childConfig = MultisigConfig.from({
|
|
228
|
-
owners: [
|
|
229
|
-
{ owner: owners[1]!.address, weight: 1 },
|
|
230
|
-
{ owner: owners[2]!.address, weight: 1 },
|
|
231
|
-
],
|
|
232
|
-
threshold: 2,
|
|
233
|
-
})
|
|
234
|
-
const child = MultisigConfig.getAddress(childConfig)
|
|
235
|
-
const config = MultisigConfig.from({
|
|
236
|
-
owners: [
|
|
237
|
-
{ owner: owners[0]!.address, weight: 1 },
|
|
238
|
-
{ owner: child, weight: 2 },
|
|
239
|
-
],
|
|
240
|
-
threshold: 2,
|
|
241
|
-
})
|
|
242
|
-
const account = MultisigConfig.getAddress(config)
|
|
243
|
-
const hash = MultisigOperation.getHash({
|
|
244
|
-
account,
|
|
245
|
-
config: { ...config, version: 1n },
|
|
246
|
-
transaction,
|
|
247
|
-
type: 'transaction',
|
|
248
|
-
})
|
|
249
|
-
const childHash = MultisigConfig.getSignPayload({
|
|
250
|
-
account: child,
|
|
251
|
-
config: { ...childConfig, version: 2n },
|
|
252
|
-
payload: hash,
|
|
253
|
-
})
|
|
254
|
-
const childApprovals = [
|
|
255
|
-
signApproval(owners[1]!, childHash),
|
|
256
|
-
signApproval(owners[2]!, childHash),
|
|
257
|
-
]
|
|
258
|
-
const rootApproval = signApproval(owners[0]!, hash)
|
|
259
|
-
const partial = await MultisigOperation.selectApprovals({
|
|
226
|
+
test('accepts an explicit account from a chain-configured factory', async () => {
|
|
227
|
+
const selected = await MultisigOperation.selectApprovals({
|
|
260
228
|
account,
|
|
261
|
-
approvals: [
|
|
262
|
-
rootApproval,
|
|
263
|
-
SignatureEnvelope.serialize({
|
|
264
|
-
account: child,
|
|
265
|
-
config: MultisigConfig.from({ ...childConfig, version: 2n }),
|
|
266
|
-
signatures: [SignatureEnvelope.deserialize(childApprovals[0]!)],
|
|
267
|
-
type: 'multisig',
|
|
268
|
-
}),
|
|
269
|
-
],
|
|
229
|
+
approvals: [],
|
|
270
230
|
config,
|
|
271
|
-
hash,
|
|
231
|
+
hash: transactionHash_,
|
|
272
232
|
})
|
|
273
|
-
|
|
274
|
-
account,
|
|
275
|
-
approvals: [
|
|
276
|
-
rootApproval,
|
|
277
|
-
SignatureEnvelope.serialize({
|
|
278
|
-
account: child,
|
|
279
|
-
config: MultisigConfig.from({ ...childConfig, version: 2n }),
|
|
280
|
-
signatures: childApprovals.map((approval) =>
|
|
281
|
-
SignatureEnvelope.deserialize(approval),
|
|
282
|
-
),
|
|
283
|
-
type: 'multisig',
|
|
284
|
-
}),
|
|
285
|
-
],
|
|
286
|
-
config,
|
|
287
|
-
hash,
|
|
288
|
-
})
|
|
289
|
-
|
|
290
|
-
expect({
|
|
291
|
-
complete: {
|
|
292
|
-
...complete,
|
|
293
|
-
approvals: approvalAddresses(complete.approvals, hash),
|
|
294
|
-
selectedApprovals: approvalAddresses(complete.selectedApprovals, hash),
|
|
295
|
-
},
|
|
296
|
-
partial: {
|
|
297
|
-
...partial,
|
|
298
|
-
approvals: approvalAddresses(partial.approvals, hash),
|
|
299
|
-
selectedApprovals: approvalAddresses(partial.selectedApprovals, hash),
|
|
300
|
-
},
|
|
301
|
-
}).toMatchInlineSnapshot(`
|
|
302
|
-
{
|
|
303
|
-
"complete": {
|
|
304
|
-
"approvals": [
|
|
305
|
-
"0x07e1ed8ea0e9601e5546b0a03aed683df3601407",
|
|
306
|
-
"0xf75618474e5f7fd9ef17dd85167a5b1e1f19b84b",
|
|
307
|
-
],
|
|
308
|
-
"selectedApprovals": [
|
|
309
|
-
"0xf75618474e5f7fd9ef17dd85167a5b1e1f19b84b",
|
|
310
|
-
],
|
|
311
|
-
"signatureCount": 1,
|
|
312
|
-
"threshold": 2,
|
|
313
|
-
"weight": 2,
|
|
314
|
-
},
|
|
315
|
-
"partial": {
|
|
316
|
-
"approvals": [
|
|
317
|
-
"0x07e1ed8ea0e9601e5546b0a03aed683df3601407",
|
|
318
|
-
"0xf75618474e5f7fd9ef17dd85167a5b1e1f19b84b",
|
|
319
|
-
],
|
|
320
|
-
"selectedApprovals": [
|
|
321
|
-
"0x07e1ed8ea0e9601e5546b0a03aed683df3601407",
|
|
322
|
-
],
|
|
323
|
-
"signatureCount": 1,
|
|
324
|
-
"threshold": 2,
|
|
325
|
-
"weight": 1,
|
|
326
|
-
},
|
|
327
|
-
}
|
|
328
|
-
`)
|
|
233
|
+
expect(selected.weight).toMatchInlineSnapshot(`0`)
|
|
329
234
|
})
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
threshold: 1,
|
|
340
|
-
})
|
|
341
|
-
const account = MultisigConfig.getAddress(config)
|
|
342
|
-
const hash = MultisigOperation.getHash({
|
|
343
|
-
account,
|
|
344
|
-
config: { ...config, version: 1n },
|
|
345
|
-
transaction,
|
|
346
|
-
type: 'transaction',
|
|
347
|
-
})
|
|
348
|
-
const config_2 = MultisigConfig.from({
|
|
349
|
-
...childConfig,
|
|
350
|
-
version: 2n,
|
|
351
|
-
})
|
|
352
|
-
const config_3 = MultisigConfig.from({
|
|
353
|
-
...childConfig,
|
|
354
|
-
version: 3n,
|
|
355
|
-
})
|
|
356
|
-
const childHash_2 = MultisigConfig.getSignPayload({
|
|
357
|
-
account: child,
|
|
358
|
-
config: config_2,
|
|
359
|
-
payload: hash,
|
|
360
|
-
})
|
|
361
|
-
const childHash_3 = MultisigConfig.getSignPayload({
|
|
362
|
-
account: child,
|
|
363
|
-
config: config_3,
|
|
364
|
-
payload: hash,
|
|
365
|
-
})
|
|
366
|
-
|
|
367
|
-
await expect(
|
|
368
|
-
MultisigOperation.selectApprovals({
|
|
235
|
+
test('rejects keychain and multisig owner approvals', async () => {
|
|
236
|
+
for (const signature of [
|
|
237
|
+
SignatureEnvelope.from({
|
|
238
|
+
inner: ownerSignature_1,
|
|
239
|
+
type: 'keychain',
|
|
240
|
+
userAddress: account,
|
|
241
|
+
version: 'v2',
|
|
242
|
+
}),
|
|
243
|
+
SignatureEnvelope.from({
|
|
369
244
|
account,
|
|
370
|
-
approvals: [
|
|
371
|
-
SignatureEnvelope.serialize({
|
|
372
|
-
account: child,
|
|
373
|
-
config: config_2,
|
|
374
|
-
signatures: [
|
|
375
|
-
SignatureEnvelope.deserialize(
|
|
376
|
-
signApproval(owners[1]!, childHash_2),
|
|
377
|
-
),
|
|
378
|
-
],
|
|
379
|
-
type: 'multisig',
|
|
380
|
-
}),
|
|
381
|
-
SignatureEnvelope.serialize({
|
|
382
|
-
account: child,
|
|
383
|
-
config: config_3,
|
|
384
|
-
signatures: [
|
|
385
|
-
SignatureEnvelope.deserialize(
|
|
386
|
-
signApproval(owners[1]!, childHash_3),
|
|
387
|
-
),
|
|
388
|
-
],
|
|
389
|
-
type: 'multisig',
|
|
390
|
-
}),
|
|
391
|
-
],
|
|
392
245
|
config,
|
|
393
|
-
|
|
246
|
+
signatures: [ownerSignature_1],
|
|
394
247
|
}),
|
|
395
|
-
)
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
MultisigOperation.selectApprovals({
|
|
403
|
-
account,
|
|
404
|
-
approvals: [],
|
|
405
|
-
config: MultisigConfig.from({
|
|
406
|
-
...config,
|
|
407
|
-
salt: `0x${'ff'.repeat(32)}`,
|
|
248
|
+
])
|
|
249
|
+
await expect(
|
|
250
|
+
MultisigOperation.selectApprovals({
|
|
251
|
+
account,
|
|
252
|
+
approvals: [SignatureEnvelope.serialize(signature)],
|
|
253
|
+
config,
|
|
254
|
+
hash: transactionHash_,
|
|
408
255
|
}),
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
`[MultisigOperation.InvalidApprovalError: Invalid multisig approval: initial config does not derive the root multisig account.]`,
|
|
413
|
-
)
|
|
256
|
+
).rejects.toThrowErrorMatchingInlineSnapshot(
|
|
257
|
+
`[MultisigOperation.InvalidApprovalError: Invalid multisig approval: only primitive signatures can approve a multisig operation.]`,
|
|
258
|
+
)
|
|
414
259
|
})
|
|
415
260
|
|
|
416
261
|
test('rejects invalid and non-owner approvals', async () => {
|
|
@@ -447,234 +292,6 @@ describe('selectApprovals', () => {
|
|
|
447
292
|
`[MultisigOperation.InvalidApprovalError: Invalid multisig approval: signature is from non-owner 0xd3a9f047ad43d7e2e4e7e491f1fe2e657a2651b6.]`,
|
|
448
293
|
)
|
|
449
294
|
})
|
|
450
|
-
|
|
451
|
-
test('reads current nested config witnesses from approvals', async () => {
|
|
452
|
-
const childConfig = MultisigConfig.from({
|
|
453
|
-
owners: [{ owner: owners[1]!.address, weight: 1 }],
|
|
454
|
-
threshold: 1,
|
|
455
|
-
})
|
|
456
|
-
const child = MultisigConfig.getAddress(childConfig)
|
|
457
|
-
const config = MultisigConfig.from({
|
|
458
|
-
owners: [{ owner: child, weight: 1 }],
|
|
459
|
-
threshold: 1,
|
|
460
|
-
})
|
|
461
|
-
const account = MultisigConfig.getAddress(config)
|
|
462
|
-
const hash = MultisigOperation.getHash({
|
|
463
|
-
account,
|
|
464
|
-
config: { ...config, version: 1n },
|
|
465
|
-
transaction,
|
|
466
|
-
type: 'transaction',
|
|
467
|
-
})
|
|
468
|
-
const childHash = MultisigConfig.getSignPayload({
|
|
469
|
-
account: child,
|
|
470
|
-
config: { ...childConfig, version: 1n },
|
|
471
|
-
payload: hash,
|
|
472
|
-
})
|
|
473
|
-
|
|
474
|
-
const selection = await MultisigOperation.selectApprovals({
|
|
475
|
-
account,
|
|
476
|
-
approvals: [
|
|
477
|
-
SignatureEnvelope.serialize({
|
|
478
|
-
account: child,
|
|
479
|
-
config: MultisigConfig.from({ ...childConfig, version: 1n }),
|
|
480
|
-
signatures: [
|
|
481
|
-
SignatureEnvelope.deserialize(signApproval(owners[1]!, childHash)),
|
|
482
|
-
],
|
|
483
|
-
type: 'multisig',
|
|
484
|
-
}),
|
|
485
|
-
],
|
|
486
|
-
config,
|
|
487
|
-
hash,
|
|
488
|
-
})
|
|
489
|
-
expect(selection).toMatchInlineSnapshot(
|
|
490
|
-
{
|
|
491
|
-
approvals: [expect.any(String)],
|
|
492
|
-
selectedApprovals: [expect.any(String)],
|
|
493
|
-
},
|
|
494
|
-
`
|
|
495
|
-
{
|
|
496
|
-
"approvals": [
|
|
497
|
-
Any<String>,
|
|
498
|
-
],
|
|
499
|
-
"selectedApprovals": [
|
|
500
|
-
Any<String>,
|
|
501
|
-
],
|
|
502
|
-
"signatureCount": 1,
|
|
503
|
-
"threshold": 1,
|
|
504
|
-
"weight": 1,
|
|
505
|
-
}
|
|
506
|
-
`,
|
|
507
|
-
)
|
|
508
|
-
})
|
|
509
|
-
|
|
510
|
-
test('rejects keychain and accepts initial nested approvals', async () => {
|
|
511
|
-
const childConfig = MultisigConfig.from({
|
|
512
|
-
owners: [{ owner: owners[1]!.address, weight: 1 }],
|
|
513
|
-
threshold: 1,
|
|
514
|
-
})
|
|
515
|
-
const child = MultisigConfig.getAddress(childConfig)
|
|
516
|
-
const config = MultisigConfig.from({
|
|
517
|
-
owners: [
|
|
518
|
-
{ owner: owners[0]!.address, weight: 1 },
|
|
519
|
-
{ owner: child, weight: 1 },
|
|
520
|
-
],
|
|
521
|
-
threshold: 1,
|
|
522
|
-
})
|
|
523
|
-
const account = MultisigConfig.getAddress(config)
|
|
524
|
-
const hash = MultisigOperation.getHash({
|
|
525
|
-
account,
|
|
526
|
-
config: { ...config, version: 1n },
|
|
527
|
-
transaction,
|
|
528
|
-
type: 'transaction',
|
|
529
|
-
})
|
|
530
|
-
const childHash = MultisigConfig.getSignPayload({
|
|
531
|
-
account: child,
|
|
532
|
-
config: childConfig,
|
|
533
|
-
payload: hash,
|
|
534
|
-
})
|
|
535
|
-
|
|
536
|
-
await expect(
|
|
537
|
-
MultisigOperation.selectApprovals({
|
|
538
|
-
account,
|
|
539
|
-
approvals: [
|
|
540
|
-
SignatureEnvelope.serialize({
|
|
541
|
-
inner: SignatureEnvelope.deserialize(
|
|
542
|
-
signApproval(owners[0]!, hash),
|
|
543
|
-
),
|
|
544
|
-
type: 'keychain',
|
|
545
|
-
userAddress: owners[0]!.address,
|
|
546
|
-
}),
|
|
547
|
-
],
|
|
548
|
-
config,
|
|
549
|
-
hash,
|
|
550
|
-
}),
|
|
551
|
-
).rejects.toThrowErrorMatchingInlineSnapshot(
|
|
552
|
-
`[MultisigOperation.InvalidApprovalError: Invalid multisig approval: keychain signatures cannot approve a multisig operation.]`,
|
|
553
|
-
)
|
|
554
|
-
const selection = await MultisigOperation.selectApprovals({
|
|
555
|
-
account,
|
|
556
|
-
approvals: [
|
|
557
|
-
SignatureEnvelope.serialize({
|
|
558
|
-
account: child,
|
|
559
|
-
config: childConfig,
|
|
560
|
-
signatures: [
|
|
561
|
-
SignatureEnvelope.deserialize(signApproval(owners[1]!, childHash)),
|
|
562
|
-
],
|
|
563
|
-
type: 'multisig',
|
|
564
|
-
}),
|
|
565
|
-
],
|
|
566
|
-
config,
|
|
567
|
-
hash,
|
|
568
|
-
})
|
|
569
|
-
expect({
|
|
570
|
-
signatureCount: selection.signatureCount,
|
|
571
|
-
threshold: selection.threshold,
|
|
572
|
-
weight: selection.weight,
|
|
573
|
-
}).toMatchInlineSnapshot(`
|
|
574
|
-
{
|
|
575
|
-
"signatureCount": 1,
|
|
576
|
-
"threshold": 1,
|
|
577
|
-
"weight": 1,
|
|
578
|
-
}
|
|
579
|
-
`)
|
|
580
|
-
})
|
|
581
|
-
|
|
582
|
-
test('rejects nested account cycles while serializing', () => {
|
|
583
|
-
const config = MultisigConfig.from({
|
|
584
|
-
owners: [{ owner: account, weight: 1 }],
|
|
585
|
-
threshold: 1,
|
|
586
|
-
})
|
|
587
|
-
const hash = MultisigOperation.getHash({
|
|
588
|
-
account,
|
|
589
|
-
config: { ...config, version: 2n },
|
|
590
|
-
transaction,
|
|
591
|
-
type: 'transaction',
|
|
592
|
-
})
|
|
593
|
-
const nestedHash = MultisigConfig.getSignPayload({
|
|
594
|
-
account,
|
|
595
|
-
config: { version: 2n },
|
|
596
|
-
payload: hash,
|
|
597
|
-
})
|
|
598
|
-
|
|
599
|
-
expect(() =>
|
|
600
|
-
SignatureEnvelope.serialize({
|
|
601
|
-
account,
|
|
602
|
-
config: MultisigConfig.from({ ...config, version: 2n }),
|
|
603
|
-
signatures: [
|
|
604
|
-
SignatureEnvelope.deserialize(signApproval(owners[0]!, nestedHash)),
|
|
605
|
-
],
|
|
606
|
-
type: 'multisig',
|
|
607
|
-
}),
|
|
608
|
-
).toThrowErrorMatchingInlineSnapshot(
|
|
609
|
-
`[SignatureEnvelope.InvalidMultisigApprovalError: Invalid native multisig owner approval: multisig account cannot be an owner.]`,
|
|
610
|
-
)
|
|
611
|
-
})
|
|
612
|
-
|
|
613
|
-
test('rejects excess nesting depth', async () => {
|
|
614
|
-
const grandchildConfig = MultisigConfig.from({
|
|
615
|
-
owners: [{ owner: owners[2]!.address, weight: 1 }],
|
|
616
|
-
threshold: 1,
|
|
617
|
-
})
|
|
618
|
-
const grandchild = MultisigConfig.getAddress(grandchildConfig)
|
|
619
|
-
const childConfig = MultisigConfig.from({
|
|
620
|
-
owners: [{ owner: grandchild, weight: 1 }],
|
|
621
|
-
threshold: 1,
|
|
622
|
-
})
|
|
623
|
-
const child = MultisigConfig.getAddress(childConfig)
|
|
624
|
-
const config = MultisigConfig.from({
|
|
625
|
-
owners: [{ owner: child, weight: 1 }],
|
|
626
|
-
threshold: 1,
|
|
627
|
-
})
|
|
628
|
-
const account = MultisigConfig.getAddress(config)
|
|
629
|
-
const hash = MultisigOperation.getHash({
|
|
630
|
-
account,
|
|
631
|
-
config: { ...config, version: 1n },
|
|
632
|
-
transaction,
|
|
633
|
-
type: 'transaction',
|
|
634
|
-
})
|
|
635
|
-
const childHash = MultisigConfig.getSignPayload({
|
|
636
|
-
account: child,
|
|
637
|
-
config: { ...childConfig, version: 1n },
|
|
638
|
-
payload: hash,
|
|
639
|
-
})
|
|
640
|
-
const grandchildHash = MultisigConfig.getSignPayload({
|
|
641
|
-
account: grandchild,
|
|
642
|
-
config: { ...grandchildConfig, version: 1n },
|
|
643
|
-
payload: childHash,
|
|
644
|
-
})
|
|
645
|
-
|
|
646
|
-
await expect(
|
|
647
|
-
MultisigOperation.selectApprovals({
|
|
648
|
-
account,
|
|
649
|
-
approvals: [
|
|
650
|
-
SignatureEnvelope.serialize({
|
|
651
|
-
account: child,
|
|
652
|
-
config: MultisigConfig.from({ ...childConfig, version: 1n }),
|
|
653
|
-
signatures: [
|
|
654
|
-
{
|
|
655
|
-
account: grandchild,
|
|
656
|
-
config: MultisigConfig.from({
|
|
657
|
-
...grandchildConfig,
|
|
658
|
-
version: 1n,
|
|
659
|
-
}),
|
|
660
|
-
signatures: [
|
|
661
|
-
SignatureEnvelope.deserialize(
|
|
662
|
-
signApproval(owners[2]!, grandchildHash),
|
|
663
|
-
),
|
|
664
|
-
],
|
|
665
|
-
type: 'multisig',
|
|
666
|
-
},
|
|
667
|
-
],
|
|
668
|
-
type: 'multisig',
|
|
669
|
-
}),
|
|
670
|
-
],
|
|
671
|
-
config,
|
|
672
|
-
hash,
|
|
673
|
-
}),
|
|
674
|
-
).rejects.toThrowErrorMatchingInlineSnapshot(
|
|
675
|
-
`[MultisigOperation.InvalidApprovalError: Invalid multisig approval: nested multisig owner 0x4e51c0503aab130b1a358e8eab4c6302618fb3a6 is invalid.]`,
|
|
676
|
-
)
|
|
677
|
-
})
|
|
678
295
|
})
|
|
679
296
|
|
|
680
297
|
describe('serializeKeyAuthorization', () => {
|
|
@@ -725,14 +342,14 @@ describe('serializeKeyAuthorization', () => {
|
|
|
725
342
|
expect(results).toMatchInlineSnapshot(`
|
|
726
343
|
[
|
|
727
344
|
{
|
|
728
|
-
"account": "
|
|
729
|
-
"hash": "
|
|
345
|
+
"account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
346
|
+
"hash": "0xcd4283709cc1853dc8ed9cc4dd8c3b6a22e1b01f19ad3f6348f4bebe79590408",
|
|
730
347
|
"signatureCount": 2,
|
|
731
348
|
"version": 1n,
|
|
732
349
|
},
|
|
733
350
|
{
|
|
734
|
-
"account": "
|
|
735
|
-
"hash": "
|
|
351
|
+
"account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
352
|
+
"hash": "0x1f66e6adc4ddf8ac9d4575f518be11509ca616ac13d4e0a286b4eef7b96959f2",
|
|
736
353
|
"signatureCount": 2,
|
|
737
354
|
"version": 0n,
|
|
738
355
|
},
|
|
@@ -826,15 +443,15 @@ describe('serializeTransaction', () => {
|
|
|
826
443
|
expect(results).toMatchInlineSnapshot(`
|
|
827
444
|
[
|
|
828
445
|
{
|
|
829
|
-
"account": "
|
|
830
|
-
"hash": "
|
|
446
|
+
"account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
447
|
+
"hash": "0x6a034f208339f7eaa4a42b3fa03aad5df77ebe83659dac2e4d2b11226d221928",
|
|
831
448
|
"signatureCount": 2,
|
|
832
449
|
"type": "0x76",
|
|
833
450
|
"version": 1n,
|
|
834
451
|
},
|
|
835
452
|
{
|
|
836
|
-
"account": "
|
|
837
|
-
"hash": "
|
|
453
|
+
"account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
454
|
+
"hash": "0x04d36e54d7a816b080dfa03370da6fbeb3523ce3eff5211d7f22a3c7e87476ee",
|
|
838
455
|
"signatureCount": 2,
|
|
839
456
|
"type": "0x76",
|
|
840
457
|
"version": 0n,
|
|
@@ -911,7 +528,7 @@ describe('serializeTransaction', () => {
|
|
|
911
528
|
[
|
|
912
529
|
{
|
|
913
530
|
"feePayerSignature": null,
|
|
914
|
-
"from": "
|
|
531
|
+
"from": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
915
532
|
"signatureCount": 2,
|
|
916
533
|
"type": "0x78",
|
|
917
534
|
},
|
|
@@ -921,7 +538,7 @@ describe('serializeTransaction', () => {
|
|
|
921
538
|
"s": 6n,
|
|
922
539
|
"yParity": 0,
|
|
923
540
|
},
|
|
924
|
-
"from": "
|
|
541
|
+
"from": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
925
542
|
"signatureCount": 2,
|
|
926
543
|
"type": "0x78",
|
|
927
544
|
},
|
|
@@ -993,7 +610,7 @@ describe('from', () => {
|
|
|
993
610
|
expect({ pending, submitting, success }).toMatchInlineSnapshot(`
|
|
994
611
|
{
|
|
995
612
|
"pending": {
|
|
996
|
-
"account": "
|
|
613
|
+
"account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
997
614
|
"approvals": [
|
|
998
615
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
999
616
|
],
|
|
@@ -1013,7 +630,7 @@ describe('from', () => {
|
|
|
1013
630
|
"version": 1n,
|
|
1014
631
|
},
|
|
1015
632
|
"createdAt": 1,
|
|
1016
|
-
"hash": "
|
|
633
|
+
"hash": "0x2d7e3c7c38a9acf85f0a9d70a39b0e9e5a05d92c7a73b633a47a45be4a112b3b",
|
|
1017
634
|
"signatureCount": 1,
|
|
1018
635
|
"status": "pending",
|
|
1019
636
|
"threshold": 2,
|
|
@@ -1023,7 +640,7 @@ describe('from', () => {
|
|
|
1023
640
|
"weight": 1,
|
|
1024
641
|
},
|
|
1025
642
|
"submitting": {
|
|
1026
|
-
"account": "
|
|
643
|
+
"account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
1027
644
|
"approvals": [
|
|
1028
645
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
1029
646
|
"0x01000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
|
|
@@ -1045,7 +662,7 @@ describe('from', () => {
|
|
|
1045
662
|
},
|
|
1046
663
|
"createdAt": 1,
|
|
1047
664
|
"expiresAt": 10,
|
|
1048
|
-
"hash": "
|
|
665
|
+
"hash": "0x2d7e3c7c38a9acf85f0a9d70a39b0e9e5a05d92c7a73b633a47a45be4a112b3b",
|
|
1049
666
|
"signatureCount": 2,
|
|
1050
667
|
"status": "submitting",
|
|
1051
668
|
"submissionId": "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
|
@@ -1056,7 +673,7 @@ describe('from', () => {
|
|
|
1056
673
|
"weight": 2,
|
|
1057
674
|
},
|
|
1058
675
|
"success": {
|
|
1059
|
-
"account": "
|
|
676
|
+
"account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
1060
677
|
"approvals": [
|
|
1061
678
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
1062
679
|
"0x01000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
|
|
@@ -1077,7 +694,7 @@ describe('from', () => {
|
|
|
1077
694
|
"version": 1n,
|
|
1078
695
|
},
|
|
1079
696
|
"createdAt": 1,
|
|
1080
|
-
"hash": "
|
|
697
|
+
"hash": "0x2d7e3c7c38a9acf85f0a9d70a39b0e9e5a05d92c7a73b633a47a45be4a112b3b",
|
|
1081
698
|
"signatureCount": 2,
|
|
1082
699
|
"status": "success",
|
|
1083
700
|
"threshold": 2,
|
|
@@ -1118,7 +735,7 @@ describe('from', () => {
|
|
|
1118
735
|
},
|
|
1119
736
|
`
|
|
1120
737
|
{
|
|
1121
|
-
"account": "
|
|
738
|
+
"account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
1122
739
|
"approvals": [
|
|
1123
740
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
1124
741
|
],
|
|
@@ -1195,7 +812,7 @@ describe('from', () => {
|
|
|
1195
812
|
},
|
|
1196
813
|
`
|
|
1197
814
|
{
|
|
1198
|
-
"account": "
|
|
815
|
+
"account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
1199
816
|
"approvals": [
|
|
1200
817
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
1201
818
|
],
|
|
@@ -1239,10 +856,7 @@ describe('from', () => {
|
|
|
1239
856
|
signature: {
|
|
1240
857
|
account,
|
|
1241
858
|
config: currentConfig,
|
|
1242
|
-
signatures: [
|
|
1243
|
-
SignatureEnvelope.deserialize(approval_1),
|
|
1244
|
-
SignatureEnvelope.deserialize(approval_2),
|
|
1245
|
-
],
|
|
859
|
+
signatures: [ownerSignature_1, owners[1]!.signature],
|
|
1246
860
|
type: 'multisig',
|
|
1247
861
|
},
|
|
1248
862
|
}),
|
|
@@ -1255,7 +869,7 @@ describe('from', () => {
|
|
|
1255
869
|
expect({ pending, success }).toMatchInlineSnapshot(`
|
|
1256
870
|
{
|
|
1257
871
|
"pending": {
|
|
1258
|
-
"account": "
|
|
872
|
+
"account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
1259
873
|
"approvals": [
|
|
1260
874
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
1261
875
|
],
|
|
@@ -1275,8 +889,8 @@ describe('from', () => {
|
|
|
1275
889
|
"version": 1n,
|
|
1276
890
|
},
|
|
1277
891
|
"createdAt": 1,
|
|
1278
|
-
"hash": "
|
|
1279
|
-
"keyAuthorization": "
|
|
892
|
+
"hash": "0xa83016f0e94c4a6125483ffeba3abb0a8df1bc0f5a503f63639e806b793520bb",
|
|
893
|
+
"keyAuthorization": "0xf838f782107980943333333333333333333333333333333333333333846b49d2008080808094ef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
1280
894
|
"signatureCount": 1,
|
|
1281
895
|
"status": "pending",
|
|
1282
896
|
"threshold": 2,
|
|
@@ -1285,7 +899,7 @@ describe('from', () => {
|
|
|
1285
899
|
"weight": 1,
|
|
1286
900
|
},
|
|
1287
901
|
"success": {
|
|
1288
|
-
"account": "
|
|
902
|
+
"account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
1289
903
|
"approvals": [
|
|
1290
904
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
1291
905
|
"0x01000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
|
|
@@ -1306,8 +920,8 @@ describe('from', () => {
|
|
|
1306
920
|
"version": 1n,
|
|
1307
921
|
},
|
|
1308
922
|
"createdAt": 1,
|
|
1309
|
-
"hash": "
|
|
1310
|
-
"keyAuthorization": "
|
|
923
|
+
"hash": "0xa83016f0e94c4a6125483ffeba3abb0a8df1bc0f5a503f63639e806b793520bb",
|
|
924
|
+
"keyAuthorization": "0xf901b3f782107980943333333333333333333333333333333333333333846b49d2008080808094ef6b17836e1b3647105c3084124485e3e1b0ab7fb9017805f9017494ef6b17836e1b3647105c3084124485e3e1b0ab7ff852a000000000000000000000000000000000000000000000000000000000000000000102eed69407e1ed8ea0e9601e5546b0a03aed683df360140701d694288f0cd85005f34168f731a468aef268c2f9456f01f90108b88201000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200b88201000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
|
|
1311
925
|
"signatureCount": 2,
|
|
1312
926
|
"status": "success",
|
|
1313
927
|
"threshold": 2,
|
|
@@ -1326,10 +940,7 @@ describe('from', () => {
|
|
|
1326
940
|
signature: {
|
|
1327
941
|
account,
|
|
1328
942
|
config,
|
|
1329
|
-
signatures: [
|
|
1330
|
-
SignatureEnvelope.deserialize(approval_1),
|
|
1331
|
-
SignatureEnvelope.deserialize(approval_2),
|
|
1332
|
-
],
|
|
943
|
+
signatures: [ownerSignature_1, owners[1]!.signature],
|
|
1333
944
|
type: 'multisig',
|
|
1334
945
|
},
|
|
1335
946
|
}),
|
|
@@ -1356,7 +967,7 @@ describe('from', () => {
|
|
|
1356
967
|
},
|
|
1357
968
|
`
|
|
1358
969
|
{
|
|
1359
|
-
"account": "
|
|
970
|
+
"account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
1360
971
|
"approvals": [
|
|
1361
972
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
1362
973
|
"0x01000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
|
|
@@ -1402,7 +1013,7 @@ describe('RPC conversion', () => {
|
|
|
1402
1013
|
expect({ keyAuthorizationRpc, transactionRpc }).toMatchInlineSnapshot(`
|
|
1403
1014
|
{
|
|
1404
1015
|
"keyAuthorizationRpc": {
|
|
1405
|
-
"account": "
|
|
1016
|
+
"account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
1406
1017
|
"approvals": [
|
|
1407
1018
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
1408
1019
|
],
|
|
@@ -1422,8 +1033,8 @@ describe('RPC conversion', () => {
|
|
|
1422
1033
|
"version": "0x1",
|
|
1423
1034
|
},
|
|
1424
1035
|
"createdAt": 1,
|
|
1425
|
-
"hash": "
|
|
1426
|
-
"keyAuthorization": "
|
|
1036
|
+
"hash": "0xa83016f0e94c4a6125483ffeba3abb0a8df1bc0f5a503f63639e806b793520bb",
|
|
1037
|
+
"keyAuthorization": "0xf838f782107980943333333333333333333333333333333333333333846b49d2008080808094ef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
1427
1038
|
"signatureCount": 1,
|
|
1428
1039
|
"status": "pending",
|
|
1429
1040
|
"threshold": 2,
|
|
@@ -1432,7 +1043,7 @@ describe('RPC conversion', () => {
|
|
|
1432
1043
|
"weight": 1,
|
|
1433
1044
|
},
|
|
1434
1045
|
"transactionRpc": {
|
|
1435
|
-
"account": "
|
|
1046
|
+
"account": "0xef6b17836e1b3647105c3084124485e3e1b0ab7f",
|
|
1436
1047
|
"approvals": [
|
|
1437
1048
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
1438
1049
|
],
|
|
@@ -1452,7 +1063,7 @@ describe('RPC conversion', () => {
|
|
|
1452
1063
|
"version": "0x1",
|
|
1453
1064
|
},
|
|
1454
1065
|
"createdAt": 1,
|
|
1455
|
-
"hash": "
|
|
1066
|
+
"hash": "0x2d7e3c7c38a9acf85f0a9d70a39b0e9e5a05d92c7a73b633a47a45be4a112b3b",
|
|
1456
1067
|
"signatureCount": 1,
|
|
1457
1068
|
"status": "pending",
|
|
1458
1069
|
"threshold": 2,
|
|
@@ -1484,7 +1095,7 @@ describe('validation', () => {
|
|
|
1484
1095
|
...transactionPending,
|
|
1485
1096
|
transaction: TxEnvelopeTempo.serialize(
|
|
1486
1097
|
TxEnvelopeTempo.deserialize(transaction),
|
|
1487
|
-
{ signature:
|
|
1098
|
+
{ signature: ownerSignature_1 },
|
|
1488
1099
|
),
|
|
1489
1100
|
},
|
|
1490
1101
|
},
|
|
@@ -1670,32 +1281,19 @@ describe('validation', () => {
|
|
|
1670
1281
|
MultisigOperation.from(operation as MultisigOperation.Operation),
|
|
1671
1282
|
).toThrowError(MultisigOperation.InvalidOperationError)
|
|
1672
1283
|
})
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
})
|
|
1680
|
-
expect(() =>
|
|
1681
|
-
MultisigOperation.from({
|
|
1682
|
-
...transactionPending,
|
|
1284
|
+
test('accepts initial accounts validated by the chain', () => {
|
|
1285
|
+
const value = MultisigOperation.from({
|
|
1286
|
+
...transactionPending,
|
|
1287
|
+
config,
|
|
1288
|
+
hash: MultisigOperation.getHash({
|
|
1289
|
+
account,
|
|
1683
1290
|
config,
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
config,
|
|
1687
|
-
payload: TxEnvelopeTempo.getSignPayload(
|
|
1688
|
-
TxEnvelopeTempo.deserialize(transaction),
|
|
1689
|
-
),
|
|
1690
|
-
}),
|
|
1291
|
+
transaction,
|
|
1292
|
+
type: 'transaction',
|
|
1691
1293
|
}),
|
|
1692
|
-
)
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
Details: Invalid native multisig owner approval: initial multisig config does not derive account.]
|
|
1697
|
-
`,
|
|
1698
|
-
)
|
|
1294
|
+
})
|
|
1295
|
+
expect(value.account).toBe(account)
|
|
1296
|
+
expect(value.config).toEqual(config)
|
|
1699
1297
|
})
|
|
1700
1298
|
|
|
1701
1299
|
test('rejects noncanonical RPC quantities', () => {
|
|
@@ -1720,10 +1318,7 @@ describe('validation', () => {
|
|
|
1720
1318
|
signature: {
|
|
1721
1319
|
account,
|
|
1722
1320
|
config: currentConfig,
|
|
1723
|
-
signatures: [
|
|
1724
|
-
SignatureEnvelope.deserialize(approval_1),
|
|
1725
|
-
SignatureEnvelope.deserialize(approval_3),
|
|
1726
|
-
],
|
|
1321
|
+
signatures: [ownerSignature_1, owners[2]!.signature],
|
|
1727
1322
|
type: 'multisig',
|
|
1728
1323
|
},
|
|
1729
1324
|
}),
|
|
@@ -1745,10 +1340,7 @@ describe('validation', () => {
|
|
|
1745
1340
|
account,
|
|
1746
1341
|
config: currentConfig,
|
|
1747
1342
|
payload: KeyAuthorization.getSignPayload(authorization),
|
|
1748
|
-
signatures: [
|
|
1749
|
-
SignatureEnvelope.deserialize(approval_1),
|
|
1750
|
-
SignatureEnvelope.deserialize(approval_2),
|
|
1751
|
-
],
|
|
1343
|
+
signatures: [ownerSignature_1, owners[1]!.signature],
|
|
1752
1344
|
}),
|
|
1753
1345
|
].reverse()
|
|
1754
1346
|
const operation = {
|
|
@@ -1784,10 +1376,7 @@ describe('validation', () => {
|
|
|
1784
1376
|
signature: {
|
|
1785
1377
|
account,
|
|
1786
1378
|
config: currentConfig,
|
|
1787
|
-
signatures: [
|
|
1788
|
-
SignatureEnvelope.deserialize(approval_1),
|
|
1789
|
-
SignatureEnvelope.deserialize(approval_1),
|
|
1790
|
-
],
|
|
1379
|
+
signatures: [ownerSignature_1, ownerSignature_1],
|
|
1791
1380
|
type: 'multisig',
|
|
1792
1381
|
},
|
|
1793
1382
|
}),
|
|
@@ -1802,63 +1391,6 @@ describe('validation', () => {
|
|
|
1802
1391
|
)
|
|
1803
1392
|
})
|
|
1804
1393
|
|
|
1805
|
-
test('rejects reordered nested key authorization approvals', () => {
|
|
1806
|
-
const authorization = KeyAuthorization.deserialize(keyAuthorization)
|
|
1807
|
-
const nestedConfig = MultisigConfig.from({
|
|
1808
|
-
owners: [{ owner: owner_2, weight: 1 }],
|
|
1809
|
-
threshold: 1,
|
|
1810
|
-
version: 1n,
|
|
1811
|
-
})
|
|
1812
|
-
const childSignatures = SignatureEnvelope.sortMultisigApprovals({
|
|
1813
|
-
account: owner_1,
|
|
1814
|
-
config: nestedConfig,
|
|
1815
|
-
payload: keyAuthorizationHash,
|
|
1816
|
-
signatures: [
|
|
1817
|
-
SignatureEnvelope.deserialize(approval_1),
|
|
1818
|
-
SignatureEnvelope.deserialize(approval_2),
|
|
1819
|
-
],
|
|
1820
|
-
})
|
|
1821
|
-
const retainedNested = SignatureEnvelope.from({
|
|
1822
|
-
account: owner_1,
|
|
1823
|
-
config: nestedConfig,
|
|
1824
|
-
signatures: childSignatures,
|
|
1825
|
-
type: 'multisig',
|
|
1826
|
-
})
|
|
1827
|
-
const selectedNested = SignatureEnvelope.from({
|
|
1828
|
-
account: owner_1,
|
|
1829
|
-
config: nestedConfig,
|
|
1830
|
-
signatures: [...childSignatures].reverse(),
|
|
1831
|
-
type: 'multisig',
|
|
1832
|
-
})
|
|
1833
|
-
const selected = SignatureEnvelope.sortMultisigApprovals({
|
|
1834
|
-
account,
|
|
1835
|
-
config: currentConfig,
|
|
1836
|
-
payload: KeyAuthorization.getSignPayload(authorization),
|
|
1837
|
-
signatures: [selectedNested, SignatureEnvelope.deserialize(approval_2)],
|
|
1838
|
-
})
|
|
1839
|
-
const operation = {
|
|
1840
|
-
...keyAuthorizationPending,
|
|
1841
|
-
approvals: [SignatureEnvelope.serialize(retainedNested), approval_2],
|
|
1842
|
-
keyAuthorization: KeyAuthorization.serialize(
|
|
1843
|
-
KeyAuthorization.from(authorization, {
|
|
1844
|
-
signature: {
|
|
1845
|
-
account,
|
|
1846
|
-
config: currentConfig,
|
|
1847
|
-
signatures: selected,
|
|
1848
|
-
type: 'multisig',
|
|
1849
|
-
},
|
|
1850
|
-
}),
|
|
1851
|
-
),
|
|
1852
|
-
signatureCount: 2,
|
|
1853
|
-
status: 'success',
|
|
1854
|
-
weight: 2,
|
|
1855
|
-
} as const
|
|
1856
|
-
|
|
1857
|
-
expect(() => MultisigOperation.from(operation)).toThrowError(
|
|
1858
|
-
'Invalid multisig operation: key authorization signature is not a retained approval.',
|
|
1859
|
-
)
|
|
1860
|
-
})
|
|
1861
|
-
|
|
1862
1394
|
test('accepts case-insensitive initial configs', () => {
|
|
1863
1395
|
const config = MultisigConfig.from({
|
|
1864
1396
|
owners: [
|
|
@@ -1874,7 +1406,7 @@ describe('validation', () => {
|
|
|
1874
1406
|
salt: `0x${'AB'.repeat(32)}`,
|
|
1875
1407
|
threshold: 2,
|
|
1876
1408
|
})
|
|
1877
|
-
const account = MultisigConfig.getAddress(config)
|
|
1409
|
+
const account = MultisigConfig.getAddress(config, { factory })
|
|
1878
1410
|
const authorization = KeyAuthorization.from({
|
|
1879
1411
|
account,
|
|
1880
1412
|
address: '0x3333333333333333333333333333333333333333',
|
|
@@ -1887,10 +1419,7 @@ describe('validation', () => {
|
|
|
1887
1419
|
account,
|
|
1888
1420
|
config,
|
|
1889
1421
|
payload: KeyAuthorization.getSignPayload(authorization),
|
|
1890
|
-
signatures: [
|
|
1891
|
-
SignatureEnvelope.deserialize(approval_1),
|
|
1892
|
-
SignatureEnvelope.deserialize(approval_2),
|
|
1893
|
-
],
|
|
1422
|
+
signatures: [ownerSignature_1, owners[1]!.signature],
|
|
1894
1423
|
})
|
|
1895
1424
|
const approvals = signatures.map((signature) =>
|
|
1896
1425
|
SignatureEnvelope.serialize(signature),
|