ox 1.7.1 → 1.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -0
- package/dist/core/Hash.js +1 -1
- package/dist/core/Hash.js.map +1 -1
- package/dist/tempo/KeyAuthorization.d.ts +2 -2
- package/dist/tempo/KeyAuthorization.d.ts.map +1 -1
- package/dist/tempo/MultisigConfig.d.ts +151 -83
- package/dist/tempo/MultisigConfig.d.ts.map +1 -1
- package/dist/tempo/MultisigConfig.js +164 -86
- package/dist/tempo/MultisigConfig.js.map +1 -1
- package/dist/tempo/MultisigOperation.d.ts +340 -0
- package/dist/tempo/MultisigOperation.d.ts.map +1 -0
- package/dist/tempo/MultisigOperation.js +839 -0
- package/dist/tempo/MultisigOperation.js.map +1 -0
- package/dist/tempo/MultisigSimulation.d.ts +132 -0
- package/dist/tempo/MultisigSimulation.d.ts.map +1 -0
- package/dist/tempo/MultisigSimulation.js +140 -0
- package/dist/tempo/MultisigSimulation.js.map +1 -0
- package/dist/tempo/RpcSchemaTempo.d.ts +45 -0
- package/dist/tempo/RpcSchemaTempo.d.ts.map +1 -1
- package/dist/tempo/SignatureEnvelope.d.ts +55 -86
- package/dist/tempo/SignatureEnvelope.d.ts.map +1 -1
- package/dist/tempo/SignatureEnvelope.js +93 -158
- package/dist/tempo/SignatureEnvelope.js.map +1 -1
- package/dist/tempo/TransactionRequest.d.ts +9 -17
- package/dist/tempo/TransactionRequest.d.ts.map +1 -1
- package/dist/tempo/TransactionRequest.js +7 -7
- package/dist/tempo/TransactionRequest.js.map +1 -1
- package/dist/tempo/TxEnvelopeTempo.d.ts +3 -2
- package/dist/tempo/TxEnvelopeTempo.d.ts.map +1 -1
- package/dist/tempo/TxEnvelopeTempo.js +3 -2
- package/dist/tempo/TxEnvelopeTempo.js.map +1 -1
- package/dist/tempo/index.d.ts +22 -2
- package/dist/tempo/index.d.ts.map +1 -1
- package/dist/tempo/index.js +22 -2
- package/dist/tempo/index.js.map +1 -1
- package/dist/zod/tempo/AuthorizationTempo.d.ts +60 -180
- package/dist/zod/tempo/AuthorizationTempo.d.ts.map +1 -1
- package/dist/zod/tempo/KeyAuthorization.d.ts +65 -118
- package/dist/zod/tempo/KeyAuthorization.d.ts.map +1 -1
- package/dist/zod/tempo/MultisigConfig.d.ts +31 -2
- package/dist/zod/tempo/MultisigConfig.d.ts.map +1 -1
- package/dist/zod/tempo/MultisigConfig.js +26 -3
- package/dist/zod/tempo/MultisigConfig.js.map +1 -1
- package/dist/zod/tempo/MultisigOperation.d.ts +158 -0
- package/dist/zod/tempo/MultisigOperation.d.ts.map +1 -0
- package/dist/zod/tempo/MultisigOperation.js +62 -0
- package/dist/zod/tempo/MultisigOperation.js.map +1 -0
- package/dist/zod/tempo/MultisigSimulation.d.ts +120 -0
- package/dist/zod/tempo/MultisigSimulation.d.ts.map +1 -0
- package/dist/zod/tempo/MultisigSimulation.js +78 -0
- package/dist/zod/tempo/MultisigSimulation.js.map +1 -0
- package/dist/zod/tempo/RpcSchemaTempo.d.ts +528 -144
- package/dist/zod/tempo/RpcSchemaTempo.d.ts.map +1 -1
- package/dist/zod/tempo/RpcSchemaTempo.js +47 -0
- package/dist/zod/tempo/RpcSchemaTempo.js.map +1 -1
- package/dist/zod/tempo/SignatureEnvelope.d.ts +18 -54
- package/dist/zod/tempo/SignatureEnvelope.d.ts.map +1 -1
- package/dist/zod/tempo/SignatureEnvelope.js +5 -22
- package/dist/zod/tempo/SignatureEnvelope.js.map +1 -1
- package/dist/zod/tempo/Transaction.d.ts +138 -348
- package/dist/zod/tempo/Transaction.d.ts.map +1 -1
- package/dist/zod/tempo/TransactionRequest.d.ts +286 -239
- package/dist/zod/tempo/TransactionRequest.d.ts.map +1 -1
- package/dist/zod/tempo/TransactionRequest.js +11 -22
- package/dist/zod/tempo/TransactionRequest.js.map +1 -1
- package/dist/zod/tempo/TxEnvelopeTempo.d.ts +60 -48
- package/dist/zod/tempo/TxEnvelopeTempo.d.ts.map +1 -1
- package/dist/zod/tempo/ZoneRpcAuthentication.d.ts +15 -12
- package/dist/zod/tempo/ZoneRpcAuthentication.d.ts.map +1 -1
- package/dist/zod/tempo/z.d.ts +2 -0
- package/dist/zod/tempo/z.d.ts.map +1 -1
- package/dist/zod/tempo/z.js +2 -0
- package/dist/zod/tempo/z.js.map +1 -1
- package/package.json +21 -1
- package/src/core/Hash.ts +1 -1
- package/src/core/_test/Hash.test.ts +15 -0
- package/src/tempo/AuthorizationTempo.test.ts +4 -0
- package/src/tempo/KeyAuthorization.test-d.ts +13 -12
- package/src/tempo/KeyAuthorization.test.ts +109 -3
- package/src/tempo/KeyAuthorization.ts +4 -4
- package/src/tempo/MultisigConfig.test-d.ts +52 -0
- package/src/tempo/MultisigConfig.test.ts +288 -227
- package/src/tempo/MultisigConfig.ts +275 -104
- package/src/tempo/MultisigOperation.test-d.ts +79 -0
- package/src/tempo/MultisigOperation.test.ts +1950 -0
- package/src/tempo/MultisigOperation.ts +1293 -0
- package/src/tempo/MultisigSimulation.test-d.ts +33 -0
- package/src/tempo/MultisigSimulation.test.ts +283 -0
- package/src/tempo/MultisigSimulation.ts +266 -0
- package/src/tempo/RpcSchemaTempo.test-d.ts +91 -0
- package/src/tempo/RpcSchemaTempo.ts +46 -0
- package/src/tempo/SignatureEnvelope.test-d.ts +33 -72
- package/src/tempo/SignatureEnvelope.test.ts +533 -500
- package/src/tempo/SignatureEnvelope.ts +171 -258
- package/src/tempo/Transaction.test.ts +61 -0
- package/src/tempo/TransactionRequest.test-d.ts +11 -0
- package/src/tempo/TransactionRequest.test.ts +214 -41
- package/src/tempo/TransactionRequest.ts +19 -20
- package/src/tempo/TxEnvelopeTempo.test-d.ts +7 -0
- package/src/tempo/TxEnvelopeTempo.test.ts +25 -0
- package/src/tempo/TxEnvelopeTempo.ts +5 -3
- package/src/tempo/index.ts +22 -2
- package/src/tempo/multisig.e2e.test.ts +164 -87
- package/src/version.ts +1 -1
- package/src/zod/tempo/MultisigConfig.ts +29 -3
- package/src/zod/tempo/MultisigOperation.ts +66 -0
- package/src/zod/tempo/MultisigSimulation.ts +98 -0
- package/src/zod/tempo/RpcSchemaTempo.ts +53 -0
- package/src/zod/tempo/SignatureEnvelope.ts +12 -54
- package/src/zod/tempo/TransactionRequest.ts +17 -26
- package/src/zod/tempo/_test/KeyAuthorization.test.ts +2 -4
- package/src/zod/tempo/_test/MultisigConfig.test-d.ts +13 -0
- package/src/zod/tempo/_test/MultisigConfig.test.ts +13 -2
- package/src/zod/tempo/_test/MultisigOperation.test-d.ts +27 -0
- package/src/zod/tempo/_test/MultisigOperation.test.ts +66 -0
- package/src/zod/tempo/_test/MultisigSimulation.test-d.ts +13 -0
- package/src/zod/tempo/_test/MultisigSimulation.test.ts +78 -0
- package/src/zod/tempo/_test/RpcSchemaTempo.test-d.ts +48 -0
- package/src/zod/tempo/_test/RpcSchemaTempo.test.ts +83 -0
- package/src/zod/tempo/_test/SignatureEnvelope.test-d.ts +1 -1
- package/src/zod/tempo/_test/SignatureEnvelope.test.ts +57 -120
- package/src/zod/tempo/_test/TransactionRequest.test.ts +43 -16
- package/src/zod/tempo/z.ts +2 -0
|
@@ -348,6 +348,7 @@ describe('fromRpc', () => {
|
|
|
348
348
|
type: 'p256',
|
|
349
349
|
},
|
|
350
350
|
})
|
|
351
|
+
if (typeof result.signature === 'string') throw new Error('unreachable')
|
|
351
352
|
expect(result.signature.type).toBe('p256')
|
|
352
353
|
expect(result.signature).toHaveProperty('prehash', true)
|
|
353
354
|
expect(result.signature).toHaveProperty('publicKey')
|
|
@@ -370,6 +371,7 @@ describe('fromRpc', () => {
|
|
|
370
371
|
'0x49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d976305000000007b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a22222c226f726967696e223a2268747470733a2f2f6578616d706c652e636f6d222c2263726f73734f726967696e223a66616c73657d',
|
|
371
372
|
},
|
|
372
373
|
})
|
|
374
|
+
if (typeof result.signature === 'string') throw new Error('unreachable')
|
|
373
375
|
expect(result.signature.type).toBe('webAuthn')
|
|
374
376
|
expect(result.signature).toHaveProperty('metadata')
|
|
375
377
|
expect(result.signature).toHaveProperty('publicKey')
|
|
@@ -994,6 +996,7 @@ describe('toRpc', () => {
|
|
|
994
996
|
type: 'p256',
|
|
995
997
|
},
|
|
996
998
|
})
|
|
999
|
+
if (typeof result.signature === 'string') throw new Error('unreachable')
|
|
997
1000
|
expect(result.signature.type).toBe('p256')
|
|
998
1001
|
})
|
|
999
1002
|
|
|
@@ -1019,6 +1022,7 @@ describe('toRpc', () => {
|
|
|
1019
1022
|
type: 'webAuthn',
|
|
1020
1023
|
},
|
|
1021
1024
|
})
|
|
1025
|
+
if (typeof result.signature === 'string') throw new Error('unreachable')
|
|
1022
1026
|
expect(result.signature.type).toBe('webAuthn')
|
|
1023
1027
|
})
|
|
1024
1028
|
})
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { expectTypeOf, test } from 'vp/test'
|
|
2
2
|
import * as KeyAuthorization from './KeyAuthorization.js'
|
|
3
|
-
import * as
|
|
3
|
+
import * as MultisigConfig from './MultisigConfig.js'
|
|
4
|
+
import type * as SignatureEnvelope from './SignatureEnvelope.js'
|
|
4
5
|
|
|
5
6
|
const authorization = {
|
|
6
7
|
address: '0x1111111111111111111111111111111111111111',
|
|
@@ -19,6 +20,16 @@ const signature = {
|
|
|
19
20
|
|
|
20
21
|
const multisig = {
|
|
21
22
|
account: '0x2222222222222222222222222222222222222222',
|
|
23
|
+
config: MultisigConfig.from({
|
|
24
|
+
owners: [
|
|
25
|
+
{
|
|
26
|
+
owner: '0x1111111111111111111111111111111111111111',
|
|
27
|
+
weight: 1,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
threshold: 1,
|
|
31
|
+
version: 1n,
|
|
32
|
+
}),
|
|
22
33
|
signatures: [signature],
|
|
23
34
|
type: 'multisig',
|
|
24
35
|
} as const satisfies SignatureEnvelope.Multisig
|
|
@@ -44,17 +55,7 @@ test('accepts multisig signatures', () => {
|
|
|
44
55
|
KeyAuthorization.Signed['signature']
|
|
45
56
|
>()
|
|
46
57
|
|
|
47
|
-
const multisigRpc =
|
|
48
|
-
account: multisig.account,
|
|
49
|
-
signatures: [
|
|
50
|
-
{
|
|
51
|
-
r: '0x01',
|
|
52
|
-
s: '0x02',
|
|
53
|
-
type: 'secp256k1',
|
|
54
|
-
yParity: '0x0',
|
|
55
|
-
},
|
|
56
|
-
],
|
|
57
|
-
} as const satisfies SignatureEnvelope.MultisigRpc
|
|
58
|
+
const multisigRpc = '0xf8' as const satisfies SignatureEnvelope.MultisigRpc
|
|
58
59
|
|
|
59
60
|
const rpc: KeyAuthorization.Rpc = {
|
|
60
61
|
chainId: '0x1',
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
} from 'ox'
|
|
10
10
|
import { describe, expect, test } from 'vp/test'
|
|
11
11
|
import * as KeyAuthorization from './KeyAuthorization.js'
|
|
12
|
+
import * as MultisigConfig from './MultisigConfig.js'
|
|
12
13
|
import * as Period from './Period.js'
|
|
13
14
|
import * as SignatureEnvelope from './SignatureEnvelope.js'
|
|
14
15
|
|
|
@@ -55,9 +56,21 @@ const signature_webauthn = SignatureEnvelope.from({
|
|
|
55
56
|
|
|
56
57
|
const signature_multisig = {
|
|
57
58
|
account: address,
|
|
59
|
+
config: MultisigConfig.from({
|
|
60
|
+
owners: [
|
|
61
|
+
{
|
|
62
|
+
owner: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
|
|
63
|
+
weight: 1,
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
threshold: 1,
|
|
67
|
+
version: 1n,
|
|
68
|
+
}),
|
|
58
69
|
signatures: [SignatureEnvelope.from(signature_secp256k1)],
|
|
59
70
|
type: 'multisig',
|
|
60
71
|
} as const satisfies SignatureEnvelope.Multisig
|
|
72
|
+
const signature_multisig_rpc =
|
|
73
|
+
'0xf89794be95c3f554e9fc85ec51be69a3d807a0d55bcf2cf83ba000000000000000000000000000000000000000000000000000000000000000000101d7d694f39fd6e51aad88f6f4ce6ab8827279cfffb9226601f843b841fa78c5905fb0b9d6066ef531f962a62bc6ef0d5eb59ecb134056d206f75aaed7780926ff2601a935c2c79707d9e1799948c9f19dcdde1e090e903b19a07923d01c' as const
|
|
61
74
|
|
|
62
75
|
const signature_keychain = {
|
|
63
76
|
inner: SignatureEnvelope.from(signature_secp256k1),
|
|
@@ -491,16 +504,42 @@ describe('from', () => {
|
|
|
491
504
|
})
|
|
492
505
|
|
|
493
506
|
describe('fromRpc', () => {
|
|
494
|
-
test('multisig', () => {
|
|
507
|
+
test('behavior: multisig', () => {
|
|
495
508
|
const authorization = KeyAuthorization.fromRpc({
|
|
496
509
|
chainId: '0x1',
|
|
497
510
|
expiry: null,
|
|
498
511
|
keyId: address,
|
|
499
512
|
keyType: 'secp256k1',
|
|
500
|
-
signature:
|
|
513
|
+
signature: signature_multisig_rpc,
|
|
501
514
|
})
|
|
502
515
|
|
|
503
|
-
expect(authorization.signature).
|
|
516
|
+
expect(authorization.signature).toMatchInlineSnapshot(`
|
|
517
|
+
{
|
|
518
|
+
"account": "0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c",
|
|
519
|
+
"config": {
|
|
520
|
+
"owners": [
|
|
521
|
+
{
|
|
522
|
+
"owner": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
|
|
523
|
+
"weight": 1,
|
|
524
|
+
},
|
|
525
|
+
],
|
|
526
|
+
"salt": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
527
|
+
"threshold": 1,
|
|
528
|
+
"version": 1n,
|
|
529
|
+
},
|
|
530
|
+
"signatures": [
|
|
531
|
+
{
|
|
532
|
+
"signature": {
|
|
533
|
+
"r": "0xfa78c5905fb0b9d6066ef531f962a62bc6ef0d5eb59ecb134056d206f75aaed7",
|
|
534
|
+
"s": "0x780926ff2601a935c2c79707d9e1799948c9f19dcdde1e090e903b19a07923d0",
|
|
535
|
+
"yParity": 1,
|
|
536
|
+
},
|
|
537
|
+
"type": "secp256k1",
|
|
538
|
+
},
|
|
539
|
+
],
|
|
540
|
+
"type": "multisig",
|
|
541
|
+
}
|
|
542
|
+
`)
|
|
504
543
|
})
|
|
505
544
|
|
|
506
545
|
test('rejects a keychain signature', () => {
|
|
@@ -1071,6 +1110,60 @@ describe('getSignPayload', () => {
|
|
|
1071
1110
|
})
|
|
1072
1111
|
|
|
1073
1112
|
describe('deserialize', () => {
|
|
1113
|
+
test('example: matches the frozen multisig witness vector', () => {
|
|
1114
|
+
const serialized =
|
|
1115
|
+
'0xf8f1f85382107980941eff47bc3a10a45d4b230b5d10e37751fe6aa718808080a0535353535353535353535353535353535353535353535353535353535353535380949dba7f426b711d4893c11611eacf7cc334e7146bb89a05f897949dba7f426b711d4893c11611eacf7cc334e7146bf83ba000000000000000000000000000000000000000000000000000000000000000008001d7d6947e5f4552091a69125d5dfcb7b8c2659029395bdf01f843b8412cfed9350faf80e4115e3c4c967356b80a8e6ee42e4a49ab953c8c8a3537d8d8359bf035a9bea18f32b0da7129cdce3ce701abc09ad8919b93da21a0d57e21451b' as const
|
|
1116
|
+
const authorization = KeyAuthorization.deserialize(serialized)
|
|
1117
|
+
|
|
1118
|
+
expect(authorization).toMatchInlineSnapshot(`
|
|
1119
|
+
{
|
|
1120
|
+
"account": "0x9dba7f426b711d4893c11611eacf7cc334e7146b",
|
|
1121
|
+
"address": "0x1eff47bc3a10a45d4b230b5d10e37751fe6aa718",
|
|
1122
|
+
"chainId": 4217n,
|
|
1123
|
+
"isAdmin": false,
|
|
1124
|
+
"signature": {
|
|
1125
|
+
"account": "0x9dba7f426b711d4893c11611eacf7cc334e7146b",
|
|
1126
|
+
"config": {
|
|
1127
|
+
"owners": [
|
|
1128
|
+
{
|
|
1129
|
+
"owner": "0x7e5f4552091a69125d5dfcb7b8c2659029395bdf",
|
|
1130
|
+
"weight": 1,
|
|
1131
|
+
},
|
|
1132
|
+
],
|
|
1133
|
+
"salt": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
1134
|
+
"threshold": 1,
|
|
1135
|
+
"version": 0n,
|
|
1136
|
+
},
|
|
1137
|
+
"signatures": [
|
|
1138
|
+
{
|
|
1139
|
+
"signature": {
|
|
1140
|
+
"r": "0x2cfed9350faf80e4115e3c4c967356b80a8e6ee42e4a49ab953c8c8a3537d8d8",
|
|
1141
|
+
"s": "0x359bf035a9bea18f32b0da7129cdce3ce701abc09ad8919b93da21a0d57e2145",
|
|
1142
|
+
"yParity": 0,
|
|
1143
|
+
},
|
|
1144
|
+
"type": "secp256k1",
|
|
1145
|
+
},
|
|
1146
|
+
],
|
|
1147
|
+
"type": "multisig",
|
|
1148
|
+
},
|
|
1149
|
+
"type": "secp256k1",
|
|
1150
|
+
"witness": "0x5353535353535353535353535353535353535353535353535353535353535353",
|
|
1151
|
+
}
|
|
1152
|
+
`)
|
|
1153
|
+
expect(KeyAuthorization.serialize(authorization)).toBe(serialized)
|
|
1154
|
+
})
|
|
1155
|
+
|
|
1156
|
+
test('multisig', () => {
|
|
1157
|
+
const serialized = Rlp.fromHex([
|
|
1158
|
+
['0x1', '0x', address],
|
|
1159
|
+
SignatureEnvelope.serialize(signature_multisig),
|
|
1160
|
+
])
|
|
1161
|
+
|
|
1162
|
+
expect(KeyAuthorization.deserialize(serialized).signature).toEqual(
|
|
1163
|
+
signature_multisig,
|
|
1164
|
+
)
|
|
1165
|
+
})
|
|
1166
|
+
|
|
1074
1167
|
test('default', () => {
|
|
1075
1168
|
const authorization = KeyAuthorization.from({
|
|
1076
1169
|
address,
|
|
@@ -1241,6 +1334,19 @@ describe('serialize', () => {
|
|
|
1241
1334
|
})
|
|
1242
1335
|
|
|
1243
1336
|
describe('toRpc', () => {
|
|
1337
|
+
test('behavior: multisig', () => {
|
|
1338
|
+
const authorization = KeyAuthorization.toRpc({
|
|
1339
|
+
address,
|
|
1340
|
+
chainId: 1n,
|
|
1341
|
+
signature: signature_multisig,
|
|
1342
|
+
type: 'secp256k1',
|
|
1343
|
+
})
|
|
1344
|
+
|
|
1345
|
+
expect(authorization.signature).toMatchInlineSnapshot(
|
|
1346
|
+
`"${signature_multisig_rpc}"`,
|
|
1347
|
+
)
|
|
1348
|
+
})
|
|
1349
|
+
|
|
1244
1350
|
test('secp256k1', () => {
|
|
1245
1351
|
const authorization = KeyAuthorization.from({
|
|
1246
1352
|
address,
|
|
@@ -90,9 +90,9 @@ export type Signature<numberType = number> = OneOf<
|
|
|
90
90
|
>
|
|
91
91
|
|
|
92
92
|
/** RPC-formatted signature that can authorize an access key. */
|
|
93
|
-
export type SignatureRpc =
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
export type SignatureRpc =
|
|
94
|
+
| SignatureEnvelope.MultisigRpc
|
|
95
|
+
| SignatureEnvelope.PrimitiveRpc
|
|
96
96
|
|
|
97
97
|
/** Input type for a Key Authorization. */
|
|
98
98
|
export type Input = KeyAuthorization<false, bigint, number>
|
|
@@ -151,7 +151,7 @@ type SignatureValue =
|
|
|
151
151
|
| UnionPartialBy<Signature, 'prehash' | 'type'>
|
|
152
152
|
| SignatureEnvelope.Secp256k1Flat
|
|
153
153
|
| SignatureEnvelope.Serialized
|
|
154
|
-
| SignatureEnvelope.from.
|
|
154
|
+
| SignatureEnvelope.from.MultisigFromConfig
|
|
155
155
|
|
|
156
156
|
type BaseTuple = readonly [
|
|
157
157
|
chainId: Hex.Hex,
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { expectTypeOf, test } from 'vp/test'
|
|
2
|
+
import * as MultisigConfig from './MultisigConfig.js'
|
|
3
|
+
|
|
4
|
+
const input = {
|
|
5
|
+
owners: [
|
|
6
|
+
{
|
|
7
|
+
owner: '0x1111111111111111111111111111111111111111',
|
|
8
|
+
weight: 1,
|
|
9
|
+
},
|
|
10
|
+
],
|
|
11
|
+
threshold: 1,
|
|
12
|
+
} as const satisfies MultisigConfig.Input
|
|
13
|
+
|
|
14
|
+
test('from returns a complete configuration', () => {
|
|
15
|
+
const config = MultisigConfig.from(input)
|
|
16
|
+
const numeric = MultisigConfig.from({ ...input, version: 1 })
|
|
17
|
+
const zero = MultisigConfig.from({ ...input, version: 0 })
|
|
18
|
+
|
|
19
|
+
expectTypeOf(config).toMatchTypeOf<MultisigConfig.Config>()
|
|
20
|
+
expectTypeOf(config.version).toEqualTypeOf<0n>()
|
|
21
|
+
expectTypeOf(numeric.version).toEqualTypeOf<bigint>()
|
|
22
|
+
expectTypeOf(zero.version).toEqualTypeOf<0n>()
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
test('RPC configurations use hexadecimal versions', () => {
|
|
26
|
+
const rpc = MultisigConfig.toRpc(MultisigConfig.from(input))
|
|
27
|
+
|
|
28
|
+
expectTypeOf(rpc).toEqualTypeOf<MultisigConfig.Rpc>()
|
|
29
|
+
expectTypeOf(rpc.version).toEqualTypeOf<`0x${string}`>()
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
test('complete configurations require a version', () => {
|
|
33
|
+
// @ts-expect-error Complete configurations include their version.
|
|
34
|
+
const config: MultisigConfig.Config = input
|
|
35
|
+
|
|
36
|
+
expectTypeOf(config).toEqualTypeOf<MultisigConfig.Config>()
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
test('sign payloads take the version from config', () => {
|
|
40
|
+
MultisigConfig.getSignPayload({
|
|
41
|
+
account: '0x2222222222222222222222222222222222222222',
|
|
42
|
+
config: { version: 1 },
|
|
43
|
+
payload: '0x1234',
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
MultisigConfig.getSignPayload({
|
|
47
|
+
account: '0x2222222222222222222222222222222222222222',
|
|
48
|
+
// @ts-expect-error A configuration version is required.
|
|
49
|
+
config: {},
|
|
50
|
+
payload: '0x1234',
|
|
51
|
+
})
|
|
52
|
+
})
|