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