ox 1.8.5 → 1.8.7
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 +37 -0
- 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 +37 -27
- package/dist/tempo/KeyAuthorization.d.ts.map +1 -1
- package/dist/tempo/KeyAuthorization.js +17 -19
- 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/TokenRole.d.ts +4 -2
- package/dist/tempo/TokenRole.d.ts.map +1 -1
- package/dist/tempo/TokenRole.js +4 -1
- package/dist/tempo/TokenRole.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/TokenRole.d.ts +1 -1
- package/dist/zod/tempo/TokenRole.d.ts.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/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 +15 -6
- package/src/tempo/KeyAuthorization.test.ts +117 -37
- package/src/tempo/KeyAuthorization.ts +68 -59
- 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/TokenRole.ts +4 -1
- 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/e2e.test.ts +32 -20
- 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,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
type
|
|
2
|
+
AccountConfig,
|
|
3
|
+
type AccountSimulation,
|
|
4
4
|
TransactionRequest,
|
|
5
5
|
} from 'ox/tempo'
|
|
6
6
|
import { describe, expect, test } from 'vp/test'
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const accountSimulationRpc = {
|
|
9
9
|
approvals: [
|
|
10
10
|
{
|
|
11
11
|
keyType: 'webAuthn',
|
|
@@ -15,9 +15,9 @@ const multisigSimulationRpc = {
|
|
|
15
15
|
],
|
|
16
16
|
config:
|
|
17
17
|
'0xf852a011111111111111111111111111111111111111111111111111111111111111118002eed694111111111111111111111111111111111111111101d694bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb01',
|
|
18
|
-
} as const satisfies
|
|
18
|
+
} as const satisfies AccountSimulation.Rpc
|
|
19
19
|
|
|
20
|
-
const
|
|
20
|
+
const accountSimulation = {
|
|
21
21
|
approvals: [
|
|
22
22
|
{
|
|
23
23
|
keyType: 'webAuthn',
|
|
@@ -25,7 +25,7 @@ const multisigSimulation = {
|
|
|
25
25
|
owner: '0x1111111111111111111111111111111111111111',
|
|
26
26
|
},
|
|
27
27
|
],
|
|
28
|
-
config:
|
|
28
|
+
config: AccountConfig.from({
|
|
29
29
|
owners: [
|
|
30
30
|
{
|
|
31
31
|
owner: '0x1111111111111111111111111111111111111111',
|
|
@@ -39,7 +39,7 @@ const multisigSimulation = {
|
|
|
39
39
|
salt: `0x${'11'.repeat(32)}`,
|
|
40
40
|
threshold: 2,
|
|
41
41
|
}),
|
|
42
|
-
} as const satisfies
|
|
42
|
+
} as const satisfies AccountSimulation.Spec
|
|
43
43
|
|
|
44
44
|
describe('fromRpc', () => {
|
|
45
45
|
test('default', () => {
|
|
@@ -139,14 +139,22 @@ describe('fromRpc', () => {
|
|
|
139
139
|
`)
|
|
140
140
|
})
|
|
141
141
|
|
|
142
|
-
test('behavior: multisig
|
|
142
|
+
test('behavior: multisig key type decodes as configurable', () => {
|
|
143
|
+
const request = TransactionRequest.fromRpc({
|
|
144
|
+
keyType: 'multisig',
|
|
145
|
+
type: '0x76',
|
|
146
|
+
})
|
|
147
|
+
expect(request.keyType).toMatchInlineSnapshot(`"configurable"`)
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
test('behavior: account simulation', () => {
|
|
143
151
|
const request = TransactionRequest.fromRpc({
|
|
144
152
|
from: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
|
|
145
|
-
multisigSimulation:
|
|
153
|
+
multisigSimulation: accountSimulationRpc,
|
|
146
154
|
type: '0x76',
|
|
147
155
|
})
|
|
148
156
|
|
|
149
|
-
expect(request.
|
|
157
|
+
expect(request.accountSimulation).toMatchInlineSnapshot(`
|
|
150
158
|
{
|
|
151
159
|
"approvals": [
|
|
152
160
|
{
|
|
@@ -258,10 +266,17 @@ describe('toRpc', () => {
|
|
|
258
266
|
`)
|
|
259
267
|
})
|
|
260
268
|
|
|
261
|
-
test('behavior: multisig
|
|
269
|
+
test('behavior: configurable key type encodes as multisig', () => {
|
|
270
|
+
const request = TransactionRequest.toRpc({
|
|
271
|
+
keyType: 'configurable',
|
|
272
|
+
})
|
|
273
|
+
expect(request.keyType).toMatchInlineSnapshot(`"multisig"`)
|
|
274
|
+
})
|
|
275
|
+
|
|
276
|
+
test('behavior: account simulation', () => {
|
|
262
277
|
const request = TransactionRequest.toRpc({
|
|
278
|
+
accountSimulation,
|
|
263
279
|
from: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
|
|
264
|
-
multisigSimulation,
|
|
265
280
|
})
|
|
266
281
|
|
|
267
282
|
expect(request).toMatchInlineSnapshot(`
|
|
@@ -386,8 +401,8 @@ describe('roundtrip', () => {
|
|
|
386
401
|
nonceKey: 255n,
|
|
387
402
|
gas: 100000n,
|
|
388
403
|
maxFeePerGas: 1000000000n,
|
|
389
|
-
keyAuthorizationSimulation:
|
|
390
|
-
|
|
404
|
+
keyAuthorizationSimulation: accountSimulation,
|
|
405
|
+
accountSimulation,
|
|
391
406
|
}
|
|
392
407
|
|
|
393
408
|
const rpc = TransactionRequest.toRpc(original)
|
|
@@ -411,7 +426,7 @@ describe('roundtrip', () => {
|
|
|
411
426
|
expect(converted.keyAuthorizationSimulation).toEqual(
|
|
412
427
|
original.keyAuthorizationSimulation,
|
|
413
428
|
)
|
|
414
|
-
expect(converted.
|
|
429
|
+
expect(converted.accountSimulation).toEqual(original.accountSimulation)
|
|
415
430
|
expect(converted.type).toBe('tempo')
|
|
416
431
|
})
|
|
417
432
|
|
|
@@ -429,8 +444,8 @@ describe('roundtrip', () => {
|
|
|
429
444
|
validAfter: '0x32',
|
|
430
445
|
nonceKey: '0xff',
|
|
431
446
|
gas: '0x186a0',
|
|
432
|
-
keyAuthorizationSimulation:
|
|
433
|
-
multisigSimulation:
|
|
447
|
+
keyAuthorizationSimulation: accountSimulationRpc,
|
|
448
|
+
multisigSimulation: accountSimulationRpc,
|
|
434
449
|
type: '0x76',
|
|
435
450
|
}
|
|
436
451
|
|
|
@@ -5,15 +5,15 @@ import * as Quantity from '../core/internal/quantity.js'
|
|
|
5
5
|
import type { Compute } from '../core/internal/types.js'
|
|
6
6
|
import * as Signature from '../core/Signature.js'
|
|
7
7
|
import * as ox_TransactionRequest from '../core/TransactionRequest.js'
|
|
8
|
+
import * as AccountSimulation from './AccountSimulation.js'
|
|
8
9
|
import * as AuthorizationTempo from './AuthorizationTempo.js'
|
|
9
10
|
import * as KeyAuthorization from './KeyAuthorization.js'
|
|
10
|
-
import * as MultisigSimulation from './MultisigSimulation.js'
|
|
11
11
|
import * as SignatureEnvelope from './SignatureEnvelope.js'
|
|
12
12
|
import * as Transaction from './Transaction.js'
|
|
13
13
|
import * as TxEnvelopeTempo from './TxEnvelopeTempo.js'
|
|
14
14
|
import type { Call } from './TxEnvelopeTempo.js'
|
|
15
15
|
|
|
16
|
-
type KeyType = SignatureEnvelope.Type | '
|
|
16
|
+
type KeyType = SignatureEnvelope.Type | 'configurable'
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* A Transaction Request that is generic to all transaction types.
|
|
@@ -32,6 +32,7 @@ export type TransactionRequest<
|
|
|
32
32
|
ox_TransactionRequest.TransactionRequest<bigintType, numberType, type>,
|
|
33
33
|
'authorizationList'
|
|
34
34
|
> & {
|
|
35
|
+
accountSimulation?: AccountSimulation.Spec | undefined
|
|
35
36
|
authorizationList?:
|
|
36
37
|
| AuthorizationTempo.ListSigned<bigintType, numberType>
|
|
37
38
|
| undefined
|
|
@@ -41,11 +42,10 @@ export type TransactionRequest<
|
|
|
41
42
|
feePayerSignature?: Signature.Signature<true, numberType> | null | undefined
|
|
42
43
|
feeToken?: Address.Address | undefined
|
|
43
44
|
keyAuthorization?: KeyAuthorization.KeyAuthorization<true> | undefined
|
|
44
|
-
keyAuthorizationSimulation?:
|
|
45
|
+
keyAuthorizationSimulation?: AccountSimulation.Spec | undefined
|
|
45
46
|
keyData?: Hex.Hex | undefined
|
|
46
47
|
keyId?: Address.Address | undefined
|
|
47
48
|
keyType?: KeyType | undefined
|
|
48
|
-
multisigSimulation?: MultisigSimulation.Spec | undefined
|
|
49
49
|
nonceKey?: 'random' | bigintType | undefined
|
|
50
50
|
signature?: SignatureEnvelope.SignatureEnvelope<numberType> | undefined
|
|
51
51
|
validAfter?: numberType | undefined
|
|
@@ -56,20 +56,23 @@ export type TransactionRequest<
|
|
|
56
56
|
/** RPC representation of a {@link ox#TransactionRequest.TransactionRequest}. */
|
|
57
57
|
export type Rpc = Omit<
|
|
58
58
|
TransactionRequest<Hex.Hex, Hex.Hex, string>,
|
|
59
|
+
| 'accountSimulation'
|
|
59
60
|
| 'authorizationList'
|
|
60
61
|
| 'feePayerSignature'
|
|
61
62
|
| 'feeToken'
|
|
62
63
|
| 'keyAuthorization'
|
|
63
|
-
| 'multisigSimulation'
|
|
64
64
|
| 'keyAuthorizationSimulation'
|
|
65
|
+
| 'keyType'
|
|
65
66
|
| 'signature'
|
|
66
67
|
> & {
|
|
67
68
|
authorizationList?: AuthorizationTempo.ListRpc | undefined
|
|
68
69
|
feePayerSignature?: Signature.Rpc | null | undefined
|
|
69
70
|
feeToken?: Hex.Hex | undefined
|
|
70
71
|
keyAuthorization?: KeyAuthorization.Rpc | undefined
|
|
71
|
-
keyAuthorizationSimulation?:
|
|
72
|
-
|
|
72
|
+
keyAuthorizationSimulation?: AccountSimulation.Rpc | undefined
|
|
73
|
+
/** Key type. Configurable accounts use the node's `multisig` key type. */
|
|
74
|
+
keyType?: SignatureEnvelope.Type | 'multisig' | undefined
|
|
75
|
+
multisigSimulation?: AccountSimulation.Rpc | undefined
|
|
73
76
|
nonceKey?: Hex.Hex | undefined
|
|
74
77
|
signature?: SignatureEnvelope.SignatureEnvelopeRpc | undefined
|
|
75
78
|
}
|
|
@@ -99,8 +102,9 @@ export type Rpc = Omit<
|
|
|
99
102
|
export function fromRpc(request: Rpc): TransactionRequest {
|
|
100
103
|
const {
|
|
101
104
|
authorizationList: _,
|
|
102
|
-
|
|
103
|
-
|
|
105
|
+
keyAuthorizationSimulation: __,
|
|
106
|
+
keyType: ___,
|
|
107
|
+
multisigSimulation: ____,
|
|
104
108
|
...rest
|
|
105
109
|
} = request
|
|
106
110
|
const request_ = ox_TransactionRequest.fromRpc(
|
|
@@ -138,11 +142,14 @@ export function fromRpc(request: Rpc): TransactionRequest {
|
|
|
138
142
|
request.keyAuthorization,
|
|
139
143
|
)
|
|
140
144
|
if (request.keyAuthorizationSimulation)
|
|
141
|
-
request_.keyAuthorizationSimulation =
|
|
145
|
+
request_.keyAuthorizationSimulation = AccountSimulation.fromRpc(
|
|
142
146
|
request.keyAuthorizationSimulation,
|
|
143
147
|
)
|
|
148
|
+
if (typeof request.keyType !== 'undefined')
|
|
149
|
+
request_.keyType =
|
|
150
|
+
request.keyType === 'multisig' ? 'configurable' : request.keyType
|
|
144
151
|
if (request.multisigSimulation)
|
|
145
|
-
request_.
|
|
152
|
+
request_.accountSimulation = AccountSimulation.fromRpc(
|
|
146
153
|
request.multisigSimulation,
|
|
147
154
|
)
|
|
148
155
|
if (typeof request.validBefore !== 'undefined')
|
|
@@ -160,7 +167,7 @@ export declare namespace fromRpc {
|
|
|
160
167
|
| AuthorizationTempo.fromRpcList.ErrorType
|
|
161
168
|
| Hex.toNumber.ErrorType
|
|
162
169
|
| Hex.toBigInt.ErrorType
|
|
163
|
-
|
|
|
170
|
+
| AccountSimulation.fromRpc.ErrorType
|
|
164
171
|
| Errors.GlobalErrorType
|
|
165
172
|
}
|
|
166
173
|
|
|
@@ -226,6 +233,7 @@ export function toRpc(request: toRpc.Input): Rpc {
|
|
|
226
233
|
}) as Rpc
|
|
227
234
|
|
|
228
235
|
const tempo =
|
|
236
|
+
typeof request.accountSimulation !== 'undefined' ||
|
|
229
237
|
typeof request.calls !== 'undefined' ||
|
|
230
238
|
typeof request.capabilities !== 'undefined' ||
|
|
231
239
|
typeof request.feePayer !== 'undefined' ||
|
|
@@ -235,7 +243,6 @@ export function toRpc(request: toRpc.Input): Rpc {
|
|
|
235
243
|
typeof request.keyId !== 'undefined' ||
|
|
236
244
|
typeof request.keyType !== 'undefined' ||
|
|
237
245
|
typeof request.keyAuthorizationSimulation !== 'undefined' ||
|
|
238
|
-
typeof request.multisigSimulation !== 'undefined' ||
|
|
239
246
|
typeof request.nonceKey !== 'undefined' ||
|
|
240
247
|
typeof request.validBefore !== 'undefined' ||
|
|
241
248
|
typeof request.validAfter !== 'undefined' ||
|
|
@@ -284,14 +291,15 @@ export function toRpc(request: toRpc.Input): Rpc {
|
|
|
284
291
|
request_rpc.keyData = shimKeyData(request.keyData)
|
|
285
292
|
if (typeof request.keyId !== 'undefined') request_rpc.keyId = request.keyId
|
|
286
293
|
if (typeof request.keyType !== 'undefined')
|
|
287
|
-
request_rpc.keyType =
|
|
294
|
+
request_rpc.keyType =
|
|
295
|
+
request.keyType === 'configurable' ? 'multisig' : request.keyType
|
|
288
296
|
if (typeof request.keyAuthorizationSimulation !== 'undefined')
|
|
289
|
-
request_rpc.keyAuthorizationSimulation =
|
|
297
|
+
request_rpc.keyAuthorizationSimulation = AccountSimulation.toRpc(
|
|
290
298
|
request.keyAuthorizationSimulation,
|
|
291
299
|
)
|
|
292
|
-
if (typeof request.
|
|
293
|
-
request_rpc.multisigSimulation =
|
|
294
|
-
request.
|
|
300
|
+
if (typeof request.accountSimulation !== 'undefined')
|
|
301
|
+
request_rpc.multisigSimulation = AccountSimulation.toRpc(
|
|
302
|
+
request.accountSimulation,
|
|
295
303
|
)
|
|
296
304
|
if (typeof request.validBefore !== 'undefined')
|
|
297
305
|
request_rpc.validBefore = Quantity.fromNumberish(request.validBefore)
|
|
@@ -327,7 +335,7 @@ export declare namespace toRpc {
|
|
|
327
335
|
export type ErrorType =
|
|
328
336
|
| AuthorizationTempo.toRpcList.ErrorType
|
|
329
337
|
| Hex.fromNumber.ErrorType
|
|
330
|
-
|
|
|
338
|
+
| AccountSimulation.toRpc.ErrorType
|
|
331
339
|
| Errors.GlobalErrorType
|
|
332
340
|
}
|
|
333
341
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { AbiFunction, Address, Hex, Secp256k1, Value } from 'ox'
|
|
2
2
|
import { describe, expect, test } from 'vp/test'
|
|
3
3
|
import { chain, client, fundAddress } from '../../test/tempo/config.js'
|
|
4
|
-
import { factory } from '../../test/tempo/
|
|
4
|
+
import { factory } from '../../test/tempo/configurableAccounts.js'
|
|
5
5
|
import {
|
|
6
|
+
AccountConfig,
|
|
6
7
|
KeyAuthorization,
|
|
7
|
-
|
|
8
|
-
MultisigOperation,
|
|
8
|
+
AccountOperation,
|
|
9
9
|
SignatureEnvelope,
|
|
10
10
|
} from './index.js'
|
|
11
11
|
import * as Transaction from './Transaction.js'
|
|
@@ -26,12 +26,12 @@ async function setup() {
|
|
|
26
26
|
address: Address.fromPublicKey(Secp256k1.getPublicKey({ privateKey })),
|
|
27
27
|
}
|
|
28
28
|
})
|
|
29
|
-
const config:
|
|
29
|
+
const config: AccountConfig.Config = AccountConfig.from({
|
|
30
30
|
salt: Hex.random(32),
|
|
31
31
|
threshold: 2,
|
|
32
32
|
owners: keys.map((key) => ({ owner: key.address, weight: 1 })),
|
|
33
33
|
})
|
|
34
|
-
const account =
|
|
34
|
+
const account = AccountConfig.getAddress(config, { factory })
|
|
35
35
|
await fundAddress(client, { address: account })
|
|
36
36
|
return { account, config, keys }
|
|
37
37
|
}
|
|
@@ -59,11 +59,11 @@ function sign(account: Awaited<ReturnType<typeof setup>>, payload: Hex.Hex) {
|
|
|
59
59
|
config: account.config,
|
|
60
60
|
payload,
|
|
61
61
|
}
|
|
62
|
-
const digest =
|
|
62
|
+
const digest = AccountConfig.getSignPayload(value)
|
|
63
63
|
return SignatureEnvelope.from({
|
|
64
64
|
account: account.account,
|
|
65
65
|
config: account.config,
|
|
66
|
-
signatures: SignatureEnvelope.
|
|
66
|
+
signatures: SignatureEnvelope.sortApprovals({
|
|
67
67
|
...value,
|
|
68
68
|
signatures: account.keys
|
|
69
69
|
.slice(0, 2)
|
|
@@ -109,13 +109,13 @@ describe('behavior: configurable accounts', () => {
|
|
|
109
109
|
const account = await setup()
|
|
110
110
|
const tx = transaction(0n)
|
|
111
111
|
const serialized = TxEnvelopeTempo.serialize(tx)
|
|
112
|
-
const hash =
|
|
112
|
+
const hash = AccountOperation.getHash({
|
|
113
113
|
account: account.account,
|
|
114
114
|
config: account.config,
|
|
115
115
|
transaction: serialized,
|
|
116
116
|
type: 'transaction',
|
|
117
117
|
})
|
|
118
|
-
const selected = await
|
|
118
|
+
const selected = await AccountOperation.selectApprovals({
|
|
119
119
|
account: account.account,
|
|
120
120
|
approvals: account.keys.map(({ privateKey }) =>
|
|
121
121
|
SignatureEnvelope.serialize(
|
|
@@ -125,7 +125,7 @@ describe('behavior: configurable accounts', () => {
|
|
|
125
125
|
config: account.config,
|
|
126
126
|
hash,
|
|
127
127
|
})
|
|
128
|
-
const operation =
|
|
128
|
+
const operation = AccountOperation.from({
|
|
129
129
|
account: account.account,
|
|
130
130
|
approvals: selected.approvals,
|
|
131
131
|
config: account.config,
|
|
@@ -139,7 +139,7 @@ describe('behavior: configurable accounts', () => {
|
|
|
139
139
|
updatedAt: 1,
|
|
140
140
|
weight: selected.weight,
|
|
141
141
|
})
|
|
142
|
-
const signed =
|
|
142
|
+
const signed = AccountOperation.serializeTransaction(operation, {
|
|
143
143
|
approvals: selected.selectedApprovals,
|
|
144
144
|
})
|
|
145
145
|
const result = await client.request({
|
|
@@ -167,7 +167,7 @@ describe('behavior: configurable accounts', () => {
|
|
|
167
167
|
data,
|
|
168
168
|
gas: 5_000_000n,
|
|
169
169
|
feeToken: '0x20c0000000000000000000000000000000000001',
|
|
170
|
-
|
|
170
|
+
accountSimulation: {
|
|
171
171
|
config: account.config,
|
|
172
172
|
approvals: account.config.owners
|
|
173
173
|
.slice(0, 2)
|
|
@@ -178,7 +178,7 @@ describe('behavior: configurable accounts', () => {
|
|
|
178
178
|
method: 'eth_call',
|
|
179
179
|
params: [request as never, 'latest'],
|
|
180
180
|
})
|
|
181
|
-
expect(simulated).not.toBe(
|
|
181
|
+
expect(simulated).not.toBe(AccountConfig.zeroSalt)
|
|
182
182
|
const estimate = await client.request({
|
|
183
183
|
method: 'eth_estimateGas',
|
|
184
184
|
params: [request as never],
|
|
@@ -188,7 +188,7 @@ describe('behavior: configurable accounts', () => {
|
|
|
188
188
|
method: 'eth_call',
|
|
189
189
|
params: [{ to: precompile, data }, 'latest'],
|
|
190
190
|
})
|
|
191
|
-
expect(persisted).toBe(
|
|
191
|
+
expect(persisted).toBe(AccountConfig.zeroSalt)
|
|
192
192
|
const tx = transaction(0n)
|
|
193
193
|
await submit(tx, sign(account, TxEnvelopeTempo.getSignPayload(tx)))
|
|
194
194
|
expect(
|
|
@@ -252,14 +252,14 @@ describe('behavior: configurable accounts', () => {
|
|
|
252
252
|
)
|
|
253
253
|
})
|
|
254
254
|
|
|
255
|
-
test('authorizes a
|
|
255
|
+
test('authorizes a configurable delegate and preserves the grant after delegate rotation', async () => {
|
|
256
256
|
const parent = await setup()
|
|
257
257
|
const delegate = await setup()
|
|
258
258
|
const grant = KeyAuthorization.from({
|
|
259
259
|
address: delegate.account,
|
|
260
260
|
account: parent.account,
|
|
261
261
|
chainId: BigInt(chain.id),
|
|
262
|
-
type: '
|
|
262
|
+
type: 'configurable',
|
|
263
263
|
})
|
|
264
264
|
const signed = KeyAuthorization.from(grant, {
|
|
265
265
|
signature: sign(parent, KeyAuthorization.getSignPayload(grant)),
|
package/src/tempo/e2e.test.ts
CHANGED
|
@@ -2329,14 +2329,14 @@ describe('behavior: keyAuthorization', () => {
|
|
|
2329
2329
|
Value.from('1', 6),
|
|
2330
2330
|
])
|
|
2331
2331
|
|
|
2332
|
-
// Scope key to only
|
|
2332
|
+
// Scope key to only token2
|
|
2333
2333
|
const keyAuth = KeyAuthorization.from({
|
|
2334
2334
|
address: accessAddress,
|
|
2335
2335
|
chainId: BigInt(chainId),
|
|
2336
2336
|
type: 'secp256k1',
|
|
2337
2337
|
scopes: [
|
|
2338
2338
|
{
|
|
2339
|
-
address:
|
|
2339
|
+
address: token2,
|
|
2340
2340
|
selector: AbiFunction.getSelector(transfer),
|
|
2341
2341
|
},
|
|
2342
2342
|
],
|
|
@@ -2356,9 +2356,9 @@ describe('behavior: keyAuthorization', () => {
|
|
|
2356
2356
|
blockTag: 'pending',
|
|
2357
2357
|
})
|
|
2358
2358
|
|
|
2359
|
-
// Call transfer on
|
|
2359
|
+
// Call transfer on token1 (not scoped), which the account could otherwise pay
|
|
2360
2360
|
const transaction = TxEnvelopeTempo.from({
|
|
2361
|
-
calls: [{ to:
|
|
2361
|
+
calls: [{ to: token1, data: transferData }],
|
|
2362
2362
|
chainId,
|
|
2363
2363
|
feeToken: token1,
|
|
2364
2364
|
keyAuthorization: keyAuth_signed,
|
|
@@ -2383,12 +2383,15 @@ describe('behavior: keyAuthorization', () => {
|
|
|
2383
2383
|
}),
|
|
2384
2384
|
})
|
|
2385
2385
|
|
|
2386
|
-
|
|
2387
|
-
|
|
2386
|
+
// The keychain rejects out-of-scope calls during execution, so the
|
|
2387
|
+
// transaction is mined with a reverted status.
|
|
2388
|
+
const receipt = await client
|
|
2389
|
+
.request({
|
|
2388
2390
|
method: 'eth_sendRawTransactionSync',
|
|
2389
2391
|
params: [serialized_signed],
|
|
2390
|
-
})
|
|
2391
|
-
|
|
2392
|
+
})
|
|
2393
|
+
.then((tx) => TransactionReceipt.fromRpc(tx as any))
|
|
2394
|
+
expect(receipt?.status).toBe('reverted')
|
|
2392
2395
|
},
|
|
2393
2396
|
)
|
|
2394
2397
|
|
|
@@ -2466,12 +2469,15 @@ describe('behavior: keyAuthorization', () => {
|
|
|
2466
2469
|
}),
|
|
2467
2470
|
})
|
|
2468
2471
|
|
|
2469
|
-
|
|
2470
|
-
|
|
2472
|
+
// The keychain rejects out-of-scope calls during execution, so the
|
|
2473
|
+
// transaction is mined with a reverted status.
|
|
2474
|
+
const receipt = await client
|
|
2475
|
+
.request({
|
|
2471
2476
|
method: 'eth_sendRawTransactionSync',
|
|
2472
2477
|
params: [serialized_signed],
|
|
2473
|
-
})
|
|
2474
|
-
|
|
2478
|
+
})
|
|
2479
|
+
.then((tx) => TransactionReceipt.fromRpc(tx as any))
|
|
2480
|
+
expect(receipt?.status).toBe('reverted')
|
|
2475
2481
|
},
|
|
2476
2482
|
)
|
|
2477
2483
|
|
|
@@ -2549,12 +2555,15 @@ describe('behavior: keyAuthorization', () => {
|
|
|
2549
2555
|
}),
|
|
2550
2556
|
})
|
|
2551
2557
|
|
|
2552
|
-
|
|
2553
|
-
|
|
2558
|
+
// The keychain rejects out-of-scope calls during execution, so the
|
|
2559
|
+
// transaction is mined with a reverted status.
|
|
2560
|
+
const receipt = await client
|
|
2561
|
+
.request({
|
|
2554
2562
|
method: 'eth_sendRawTransactionSync',
|
|
2555
2563
|
params: [serialized_signed],
|
|
2556
|
-
})
|
|
2557
|
-
|
|
2564
|
+
})
|
|
2565
|
+
.then((tx) => TransactionReceipt.fromRpc(tx as any))
|
|
2566
|
+
expect(receipt?.status).toBe('reverted')
|
|
2558
2567
|
},
|
|
2559
2568
|
)
|
|
2560
2569
|
|
|
@@ -2623,12 +2632,15 @@ describe('behavior: keyAuthorization', () => {
|
|
|
2623
2632
|
}),
|
|
2624
2633
|
})
|
|
2625
2634
|
|
|
2626
|
-
|
|
2627
|
-
|
|
2635
|
+
// The keychain rejects out-of-scope calls during execution, so the
|
|
2636
|
+
// transaction is mined with a reverted status.
|
|
2637
|
+
const receipt = await client
|
|
2638
|
+
.request({
|
|
2628
2639
|
method: 'eth_sendRawTransactionSync',
|
|
2629
2640
|
params: [serialized_signed],
|
|
2630
|
-
})
|
|
2631
|
-
|
|
2641
|
+
})
|
|
2642
|
+
.then((tx) => TransactionReceipt.fromRpc(tx as any))
|
|
2643
|
+
expect(receipt?.status).toBe('reverted')
|
|
2632
2644
|
},
|
|
2633
2645
|
)
|
|
2634
2646
|
|
package/src/tempo/index.ts
CHANGED
|
@@ -1,6 +1,60 @@
|
|
|
1
1
|
/** @entrypointCategory Tempo */
|
|
2
2
|
// biome-ignore lint/complexity/noUselessEmptyExport: tsdoc
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Configurable account configuration utilities (TIP-1107).
|
|
6
|
+
*
|
|
7
|
+
* Configurable accounts have weighted owners and an approval threshold that
|
|
8
|
+
* can change without changing the account address. Derives the stable account
|
|
9
|
+
* address from the initial configuration, computes configuration commitments,
|
|
10
|
+
* and computes the owner approval digest that owners sign.
|
|
11
|
+
*
|
|
12
|
+
* [TIP-1107](https://tips.sh/1107) · [TIP-1114](https://tips.sh/1114)
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts twoslash
|
|
16
|
+
* import { AccountConfig } from 'ox/tempo'
|
|
17
|
+
*
|
|
18
|
+
* const initialConfig = AccountConfig.from({
|
|
19
|
+
* threshold: 2,
|
|
20
|
+
* owners: [
|
|
21
|
+
* {
|
|
22
|
+
* owner: '0x1111111111111111111111111111111111111111',
|
|
23
|
+
* weight: 1
|
|
24
|
+
* },
|
|
25
|
+
* {
|
|
26
|
+
* owner: '0x2222222222222222222222222222222222222222',
|
|
27
|
+
* weight: 1
|
|
28
|
+
* }
|
|
29
|
+
* ]
|
|
30
|
+
* })
|
|
31
|
+
*
|
|
32
|
+
* const account = AccountConfig.getAddress(initialConfig, {
|
|
33
|
+
* factory: '0x7171717171717171717171717171717171717171'
|
|
34
|
+
* })
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @category Reference
|
|
38
|
+
*/
|
|
39
|
+
export * as AccountConfig from './AccountConfig.js'
|
|
40
|
+
/**
|
|
41
|
+
* Offchain configurable account transaction and key authorization operation utilities.
|
|
42
|
+
*
|
|
43
|
+
* Derives operation hashes, selects owner approvals, serializes transactions,
|
|
44
|
+
* validates operation state, and converts JSON-RPC representations.
|
|
45
|
+
*
|
|
46
|
+
* @category Reference
|
|
47
|
+
*/
|
|
48
|
+
export * as AccountOperation from './AccountOperation.js'
|
|
49
|
+
/**
|
|
50
|
+
* Configurable account RPC simulation utilities.
|
|
51
|
+
*
|
|
52
|
+
* Converts the owner approvals and configuration modeled during gas estimation
|
|
53
|
+
* between their domain and Tempo JSON-RPC representations.
|
|
54
|
+
*
|
|
55
|
+
* @category Reference
|
|
56
|
+
*/
|
|
57
|
+
export * as AccountSimulation from './AccountSimulation.js'
|
|
4
58
|
/**
|
|
5
59
|
* Utilities for Tempo-flavoured EIP-7702 authorizations.
|
|
6
60
|
*
|
|
@@ -141,58 +195,6 @@ export * as EarnShares from './EarnShares.js'
|
|
|
141
195
|
* @category Reference
|
|
142
196
|
*/
|
|
143
197
|
export * as KeyAuthorization from './KeyAuthorization.js'
|
|
144
|
-
/**
|
|
145
|
-
* Native multisig account utilities (TIP-1061).
|
|
146
|
-
*
|
|
147
|
-
* Derives stable multisig account addresses from a weighted owner
|
|
148
|
-
* configuration, and computes the owner approval digest that owners sign.
|
|
149
|
-
*
|
|
150
|
-
* [TIP-1061](https://tips.sh/1061)
|
|
151
|
-
*
|
|
152
|
-
* @example
|
|
153
|
-
* ```ts twoslash
|
|
154
|
-
* import { MultisigConfig } from 'ox/tempo'
|
|
155
|
-
*
|
|
156
|
-
* const initialConfig = MultisigConfig.from({
|
|
157
|
-
* threshold: 2,
|
|
158
|
-
* owners: [
|
|
159
|
-
* {
|
|
160
|
-
* owner: '0x1111111111111111111111111111111111111111',
|
|
161
|
-
* weight: 1
|
|
162
|
-
* },
|
|
163
|
-
* {
|
|
164
|
-
* owner: '0x2222222222222222222222222222222222222222',
|
|
165
|
-
* weight: 1
|
|
166
|
-
* }
|
|
167
|
-
* ]
|
|
168
|
-
* })
|
|
169
|
-
*
|
|
170
|
-
* const account = MultisigConfig.getAddress(initialConfig, {
|
|
171
|
-
* factory: '0x7171717171717171717171717171717171717171'
|
|
172
|
-
* })
|
|
173
|
-
* ```
|
|
174
|
-
*
|
|
175
|
-
* @category Reference
|
|
176
|
-
*/
|
|
177
|
-
export * as MultisigConfig from './MultisigConfig.js'
|
|
178
|
-
/**
|
|
179
|
-
* Offchain multisig transaction and key authorization operation utilities.
|
|
180
|
-
*
|
|
181
|
-
* Derives operation hashes, selects owner approvals, serializes transactions,
|
|
182
|
-
* validates operation state, and converts JSON-RPC representations.
|
|
183
|
-
*
|
|
184
|
-
* @category Reference
|
|
185
|
-
*/
|
|
186
|
-
export * as MultisigOperation from './MultisigOperation.js'
|
|
187
|
-
/**
|
|
188
|
-
* Native multisig RPC simulation utilities.
|
|
189
|
-
*
|
|
190
|
-
* Converts complete root and nested owner specs between their domain and Tempo
|
|
191
|
-
* JSON-RPC representations.
|
|
192
|
-
*
|
|
193
|
-
* @category Reference
|
|
194
|
-
*/
|
|
195
|
-
export * as MultisigSimulation from './MultisigSimulation.js'
|
|
196
198
|
/**
|
|
197
199
|
* Utilities for constructing period durations (in seconds) for recurring spending limits.
|
|
198
200
|
*
|
|
@@ -271,7 +273,7 @@ export * as PoolId from './PoolId.js'
|
|
|
271
273
|
*/
|
|
272
274
|
export * as ReceivePolicyReceipt from './ReceivePolicyReceipt.js'
|
|
273
275
|
/**
|
|
274
|
-
* JSON-RPC schemas for the `tempo_` and `
|
|
276
|
+
* JSON-RPC schemas for the `tempo_` and `account_` namespaces.
|
|
275
277
|
*
|
|
276
278
|
* @example
|
|
277
279
|
* ```ts twoslash
|
|
@@ -281,7 +283,7 @@ export * as ReceivePolicyReceipt from './ReceivePolicyReceipt.js'
|
|
|
281
283
|
*
|
|
282
284
|
* const schema = RpcSchema.from<
|
|
283
285
|
* | RpcSchema.Default
|
|
284
|
-
* | RpcSchemaTempo.
|
|
286
|
+
* | RpcSchemaTempo.Account
|
|
285
287
|
* | RpcSchemaTempo.Tempo
|
|
286
288
|
* >()
|
|
287
289
|
*
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** @internal */
|
|
2
|
-
export const version = '1.8.
|
|
2
|
+
export const version = '1.8.7'
|