ox 1.8.7 → 1.8.9
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 +25 -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/AccountConfig.d.ts +46 -3
- package/dist/tempo/AccountConfig.d.ts.map +1 -1
- package/dist/tempo/AccountConfig.js +58 -9
- package/dist/tempo/AccountConfig.js.map +1 -1
- package/dist/tempo/AccountSimulation.d.ts +6 -2
- package/dist/tempo/AccountSimulation.d.ts.map +1 -1
- package/dist/tempo/AccountSimulation.js +15 -5
- package/dist/tempo/AccountSimulation.js.map +1 -1
- package/dist/tempo/KeyAuthorization.d.ts +14 -9
- package/dist/tempo/KeyAuthorization.d.ts.map +1 -1
- package/dist/tempo/KeyAuthorization.js +8 -12
- package/dist/tempo/KeyAuthorization.js.map +1 -1
- package/dist/tempo/TransactionRequest.d.ts +3 -3
- package/dist/tempo/TransactionRequest.d.ts.map +1 -1
- package/dist/tempo/TransactionRequest.js +10 -6
- package/dist/tempo/TransactionRequest.js.map +1 -1
- package/dist/zod/tempo/AccountSimulation.d.ts +4 -0
- package/dist/zod/tempo/AccountSimulation.d.ts.map +1 -1
- package/dist/zod/tempo/AccountSimulation.js +2 -0
- package/dist/zod/tempo/AccountSimulation.js.map +1 -1
- package/dist/zod/tempo/KeyAuthorization.d.ts +5 -5
- package/dist/zod/tempo/KeyAuthorization.d.ts.map +1 -1
- package/dist/zod/tempo/KeyAuthorization.js +10 -13
- package/dist/zod/tempo/KeyAuthorization.js.map +1 -1
- package/dist/zod/tempo/RpcSchemaTempo.d.ts +16 -8
- package/dist/zod/tempo/RpcSchemaTempo.d.ts.map +1 -1
- package/dist/zod/tempo/Transaction.d.ts +6 -6
- package/dist/zod/tempo/TransactionRequest.d.ts +23 -9
- package/dist/zod/tempo/TransactionRequest.d.ts.map +1 -1
- package/dist/zod/tempo/TransactionRequest.js +13 -9
- package/dist/zod/tempo/TransactionRequest.js.map +1 -1
- package/package.json +1 -1
- 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/AccountConfig.test-d.ts +10 -0
- package/src/tempo/AccountConfig.test.ts +143 -10
- package/src/tempo/AccountConfig.ts +80 -9
- package/src/tempo/AccountOperation.test.ts +32 -32
- package/src/tempo/AccountSimulation.test.ts +43 -0
- package/src/tempo/AccountSimulation.ts +19 -5
- package/src/tempo/KeyAuthorization.test.ts +91 -32
- package/src/tempo/KeyAuthorization.ts +16 -39
- package/src/tempo/RpcSchemaTempo.test-d.ts +2 -2
- package/src/tempo/TransactionRequest.test-d.ts +5 -5
- package/src/tempo/TransactionRequest.test.ts +11 -9
- package/src/tempo/TransactionRequest.ts +13 -9
- package/src/version.ts +1 -1
- package/src/zod/tempo/AccountSimulation.ts +2 -0
- package/src/zod/tempo/KeyAuthorization.ts +28 -46
- package/src/zod/tempo/TransactionRequest.ts +17 -9
- package/src/zod/tempo/_test/AccountOperation.test.ts +1 -1
- package/src/zod/tempo/_test/KeyAuthorization.test.ts +5 -5
- package/src/zod/tempo/_test/TransactionRequest.test.ts +12 -7
|
@@ -22,6 +22,16 @@ test('from returns a complete configuration', () => {
|
|
|
22
22
|
expectTypeOf(zero.version).toEqualTypeOf<0n>()
|
|
23
23
|
})
|
|
24
24
|
|
|
25
|
+
test('fromUpgrade returns a version-one configuration', () => {
|
|
26
|
+
const config = AccountConfig.fromUpgrade(
|
|
27
|
+
'0x3333333333333333333333333333333333333333',
|
|
28
|
+
input,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
expectTypeOf(config).toMatchTypeOf<AccountConfig.Config>()
|
|
32
|
+
expectTypeOf(config.version).toEqualTypeOf<1n>()
|
|
33
|
+
})
|
|
34
|
+
|
|
25
35
|
test('update returns the next complete configuration', () => {
|
|
26
36
|
const config = AccountConfig.update(AccountConfig.from(input), {
|
|
27
37
|
owners: input.owners,
|
|
@@ -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(
|
|
@@ -98,10 +105,103 @@ describe('fromRpc/toRpc', () => {
|
|
|
98
105
|
})
|
|
99
106
|
})
|
|
100
107
|
|
|
108
|
+
describe('fromUpgrade', () => {
|
|
109
|
+
const root = '0x3333333333333333333333333333333333333333'
|
|
110
|
+
|
|
111
|
+
test('example: derives the migrated config', () => {
|
|
112
|
+
// The root key may also be listed as an owner.
|
|
113
|
+
const config = AccountConfig.fromUpgrade(root, {
|
|
114
|
+
owners: [
|
|
115
|
+
{ owner: root, weight: 1 },
|
|
116
|
+
{ owner: owner_1, weight: 1 },
|
|
117
|
+
],
|
|
118
|
+
threshold: 2,
|
|
119
|
+
})
|
|
120
|
+
expect({
|
|
121
|
+
commitment: AccountConfig.getCommitment(config),
|
|
122
|
+
config,
|
|
123
|
+
}).toMatchInlineSnapshot(`
|
|
124
|
+
{
|
|
125
|
+
"commitment": "0xabca6d8f3a14b99ecaef378042e6a2ffa4f231125517e073cfbd3bcd69ac6ea1",
|
|
126
|
+
"config": {
|
|
127
|
+
"owners": [
|
|
128
|
+
{
|
|
129
|
+
"owner": "0x1111111111111111111111111111111111111111",
|
|
130
|
+
"weight": 1,
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"owner": "0x3333333333333333333333333333333333333333",
|
|
134
|
+
"weight": 1,
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
"salt": "0x42b3dad8fa6c40b50e6dbbbdaaace72d6c04250c16c1e263a52355983a30eb56",
|
|
138
|
+
"threshold": 2,
|
|
139
|
+
"version": 1n,
|
|
140
|
+
},
|
|
141
|
+
}
|
|
142
|
+
`)
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
test('behavior: binds the salt to the account', () => {
|
|
146
|
+
const options = {
|
|
147
|
+
owners: [{ owner: owner_1, weight: 1 }],
|
|
148
|
+
threshold: 1,
|
|
149
|
+
} as const
|
|
150
|
+
expect(AccountConfig.fromUpgrade(root, options).salt).not.toBe(
|
|
151
|
+
AccountConfig.fromUpgrade(owner_2, options).salt,
|
|
152
|
+
)
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
test('error: rejects an invalid account', () => {
|
|
156
|
+
expect(() =>
|
|
157
|
+
AccountConfig.fromUpgrade('0x1234', {
|
|
158
|
+
owners: [{ owner: owner_1, weight: 1 }],
|
|
159
|
+
threshold: 1,
|
|
160
|
+
}),
|
|
161
|
+
).toThrowErrorMatchingInlineSnapshot(`
|
|
162
|
+
[Address.InvalidAddressError: Address "0x1234" is invalid.
|
|
163
|
+
|
|
164
|
+
Details: Address is not a 20 byte (40 hexadecimal character) value.]
|
|
165
|
+
`)
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
test('error: rejects an invalid config', () => {
|
|
169
|
+
expect(() =>
|
|
170
|
+
AccountConfig.fromUpgrade(root, {
|
|
171
|
+
owners: [{ owner: owner_1, weight: 1 }],
|
|
172
|
+
threshold: 2,
|
|
173
|
+
}),
|
|
174
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
175
|
+
`[AccountConfig.InvalidConfigError: Invalid account config: threshold exceeds total owner weight.]`,
|
|
176
|
+
)
|
|
177
|
+
})
|
|
178
|
+
})
|
|
179
|
+
|
|
101
180
|
describe('getAddress', () => {
|
|
181
|
+
test('example: matches the Tempo vectors', () => {
|
|
182
|
+
expect({
|
|
183
|
+
maxOwners: AccountConfig.getAddress(
|
|
184
|
+
{
|
|
185
|
+
owners: Array.from({ length: AccountConfig.maxOwners }, (_, i) => ({
|
|
186
|
+
owner: Hex.padLeft(Hex.fromNumber(i + 1), 20),
|
|
187
|
+
weight: 1,
|
|
188
|
+
})),
|
|
189
|
+
threshold: 8,
|
|
190
|
+
},
|
|
191
|
+
{ factory: tempo.factory },
|
|
192
|
+
),
|
|
193
|
+
single: AccountConfig.getAddress(config, { factory: tempo.factory }),
|
|
194
|
+
}).toMatchInlineSnapshot(`
|
|
195
|
+
{
|
|
196
|
+
"maxOwners": "0x7a4279bb3f1b8b54d703484317f64eae6814e827",
|
|
197
|
+
"single": "0x87c346a9029d675f296db533b12e146439cf20d5",
|
|
198
|
+
}
|
|
199
|
+
`)
|
|
200
|
+
})
|
|
201
|
+
|
|
102
202
|
test('example: matches the frozen CREATE2 vector', () => {
|
|
103
203
|
expect(account).toMatchInlineSnapshot(
|
|
104
|
-
`"
|
|
204
|
+
`"0x2318ebe50d1d476ec10854bfd949f96ea7737b68"`,
|
|
105
205
|
)
|
|
106
206
|
expect(account).not.toBe('0x8820d1497eeaf4f68e00b2cfc00a2f3b1dbb00da')
|
|
107
207
|
})
|
|
@@ -119,7 +219,7 @@ describe('getAddress', () => {
|
|
|
119
219
|
},
|
|
120
220
|
{ factory },
|
|
121
221
|
),
|
|
122
|
-
).toMatchInlineSnapshot(`"
|
|
222
|
+
).toMatchInlineSnapshot(`"0x1baa996a4f142d99999aa22f1cb1eb97eed2a24a"`)
|
|
123
223
|
})
|
|
124
224
|
|
|
125
225
|
test('behavior: is stable and binds the salt', () => {
|
|
@@ -134,8 +234,8 @@ describe('getAddress', () => {
|
|
|
134
234
|
),
|
|
135
235
|
}).toMatchInlineSnapshot(`
|
|
136
236
|
{
|
|
137
|
-
"repeated": "
|
|
138
|
-
"salted": "
|
|
237
|
+
"repeated": "0x2318ebe50d1d476ec10854bfd949f96ea7737b68",
|
|
238
|
+
"salted": "0x70d2e44032514493b68641ce5182cc878baa51f0",
|
|
139
239
|
}
|
|
140
240
|
`)
|
|
141
241
|
})
|
|
@@ -156,6 +256,18 @@ describe('getAddress', () => {
|
|
|
156
256
|
})
|
|
157
257
|
|
|
158
258
|
describe('getCommitment', () => {
|
|
259
|
+
test('example: matches the Tempo vectors', () => {
|
|
260
|
+
expect({
|
|
261
|
+
current: AccountConfig.getCommitment({ ...config, version: 1n }),
|
|
262
|
+
initial: AccountConfig.getCommitment(config),
|
|
263
|
+
}).toMatchInlineSnapshot(`
|
|
264
|
+
{
|
|
265
|
+
"current": "0xee570a0f26f17b41cdf0952a04ee01ea23495b0c0a59f9c904b0d60cb76453c3",
|
|
266
|
+
"initial": "0x79cc3a5fcbe18cb8cbbd2b41393750ccf3bbc20533a846755767fa10068ae01d",
|
|
267
|
+
}
|
|
268
|
+
`)
|
|
269
|
+
})
|
|
270
|
+
|
|
159
271
|
test('example: matches the frozen initial and current vectors', () => {
|
|
160
272
|
expect({
|
|
161
273
|
current: AccountConfig.getCommitment({ ...config, version: 1n }),
|
|
@@ -163,20 +275,40 @@ describe('getCommitment', () => {
|
|
|
163
275
|
initial: AccountConfig.getCommitment(config),
|
|
164
276
|
}).toMatchInlineSnapshot(`
|
|
165
277
|
{
|
|
166
|
-
"current": "
|
|
167
|
-
"currentNumber": "
|
|
168
|
-
"initial": "
|
|
278
|
+
"current": "0xee570a0f26f17b41cdf0952a04ee01ea23495b0c0a59f9c904b0d60cb76453c3",
|
|
279
|
+
"currentNumber": "0xee570a0f26f17b41cdf0952a04ee01ea23495b0c0a59f9c904b0d60cb76453c3",
|
|
280
|
+
"initial": "0x79cc3a5fcbe18cb8cbbd2b41393750ccf3bbc20533a846755767fa10068ae01d",
|
|
169
281
|
}
|
|
170
282
|
`)
|
|
171
283
|
})
|
|
172
284
|
})
|
|
173
285
|
|
|
174
286
|
describe('getSignPayload', () => {
|
|
287
|
+
test('example: matches the Tempo vectors', () => {
|
|
288
|
+
expect({
|
|
289
|
+
current: AccountConfig.getSignPayload({
|
|
290
|
+
account: tempo.account,
|
|
291
|
+
config: { version: 1n },
|
|
292
|
+
payload,
|
|
293
|
+
}),
|
|
294
|
+
initial: AccountConfig.getSignPayload({
|
|
295
|
+
account: tempo.account,
|
|
296
|
+
config,
|
|
297
|
+
payload,
|
|
298
|
+
}),
|
|
299
|
+
}).toMatchInlineSnapshot(`
|
|
300
|
+
{
|
|
301
|
+
"current": "0x285c850cb2803beb10f2f212dac73784a1a03b3991ba79081b24bfa91beb9182",
|
|
302
|
+
"initial": "0xe6fa513b5ab32da6f116443f13191096bce77b4850f4d51f3aa436fa7650c964",
|
|
303
|
+
}
|
|
304
|
+
`)
|
|
305
|
+
})
|
|
306
|
+
|
|
175
307
|
test('example: matches the frozen version-0 vector', () => {
|
|
176
308
|
expect(
|
|
177
309
|
AccountConfig.getSignPayload({ account, config, payload }),
|
|
178
310
|
).toMatchInlineSnapshot(
|
|
179
|
-
`"
|
|
311
|
+
`"0x32144254ec42f7a37b97e3a843667b527479f933320be553265e6594dc44ea87"`,
|
|
180
312
|
)
|
|
181
313
|
})
|
|
182
314
|
|
|
@@ -324,8 +456,8 @@ describe('assert/validate', () => {
|
|
|
324
456
|
valid: AccountConfig.validate(boundary),
|
|
325
457
|
}).toMatchInlineSnapshot(`
|
|
326
458
|
{
|
|
327
|
-
"account": "
|
|
328
|
-
"commitment": "
|
|
459
|
+
"account": "0x8400988285be93cba9391d445e473601633e5d62",
|
|
460
|
+
"commitment": "0xa9282ca5b73ac63b7e27f49cafa6ab13bd2aa79fc45267cf27342db73150cd46",
|
|
329
461
|
"rlpHash": "0xbaf0d030add91caaa10815d2e99c942f1e39b0d199216973781adb4fc1af6955",
|
|
330
462
|
"rlpLength": 1145,
|
|
331
463
|
"valid": true,
|
|
@@ -495,6 +627,7 @@ test('exports', () => {
|
|
|
495
627
|
"from",
|
|
496
628
|
"fromRpc",
|
|
497
629
|
"fromTuple",
|
|
630
|
+
"fromUpgrade",
|
|
498
631
|
"getAddress",
|
|
499
632
|
"getCommitment",
|
|
500
633
|
"getSignPayload",
|
|
@@ -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.
|
|
@@ -347,12 +355,75 @@ export function fromTuple(tuple: Tuple): Config {
|
|
|
347
355
|
return config
|
|
348
356
|
}
|
|
349
357
|
|
|
358
|
+
/**
|
|
359
|
+
* Derives the configuration an existing account installs when it migrates in
|
|
360
|
+
* place with the `upgradeAccount` precompile call
|
|
361
|
+
* ([TIP-1113](https://tips.sh/1113)).
|
|
362
|
+
*
|
|
363
|
+
* The account keeps its address. Its salt is
|
|
364
|
+
* `keccak256("tempo:configurable-account:upgrade" || account)` and its version
|
|
365
|
+
* is `1n`. Owners are sorted into canonical order and the config is validated.
|
|
366
|
+
* The account itself may be listed as an owner.
|
|
367
|
+
*
|
|
368
|
+
* @example
|
|
369
|
+
* ```ts twoslash
|
|
370
|
+
* import { AccountConfig } from 'ox/tempo'
|
|
371
|
+
*
|
|
372
|
+
* const config = AccountConfig.fromUpgrade(
|
|
373
|
+
* '0x3333333333333333333333333333333333333333',
|
|
374
|
+
* {
|
|
375
|
+
* owners: [
|
|
376
|
+
* {
|
|
377
|
+
* owner: '0x1111111111111111111111111111111111111111',
|
|
378
|
+
* weight: 1
|
|
379
|
+
* }
|
|
380
|
+
* ],
|
|
381
|
+
* threshold: 1
|
|
382
|
+
* }
|
|
383
|
+
* )
|
|
384
|
+
* // config.version === 1n
|
|
385
|
+
* ```
|
|
386
|
+
*
|
|
387
|
+
* @param account - The account migrating in place.
|
|
388
|
+
* @param options - The owners and threshold to install.
|
|
389
|
+
* @returns The installed account config.
|
|
390
|
+
*/
|
|
391
|
+
export function fromUpgrade<numberType = number>(
|
|
392
|
+
account: Address.Address,
|
|
393
|
+
options: fromUpgrade.Options<numberType>,
|
|
394
|
+
): Config<1n, numberType> {
|
|
395
|
+
Address.assert(account)
|
|
396
|
+
return from({
|
|
397
|
+
owners: options.owners,
|
|
398
|
+
salt: Hash.keccak256(Hex.concat(Hex.fromString(upgradeDomain), account)),
|
|
399
|
+
threshold: options.threshold,
|
|
400
|
+
version: 1n,
|
|
401
|
+
})
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
export declare namespace fromUpgrade {
|
|
405
|
+
type Options<numberType = number> = {
|
|
406
|
+
/** Weighted owners to install. Sorted into canonical order. */
|
|
407
|
+
owners: readonly Owner<numberType>[]
|
|
408
|
+
/** Minimum total owner weight required for authorization. */
|
|
409
|
+
threshold: numberType
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
type ErrorType =
|
|
413
|
+
| Address.assert.ErrorType
|
|
414
|
+
| assert.ErrorType
|
|
415
|
+
| Hash.keccak256.ErrorType
|
|
416
|
+
| Hex.concat.ErrorType
|
|
417
|
+
| Hex.fromString.ErrorType
|
|
418
|
+
| Errors.GlobalErrorType
|
|
419
|
+
}
|
|
420
|
+
|
|
350
421
|
/**
|
|
351
422
|
* Derives the stable configurable account address.
|
|
352
423
|
*
|
|
353
424
|
* The initial config is hashed into a CREATE2 salt using fixed-width
|
|
354
425
|
* big-endian fields, not RLP. The account uses the chain-configured recovery
|
|
355
|
-
* factory and
|
|
426
|
+
* factory and account proxy init-code hash.
|
|
356
427
|
*
|
|
357
428
|
* The address is derived once from the initial version-0 config. Config
|
|
358
429
|
* updates do not change it.
|
|
@@ -403,7 +474,7 @@ export function getAddress(
|
|
|
403
474
|
),
|
|
404
475
|
)
|
|
405
476
|
const account = ContractAddress.fromCreate2({
|
|
406
|
-
bytecodeHash:
|
|
477
|
+
bytecodeHash: accountProxyInitCodeHash,
|
|
407
478
|
from: options.factory,
|
|
408
479
|
salt: accountSalt,
|
|
409
480
|
})
|
|
@@ -436,7 +507,7 @@ export declare namespace getAddress {
|
|
|
436
507
|
* Computes the commitment for an account configuration.
|
|
437
508
|
*
|
|
438
509
|
* The commitment uses raw fixed-width fields, not RLP or ABI encoding:
|
|
439
|
-
* `keccak256("tempo:
|
|
510
|
+
* `keccak256("tempo:configurable-account:config" || salt || uint64be(version) || uint8(threshold) || uint8(owners.length) || owners)`.
|
|
440
511
|
*
|
|
441
512
|
* @example
|
|
442
513
|
* ```ts twoslash
|
|
@@ -487,7 +558,7 @@ export declare namespace getCommitment {
|
|
|
487
558
|
/**
|
|
488
559
|
* Computes the digest a configurable account owner approves (signs).
|
|
489
560
|
*
|
|
490
|
-
* `keccak256("tempo:
|
|
561
|
+
* `keccak256("tempo:configurable-account:signature" || inner_digest || account || uint64be(version))`,
|
|
491
562
|
* where `inner_digest` is the transaction sign payload
|
|
492
563
|
* ({@link ox#TxEnvelopeTempo.(getSignPayload:function)}).
|
|
493
564
|
*
|
|
@@ -153,8 +153,8 @@ describe('getHash', () => {
|
|
|
153
153
|
}),
|
|
154
154
|
}).toMatchInlineSnapshot(`
|
|
155
155
|
{
|
|
156
|
-
"keyAuthorization": "
|
|
157
|
-
"transaction": "
|
|
156
|
+
"keyAuthorization": "0xd18f389ae23bdc81939861c9a1079201968a2ec5fbd67ad1063556b46af8914f",
|
|
157
|
+
"transaction": "0x246027f7c6940fb4b68a746c49819c1c45737aa6c975aafcce721b4a619a9ab1",
|
|
158
158
|
}
|
|
159
159
|
`)
|
|
160
160
|
})
|
|
@@ -345,14 +345,14 @@ describe('serializeKeyAuthorization', () => {
|
|
|
345
345
|
expect(results).toMatchInlineSnapshot(`
|
|
346
346
|
[
|
|
347
347
|
{
|
|
348
|
-
"account": "
|
|
349
|
-
"hash": "
|
|
348
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
349
|
+
"hash": "0x8d72c92f8aca5cf651ff914a928a32b1717e51b70fce97e305aaab02617474f5",
|
|
350
350
|
"signatureCount": 2,
|
|
351
351
|
"version": 1n,
|
|
352
352
|
},
|
|
353
353
|
{
|
|
354
|
-
"account": "
|
|
355
|
-
"hash": "
|
|
354
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
355
|
+
"hash": "0x1dce79ae000bb60526cbe3b18be29d517319ee0958b01e5e3e89608e19c13459",
|
|
356
356
|
"signatureCount": 2,
|
|
357
357
|
"version": 0n,
|
|
358
358
|
},
|
|
@@ -446,15 +446,15 @@ describe('serializeTransaction', () => {
|
|
|
446
446
|
expect(results).toMatchInlineSnapshot(`
|
|
447
447
|
[
|
|
448
448
|
{
|
|
449
|
-
"account": "
|
|
450
|
-
"hash": "
|
|
449
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
450
|
+
"hash": "0x75106153400c34efbeb7380828e3fef939340eb0a3a42dda6a22f798f94665d0",
|
|
451
451
|
"signatureCount": 2,
|
|
452
452
|
"type": "0x76",
|
|
453
453
|
"version": 1n,
|
|
454
454
|
},
|
|
455
455
|
{
|
|
456
|
-
"account": "
|
|
457
|
-
"hash": "
|
|
456
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
457
|
+
"hash": "0x2718b956492b1f8ff4e25165ac425e9e7064580b76eb087ce764e263723152bc",
|
|
458
458
|
"signatureCount": 2,
|
|
459
459
|
"type": "0x76",
|
|
460
460
|
"version": 0n,
|
|
@@ -535,7 +535,7 @@ describe('serializeTransaction', () => {
|
|
|
535
535
|
[
|
|
536
536
|
{
|
|
537
537
|
"feePayerSignature": null,
|
|
538
|
-
"from": "
|
|
538
|
+
"from": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
539
539
|
"signatureCount": 2,
|
|
540
540
|
"type": "0x78",
|
|
541
541
|
},
|
|
@@ -545,7 +545,7 @@ describe('serializeTransaction', () => {
|
|
|
545
545
|
"s": "0x0000000000000000000000000000000000000000000000000000000000000006",
|
|
546
546
|
"yParity": 0,
|
|
547
547
|
},
|
|
548
|
-
"from": "
|
|
548
|
+
"from": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
549
549
|
"signatureCount": 2,
|
|
550
550
|
"type": "0x78",
|
|
551
551
|
},
|
|
@@ -617,7 +617,7 @@ describe('from', () => {
|
|
|
617
617
|
expect({ pending, submitting, success }).toMatchInlineSnapshot(`
|
|
618
618
|
{
|
|
619
619
|
"pending": {
|
|
620
|
-
"account": "
|
|
620
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
621
621
|
"approvals": [
|
|
622
622
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
623
623
|
],
|
|
@@ -637,7 +637,7 @@ describe('from', () => {
|
|
|
637
637
|
"version": 1n,
|
|
638
638
|
},
|
|
639
639
|
"createdAt": 1,
|
|
640
|
-
"hash": "
|
|
640
|
+
"hash": "0x246027f7c6940fb4b68a746c49819c1c45737aa6c975aafcce721b4a619a9ab1",
|
|
641
641
|
"signatureCount": 1,
|
|
642
642
|
"status": "pending",
|
|
643
643
|
"threshold": 2,
|
|
@@ -647,7 +647,7 @@ describe('from', () => {
|
|
|
647
647
|
"weight": 1,
|
|
648
648
|
},
|
|
649
649
|
"submitting": {
|
|
650
|
-
"account": "
|
|
650
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
651
651
|
"approvals": [
|
|
652
652
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
653
653
|
"0x01000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
|
|
@@ -669,7 +669,7 @@ describe('from', () => {
|
|
|
669
669
|
},
|
|
670
670
|
"createdAt": 1,
|
|
671
671
|
"expiresAt": 10,
|
|
672
|
-
"hash": "
|
|
672
|
+
"hash": "0x246027f7c6940fb4b68a746c49819c1c45737aa6c975aafcce721b4a619a9ab1",
|
|
673
673
|
"signatureCount": 2,
|
|
674
674
|
"status": "submitting",
|
|
675
675
|
"submissionId": "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
|
@@ -680,7 +680,7 @@ describe('from', () => {
|
|
|
680
680
|
"weight": 2,
|
|
681
681
|
},
|
|
682
682
|
"success": {
|
|
683
|
-
"account": "
|
|
683
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
684
684
|
"approvals": [
|
|
685
685
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
686
686
|
"0x01000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
|
|
@@ -701,7 +701,7 @@ describe('from', () => {
|
|
|
701
701
|
"version": 1n,
|
|
702
702
|
},
|
|
703
703
|
"createdAt": 1,
|
|
704
|
-
"hash": "
|
|
704
|
+
"hash": "0x246027f7c6940fb4b68a746c49819c1c45737aa6c975aafcce721b4a619a9ab1",
|
|
705
705
|
"signatureCount": 2,
|
|
706
706
|
"status": "success",
|
|
707
707
|
"threshold": 2,
|
|
@@ -747,7 +747,7 @@ describe('from', () => {
|
|
|
747
747
|
},
|
|
748
748
|
`
|
|
749
749
|
{
|
|
750
|
-
"account": "
|
|
750
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
751
751
|
"approvals": [
|
|
752
752
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
753
753
|
],
|
|
@@ -833,7 +833,7 @@ describe('from', () => {
|
|
|
833
833
|
},
|
|
834
834
|
`
|
|
835
835
|
{
|
|
836
|
-
"account": "
|
|
836
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
837
837
|
"approvals": [
|
|
838
838
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
839
839
|
],
|
|
@@ -890,7 +890,7 @@ describe('from', () => {
|
|
|
890
890
|
expect({ pending, success }).toMatchInlineSnapshot(`
|
|
891
891
|
{
|
|
892
892
|
"pending": {
|
|
893
|
-
"account": "
|
|
893
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
894
894
|
"approvals": [
|
|
895
895
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
896
896
|
],
|
|
@@ -910,8 +910,8 @@ describe('from', () => {
|
|
|
910
910
|
"version": 1n,
|
|
911
911
|
},
|
|
912
912
|
"createdAt": 1,
|
|
913
|
-
"hash": "
|
|
914
|
-
"keyAuthorization": "
|
|
913
|
+
"hash": "0xd18f389ae23bdc81939861c9a1079201968a2ec5fbd67ad1063556b46af8914f",
|
|
914
|
+
"keyAuthorization": "0xf838f782107980943333333333333333333333333333333333333333846b49d20080808080940f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
915
915
|
"signatureCount": 1,
|
|
916
916
|
"status": "pending",
|
|
917
917
|
"threshold": 2,
|
|
@@ -920,7 +920,7 @@ describe('from', () => {
|
|
|
920
920
|
"weight": 1,
|
|
921
921
|
},
|
|
922
922
|
"success": {
|
|
923
|
-
"account": "
|
|
923
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
924
924
|
"approvals": [
|
|
925
925
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
926
926
|
"0x01000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
|
|
@@ -941,8 +941,8 @@ describe('from', () => {
|
|
|
941
941
|
"version": 1n,
|
|
942
942
|
},
|
|
943
943
|
"createdAt": 1,
|
|
944
|
-
"hash": "
|
|
945
|
-
"keyAuthorization": "
|
|
944
|
+
"hash": "0xd18f389ae23bdc81939861c9a1079201968a2ec5fbd67ad1063556b46af8914f",
|
|
945
|
+
"keyAuthorization": "0xf901b3f782107980943333333333333333333333333333333333333333846b49d20080808080940f8659dd87410f00a1668211ecda7ac7f9c9fd13b9017805f90174940f8659dd87410f00a1668211ecda7ac7f9c9fd13f852a000000000000000000000000000000000000000000000000000000000000000000102eed69407e1ed8ea0e9601e5546b0a03aed683df360140701d694288f0cd85005f34168f731a468aef268c2f9456f01f90108b88201000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200b88201000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
|
|
946
946
|
"signatureCount": 2,
|
|
947
947
|
"status": "success",
|
|
948
948
|
"threshold": 2,
|
|
@@ -988,7 +988,7 @@ describe('from', () => {
|
|
|
988
988
|
},
|
|
989
989
|
`
|
|
990
990
|
{
|
|
991
|
-
"account": "
|
|
991
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
992
992
|
"approvals": [
|
|
993
993
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
994
994
|
"0x01000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000047cf27b188d034f7e8a52380304b51ac3c08969e277f21b35a60b48fc4766997807775510db8ed040293d9ac69f7430dbba7dade63ce982299e04b79d227873d100",
|
|
@@ -1034,7 +1034,7 @@ describe('RPC conversion', () => {
|
|
|
1034
1034
|
expect({ keyAuthorizationRpc, transactionRpc }).toMatchInlineSnapshot(`
|
|
1035
1035
|
{
|
|
1036
1036
|
"keyAuthorizationRpc": {
|
|
1037
|
-
"account": "
|
|
1037
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
1038
1038
|
"approvals": [
|
|
1039
1039
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
1040
1040
|
],
|
|
@@ -1054,8 +1054,8 @@ describe('RPC conversion', () => {
|
|
|
1054
1054
|
"version": "0x1",
|
|
1055
1055
|
},
|
|
1056
1056
|
"createdAt": 1,
|
|
1057
|
-
"hash": "
|
|
1058
|
-
"keyAuthorization": "
|
|
1057
|
+
"hash": "0xd18f389ae23bdc81939861c9a1079201968a2ec5fbd67ad1063556b46af8914f",
|
|
1058
|
+
"keyAuthorization": "0xf838f782107980943333333333333333333333333333333333333333846b49d20080808080940f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
1059
1059
|
"signatureCount": 1,
|
|
1060
1060
|
"status": "pending",
|
|
1061
1061
|
"threshold": 2,
|
|
@@ -1064,7 +1064,7 @@ describe('RPC conversion', () => {
|
|
|
1064
1064
|
"weight": 1,
|
|
1065
1065
|
},
|
|
1066
1066
|
"transactionRpc": {
|
|
1067
|
-
"account": "
|
|
1067
|
+
"account": "0x0f8659dd87410f00a1668211ecda7ac7f9c9fd13",
|
|
1068
1068
|
"approvals": [
|
|
1069
1069
|
"0x01000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000065ecbe4d1a6330a44c8f7ef951d4bf165e6c6b721efada985fb41661bc6e7fd6c8734640c4998ff7e374b06ce1a64a2ecd82ab036384fb83d9a79b127a27d503200",
|
|
1070
1070
|
],
|
|
@@ -1084,7 +1084,7 @@ describe('RPC conversion', () => {
|
|
|
1084
1084
|
"version": "0x1",
|
|
1085
1085
|
},
|
|
1086
1086
|
"createdAt": 1,
|
|
1087
|
-
"hash": "
|
|
1087
|
+
"hash": "0x246027f7c6940fb4b68a746c49819c1c45737aa6c975aafcce721b4a619a9ab1",
|
|
1088
1088
|
"signatureCount": 1,
|
|
1089
1089
|
"status": "pending",
|
|
1090
1090
|
"threshold": 2,
|
|
@@ -113,6 +113,25 @@ 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(() => AccountSimulation.fromRpc({ ...rpc, signer: '0x1234' }))
|
|
128
|
+
.toThrowErrorMatchingInlineSnapshot(`
|
|
129
|
+
[Address.InvalidAddressError: Address "0x1234" is invalid.
|
|
130
|
+
|
|
131
|
+
Details: Address is not a 20 byte (40 hexadecimal character) value.]
|
|
132
|
+
`)
|
|
133
|
+
})
|
|
134
|
+
|
|
116
135
|
test('behavior: encodes configurations and shims long key data', () => {
|
|
117
136
|
expect(AccountSimulation.toRpc(AccountSimulation.fromRpc(rpc)))
|
|
118
137
|
.toMatchInlineSnapshot(`
|
|
@@ -146,6 +165,30 @@ describe('toRpc', () => {
|
|
|
146
165
|
`)
|
|
147
166
|
})
|
|
148
167
|
|
|
168
|
+
test('behavior: shims key data that is not a valid length hint', () => {
|
|
169
|
+
const keyData = (keyData: `0x${string}`) =>
|
|
170
|
+
AccountSimulation.toRpc(
|
|
171
|
+
AccountSimulation.fromRpc({
|
|
172
|
+
...rpc,
|
|
173
|
+
approvals: [{ ...rpc.approvals[0], keyData }],
|
|
174
|
+
}),
|
|
175
|
+
).approvals[0]?.keyData
|
|
176
|
+
|
|
177
|
+
expect({
|
|
178
|
+
empty: keyData('0x'),
|
|
179
|
+
four: keyData('0x01020304'),
|
|
180
|
+
one: keyData('0x01'),
|
|
181
|
+
three: keyData('0x010203'),
|
|
182
|
+
}).toMatchInlineSnapshot(`
|
|
183
|
+
{
|
|
184
|
+
"empty": "0x0000",
|
|
185
|
+
"four": "0x01020304",
|
|
186
|
+
"one": "0x01",
|
|
187
|
+
"three": "0x0003",
|
|
188
|
+
}
|
|
189
|
+
`)
|
|
190
|
+
})
|
|
191
|
+
|
|
149
192
|
test('behavior: encodes the maximum uint64 configuration version', () => {
|
|
150
193
|
const spec = AccountSimulation.fromRpc(rpc)
|
|
151
194
|
|