ox 0.14.55 → 0.14.56
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 +29 -0
- package/_cjs/tempo/{MultisigConfig.js → AccountConfig.js} +16 -4
- package/_cjs/tempo/AccountConfig.js.map +1 -0
- package/_cjs/tempo/{MultisigOperation.js → AccountOperation.js} +29 -29
- package/_cjs/tempo/AccountOperation.js.map +1 -0
- package/_cjs/tempo/{MultisigSimulation.js → AccountSimulation.js} +9 -9
- package/_cjs/tempo/AccountSimulation.js.map +1 -0
- package/_cjs/tempo/KeyAuthorization.js +12 -11
- package/_cjs/tempo/KeyAuthorization.js.map +1 -1
- package/_cjs/tempo/SignatureEnvelope.js +64 -64
- package/_cjs/tempo/SignatureEnvelope.js.map +1 -1
- package/_cjs/tempo/TransactionRequest.js +12 -9
- package/_cjs/tempo/TransactionRequest.js.map +1 -1
- package/_cjs/tempo/index.js +4 -4
- package/_cjs/tempo/index.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/tempo/{MultisigConfig.js → AccountConfig.js} +103 -55
- package/_esm/tempo/AccountConfig.js.map +1 -0
- package/_esm/tempo/{MultisigOperation.js → AccountOperation.js} +64 -64
- package/_esm/tempo/AccountOperation.js.map +1 -0
- package/_esm/tempo/{MultisigSimulation.js → AccountSimulation.js} +20 -20
- package/_esm/tempo/AccountSimulation.js.map +1 -0
- package/_esm/tempo/KeyAuthorization.js +13 -12
- package/_esm/tempo/KeyAuthorization.js.map +1 -1
- package/_esm/tempo/SignatureEnvelope.js +71 -71
- package/_esm/tempo/SignatureEnvelope.js.map +1 -1
- package/_esm/tempo/TransactionRequest.js +12 -9
- package/_esm/tempo/TransactionRequest.js.map +1 -1
- package/_esm/tempo/index.js +50 -48
- package/_esm/tempo/index.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/tempo/{MultisigConfig.d.ts → AccountConfig.d.ts} +110 -63
- package/_types/tempo/AccountConfig.d.ts.map +1 -0
- package/_types/tempo/{MultisigOperation.d.ts → AccountOperation.d.ts} +62 -62
- package/_types/tempo/AccountOperation.d.ts.map +1 -0
- package/_types/tempo/{MultisigSimulation.d.ts → AccountSimulation.d.ts} +21 -21
- package/_types/tempo/AccountSimulation.d.ts.map +1 -0
- package/_types/tempo/KeyAuthorization.d.ts +14 -14
- package/_types/tempo/KeyAuthorization.d.ts.map +1 -1
- package/_types/tempo/RpcSchemaTempo.d.ts +13 -13
- package/_types/tempo/RpcSchemaTempo.d.ts.map +1 -1
- package/_types/tempo/SignatureEnvelope.d.ts +36 -33
- package/_types/tempo/SignatureEnvelope.d.ts.map +1 -1
- package/_types/tempo/TransactionRequest.d.ts +11 -9
- package/_types/tempo/TransactionRequest.d.ts.map +1 -1
- package/_types/tempo/index.d.ts +50 -48
- package/_types/tempo/index.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/package.json +31 -31
- package/tempo/AccountConfig/package.json +6 -0
- package/tempo/AccountConfig.test-d/package.json +6 -0
- package/tempo/{MultisigConfig.test-d.ts → AccountConfig.test-d.ts} +22 -12
- package/tempo/{MultisigConfig.test.ts → AccountConfig.test.ts} +155 -37
- package/tempo/{MultisigConfig.ts → AccountConfig.ts} +132 -66
- package/tempo/AccountOperation/package.json +6 -0
- package/tempo/AccountOperation.test-d/package.json +6 -0
- package/tempo/AccountOperation.test-d.ts +71 -0
- package/tempo/{MultisigOperation.test.ts → AccountOperation.test.ts} +97 -97
- package/tempo/{MultisigOperation.ts → AccountOperation.ts} +95 -97
- package/tempo/AccountSimulation/package.json +6 -0
- package/tempo/AccountSimulation.test-d/package.json +6 -0
- package/tempo/{MultisigSimulation.test-d.ts → AccountSimulation.test-d.ts} +7 -9
- package/tempo/{MultisigSimulation.test.ts → AccountSimulation.test.ts} +29 -29
- package/tempo/{MultisigSimulation.ts → AccountSimulation.ts} +28 -30
- package/tempo/KeyAuthorization.test-d.ts +14 -14
- package/tempo/KeyAuthorization.test.ts +70 -49
- package/tempo/KeyAuthorization.ts +29 -27
- package/tempo/RpcSchemaTempo.test-d.ts +19 -19
- package/tempo/RpcSchemaTempo.ts +13 -13
- package/tempo/SignatureEnvelope.test-d.ts +7 -7
- package/tempo/SignatureEnvelope.test.ts +34 -34
- package/tempo/SignatureEnvelope.ts +107 -103
- package/tempo/Transaction.test.ts +4 -4
- package/tempo/TransactionRequest.test-d.ts +16 -7
- package/tempo/TransactionRequest.test.ts +25 -17
- package/tempo/TransactionRequest.ts +25 -18
- package/tempo/{multisig.e2e.test.ts → configurableAccounts.e2e.test.ts} +16 -16
- package/tempo/index.ts +50 -48
- package/version.ts +1 -1
- package/_cjs/tempo/MultisigConfig.js.map +0 -1
- package/_cjs/tempo/MultisigOperation.js.map +0 -1
- package/_cjs/tempo/MultisigSimulation.js.map +0 -1
- package/_esm/tempo/MultisigConfig.js.map +0 -1
- package/_esm/tempo/MultisigOperation.js.map +0 -1
- package/_esm/tempo/MultisigSimulation.js.map +0 -1
- package/_types/tempo/MultisigConfig.d.ts.map +0 -1
- package/_types/tempo/MultisigOperation.d.ts.map +0 -1
- package/_types/tempo/MultisigSimulation.d.ts.map +0 -1
- package/tempo/MultisigConfig/package.json +0 -6
- package/tempo/MultisigConfig.test-d/package.json +0 -6
- package/tempo/MultisigOperation/package.json +0 -6
- package/tempo/MultisigOperation.test-d/package.json +0 -6
- package/tempo/MultisigOperation.test-d.ts +0 -71
- package/tempo/MultisigSimulation/package.json +0 -6
- package/tempo/MultisigSimulation.test-d/package.json +0 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { expectTypeOf, test } from 'vitest'
|
|
2
|
-
import * as
|
|
2
|
+
import * as AccountConfig from './AccountConfig.js'
|
|
3
3
|
|
|
4
4
|
const input = {
|
|
5
5
|
owners: [
|
|
@@ -9,41 +9,51 @@ const input = {
|
|
|
9
9
|
},
|
|
10
10
|
],
|
|
11
11
|
threshold: 1,
|
|
12
|
-
} as const satisfies
|
|
12
|
+
} as const satisfies AccountConfig.Input
|
|
13
13
|
|
|
14
14
|
test('from returns a complete configuration', () => {
|
|
15
|
-
const config =
|
|
16
|
-
const numeric =
|
|
17
|
-
const zero =
|
|
15
|
+
const config = AccountConfig.from(input)
|
|
16
|
+
const numeric = AccountConfig.from({ ...input, version: 1 })
|
|
17
|
+
const zero = AccountConfig.from({ ...input, version: 0 })
|
|
18
18
|
|
|
19
|
-
expectTypeOf(config).toMatchTypeOf<
|
|
19
|
+
expectTypeOf(config).toMatchTypeOf<AccountConfig.Config>()
|
|
20
20
|
expectTypeOf(config.version).toEqualTypeOf<0n>()
|
|
21
21
|
expectTypeOf(numeric.version).toEqualTypeOf<bigint>()
|
|
22
22
|
expectTypeOf(zero.version).toEqualTypeOf<0n>()
|
|
23
23
|
})
|
|
24
24
|
|
|
25
|
+
test('update returns the next complete configuration', () => {
|
|
26
|
+
const config = AccountConfig.update(AccountConfig.from(input), {
|
|
27
|
+
owners: input.owners,
|
|
28
|
+
threshold: 1,
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
expectTypeOf(config).toEqualTypeOf<AccountConfig.Config>()
|
|
32
|
+
expectTypeOf(config.version).toEqualTypeOf<bigint>()
|
|
33
|
+
})
|
|
34
|
+
|
|
25
35
|
test('RPC configurations use hexadecimal versions', () => {
|
|
26
|
-
const rpc =
|
|
36
|
+
const rpc = AccountConfig.toRpc(AccountConfig.from(input))
|
|
27
37
|
|
|
28
|
-
expectTypeOf(rpc).toEqualTypeOf<
|
|
38
|
+
expectTypeOf(rpc).toEqualTypeOf<AccountConfig.Rpc>()
|
|
29
39
|
expectTypeOf(rpc.version).toEqualTypeOf<`0x${string}`>()
|
|
30
40
|
})
|
|
31
41
|
|
|
32
42
|
test('complete configurations require a version', () => {
|
|
33
43
|
// @ts-expect-error Complete configurations include their version.
|
|
34
|
-
const config:
|
|
44
|
+
const config: AccountConfig.Config = input
|
|
35
45
|
|
|
36
|
-
expectTypeOf(config).toEqualTypeOf<
|
|
46
|
+
expectTypeOf(config).toEqualTypeOf<AccountConfig.Config>()
|
|
37
47
|
})
|
|
38
48
|
|
|
39
49
|
test('sign payloads take the version from config', () => {
|
|
40
|
-
|
|
50
|
+
AccountConfig.getSignPayload({
|
|
41
51
|
account: '0x2222222222222222222222222222222222222222',
|
|
42
52
|
config: { version: 1 },
|
|
43
53
|
payload: '0x1234',
|
|
44
54
|
})
|
|
45
55
|
|
|
46
|
-
|
|
56
|
+
AccountConfig.getSignPayload({
|
|
47
57
|
account: '0x2222222222222222222222222222222222222222',
|
|
48
58
|
// @ts-expect-error A configuration version is required.
|
|
49
59
|
config: {},
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { Hash, Hex, Rlp } from 'ox'
|
|
2
|
-
import {
|
|
2
|
+
import { AccountConfig } from 'ox/tempo'
|
|
3
3
|
import { describe, expect, test } from 'vitest'
|
|
4
|
-
import { factory } from '../../test/tempo/
|
|
4
|
+
import { factory } from '../../test/tempo/configurableAccounts.js'
|
|
5
5
|
|
|
6
6
|
const owner_1 = '0x1111111111111111111111111111111111111111'
|
|
7
7
|
const owner_2 = '0x2222222222222222222222222222222222222222'
|
|
8
8
|
const payload = `0x${'42'.repeat(32)}` as const
|
|
9
|
-
const config =
|
|
9
|
+
const config = AccountConfig.from({
|
|
10
10
|
owners: [{ owner: owner_1, weight: 1 }],
|
|
11
11
|
threshold: 1,
|
|
12
12
|
})
|
|
13
|
-
const account =
|
|
13
|
+
const account = AccountConfig.getAddress(config, { factory })
|
|
14
14
|
|
|
15
15
|
describe('from', () => {
|
|
16
16
|
test('behavior: normalizes an initial configuration', () => {
|
|
17
17
|
expect(
|
|
18
|
-
|
|
18
|
+
AccountConfig.from({
|
|
19
19
|
owners: [
|
|
20
20
|
{ owner: owner_2, weight: 1 },
|
|
21
21
|
{ owner: owner_1, weight: 1 },
|
|
@@ -43,7 +43,7 @@ describe('from', () => {
|
|
|
43
43
|
|
|
44
44
|
test('behavior: normalizes a numeric configuration version', () => {
|
|
45
45
|
expect(
|
|
46
|
-
|
|
46
|
+
AccountConfig.from({ ...config, version: 1 }),
|
|
47
47
|
).toMatchInlineSnapshot(`
|
|
48
48
|
{
|
|
49
49
|
"owners": [
|
|
@@ -61,24 +61,24 @@ describe('from', () => {
|
|
|
61
61
|
|
|
62
62
|
test('error: rejects an invalid configuration', () => {
|
|
63
63
|
expect(() =>
|
|
64
|
-
|
|
64
|
+
AccountConfig.from({ owners: [], threshold: 0 }),
|
|
65
65
|
).toThrowErrorMatchingInlineSnapshot(
|
|
66
|
-
`[
|
|
66
|
+
`[AccountConfig.InvalidConfigError: Invalid account config: owners cannot be empty.]`,
|
|
67
67
|
)
|
|
68
68
|
})
|
|
69
69
|
|
|
70
70
|
test('error: rejects an invalid numeric version', () => {
|
|
71
71
|
expect(() =>
|
|
72
|
-
|
|
72
|
+
AccountConfig.from({ ...config, version: 1.5 }),
|
|
73
73
|
).toThrowErrorMatchingInlineSnapshot(
|
|
74
|
-
`[
|
|
74
|
+
`[AccountConfig.InvalidConfigError: Invalid account config: version must be an unsigned 64-bit integer.]`,
|
|
75
75
|
)
|
|
76
76
|
})
|
|
77
77
|
})
|
|
78
78
|
|
|
79
79
|
describe('fromRpc/toRpc', () => {
|
|
80
80
|
test('behavior: round trips a configuration', () => {
|
|
81
|
-
const rpc =
|
|
81
|
+
const rpc = AccountConfig.toRpc({ ...config, version: 1n })
|
|
82
82
|
expect(rpc).toMatchInlineSnapshot(`
|
|
83
83
|
{
|
|
84
84
|
"owners": [
|
|
@@ -92,7 +92,7 @@ describe('fromRpc/toRpc', () => {
|
|
|
92
92
|
"version": "0x1",
|
|
93
93
|
}
|
|
94
94
|
`)
|
|
95
|
-
expect(
|
|
95
|
+
expect(AccountConfig.fromRpc(rpc)).toStrictEqual({
|
|
96
96
|
...config,
|
|
97
97
|
version: 1n,
|
|
98
98
|
})
|
|
@@ -109,7 +109,7 @@ describe('getAddress', () => {
|
|
|
109
109
|
|
|
110
110
|
test('behavior: includes salt, threshold, and owners', () => {
|
|
111
111
|
expect(
|
|
112
|
-
|
|
112
|
+
AccountConfig.getAddress(
|
|
113
113
|
{
|
|
114
114
|
owners: [
|
|
115
115
|
{ owner: owner_1, weight: 1 },
|
|
@@ -125,8 +125,8 @@ describe('getAddress', () => {
|
|
|
125
125
|
|
|
126
126
|
test('behavior: is stable and binds the salt', () => {
|
|
127
127
|
expect({
|
|
128
|
-
repeated:
|
|
129
|
-
salted:
|
|
128
|
+
repeated: AccountConfig.getAddress(config, { factory }),
|
|
129
|
+
salted: AccountConfig.getAddress(
|
|
130
130
|
{
|
|
131
131
|
...config,
|
|
132
132
|
salt: `0x${'42'.repeat(32)}`,
|
|
@@ -143,15 +143,15 @@ describe('getAddress', () => {
|
|
|
143
143
|
|
|
144
144
|
test('error: rejects a current configuration', () => {
|
|
145
145
|
expect(() =>
|
|
146
|
-
|
|
146
|
+
AccountConfig.getAddress({ ...config, version: 1n }, { factory }),
|
|
147
147
|
).toThrowErrorMatchingInlineSnapshot(
|
|
148
|
-
`[
|
|
148
|
+
`[AccountConfig.InvalidConfigError: Invalid account config: account address requires version zero.]`,
|
|
149
149
|
)
|
|
150
150
|
})
|
|
151
151
|
|
|
152
152
|
test('behavior: accepts numeric zero for an initial configuration', () => {
|
|
153
153
|
expect(
|
|
154
|
-
|
|
154
|
+
AccountConfig.getAddress({ ...config, version: 0 }, { factory }),
|
|
155
155
|
).toBe(account)
|
|
156
156
|
})
|
|
157
157
|
})
|
|
@@ -159,9 +159,9 @@ describe('getAddress', () => {
|
|
|
159
159
|
describe('getCommitment', () => {
|
|
160
160
|
test('example: matches the frozen initial and current vectors', () => {
|
|
161
161
|
expect({
|
|
162
|
-
current:
|
|
163
|
-
currentNumber:
|
|
164
|
-
initial:
|
|
162
|
+
current: AccountConfig.getCommitment({ ...config, version: 1n }),
|
|
163
|
+
currentNumber: AccountConfig.getCommitment({ ...config, version: 1 }),
|
|
164
|
+
initial: AccountConfig.getCommitment(config),
|
|
165
165
|
}).toMatchInlineSnapshot(`
|
|
166
166
|
{
|
|
167
167
|
"current": "0x6237ca5930f2265d4fb70a0305dd6ceea4df227053b4a62c304489ede946a2f8",
|
|
@@ -175,7 +175,7 @@ describe('getCommitment', () => {
|
|
|
175
175
|
describe('getSignPayload', () => {
|
|
176
176
|
test('example: matches the frozen version-0 vector', () => {
|
|
177
177
|
expect(
|
|
178
|
-
|
|
178
|
+
AccountConfig.getSignPayload({ account, config, payload }),
|
|
179
179
|
).toMatchInlineSnapshot(
|
|
180
180
|
`"0x728efe90611b01c91c2be0da56e7eb8e0d2c274c84f97182e274187dde0b8a20"`,
|
|
181
181
|
)
|
|
@@ -183,20 +183,20 @@ describe('getSignPayload', () => {
|
|
|
183
183
|
|
|
184
184
|
test('behavior: binds the configuration version', () => {
|
|
185
185
|
expect(
|
|
186
|
-
|
|
186
|
+
AccountConfig.getSignPayload({
|
|
187
187
|
account,
|
|
188
188
|
config: { version: 1 },
|
|
189
189
|
payload,
|
|
190
190
|
}),
|
|
191
|
-
).not.toBe(
|
|
191
|
+
).not.toBe(AccountConfig.getSignPayload({ account, config, payload }))
|
|
192
192
|
})
|
|
193
193
|
})
|
|
194
194
|
|
|
195
195
|
describe('toTuple/fromTuple', () => {
|
|
196
196
|
test('example: matches the frozen initial and current RLP vectors', () => {
|
|
197
197
|
expect({
|
|
198
|
-
current: Rlp.fromHex(
|
|
199
|
-
initial: Rlp.fromHex(
|
|
198
|
+
current: Rlp.fromHex(AccountConfig.toTuple({ ...config, version: 1n })),
|
|
199
|
+
initial: Rlp.fromHex(AccountConfig.toTuple(config)),
|
|
200
200
|
}).toMatchInlineSnapshot(`
|
|
201
201
|
{
|
|
202
202
|
"current": "0xf83ba000000000000000000000000000000000000000000000000000000000000000000101d7d694111111111111111111111111111111111111111101",
|
|
@@ -206,7 +206,7 @@ describe('toTuple/fromTuple', () => {
|
|
|
206
206
|
})
|
|
207
207
|
|
|
208
208
|
test('behavior: round trips the complete witness', () => {
|
|
209
|
-
const current =
|
|
209
|
+
const current = AccountConfig.from({
|
|
210
210
|
owners: [
|
|
211
211
|
{ owner: owner_1, weight: 1 },
|
|
212
212
|
{ owner: owner_2, weight: 2 },
|
|
@@ -216,27 +216,113 @@ describe('toTuple/fromTuple', () => {
|
|
|
216
216
|
version: 1n,
|
|
217
217
|
})
|
|
218
218
|
expect(
|
|
219
|
-
|
|
219
|
+
AccountConfig.fromTuple(AccountConfig.toTuple(current)),
|
|
220
220
|
).toStrictEqual(current)
|
|
221
221
|
})
|
|
222
222
|
})
|
|
223
223
|
|
|
224
|
+
describe('update', () => {
|
|
225
|
+
test('default', () => {
|
|
226
|
+
expect(
|
|
227
|
+
AccountConfig.update(config, {
|
|
228
|
+
owners: [
|
|
229
|
+
{ owner: owner_2, weight: 1 },
|
|
230
|
+
{ owner: owner_1, weight: 1 },
|
|
231
|
+
],
|
|
232
|
+
threshold: 2,
|
|
233
|
+
}),
|
|
234
|
+
).toMatchInlineSnapshot(`
|
|
235
|
+
{
|
|
236
|
+
"owners": [
|
|
237
|
+
{
|
|
238
|
+
"owner": "0x1111111111111111111111111111111111111111",
|
|
239
|
+
"weight": 1,
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
"owner": "0x2222222222222222222222222222222222222222",
|
|
243
|
+
"weight": 1,
|
|
244
|
+
},
|
|
245
|
+
],
|
|
246
|
+
"salt": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
247
|
+
"threshold": 2,
|
|
248
|
+
"version": 1n,
|
|
249
|
+
}
|
|
250
|
+
`)
|
|
251
|
+
})
|
|
252
|
+
|
|
253
|
+
test('behavior: keeps the salt and increments each version', () => {
|
|
254
|
+
const initialConfig = AccountConfig.from({
|
|
255
|
+
owners: [{ owner: owner_1, weight: 1 }],
|
|
256
|
+
salt: `0x${'42'.repeat(32)}`,
|
|
257
|
+
threshold: 1,
|
|
258
|
+
})
|
|
259
|
+
const next = AccountConfig.update(initialConfig, {
|
|
260
|
+
owners: [{ owner: owner_2, weight: 1 }],
|
|
261
|
+
threshold: 1,
|
|
262
|
+
})
|
|
263
|
+
const last = AccountConfig.update(next, {
|
|
264
|
+
owners: [{ owner: owner_1, weight: 1 }],
|
|
265
|
+
threshold: 1,
|
|
266
|
+
})
|
|
267
|
+
expect({
|
|
268
|
+
last: { salt: last.salt, version: last.version },
|
|
269
|
+
next: { salt: next.salt, version: next.version },
|
|
270
|
+
}).toMatchInlineSnapshot(`
|
|
271
|
+
{
|
|
272
|
+
"last": {
|
|
273
|
+
"salt": "0x4242424242424242424242424242424242424242424242424242424242424242",
|
|
274
|
+
"version": 2n,
|
|
275
|
+
},
|
|
276
|
+
"next": {
|
|
277
|
+
"salt": "0x4242424242424242424242424242424242424242424242424242424242424242",
|
|
278
|
+
"version": 1n,
|
|
279
|
+
},
|
|
280
|
+
}
|
|
281
|
+
`)
|
|
282
|
+
expect(AccountConfig.getCommitment(last)).not.toBe(
|
|
283
|
+
AccountConfig.getCommitment(initialConfig),
|
|
284
|
+
)
|
|
285
|
+
})
|
|
286
|
+
|
|
287
|
+
test('error: rejects version overflow', () => {
|
|
288
|
+
expect(() =>
|
|
289
|
+
AccountConfig.update(
|
|
290
|
+
{ ...config, version: AccountConfig.maxVersion },
|
|
291
|
+
{ owners: config.owners, threshold: 1 },
|
|
292
|
+
),
|
|
293
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
294
|
+
`[AccountConfig.InvalidConfigError: Invalid account config: version overflow.]`,
|
|
295
|
+
)
|
|
296
|
+
})
|
|
297
|
+
|
|
298
|
+
test('error: rejects an invalid replacement', () => {
|
|
299
|
+
expect(() =>
|
|
300
|
+
AccountConfig.update(config, {
|
|
301
|
+
owners: [{ owner: owner_1, weight: 1 }],
|
|
302
|
+
threshold: 2,
|
|
303
|
+
}),
|
|
304
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
305
|
+
`[AccountConfig.InvalidConfigError: Invalid account config: threshold exceeds total owner weight.]`,
|
|
306
|
+
)
|
|
307
|
+
})
|
|
308
|
+
})
|
|
309
|
+
|
|
224
310
|
describe('assert/validate', () => {
|
|
225
311
|
test('example: matches the frozen 48-owner boundary vector', () => {
|
|
226
|
-
const boundary =
|
|
312
|
+
const boundary = AccountConfig.from({
|
|
227
313
|
owners: Array.from({ length: 48 }, (_, index) => ({
|
|
228
314
|
owner: `0x${(index + 1).toString(16).padStart(40, '0')}` as const,
|
|
229
315
|
weight: 1,
|
|
230
316
|
})),
|
|
231
317
|
threshold: 8,
|
|
232
318
|
})
|
|
233
|
-
const rlp = Rlp.fromHex(
|
|
319
|
+
const rlp = Rlp.fromHex(AccountConfig.toTuple(boundary))
|
|
234
320
|
expect({
|
|
235
|
-
account:
|
|
236
|
-
commitment:
|
|
321
|
+
account: AccountConfig.getAddress(boundary, { factory }),
|
|
322
|
+
commitment: AccountConfig.getCommitment(boundary),
|
|
237
323
|
rlpHash: Hash.keccak256(rlp),
|
|
238
324
|
rlpLength: Hex.size(rlp),
|
|
239
|
-
valid:
|
|
325
|
+
valid: AccountConfig.validate(boundary),
|
|
240
326
|
}).toMatchInlineSnapshot(`
|
|
241
327
|
{
|
|
242
328
|
"account": "0x6acb25715a2b0cf05c098f753a87d9b38471e99f",
|
|
@@ -248,9 +334,30 @@ describe('assert/validate', () => {
|
|
|
248
334
|
`)
|
|
249
335
|
})
|
|
250
336
|
|
|
337
|
+
test('behavior: accepts thresholds above eight reachable by eight signatures', () => {
|
|
338
|
+
expect(
|
|
339
|
+
AccountConfig.validate({
|
|
340
|
+
owners: [
|
|
341
|
+
{ owner: owner_1, weight: 100 },
|
|
342
|
+
{ owner: owner_2, weight: 100 },
|
|
343
|
+
],
|
|
344
|
+
threshold: 150,
|
|
345
|
+
}),
|
|
346
|
+
).toBe(true)
|
|
347
|
+
expect(
|
|
348
|
+
AccountConfig.validate({
|
|
349
|
+
owners: [
|
|
350
|
+
{ owner: owner_1, weight: 128 },
|
|
351
|
+
{ owner: owner_2, weight: 127 },
|
|
352
|
+
],
|
|
353
|
+
threshold: AccountConfig.maxThreshold,
|
|
354
|
+
}),
|
|
355
|
+
).toBe(true)
|
|
356
|
+
})
|
|
357
|
+
|
|
251
358
|
test('behavior: accepts the uint8 weight boundary', () => {
|
|
252
359
|
expect(
|
|
253
|
-
|
|
360
|
+
AccountConfig.validate({
|
|
254
361
|
owners: [
|
|
255
362
|
{ owner: owner_1, weight: 128 },
|
|
256
363
|
{ owner: owner_2, weight: 127 },
|
|
@@ -336,6 +443,16 @@ describe('assert/validate', () => {
|
|
|
336
443
|
},
|
|
337
444
|
name: 'unreachable threshold',
|
|
338
445
|
},
|
|
446
|
+
{
|
|
447
|
+
config: {
|
|
448
|
+
owners: [
|
|
449
|
+
{ owner: owner_1, weight: 128 },
|
|
450
|
+
{ owner: owner_2, weight: 127 },
|
|
451
|
+
],
|
|
452
|
+
threshold: AccountConfig.maxThreshold + 1,
|
|
453
|
+
},
|
|
454
|
+
name: 'threshold above max',
|
|
455
|
+
},
|
|
339
456
|
{
|
|
340
457
|
config: { ...config, salt: '0x42' as const },
|
|
341
458
|
name: 'short salt',
|
|
@@ -349,7 +466,7 @@ describe('assert/validate', () => {
|
|
|
349
466
|
name: 'negative numeric version',
|
|
350
467
|
},
|
|
351
468
|
{
|
|
352
|
-
config: { ...config, version:
|
|
469
|
+
config: { ...config, version: AccountConfig.maxVersion + 1n },
|
|
353
470
|
name: 'version overflow',
|
|
354
471
|
},
|
|
355
472
|
{
|
|
@@ -361,12 +478,12 @@ describe('assert/validate', () => {
|
|
|
361
478
|
name: 'unsafe numeric version',
|
|
362
479
|
},
|
|
363
480
|
])('error: rejects $name', ({ config }) => {
|
|
364
|
-
expect(
|
|
481
|
+
expect(AccountConfig.validate(config as AccountConfig.Input)).toBe(false)
|
|
365
482
|
})
|
|
366
483
|
})
|
|
367
484
|
|
|
368
485
|
test('exports', () => {
|
|
369
|
-
expect(Object.keys(
|
|
486
|
+
expect(Object.keys(AccountConfig)).toMatchInlineSnapshot(`
|
|
370
487
|
[
|
|
371
488
|
"maxOwnerSignatureBytes",
|
|
372
489
|
"maxOwners",
|
|
@@ -384,6 +501,7 @@ test('exports', () => {
|
|
|
384
501
|
"getSignPayload",
|
|
385
502
|
"toRpc",
|
|
386
503
|
"toTuple",
|
|
504
|
+
"update",
|
|
387
505
|
"validate",
|
|
388
506
|
"InvalidConfigError",
|
|
389
507
|
]
|