ox 1.8.6 → 1.8.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/dist/core/internal/abiItem.d.ts.map +1 -1
- package/dist/core/internal/abiItem.js +3 -2
- package/dist/core/internal/abiItem.js.map +1 -1
- package/dist/tempo/{MultisigConfig.d.ts → AccountConfig.d.ts} +116 -63
- package/dist/tempo/AccountConfig.d.ts.map +1 -0
- package/dist/tempo/{MultisigConfig.js → AccountConfig.js} +109 -55
- package/dist/tempo/AccountConfig.js.map +1 -0
- package/dist/tempo/{MultisigOperation.d.ts → AccountOperation.d.ts} +62 -62
- package/dist/tempo/AccountOperation.d.ts.map +1 -0
- package/dist/tempo/{MultisigOperation.js → AccountOperation.js} +64 -64
- package/dist/tempo/AccountOperation.js.map +1 -0
- package/dist/tempo/{MultisigSimulation.d.ts → AccountSimulation.d.ts} +21 -21
- package/dist/tempo/AccountSimulation.d.ts.map +1 -0
- package/dist/tempo/{MultisigSimulation.js → AccountSimulation.js} +20 -20
- package/dist/tempo/AccountSimulation.js.map +1 -0
- package/dist/tempo/KeyAuthorization.d.ts +16 -16
- package/dist/tempo/KeyAuthorization.d.ts.map +1 -1
- package/dist/tempo/KeyAuthorization.js +10 -9
- package/dist/tempo/KeyAuthorization.js.map +1 -1
- package/dist/tempo/RpcSchemaTempo.d.ts +13 -13
- package/dist/tempo/RpcSchemaTempo.d.ts.map +1 -1
- package/dist/tempo/SignatureEnvelope.d.ts +36 -33
- package/dist/tempo/SignatureEnvelope.d.ts.map +1 -1
- package/dist/tempo/SignatureEnvelope.js +77 -77
- package/dist/tempo/SignatureEnvelope.js.map +1 -1
- package/dist/tempo/TransactionRequest.d.ts +11 -9
- package/dist/tempo/TransactionRequest.d.ts.map +1 -1
- package/dist/tempo/TransactionRequest.js +14 -10
- package/dist/tempo/TransactionRequest.js.map +1 -1
- package/dist/tempo/index.d.ts +56 -54
- package/dist/tempo/index.d.ts.map +1 -1
- package/dist/tempo/index.js +56 -54
- package/dist/tempo/index.js.map +1 -1
- package/dist/zod/tempo/{MultisigConfig.d.ts → AccountConfig.d.ts} +6 -6
- package/dist/zod/tempo/AccountConfig.d.ts.map +1 -0
- package/dist/zod/tempo/{MultisigConfig.js → AccountConfig.js} +12 -12
- package/dist/zod/tempo/AccountConfig.js.map +1 -0
- package/dist/zod/tempo/{MultisigOperation.d.ts → AccountOperation.d.ts} +5 -5
- package/dist/zod/tempo/AccountOperation.d.ts.map +1 -0
- package/dist/zod/tempo/{MultisigOperation.js → AccountOperation.js} +10 -10
- package/dist/zod/tempo/AccountOperation.js.map +1 -0
- package/dist/zod/tempo/{MultisigSimulation.d.ts → AccountSimulation.d.ts} +5 -5
- package/dist/zod/tempo/AccountSimulation.d.ts.map +1 -0
- package/dist/zod/tempo/AccountSimulation.js +44 -0
- package/dist/zod/tempo/AccountSimulation.js.map +1 -0
- package/dist/zod/tempo/AuthorizationTempo.d.ts +10 -10
- package/dist/zod/tempo/KeyAuthorization.d.ts +12 -12
- package/dist/zod/tempo/KeyAuthorization.js +6 -6
- package/dist/zod/tempo/KeyAuthorization.js.map +1 -1
- package/dist/zod/tempo/RpcSchemaTempo.d.ts +59 -59
- package/dist/zod/tempo/RpcSchemaTempo.d.ts.map +1 -1
- package/dist/zod/tempo/RpcSchemaTempo.js +28 -28
- package/dist/zod/tempo/RpcSchemaTempo.js.map +1 -1
- package/dist/zod/tempo/SignatureEnvelope.d.ts +7 -7
- package/dist/zod/tempo/SignatureEnvelope.d.ts.map +1 -1
- package/dist/zod/tempo/SignatureEnvelope.js +22 -16
- package/dist/zod/tempo/SignatureEnvelope.js.map +1 -1
- package/dist/zod/tempo/Transaction.d.ts +24 -24
- package/dist/zod/tempo/TransactionRequest.d.ts +84 -84
- package/dist/zod/tempo/TransactionRequest.d.ts.map +1 -1
- package/dist/zod/tempo/TransactionRequest.js +26 -17
- package/dist/zod/tempo/TransactionRequest.js.map +1 -1
- package/dist/zod/tempo/TxEnvelopeTempo.d.ts +12 -12
- package/dist/zod/tempo/ZoneRpcAuthentication.d.ts +3 -3
- package/dist/zod/tempo/z.d.ts +3 -3
- package/dist/zod/tempo/z.d.ts.map +1 -1
- package/dist/zod/tempo/z.js +3 -3
- package/dist/zod/tempo/z.js.map +1 -1
- package/package.json +31 -31
- package/src/core/_test/AbiEvent.test.ts +7 -0
- package/src/core/_test/AbiFunction.test.ts +3 -0
- package/src/core/_test/AbiItem.test.ts +20 -0
- package/src/core/internal/abiItem.ts +3 -2
- package/src/tempo/{MultisigConfig.test-d.ts → AccountConfig.test-d.ts} +22 -12
- package/src/tempo/{MultisigConfig.test.ts → AccountConfig.test.ts} +155 -37
- package/src/tempo/{MultisigConfig.ts → AccountConfig.ts} +138 -66
- package/src/tempo/AccountOperation.test-d.ts +79 -0
- package/src/tempo/{MultisigOperation.test.ts → AccountOperation.test.ts} +97 -97
- package/src/tempo/{MultisigOperation.ts → AccountOperation.ts} +95 -97
- package/src/tempo/{MultisigSimulation.test-d.ts → AccountSimulation.test-d.ts} +7 -9
- package/src/tempo/{MultisigSimulation.test.ts → AccountSimulation.test.ts} +28 -28
- package/src/tempo/{MultisigSimulation.ts → AccountSimulation.ts} +28 -30
- package/src/tempo/KeyAuthorization.test-d.ts +6 -6
- package/src/tempo/KeyAuthorization.test.ts +52 -36
- package/src/tempo/KeyAuthorization.ts +29 -27
- package/src/tempo/RpcSchemaTempo.test-d.ts +19 -19
- package/src/tempo/RpcSchemaTempo.ts +13 -13
- package/src/tempo/SignatureEnvelope.test-d.ts +7 -7
- package/src/tempo/SignatureEnvelope.test.ts +34 -34
- package/src/tempo/SignatureEnvelope.ts +112 -108
- package/src/tempo/Transaction.test.ts +4 -4
- package/src/tempo/TransactionRequest.test-d.ts +17 -6
- package/src/tempo/TransactionRequest.test.ts +32 -17
- package/src/tempo/TransactionRequest.ts +27 -19
- package/src/tempo/{multisig.e2e.test.ts → configurableAccounts.e2e.test.ts} +16 -16
- package/src/tempo/index.ts +56 -54
- package/src/version.ts +1 -1
- package/src/zod/tempo/{MultisigConfig.ts → AccountConfig.ts} +12 -12
- package/src/zod/tempo/{MultisigOperation.ts → AccountOperation.ts} +9 -9
- package/src/zod/tempo/AccountSimulation.ts +53 -0
- package/src/zod/tempo/KeyAuthorization.ts +8 -8
- package/src/zod/tempo/RpcSchemaTempo.ts +28 -28
- package/src/zod/tempo/SignatureEnvelope.ts +23 -17
- package/src/zod/tempo/TransactionRequest.ts +29 -18
- package/src/zod/tempo/_test/AccountConfig.test-d.ts +13 -0
- package/src/zod/tempo/_test/{MultisigConfig.test.ts → AccountConfig.test.ts} +7 -7
- package/src/zod/tempo/_test/AccountOperation.test-d.ts +27 -0
- package/src/zod/tempo/_test/{MultisigOperation.test.ts → AccountOperation.test.ts} +9 -9
- package/src/zod/tempo/_test/AccountSimulation.test-d.ts +13 -0
- package/src/zod/tempo/_test/{MultisigSimulation.test.ts → AccountSimulation.test.ts} +13 -13
- package/src/zod/tempo/_test/KeyAuthorization.test.ts +9 -9
- package/src/zod/tempo/_test/RpcSchemaTempo.test-d.ts +27 -27
- package/src/zod/tempo/_test/RpcSchemaTempo.test.ts +16 -18
- package/src/zod/tempo/_test/SignatureEnvelope.test-d.ts +5 -5
- package/src/zod/tempo/_test/SignatureEnvelope.test.ts +12 -9
- package/src/zod/tempo/_test/TransactionRequest.test.ts +28 -8
- package/src/zod/tempo/z.ts +3 -3
- package/dist/tempo/MultisigConfig.d.ts.map +0 -1
- package/dist/tempo/MultisigConfig.js.map +0 -1
- package/dist/tempo/MultisigOperation.d.ts.map +0 -1
- package/dist/tempo/MultisigOperation.js.map +0 -1
- package/dist/tempo/MultisigSimulation.d.ts.map +0 -1
- package/dist/tempo/MultisigSimulation.js.map +0 -1
- package/dist/zod/tempo/MultisigConfig.d.ts.map +0 -1
- package/dist/zod/tempo/MultisigConfig.js.map +0 -1
- package/dist/zod/tempo/MultisigOperation.d.ts.map +0 -1
- package/dist/zod/tempo/MultisigOperation.js.map +0 -1
- package/dist/zod/tempo/MultisigSimulation.d.ts.map +0 -1
- package/dist/zod/tempo/MultisigSimulation.js +0 -44
- package/dist/zod/tempo/MultisigSimulation.js.map +0 -1
- package/src/tempo/MultisigOperation.test-d.ts +0 -79
- package/src/zod/tempo/MultisigSimulation.ts +0 -53
- package/src/zod/tempo/_test/MultisigConfig.test-d.ts +0 -13
- package/src/zod/tempo/_test/MultisigOperation.test-d.ts +0 -27
- package/src/zod/tempo/_test/MultisigSimulation.test-d.ts +0 -13
|
@@ -1,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/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.8'
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/* eslint-disable jsdoc-js/require-jsdoc, jsdoc-js/require-description, jsdoc-js/require-example */
|
|
2
|
-
import * as
|
|
2
|
+
import * as core_AccountConfig from '../../tempo/AccountConfig.js'
|
|
3
3
|
import * as z_Address from '../Address.js'
|
|
4
4
|
import * as z_Hex from '../Hex.js'
|
|
5
5
|
import * as z from 'zod/mini'
|
|
6
6
|
|
|
7
|
-
/**
|
|
7
|
+
/** Account config owner schema. */
|
|
8
8
|
export const Owner = z.object({
|
|
9
9
|
owner: z_Address.Address,
|
|
10
10
|
weight: z.number(),
|
|
11
11
|
})
|
|
12
12
|
|
|
13
|
-
/**
|
|
13
|
+
/** Account configuration domain schema. */
|
|
14
14
|
export const Config = z
|
|
15
15
|
.object({
|
|
16
16
|
owners: z.readonly(z.array(Owner)),
|
|
@@ -20,12 +20,12 @@ export const Config = z
|
|
|
20
20
|
})
|
|
21
21
|
.check(
|
|
22
22
|
z.refine(
|
|
23
|
-
(value) =>
|
|
24
|
-
'expected valid
|
|
23
|
+
(value) => core_AccountConfig.validate(value),
|
|
24
|
+
'expected valid account configuration',
|
|
25
25
|
),
|
|
26
26
|
)
|
|
27
27
|
|
|
28
|
-
/**
|
|
28
|
+
/** Account configuration RPC schema. */
|
|
29
29
|
export const Rpc = z
|
|
30
30
|
.object({
|
|
31
31
|
owners: z.readonly(z.array(Owner)),
|
|
@@ -36,16 +36,16 @@ export const Rpc = z
|
|
|
36
36
|
.check(
|
|
37
37
|
z.refine((value) => {
|
|
38
38
|
try {
|
|
39
|
-
|
|
39
|
+
core_AccountConfig.fromRpc(value)
|
|
40
40
|
return true
|
|
41
41
|
} catch {
|
|
42
42
|
return false
|
|
43
43
|
}
|
|
44
|
-
}, 'expected valid
|
|
44
|
+
}, 'expected valid account configuration'),
|
|
45
45
|
)
|
|
46
46
|
|
|
47
|
-
/** Codec decoding an RPC
|
|
48
|
-
export const
|
|
49
|
-
decode: (value) =>
|
|
50
|
-
encode: (value) =>
|
|
47
|
+
/** Codec decoding an RPC account configuration into a domain configuration. */
|
|
48
|
+
export const AccountConfig = z.codec(Rpc, Config, {
|
|
49
|
+
decode: (value) => core_AccountConfig.fromRpc(value),
|
|
50
|
+
encode: (value) => core_AccountConfig.toRpc(value),
|
|
51
51
|
})
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/* eslint-disable jsdoc-js/require-jsdoc, jsdoc-js/require-description, jsdoc-js/require-example */
|
|
2
|
-
import * as
|
|
2
|
+
import * as core_AccountOperation from '../../tempo/AccountOperation.js'
|
|
3
3
|
import * as z_Address from '../Address.js'
|
|
4
4
|
import * as z_Hash from '../Hash.js'
|
|
5
5
|
import * as z_Hex from '../Hex.js'
|
|
6
6
|
import * as z from 'zod/mini'
|
|
7
|
-
import * as
|
|
7
|
+
import * as z_AccountConfig from './AccountConfig.js'
|
|
8
8
|
|
|
9
9
|
function baseFields() {
|
|
10
10
|
return {
|
|
11
11
|
account: z_Address.Address,
|
|
12
12
|
approvals: z.readonly(z.array(z_Hex.Hex)),
|
|
13
|
-
config:
|
|
13
|
+
config: z_AccountConfig.AccountConfig,
|
|
14
14
|
createdAt: z.number(),
|
|
15
15
|
hash: z_Hash.Hash,
|
|
16
16
|
signatureCount: z.number(),
|
|
@@ -22,17 +22,17 @@ function baseFields() {
|
|
|
22
22
|
|
|
23
23
|
const valid = z.refine((value) => {
|
|
24
24
|
try {
|
|
25
|
-
|
|
25
|
+
core_AccountOperation.from(value as never)
|
|
26
26
|
return true
|
|
27
27
|
} catch {
|
|
28
28
|
return false
|
|
29
29
|
}
|
|
30
|
-
}, 'expected valid
|
|
30
|
+
}, 'expected valid account operation')
|
|
31
31
|
|
|
32
|
-
/** Fields shared by every
|
|
32
|
+
/** Fields shared by every account operation schema. */
|
|
33
33
|
export const Base = z.object(baseFields())
|
|
34
34
|
|
|
35
|
-
/**
|
|
35
|
+
/** Account transaction approval operation schema. */
|
|
36
36
|
export const TransactionOperation = z
|
|
37
37
|
.object({
|
|
38
38
|
...baseFields(),
|
|
@@ -49,7 +49,7 @@ export const TransactionOperation = z
|
|
|
49
49
|
})
|
|
50
50
|
.check(valid)
|
|
51
51
|
|
|
52
|
-
/**
|
|
52
|
+
/** Account key authorization approval operation schema. */
|
|
53
53
|
export const KeyAuthorizationOperation = z
|
|
54
54
|
.object({
|
|
55
55
|
...baseFields(),
|
|
@@ -59,7 +59,7 @@ export const KeyAuthorizationOperation = z
|
|
|
59
59
|
})
|
|
60
60
|
.check(valid)
|
|
61
61
|
|
|
62
|
-
/** Transaction or key authorization
|
|
62
|
+
/** Transaction or key authorization account operation schema. */
|
|
63
63
|
export const Operation = z.union([
|
|
64
64
|
TransactionOperation,
|
|
65
65
|
KeyAuthorizationOperation,
|