ox 0.14.56 → 0.14.57
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 +19 -0
- package/_cjs/tempo/AccountConfig.js +16 -5
- package/_cjs/tempo/AccountConfig.js.map +1 -1
- package/_cjs/tempo/AccountSimulation.js +13 -4
- package/_cjs/tempo/AccountSimulation.js.map +1 -1
- package/_cjs/tempo/KeyAuthorization.js +2 -11
- package/_cjs/tempo/KeyAuthorization.js.map +1 -1
- package/_cjs/tempo/TransactionRequest.js +7 -5
- package/_cjs/tempo/TransactionRequest.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/tempo/AccountConfig.js +58 -9
- package/_esm/tempo/AccountConfig.js.map +1 -1
- package/_esm/tempo/AccountSimulation.js +15 -5
- package/_esm/tempo/AccountSimulation.js.map +1 -1
- package/_esm/tempo/KeyAuthorization.js +8 -12
- package/_esm/tempo/KeyAuthorization.js.map +1 -1
- package/_esm/tempo/TransactionRequest.js +7 -5
- package/_esm/tempo/TransactionRequest.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/tempo/AccountConfig.d.ts +46 -3
- package/_types/tempo/AccountConfig.d.ts.map +1 -1
- package/_types/tempo/AccountSimulation.d.ts +6 -2
- package/_types/tempo/AccountSimulation.d.ts.map +1 -1
- package/_types/tempo/KeyAuthorization.d.ts +18 -13
- package/_types/tempo/KeyAuthorization.d.ts.map +1 -1
- package/_types/tempo/TransactionRequest.d.ts +3 -3
- package/_types/tempo/TransactionRequest.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/package.json +1 -1
- package/tempo/AccountConfig.test-d.ts +10 -0
- package/tempo/AccountConfig.test.ts +143 -10
- package/tempo/AccountConfig.ts +80 -9
- package/tempo/AccountOperation.test.ts +32 -32
- package/tempo/AccountSimulation.test.ts +44 -0
- package/tempo/AccountSimulation.ts +19 -5
- package/tempo/KeyAuthorization.test-d.ts +8 -18
- package/tempo/KeyAuthorization.test.ts +95 -39
- package/tempo/KeyAuthorization.ts +20 -43
- package/tempo/RpcSchemaTempo.test-d.ts +2 -2
- package/tempo/TransactionRequest.test-d.ts +3 -3
- package/tempo/TransactionRequest.test.ts +10 -8
- package/tempo/TransactionRequest.ts +10 -8
- package/version.ts +1 -1
|
@@ -12,6 +12,13 @@ const config = AccountConfig.from({
|
|
|
12
12
|
})
|
|
13
13
|
const account = AccountConfig.getAddress(config, { factory })
|
|
14
14
|
|
|
15
|
+
// Vectors from Tempo `crates/primitives/tests/configurable_account.rs`
|
|
16
|
+
// (`configurable_account_hashes_follow_vectors_and_documented_layout`).
|
|
17
|
+
const tempo = {
|
|
18
|
+
account: '0x91847576f406d0842ad7c1a0c97c22a122e64278',
|
|
19
|
+
factory: '0x9999999999999999999999999999999999999999',
|
|
20
|
+
} as const
|
|
21
|
+
|
|
15
22
|
describe('from', () => {
|
|
16
23
|
test('behavior: normalizes an initial configuration', () => {
|
|
17
24
|
expect(
|
|
@@ -99,10 +106,103 @@ describe('fromRpc/toRpc', () => {
|
|
|
99
106
|
})
|
|
100
107
|
})
|
|
101
108
|
|
|
109
|
+
describe('fromUpgrade', () => {
|
|
110
|
+
const root = '0x3333333333333333333333333333333333333333'
|
|
111
|
+
|
|
112
|
+
test('example: derives the migrated config', () => {
|
|
113
|
+
// The root key may also be listed as an owner.
|
|
114
|
+
const config = AccountConfig.fromUpgrade(root, {
|
|
115
|
+
owners: [
|
|
116
|
+
{ owner: root, weight: 1 },
|
|
117
|
+
{ owner: owner_1, weight: 1 },
|
|
118
|
+
],
|
|
119
|
+
threshold: 2,
|
|
120
|
+
})
|
|
121
|
+
expect({
|
|
122
|
+
commitment: AccountConfig.getCommitment(config),
|
|
123
|
+
config,
|
|
124
|
+
}).toMatchInlineSnapshot(`
|
|
125
|
+
{
|
|
126
|
+
"commitment": "0xabca6d8f3a14b99ecaef378042e6a2ffa4f231125517e073cfbd3bcd69ac6ea1",
|
|
127
|
+
"config": {
|
|
128
|
+
"owners": [
|
|
129
|
+
{
|
|
130
|
+
"owner": "0x1111111111111111111111111111111111111111",
|
|
131
|
+
"weight": 1,
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"owner": "0x3333333333333333333333333333333333333333",
|
|
135
|
+
"weight": 1,
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
"salt": "0x42b3dad8fa6c40b50e6dbbbdaaace72d6c04250c16c1e263a52355983a30eb56",
|
|
139
|
+
"threshold": 2,
|
|
140
|
+
"version": 1n,
|
|
141
|
+
},
|
|
142
|
+
}
|
|
143
|
+
`)
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
test('behavior: binds the salt to the account', () => {
|
|
147
|
+
const options = {
|
|
148
|
+
owners: [{ owner: owner_1, weight: 1 }],
|
|
149
|
+
threshold: 1,
|
|
150
|
+
} as const
|
|
151
|
+
expect(AccountConfig.fromUpgrade(root, options).salt).not.toBe(
|
|
152
|
+
AccountConfig.fromUpgrade(owner_2, options).salt,
|
|
153
|
+
)
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
test('error: rejects an invalid account', () => {
|
|
157
|
+
expect(() =>
|
|
158
|
+
AccountConfig.fromUpgrade('0x1234', {
|
|
159
|
+
owners: [{ owner: owner_1, weight: 1 }],
|
|
160
|
+
threshold: 1,
|
|
161
|
+
}),
|
|
162
|
+
).toThrowErrorMatchingInlineSnapshot(`
|
|
163
|
+
[Address.InvalidAddressError: Address "0x1234" is invalid.
|
|
164
|
+
|
|
165
|
+
Details: Address is not a 20 byte (40 hexadecimal character) value.]
|
|
166
|
+
`)
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
test('error: rejects an invalid config', () => {
|
|
170
|
+
expect(() =>
|
|
171
|
+
AccountConfig.fromUpgrade(root, {
|
|
172
|
+
owners: [{ owner: owner_1, weight: 1 }],
|
|
173
|
+
threshold: 2,
|
|
174
|
+
}),
|
|
175
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
176
|
+
`[AccountConfig.InvalidConfigError: Invalid account config: threshold exceeds total owner weight.]`,
|
|
177
|
+
)
|
|
178
|
+
})
|
|
179
|
+
})
|
|
180
|
+
|
|
102
181
|
describe('getAddress', () => {
|
|
182
|
+
test('example: matches the Tempo vectors', () => {
|
|
183
|
+
expect({
|
|
184
|
+
maxOwners: AccountConfig.getAddress(
|
|
185
|
+
{
|
|
186
|
+
owners: Array.from({ length: AccountConfig.maxOwners }, (_, i) => ({
|
|
187
|
+
owner: Hex.padLeft(Hex.fromNumber(i + 1), 20),
|
|
188
|
+
weight: 1,
|
|
189
|
+
})),
|
|
190
|
+
threshold: 8,
|
|
191
|
+
},
|
|
192
|
+
{ factory: tempo.factory },
|
|
193
|
+
),
|
|
194
|
+
single: AccountConfig.getAddress(config, { factory: tempo.factory }),
|
|
195
|
+
}).toMatchInlineSnapshot(`
|
|
196
|
+
{
|
|
197
|
+
"maxOwners": "0x7a4279bb3f1b8b54d703484317f64eae6814e827",
|
|
198
|
+
"single": "0x87c346a9029d675f296db533b12e146439cf20d5",
|
|
199
|
+
}
|
|
200
|
+
`)
|
|
201
|
+
})
|
|
202
|
+
|
|
103
203
|
test('example: matches the frozen CREATE2 vector', () => {
|
|
104
204
|
expect(account).toMatchInlineSnapshot(
|
|
105
|
-
`"
|
|
205
|
+
`"0x2318ebe50d1d476ec10854bfd949f96ea7737b68"`,
|
|
106
206
|
)
|
|
107
207
|
expect(account).not.toBe('0x8820d1497eeaf4f68e00b2cfc00a2f3b1dbb00da')
|
|
108
208
|
})
|
|
@@ -120,7 +220,7 @@ describe('getAddress', () => {
|
|
|
120
220
|
},
|
|
121
221
|
{ factory },
|
|
122
222
|
),
|
|
123
|
-
).toMatchInlineSnapshot(`"
|
|
223
|
+
).toMatchInlineSnapshot(`"0x1baa996a4f142d99999aa22f1cb1eb97eed2a24a"`)
|
|
124
224
|
})
|
|
125
225
|
|
|
126
226
|
test('behavior: is stable and binds the salt', () => {
|
|
@@ -135,8 +235,8 @@ describe('getAddress', () => {
|
|
|
135
235
|
),
|
|
136
236
|
}).toMatchInlineSnapshot(`
|
|
137
237
|
{
|
|
138
|
-
"repeated": "
|
|
139
|
-
"salted": "
|
|
238
|
+
"repeated": "0x2318ebe50d1d476ec10854bfd949f96ea7737b68",
|
|
239
|
+
"salted": "0x70d2e44032514493b68641ce5182cc878baa51f0",
|
|
140
240
|
}
|
|
141
241
|
`)
|
|
142
242
|
})
|
|
@@ -157,6 +257,18 @@ describe('getAddress', () => {
|
|
|
157
257
|
})
|
|
158
258
|
|
|
159
259
|
describe('getCommitment', () => {
|
|
260
|
+
test('example: matches the Tempo vectors', () => {
|
|
261
|
+
expect({
|
|
262
|
+
current: AccountConfig.getCommitment({ ...config, version: 1n }),
|
|
263
|
+
initial: AccountConfig.getCommitment(config),
|
|
264
|
+
}).toMatchInlineSnapshot(`
|
|
265
|
+
{
|
|
266
|
+
"current": "0xee570a0f26f17b41cdf0952a04ee01ea23495b0c0a59f9c904b0d60cb76453c3",
|
|
267
|
+
"initial": "0x79cc3a5fcbe18cb8cbbd2b41393750ccf3bbc20533a846755767fa10068ae01d",
|
|
268
|
+
}
|
|
269
|
+
`)
|
|
270
|
+
})
|
|
271
|
+
|
|
160
272
|
test('example: matches the frozen initial and current vectors', () => {
|
|
161
273
|
expect({
|
|
162
274
|
current: AccountConfig.getCommitment({ ...config, version: 1n }),
|
|
@@ -164,20 +276,40 @@ describe('getCommitment', () => {
|
|
|
164
276
|
initial: AccountConfig.getCommitment(config),
|
|
165
277
|
}).toMatchInlineSnapshot(`
|
|
166
278
|
{
|
|
167
|
-
"current": "
|
|
168
|
-
"currentNumber": "
|
|
169
|
-
"initial": "
|
|
279
|
+
"current": "0xee570a0f26f17b41cdf0952a04ee01ea23495b0c0a59f9c904b0d60cb76453c3",
|
|
280
|
+
"currentNumber": "0xee570a0f26f17b41cdf0952a04ee01ea23495b0c0a59f9c904b0d60cb76453c3",
|
|
281
|
+
"initial": "0x79cc3a5fcbe18cb8cbbd2b41393750ccf3bbc20533a846755767fa10068ae01d",
|
|
170
282
|
}
|
|
171
283
|
`)
|
|
172
284
|
})
|
|
173
285
|
})
|
|
174
286
|
|
|
175
287
|
describe('getSignPayload', () => {
|
|
288
|
+
test('example: matches the Tempo vectors', () => {
|
|
289
|
+
expect({
|
|
290
|
+
current: AccountConfig.getSignPayload({
|
|
291
|
+
account: tempo.account,
|
|
292
|
+
config: { version: 1n },
|
|
293
|
+
payload,
|
|
294
|
+
}),
|
|
295
|
+
initial: AccountConfig.getSignPayload({
|
|
296
|
+
account: tempo.account,
|
|
297
|
+
config,
|
|
298
|
+
payload,
|
|
299
|
+
}),
|
|
300
|
+
}).toMatchInlineSnapshot(`
|
|
301
|
+
{
|
|
302
|
+
"current": "0x285c850cb2803beb10f2f212dac73784a1a03b3991ba79081b24bfa91beb9182",
|
|
303
|
+
"initial": "0xe6fa513b5ab32da6f116443f13191096bce77b4850f4d51f3aa436fa7650c964",
|
|
304
|
+
}
|
|
305
|
+
`)
|
|
306
|
+
})
|
|
307
|
+
|
|
176
308
|
test('example: matches the frozen version-0 vector', () => {
|
|
177
309
|
expect(
|
|
178
310
|
AccountConfig.getSignPayload({ account, config, payload }),
|
|
179
311
|
).toMatchInlineSnapshot(
|
|
180
|
-
`"
|
|
312
|
+
`"0x32144254ec42f7a37b97e3a843667b527479f933320be553265e6594dc44ea87"`,
|
|
181
313
|
)
|
|
182
314
|
})
|
|
183
315
|
|
|
@@ -325,8 +457,8 @@ describe('assert/validate', () => {
|
|
|
325
457
|
valid: AccountConfig.validate(boundary),
|
|
326
458
|
}).toMatchInlineSnapshot(`
|
|
327
459
|
{
|
|
328
|
-
"account": "
|
|
329
|
-
"commitment": "
|
|
460
|
+
"account": "0x8400988285be93cba9391d445e473601633e5d62",
|
|
461
|
+
"commitment": "0xa9282ca5b73ac63b7e27f49cafa6ab13bd2aa79fc45267cf27342db73150cd46",
|
|
330
462
|
"rlpHash": "0xbaf0d030add91caaa10815d2e99c942f1e39b0d199216973781adb4fc1af6955",
|
|
331
463
|
"rlpLength": 1145,
|
|
332
464
|
"valid": true,
|
|
@@ -496,6 +628,7 @@ test('exports', () => {
|
|
|
496
628
|
"from",
|
|
497
629
|
"fromRpc",
|
|
498
630
|
"fromTuple",
|
|
631
|
+
"fromUpgrade",
|
|
499
632
|
"getAddress",
|
|
500
633
|
"getCommitment",
|
|
501
634
|
"getSignPayload",
|
package/tempo/AccountConfig.ts
CHANGED
|
@@ -33,17 +33,25 @@ export const signatureTypeByte = '0x05' as const
|
|
|
33
33
|
export const zeroSalt = `0x${'00'.repeat(32)}` as const
|
|
34
34
|
|
|
35
35
|
/** Domain prefix for the configurable account address derivation. */
|
|
36
|
-
const accountDomain = 'tempo:
|
|
36
|
+
const accountDomain = 'tempo:configurable-account:account'
|
|
37
37
|
|
|
38
38
|
/** Domain prefix for account configuration commitments. */
|
|
39
|
-
const configDomain = 'tempo:
|
|
39
|
+
const configDomain = 'tempo:configurable-account:config'
|
|
40
40
|
|
|
41
|
-
/**
|
|
42
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Keccak-256 of the account proxy creation code.
|
|
43
|
+
*
|
|
44
|
+
* Placeholder until [TIP-1110](https://tips.sh/1110) fixes the canonical
|
|
45
|
+
* account proxy, which will change every derived address.
|
|
46
|
+
*/
|
|
47
|
+
const accountProxyInitCodeHash =
|
|
43
48
|
'0x583cc63a2e37f645b43eac911b1a6d6de08b83abdc308c61364edda8cfc3bd37'
|
|
44
49
|
|
|
45
50
|
/** Domain prefix for configurable account owner approvals. */
|
|
46
|
-
const signatureDomain = 'tempo:
|
|
51
|
+
const signatureDomain = 'tempo:configurable-account:signature'
|
|
52
|
+
|
|
53
|
+
/** Domain prefix for the salt of an account migrated in place. */
|
|
54
|
+
const upgradeDomain = 'tempo:configurable-account:upgrade'
|
|
47
55
|
|
|
48
56
|
/**
|
|
49
57
|
* Complete account configuration witness.
|
|
@@ -335,12 +343,75 @@ export function fromTuple(tuple: Tuple): Config {
|
|
|
335
343
|
return config
|
|
336
344
|
}
|
|
337
345
|
|
|
346
|
+
/**
|
|
347
|
+
* Derives the configuration an existing account installs when it migrates in
|
|
348
|
+
* place with the `upgradeAccount` precompile call
|
|
349
|
+
* ([TIP-1113](https://tips.sh/1113)).
|
|
350
|
+
*
|
|
351
|
+
* The account keeps its address. Its salt is
|
|
352
|
+
* `keccak256("tempo:configurable-account:upgrade" || account)` and its version
|
|
353
|
+
* is `1n`. Owners are sorted into canonical order and the config is validated.
|
|
354
|
+
* The account itself may be listed as an owner.
|
|
355
|
+
*
|
|
356
|
+
* @example
|
|
357
|
+
* ```ts twoslash
|
|
358
|
+
* import { AccountConfig } from 'ox/tempo'
|
|
359
|
+
*
|
|
360
|
+
* const config = AccountConfig.fromUpgrade(
|
|
361
|
+
* '0x3333333333333333333333333333333333333333',
|
|
362
|
+
* {
|
|
363
|
+
* owners: [
|
|
364
|
+
* {
|
|
365
|
+
* owner: '0x1111111111111111111111111111111111111111',
|
|
366
|
+
* weight: 1
|
|
367
|
+
* }
|
|
368
|
+
* ],
|
|
369
|
+
* threshold: 1
|
|
370
|
+
* }
|
|
371
|
+
* )
|
|
372
|
+
* // config.version === 1n
|
|
373
|
+
* ```
|
|
374
|
+
*
|
|
375
|
+
* @param account - The account migrating in place.
|
|
376
|
+
* @param options - The owners and threshold to install.
|
|
377
|
+
* @returns The installed account config.
|
|
378
|
+
*/
|
|
379
|
+
export function fromUpgrade<numberType = number>(
|
|
380
|
+
account: Address.Address,
|
|
381
|
+
options: fromUpgrade.Options<numberType>,
|
|
382
|
+
): Config<1n, numberType> {
|
|
383
|
+
Address.assert(account)
|
|
384
|
+
return from({
|
|
385
|
+
owners: options.owners,
|
|
386
|
+
salt: Hash.keccak256(Hex.concat(Hex.fromString(upgradeDomain), account)),
|
|
387
|
+
threshold: options.threshold,
|
|
388
|
+
version: 1n,
|
|
389
|
+
})
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
export declare namespace fromUpgrade {
|
|
393
|
+
type Options<numberType = number> = {
|
|
394
|
+
/** Weighted owners to install. Sorted into canonical order. */
|
|
395
|
+
owners: readonly Owner<numberType>[]
|
|
396
|
+
/** Minimum total owner weight required for authorization. */
|
|
397
|
+
threshold: numberType
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
type ErrorType =
|
|
401
|
+
| Address.assert.ErrorType
|
|
402
|
+
| assert.ErrorType
|
|
403
|
+
| Hash.keccak256.ErrorType
|
|
404
|
+
| Hex.concat.ErrorType
|
|
405
|
+
| Hex.fromString.ErrorType
|
|
406
|
+
| Errors.GlobalErrorType
|
|
407
|
+
}
|
|
408
|
+
|
|
338
409
|
/**
|
|
339
410
|
* Derives the stable configurable account address.
|
|
340
411
|
*
|
|
341
412
|
* The initial config is hashed into a CREATE2 salt using fixed-width
|
|
342
413
|
* big-endian fields, not RLP. The account uses the chain-configured recovery
|
|
343
|
-
* factory and
|
|
414
|
+
* factory and account proxy init-code hash.
|
|
344
415
|
*
|
|
345
416
|
* The address is derived once from the initial version-0 config. Config
|
|
346
417
|
* updates do not change it.
|
|
@@ -388,7 +459,7 @@ export function getAddress(
|
|
|
388
459
|
),
|
|
389
460
|
)
|
|
390
461
|
const account = ContractAddress.fromCreate2({
|
|
391
|
-
bytecodeHash:
|
|
462
|
+
bytecodeHash: accountProxyInitCodeHash,
|
|
392
463
|
from: options.factory,
|
|
393
464
|
salt: accountSalt,
|
|
394
465
|
})
|
|
@@ -421,7 +492,7 @@ export declare namespace getAddress {
|
|
|
421
492
|
* Computes the commitment for an account configuration.
|
|
422
493
|
*
|
|
423
494
|
* The commitment uses raw fixed-width fields, not RLP or ABI encoding:
|
|
424
|
-
* `keccak256("tempo:
|
|
495
|
+
* `keccak256("tempo:configurable-account:config" || salt || uint64be(version) || uint8(threshold) || uint8(owners.length) || owners)`.
|
|
425
496
|
*
|
|
426
497
|
* @example
|
|
427
498
|
* ```ts twoslash
|
|
@@ -469,7 +540,7 @@ export declare namespace getCommitment {
|
|
|
469
540
|
/**
|
|
470
541
|
* Computes the digest a configurable account owner approves (signs).
|
|
471
542
|
*
|
|
472
|
-
* `keccak256("tempo:
|
|
543
|
+
* `keccak256("tempo:configurable-account:signature" || inner_digest || account || uint64be(version))`,
|
|
473
544
|
* where `inner_digest` is the transaction sign payload
|
|
474
545
|
* ({@link ox#TxEnvelopeTempo.(getSignPayload:function)}).
|
|
475
546
|
*
|
|
@@ -150,8 +150,8 @@ describe('getHash', () => {
|
|
|
150
150
|
}),
|
|
151
151
|
}).toMatchInlineSnapshot(`
|
|
152
152
|
{
|
|
153
|
-
"keyAuthorization": "
|
|
154
|
-
"transaction": "
|
|
153
|
+
"keyAuthorization": "0xd18f389ae23bdc81939861c9a1079201968a2ec5fbd67ad1063556b46af8914f",
|
|
154
|
+
"transaction": "0x246027f7c6940fb4b68a746c49819c1c45737aa6c975aafcce721b4a619a9ab1",
|
|
155
155
|
}
|
|
156
156
|
`)
|
|
157
157
|
})
|
|
@@ -342,14 +342,14 @@ describe('serializeKeyAuthorization', () => {
|
|
|
342
342
|
expect(results).toMatchInlineSnapshot(`
|
|
343
343
|
[
|
|
344
344
|
{
|
|
345
|
-
"account": "
|
|
346
|
-
"hash": "
|
|
345
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
346
|
+
"hash": "0x8d72c92f8aca5cf651ff914a928a32b1717e51b70fce97e305aaab02617474f5",
|
|
347
347
|
"signatureCount": 2,
|
|
348
348
|
"version": 1n,
|
|
349
349
|
},
|
|
350
350
|
{
|
|
351
|
-
"account": "
|
|
352
|
-
"hash": "
|
|
351
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
352
|
+
"hash": "0x1dce79ae000bb60526cbe3b18be29d517319ee0958b01e5e3e89608e19c13459",
|
|
353
353
|
"signatureCount": 2,
|
|
354
354
|
"version": 0n,
|
|
355
355
|
},
|
|
@@ -443,15 +443,15 @@ describe('serializeTransaction', () => {
|
|
|
443
443
|
expect(results).toMatchInlineSnapshot(`
|
|
444
444
|
[
|
|
445
445
|
{
|
|
446
|
-
"account": "
|
|
447
|
-
"hash": "
|
|
446
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
447
|
+
"hash": "0x75106153400c34efbeb7380828e3fef939340eb0a3a42dda6a22f798f94665d0",
|
|
448
448
|
"signatureCount": 2,
|
|
449
449
|
"type": "0x76",
|
|
450
450
|
"version": 1n,
|
|
451
451
|
},
|
|
452
452
|
{
|
|
453
|
-
"account": "
|
|
454
|
-
"hash": "
|
|
453
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
454
|
+
"hash": "0x2718b956492b1f8ff4e25165ac425e9e7064580b76eb087ce764e263723152bc",
|
|
455
455
|
"signatureCount": 2,
|
|
456
456
|
"type": "0x76",
|
|
457
457
|
"version": 0n,
|
|
@@ -528,7 +528,7 @@ describe('serializeTransaction', () => {
|
|
|
528
528
|
[
|
|
529
529
|
{
|
|
530
530
|
"feePayerSignature": null,
|
|
531
|
-
"from": "
|
|
531
|
+
"from": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
532
532
|
"signatureCount": 2,
|
|
533
533
|
"type": "0x78",
|
|
534
534
|
},
|
|
@@ -538,7 +538,7 @@ describe('serializeTransaction', () => {
|
|
|
538
538
|
"s": 6n,
|
|
539
539
|
"yParity": 0,
|
|
540
540
|
},
|
|
541
|
-
"from": "
|
|
541
|
+
"from": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
542
542
|
"signatureCount": 2,
|
|
543
543
|
"type": "0x78",
|
|
544
544
|
},
|
|
@@ -610,7 +610,7 @@ describe('from', () => {
|
|
|
610
610
|
expect({ pending, submitting, success }).toMatchInlineSnapshot(`
|
|
611
611
|
{
|
|
612
612
|
"pending": {
|
|
613
|
-
"account": "
|
|
613
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
614
614
|
"approvals": [
|
|
615
615
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
616
616
|
],
|
|
@@ -630,7 +630,7 @@ describe('from', () => {
|
|
|
630
630
|
"version": 1n,
|
|
631
631
|
},
|
|
632
632
|
"createdAt": 1,
|
|
633
|
-
"hash": "
|
|
633
|
+
"hash": "0x246027f7c6940fb4b68a746c49819c1c45737aa6c975aafcce721b4a619a9ab1",
|
|
634
634
|
"signatureCount": 1,
|
|
635
635
|
"status": "pending",
|
|
636
636
|
"threshold": 2,
|
|
@@ -640,7 +640,7 @@ describe('from', () => {
|
|
|
640
640
|
"weight": 1,
|
|
641
641
|
},
|
|
642
642
|
"submitting": {
|
|
643
|
-
"account": "
|
|
643
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
644
644
|
"approvals": [
|
|
645
645
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
646
646
|
"0x01000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
|
|
@@ -662,7 +662,7 @@ describe('from', () => {
|
|
|
662
662
|
},
|
|
663
663
|
"createdAt": 1,
|
|
664
664
|
"expiresAt": 10,
|
|
665
|
-
"hash": "
|
|
665
|
+
"hash": "0x246027f7c6940fb4b68a746c49819c1c45737aa6c975aafcce721b4a619a9ab1",
|
|
666
666
|
"signatureCount": 2,
|
|
667
667
|
"status": "submitting",
|
|
668
668
|
"submissionId": "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
|
@@ -673,7 +673,7 @@ describe('from', () => {
|
|
|
673
673
|
"weight": 2,
|
|
674
674
|
},
|
|
675
675
|
"success": {
|
|
676
|
-
"account": "
|
|
676
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
677
677
|
"approvals": [
|
|
678
678
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
679
679
|
"0x01000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
|
|
@@ -694,7 +694,7 @@ describe('from', () => {
|
|
|
694
694
|
"version": 1n,
|
|
695
695
|
},
|
|
696
696
|
"createdAt": 1,
|
|
697
|
-
"hash": "
|
|
697
|
+
"hash": "0x246027f7c6940fb4b68a746c49819c1c45737aa6c975aafcce721b4a619a9ab1",
|
|
698
698
|
"signatureCount": 2,
|
|
699
699
|
"status": "success",
|
|
700
700
|
"threshold": 2,
|
|
@@ -735,7 +735,7 @@ describe('from', () => {
|
|
|
735
735
|
},
|
|
736
736
|
`
|
|
737
737
|
{
|
|
738
|
-
"account": "
|
|
738
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
739
739
|
"approvals": [
|
|
740
740
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
741
741
|
],
|
|
@@ -812,7 +812,7 @@ describe('from', () => {
|
|
|
812
812
|
},
|
|
813
813
|
`
|
|
814
814
|
{
|
|
815
|
-
"account": "
|
|
815
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
816
816
|
"approvals": [
|
|
817
817
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
818
818
|
],
|
|
@@ -869,7 +869,7 @@ describe('from', () => {
|
|
|
869
869
|
expect({ pending, success }).toMatchInlineSnapshot(`
|
|
870
870
|
{
|
|
871
871
|
"pending": {
|
|
872
|
-
"account": "
|
|
872
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
873
873
|
"approvals": [
|
|
874
874
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
875
875
|
],
|
|
@@ -889,8 +889,8 @@ describe('from', () => {
|
|
|
889
889
|
"version": 1n,
|
|
890
890
|
},
|
|
891
891
|
"createdAt": 1,
|
|
892
|
-
"hash": "
|
|
893
|
-
"keyAuthorization": "
|
|
892
|
+
"hash": "0xd18f389ae23bdc81939861c9a1079201968a2ec5fbd67ad1063556b46af8914f",
|
|
893
|
+
"keyAuthorization": "0xf838f782107980943333333333333333333333333333333333333333846b49d20080808080940f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
894
894
|
"signatureCount": 1,
|
|
895
895
|
"status": "pending",
|
|
896
896
|
"threshold": 2,
|
|
@@ -899,7 +899,7 @@ describe('from', () => {
|
|
|
899
899
|
"weight": 1,
|
|
900
900
|
},
|
|
901
901
|
"success": {
|
|
902
|
-
"account": "
|
|
902
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
903
903
|
"approvals": [
|
|
904
904
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
905
905
|
"0x01000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
|
|
@@ -920,8 +920,8 @@ describe('from', () => {
|
|
|
920
920
|
"version": 1n,
|
|
921
921
|
},
|
|
922
922
|
"createdAt": 1,
|
|
923
|
-
"hash": "
|
|
924
|
-
"keyAuthorization": "
|
|
923
|
+
"hash": "0xd18f389ae23bdc81939861c9a1079201968a2ec5fbd67ad1063556b46af8914f",
|
|
924
|
+
"keyAuthorization": "0xf901b3f782107980943333333333333333333333333333333333333333846b49d20080808080940f8659dd87410f00a1668211ecda7ac7f9c9fd13b9017805f90174940f8659dd87410f00a1668211ecda7ac7f9c9fd13f852a000000000000000000000000000000000000000000000000000000000000000000102eed69407e1ed8ea0e9601e5546b0a03aed683df360140701d694288f0cd85005f34168f731a468aef268c2f9456f01f90108b88201000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200b88201000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
|
|
925
925
|
"signatureCount": 2,
|
|
926
926
|
"status": "success",
|
|
927
927
|
"threshold": 2,
|
|
@@ -967,7 +967,7 @@ describe('from', () => {
|
|
|
967
967
|
},
|
|
968
968
|
`
|
|
969
969
|
{
|
|
970
|
-
"account": "
|
|
970
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
971
971
|
"approvals": [
|
|
972
972
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
973
973
|
"0x01000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
|
|
@@ -1013,7 +1013,7 @@ describe('RPC conversion', () => {
|
|
|
1013
1013
|
expect({ keyAuthorizationRpc, transactionRpc }).toMatchInlineSnapshot(`
|
|
1014
1014
|
{
|
|
1015
1015
|
"keyAuthorizationRpc": {
|
|
1016
|
-
"account": "
|
|
1016
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
1017
1017
|
"approvals": [
|
|
1018
1018
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
1019
1019
|
],
|
|
@@ -1033,8 +1033,8 @@ describe('RPC conversion', () => {
|
|
|
1033
1033
|
"version": "0x1",
|
|
1034
1034
|
},
|
|
1035
1035
|
"createdAt": 1,
|
|
1036
|
-
"hash": "
|
|
1037
|
-
"keyAuthorization": "
|
|
1036
|
+
"hash": "0xd18f389ae23bdc81939861c9a1079201968a2ec5fbd67ad1063556b46af8914f",
|
|
1037
|
+
"keyAuthorization": "0xf838f782107980943333333333333333333333333333333333333333846b49d20080808080940f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
1038
1038
|
"signatureCount": 1,
|
|
1039
1039
|
"status": "pending",
|
|
1040
1040
|
"threshold": 2,
|
|
@@ -1043,7 +1043,7 @@ describe('RPC conversion', () => {
|
|
|
1043
1043
|
"weight": 1,
|
|
1044
1044
|
},
|
|
1045
1045
|
"transactionRpc": {
|
|
1046
|
-
"account": "
|
|
1046
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
1047
1047
|
"approvals": [
|
|
1048
1048
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
1049
1049
|
],
|
|
@@ -1063,7 +1063,7 @@ describe('RPC conversion', () => {
|
|
|
1063
1063
|
"version": "0x1",
|
|
1064
1064
|
},
|
|
1065
1065
|
"createdAt": 1,
|
|
1066
|
-
"hash": "
|
|
1066
|
+
"hash": "0x246027f7c6940fb4b68a746c49819c1c45737aa6c975aafcce721b4a619a9ab1",
|
|
1067
1067
|
"signatureCount": 1,
|
|
1068
1068
|
"status": "pending",
|
|
1069
1069
|
"threshold": 2,
|
|
@@ -113,6 +113,26 @@ describe('fromRpc', () => {
|
|
|
113
113
|
})
|
|
114
114
|
|
|
115
115
|
describe('toRpc', () => {
|
|
116
|
+
test('behavior: round-trips the grant signer', () => {
|
|
117
|
+
const signer = '0x2222222222222222222222222222222222222222'
|
|
118
|
+
const spec = AccountSimulation.fromRpc({ ...rpc, signer })
|
|
119
|
+
expect(spec.signer).toBe(signer)
|
|
120
|
+
expect(AccountSimulation.toRpc(spec).signer).toBe(signer)
|
|
121
|
+
expect(
|
|
122
|
+
'signer' in AccountSimulation.toRpc(AccountSimulation.fromRpc(rpc)),
|
|
123
|
+
).toBe(false)
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
test('error: rejects an invalid grant signer', () => {
|
|
127
|
+
expect(() =>
|
|
128
|
+
AccountSimulation.fromRpc({ ...rpc, signer: '0x1234' }),
|
|
129
|
+
).toThrowErrorMatchingInlineSnapshot(`
|
|
130
|
+
[Address.InvalidAddressError: Address "0x1234" is invalid.
|
|
131
|
+
|
|
132
|
+
Details: Address is not a 20 byte (40 hexadecimal character) value.]
|
|
133
|
+
`)
|
|
134
|
+
})
|
|
135
|
+
|
|
116
136
|
test('behavior: encodes configurations and shims long key data', () => {
|
|
117
137
|
expect(
|
|
118
138
|
AccountSimulation.toRpc(AccountSimulation.fromRpc(rpc)),
|
|
@@ -147,6 +167,30 @@ describe('toRpc', () => {
|
|
|
147
167
|
`)
|
|
148
168
|
})
|
|
149
169
|
|
|
170
|
+
test('behavior: shims key data that is not a valid length hint', () => {
|
|
171
|
+
const keyData = (keyData: `0x${string}`) =>
|
|
172
|
+
AccountSimulation.toRpc(
|
|
173
|
+
AccountSimulation.fromRpc({
|
|
174
|
+
...rpc,
|
|
175
|
+
approvals: [{ ...rpc.approvals[0], keyData }],
|
|
176
|
+
}),
|
|
177
|
+
).approvals[0]?.keyData
|
|
178
|
+
|
|
179
|
+
expect({
|
|
180
|
+
empty: keyData('0x'),
|
|
181
|
+
four: keyData('0x01020304'),
|
|
182
|
+
one: keyData('0x01'),
|
|
183
|
+
three: keyData('0x010203'),
|
|
184
|
+
}).toMatchInlineSnapshot(`
|
|
185
|
+
{
|
|
186
|
+
"empty": "0x0000",
|
|
187
|
+
"four": "0x01020304",
|
|
188
|
+
"one": "0x01",
|
|
189
|
+
"three": "0x0003",
|
|
190
|
+
}
|
|
191
|
+
`)
|
|
192
|
+
})
|
|
193
|
+
|
|
150
194
|
test('behavior: encodes the maximum uint64 configuration version', () => {
|
|
151
195
|
const spec = AccountSimulation.fromRpc(rpc)
|
|
152
196
|
|