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
|
@@ -29,28 +29,24 @@ export const RpcCallScope = z.object({
|
|
|
29
29
|
})
|
|
30
30
|
|
|
31
31
|
/** RPC key authorization schema. */
|
|
32
|
-
export const Rpc = z
|
|
33
|
-
.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
.
|
|
49
|
-
|
|
50
|
-
(value) => value.keyType !== 'multisig' || value.account != null,
|
|
51
|
-
'configurable account key grants require a parent account binding',
|
|
52
|
-
),
|
|
53
|
-
)
|
|
32
|
+
export const Rpc = z.object({
|
|
33
|
+
account: z.optional(z.nullable(z_Address.Address)),
|
|
34
|
+
allowedCalls: z.optional(z.nullable(z.readonly(z.array(RpcCallScope)))),
|
|
35
|
+
chainId: z_Hex.Hex,
|
|
36
|
+
expiry: z.optional(z.nullable(z_Hex.Hex)),
|
|
37
|
+
isAdmin: z.optional(z.nullable(z.boolean())),
|
|
38
|
+
keyId: z_Address.Address,
|
|
39
|
+
keyType: z.union([
|
|
40
|
+
z_SignatureEnvelope.Type,
|
|
41
|
+
z.literal('configurableAccount'),
|
|
42
|
+
]),
|
|
43
|
+
limits: z.optional(z.nullable(z.readonly(z.array(RpcTokenLimit)))),
|
|
44
|
+
signature: z.union([
|
|
45
|
+
z_SignatureEnvelope.PrimitiveRpc,
|
|
46
|
+
z_SignatureEnvelope.ConfigurableRpc,
|
|
47
|
+
]),
|
|
48
|
+
witness: z.optional(z.nullable(z_Hex.Hex)),
|
|
49
|
+
})
|
|
54
50
|
|
|
55
51
|
/** Token spending limit schema. */
|
|
56
52
|
export const TokenLimit = z.object({
|
|
@@ -88,18 +84,11 @@ const domainShape = {
|
|
|
88
84
|
}
|
|
89
85
|
|
|
90
86
|
/** Decoded key authorization schema. */
|
|
91
|
-
export const Domain = z
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
})
|
|
97
|
-
.check(
|
|
98
|
-
z.refine(
|
|
99
|
-
(value) => value.type !== 'configurable' || value.account != null,
|
|
100
|
-
'configurable account key grants require a parent account binding',
|
|
101
|
-
),
|
|
102
|
-
)
|
|
87
|
+
export const Domain = z.object({
|
|
88
|
+
...domainShape,
|
|
89
|
+
account: z.optional(z_Address.Address),
|
|
90
|
+
isAdmin: z.optional(z.boolean()),
|
|
91
|
+
})
|
|
103
92
|
|
|
104
93
|
const domainToRpcShape = {
|
|
105
94
|
...domainShape,
|
|
@@ -109,18 +98,11 @@ const domainToRpcShape = {
|
|
|
109
98
|
}
|
|
110
99
|
|
|
111
100
|
/** Encode-only decoded key authorization schema accepting numberish `toRpc` inputs. */
|
|
112
|
-
export const DomainToRpc = z
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
})
|
|
118
|
-
.check(
|
|
119
|
-
z.refine(
|
|
120
|
-
(value) => value.type !== 'configurable' || value.account != null,
|
|
121
|
-
'configurable account key grants require a parent account binding',
|
|
122
|
-
),
|
|
123
|
-
)
|
|
101
|
+
export const DomainToRpc = z.object({
|
|
102
|
+
...domainToRpcShape,
|
|
103
|
+
account: z.optional(z_Address.Address),
|
|
104
|
+
isAdmin: z.optional(z.boolean()),
|
|
105
|
+
})
|
|
124
106
|
|
|
125
107
|
/** Codec decoding an RPC key authorization into a signed key authorization. */
|
|
126
108
|
export const KeyAuthorization = z.codec(Rpc, Domain, {
|
|
@@ -26,12 +26,12 @@ const KeyType = z.union([
|
|
|
26
26
|
z.literal('configurable'),
|
|
27
27
|
])
|
|
28
28
|
|
|
29
|
-
// The node's wire format names the configurable account key type `
|
|
29
|
+
// The node's wire format names the configurable account key type `configurableAccount`.
|
|
30
30
|
const KeyTypeRpc = z.union([
|
|
31
31
|
z.literal('secp256k1'),
|
|
32
32
|
z.literal('p256'),
|
|
33
33
|
z.literal('webAuthn'),
|
|
34
|
-
z.literal('
|
|
34
|
+
z.literal('configurableAccount'),
|
|
35
35
|
])
|
|
36
36
|
|
|
37
37
|
const SignatureRpc = z.object({
|
|
@@ -93,7 +93,7 @@ export const Rpc = z.object({
|
|
|
93
93
|
maxFeePerGas: z.optional(z_Hex.Hex),
|
|
94
94
|
maxPriorityFeePerGas: z.optional(z_Hex.Hex),
|
|
95
95
|
keyAuthorizationSimulation: z.optional(z_AccountSimulation.Rpc),
|
|
96
|
-
|
|
96
|
+
configurableAccountSimulation: z.optional(z_AccountSimulation.Rpc),
|
|
97
97
|
nonce: z.optional(z_Hex.Hex),
|
|
98
98
|
nonceKey: z.optional(z_Hex.Hex),
|
|
99
99
|
r: z.optional(z_Hex.Hex),
|
|
@@ -218,7 +218,11 @@ export const TransactionRequestToRpc = z.codec(Rpc, DomainToRpc, {
|
|
|
218
218
|
function fromRpc(
|
|
219
219
|
request: core_TransactionRequest.Rpc,
|
|
220
220
|
): core_TransactionRequest.TransactionRequest {
|
|
221
|
-
const {
|
|
221
|
+
const {
|
|
222
|
+
authorizationList: _,
|
|
223
|
+
configurableAccountSimulation: __,
|
|
224
|
+
...rest
|
|
225
|
+
} = request
|
|
222
226
|
const request_ = z.decode(
|
|
223
227
|
z_TransactionRequest.TransactionRequest,
|
|
224
228
|
rest as never,
|
|
@@ -263,16 +267,18 @@ function fromRpc(
|
|
|
263
267
|
if (typeof request.keyId !== 'undefined') request_.keyId = request.keyId
|
|
264
268
|
if (typeof request.keyType !== 'undefined')
|
|
265
269
|
request_.keyType =
|
|
266
|
-
request.keyType === '
|
|
270
|
+
request.keyType === 'configurableAccount'
|
|
271
|
+
? 'configurable'
|
|
272
|
+
: request.keyType
|
|
267
273
|
if (typeof request.keyAuthorizationSimulation !== 'undefined')
|
|
268
274
|
request_.keyAuthorizationSimulation = z.decode(
|
|
269
275
|
z_AccountSimulation.AccountSimulation,
|
|
270
276
|
request.keyAuthorizationSimulation,
|
|
271
277
|
)
|
|
272
|
-
if (typeof request.
|
|
278
|
+
if (typeof request.configurableAccountSimulation !== 'undefined')
|
|
273
279
|
request_.accountSimulation = z.decode(
|
|
274
280
|
z_AccountSimulation.AccountSimulation,
|
|
275
|
-
request.
|
|
281
|
+
request.configurableAccountSimulation,
|
|
276
282
|
)
|
|
277
283
|
if (typeof request.validBefore !== 'undefined')
|
|
278
284
|
request_.validBefore = core_Hex.toNumber(request.validBefore)
|
|
@@ -357,14 +363,16 @@ function toRpc(
|
|
|
357
363
|
if (typeof request.keyId !== 'undefined') request_rpc.keyId = request.keyId
|
|
358
364
|
if (typeof request.keyType !== 'undefined')
|
|
359
365
|
request_rpc.keyType =
|
|
360
|
-
request.keyType === 'configurable'
|
|
366
|
+
request.keyType === 'configurable'
|
|
367
|
+
? 'configurableAccount'
|
|
368
|
+
: request.keyType
|
|
361
369
|
if (typeof request.keyAuthorizationSimulation !== 'undefined')
|
|
362
370
|
request_rpc.keyAuthorizationSimulation = z.encode(
|
|
363
371
|
z_AccountSimulation.AccountSimulation,
|
|
364
372
|
request.keyAuthorizationSimulation,
|
|
365
373
|
)
|
|
366
374
|
if (typeof request.accountSimulation !== 'undefined')
|
|
367
|
-
request_rpc.
|
|
375
|
+
request_rpc.configurableAccountSimulation = z.encode(
|
|
368
376
|
z_AccountSimulation.AccountSimulation,
|
|
369
377
|
request.accountSimulation,
|
|
370
378
|
)
|
|
@@ -24,7 +24,7 @@ const rpc = {
|
|
|
24
24
|
version: '0x1',
|
|
25
25
|
},
|
|
26
26
|
createdAt: 1,
|
|
27
|
-
hash: '
|
|
27
|
+
hash: '0x2b7a9f98ab46088ccfbd145553b5ec804cd6a24eab46a21f023cbe68385f0fb4',
|
|
28
28
|
signatureCount: 1,
|
|
29
29
|
status: 'pending',
|
|
30
30
|
threshold: 2,
|
|
@@ -21,7 +21,7 @@ const rpc = {
|
|
|
21
21
|
} as const
|
|
22
22
|
|
|
23
23
|
describe('KeyAuthorization', () => {
|
|
24
|
-
test('
|
|
24
|
+
test('accepts unbound configurable grants through every schema', () => {
|
|
25
25
|
const domain = {
|
|
26
26
|
...z.decode(z_KeyAuthorization.KeyAuthorization, rpc),
|
|
27
27
|
type: 'configurable',
|
|
@@ -30,15 +30,15 @@ describe('KeyAuthorization', () => {
|
|
|
30
30
|
expect(
|
|
31
31
|
z.safeDecode(z_KeyAuthorization.KeyAuthorization, {
|
|
32
32
|
...rpc,
|
|
33
|
-
keyType: '
|
|
33
|
+
keyType: 'configurableAccount',
|
|
34
34
|
account,
|
|
35
35
|
}).success,
|
|
36
|
-
).toMatchInlineSnapshot(`
|
|
36
|
+
).toMatchInlineSnapshot(`true`)
|
|
37
37
|
for (const schema of [
|
|
38
38
|
z_KeyAuthorization.Domain,
|
|
39
39
|
z_KeyAuthorization.DomainToRpc,
|
|
40
40
|
]) {
|
|
41
|
-
expect(z.safeParse(schema, domain).success).toMatchInlineSnapshot(`
|
|
41
|
+
expect(z.safeParse(schema, domain).success).toMatchInlineSnapshot(`true`)
|
|
42
42
|
expect(
|
|
43
43
|
z.safeParse(schema, { ...domain, account: rpc.keyId }).success,
|
|
44
44
|
).toMatchInlineSnapshot(`true`)
|
|
@@ -47,7 +47,7 @@ describe('KeyAuthorization', () => {
|
|
|
47
47
|
z_KeyAuthorization.KeyAuthorization,
|
|
48
48
|
z_KeyAuthorization.KeyAuthorizationToRpc,
|
|
49
49
|
])
|
|
50
|
-
expect(z.safeEncode(codec, domain).success).toMatchInlineSnapshot(`
|
|
50
|
+
expect(z.safeEncode(codec, domain).success).toMatchInlineSnapshot(`true`)
|
|
51
51
|
})
|
|
52
52
|
|
|
53
53
|
test('decodes an RPC key authorization', () => {
|
|
@@ -79,13 +79,13 @@ describe('TransactionRequest', () => {
|
|
|
79
79
|
const decoded = z.decode(z_TransactionRequest.TransactionRequest, {
|
|
80
80
|
...rpc,
|
|
81
81
|
keyAuthorizationSimulation: accountSimulationRpc,
|
|
82
|
-
|
|
82
|
+
configurableAccountSimulation: accountSimulationRpc,
|
|
83
83
|
})
|
|
84
84
|
expect(decoded).toEqual(
|
|
85
85
|
core_TransactionRequest.fromRpc({
|
|
86
86
|
...rpc,
|
|
87
87
|
keyAuthorizationSimulation: accountSimulationRpc,
|
|
88
|
-
|
|
88
|
+
configurableAccountSimulation: accountSimulationRpc,
|
|
89
89
|
}),
|
|
90
90
|
)
|
|
91
91
|
expect(decoded.accountSimulation).toEqual(
|
|
@@ -96,22 +96,27 @@ describe('TransactionRequest', () => {
|
|
|
96
96
|
expect(encoded.keyAuthorizationSimulation).toStrictEqual(
|
|
97
97
|
accountSimulationRpc,
|
|
98
98
|
)
|
|
99
|
-
expect(encoded.
|
|
99
|
+
expect(encoded.configurableAccountSimulation).toStrictEqual(
|
|
100
|
+
accountSimulationRpc,
|
|
101
|
+
)
|
|
100
102
|
expect(encoded).toEqual(core_TransactionRequest.toRpc(decoded))
|
|
101
103
|
})
|
|
102
104
|
|
|
103
|
-
test('configurable key type maps to the
|
|
105
|
+
test('configurable key type maps to the configurableAccount RPC key type', () => {
|
|
104
106
|
const decoded = z.decode(z_TransactionRequest.TransactionRequest, {
|
|
105
107
|
...rpc,
|
|
106
|
-
keyType: '
|
|
108
|
+
keyType: 'configurableAccount',
|
|
107
109
|
})
|
|
108
110
|
expect(decoded.keyType).toBe('configurable')
|
|
109
111
|
expect(decoded).toEqual(
|
|
110
|
-
core_TransactionRequest.fromRpc({
|
|
112
|
+
core_TransactionRequest.fromRpc({
|
|
113
|
+
...rpc,
|
|
114
|
+
keyType: 'configurableAccount',
|
|
115
|
+
}),
|
|
111
116
|
)
|
|
112
117
|
|
|
113
118
|
const encoded = z.encode(z_TransactionRequest.TransactionRequest, decoded)
|
|
114
|
-
expect(encoded.keyType).toBe('
|
|
119
|
+
expect(encoded.keyType).toBe('configurableAccount')
|
|
115
120
|
expect(encoded).toEqual(core_TransactionRequest.toRpc(decoded))
|
|
116
121
|
})
|
|
117
122
|
|