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.
Files changed (59) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/core/internal/abiItem.d.ts.map +1 -1
  3. package/dist/core/internal/abiItem.js +3 -2
  4. package/dist/core/internal/abiItem.js.map +1 -1
  5. package/dist/tempo/AccountConfig.d.ts +46 -3
  6. package/dist/tempo/AccountConfig.d.ts.map +1 -1
  7. package/dist/tempo/AccountConfig.js +58 -9
  8. package/dist/tempo/AccountConfig.js.map +1 -1
  9. package/dist/tempo/AccountSimulation.d.ts +6 -2
  10. package/dist/tempo/AccountSimulation.d.ts.map +1 -1
  11. package/dist/tempo/AccountSimulation.js +15 -5
  12. package/dist/tempo/AccountSimulation.js.map +1 -1
  13. package/dist/tempo/KeyAuthorization.d.ts +14 -9
  14. package/dist/tempo/KeyAuthorization.d.ts.map +1 -1
  15. package/dist/tempo/KeyAuthorization.js +8 -12
  16. package/dist/tempo/KeyAuthorization.js.map +1 -1
  17. package/dist/tempo/TransactionRequest.d.ts +3 -3
  18. package/dist/tempo/TransactionRequest.d.ts.map +1 -1
  19. package/dist/tempo/TransactionRequest.js +10 -6
  20. package/dist/tempo/TransactionRequest.js.map +1 -1
  21. package/dist/zod/tempo/AccountSimulation.d.ts +4 -0
  22. package/dist/zod/tempo/AccountSimulation.d.ts.map +1 -1
  23. package/dist/zod/tempo/AccountSimulation.js +2 -0
  24. package/dist/zod/tempo/AccountSimulation.js.map +1 -1
  25. package/dist/zod/tempo/KeyAuthorization.d.ts +5 -5
  26. package/dist/zod/tempo/KeyAuthorization.d.ts.map +1 -1
  27. package/dist/zod/tempo/KeyAuthorization.js +10 -13
  28. package/dist/zod/tempo/KeyAuthorization.js.map +1 -1
  29. package/dist/zod/tempo/RpcSchemaTempo.d.ts +16 -8
  30. package/dist/zod/tempo/RpcSchemaTempo.d.ts.map +1 -1
  31. package/dist/zod/tempo/Transaction.d.ts +6 -6
  32. package/dist/zod/tempo/TransactionRequest.d.ts +23 -9
  33. package/dist/zod/tempo/TransactionRequest.d.ts.map +1 -1
  34. package/dist/zod/tempo/TransactionRequest.js +13 -9
  35. package/dist/zod/tempo/TransactionRequest.js.map +1 -1
  36. package/package.json +1 -1
  37. package/src/core/_test/AbiEvent.test.ts +7 -0
  38. package/src/core/_test/AbiFunction.test.ts +3 -0
  39. package/src/core/_test/AbiItem.test.ts +20 -0
  40. package/src/core/internal/abiItem.ts +3 -2
  41. package/src/tempo/AccountConfig.test-d.ts +10 -0
  42. package/src/tempo/AccountConfig.test.ts +143 -10
  43. package/src/tempo/AccountConfig.ts +80 -9
  44. package/src/tempo/AccountOperation.test.ts +32 -32
  45. package/src/tempo/AccountSimulation.test.ts +43 -0
  46. package/src/tempo/AccountSimulation.ts +19 -5
  47. package/src/tempo/KeyAuthorization.test.ts +91 -32
  48. package/src/tempo/KeyAuthorization.ts +16 -39
  49. package/src/tempo/RpcSchemaTempo.test-d.ts +2 -2
  50. package/src/tempo/TransactionRequest.test-d.ts +5 -5
  51. package/src/tempo/TransactionRequest.test.ts +11 -9
  52. package/src/tempo/TransactionRequest.ts +13 -9
  53. package/src/version.ts +1 -1
  54. package/src/zod/tempo/AccountSimulation.ts +2 -0
  55. package/src/zod/tempo/KeyAuthorization.ts +28 -46
  56. package/src/zod/tempo/TransactionRequest.ts +17 -9
  57. package/src/zod/tempo/_test/AccountOperation.test.ts +1 -1
  58. package/src/zod/tempo/_test/KeyAuthorization.test.ts +5 -5
  59. 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
- .object({
34
- account: z.optional(z.nullable(z_Address.Address)),
35
- allowedCalls: z.optional(z.nullable(z.readonly(z.array(RpcCallScope)))),
36
- chainId: z_Hex.Hex,
37
- expiry: z.optional(z.nullable(z_Hex.Hex)),
38
- isAdmin: z.optional(z.nullable(z.boolean())),
39
- keyId: z_Address.Address,
40
- keyType: z.union([z_SignatureEnvelope.Type, z.literal('multisig')]),
41
- limits: z.optional(z.nullable(z.readonly(z.array(RpcTokenLimit)))),
42
- signature: z.union([
43
- z_SignatureEnvelope.PrimitiveRpc,
44
- z_SignatureEnvelope.ConfigurableRpc,
45
- ]),
46
- witness: z.optional(z.nullable(z_Hex.Hex)),
47
- })
48
- .check(
49
- z.refine(
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
- .object({
93
- ...domainShape,
94
- account: z.optional(z_Address.Address),
95
- isAdmin: z.optional(z.boolean()),
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
- .object({
114
- ...domainToRpcShape,
115
- account: z.optional(z_Address.Address),
116
- isAdmin: z.optional(z.boolean()),
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 `multisig`.
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('multisig'),
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
- multisigSimulation: z.optional(z_AccountSimulation.Rpc),
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 { authorizationList: _, multisigSimulation: __, ...rest } = request
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 === 'multisig' ? 'configurable' : 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.multisigSimulation !== 'undefined')
278
+ if (typeof request.configurableAccountSimulation !== 'undefined')
273
279
  request_.accountSimulation = z.decode(
274
280
  z_AccountSimulation.AccountSimulation,
275
- request.multisigSimulation,
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' ? 'multisig' : request.keyType
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.multisigSimulation = z.encode(
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: '0xcdbc24a8fb192f799c5d166b13a99fb29cbb15e71a5e730988d6f8b3c5959d02',
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('rejects unbound configurable grants through every schema', () => {
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: 'multisig',
33
+ keyType: 'configurableAccount',
34
34
  account,
35
35
  }).success,
36
- ).toMatchInlineSnapshot(`false`)
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(`false`)
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(`false`)
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
- multisigSimulation: accountSimulationRpc,
82
+ configurableAccountSimulation: accountSimulationRpc,
83
83
  })
84
84
  expect(decoded).toEqual(
85
85
  core_TransactionRequest.fromRpc({
86
86
  ...rpc,
87
87
  keyAuthorizationSimulation: accountSimulationRpc,
88
- multisigSimulation: accountSimulationRpc,
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.multisigSimulation).toStrictEqual(accountSimulationRpc)
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 multisig RPC key type', () => {
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: 'multisig',
108
+ keyType: 'configurableAccount',
107
109
  })
108
110
  expect(decoded.keyType).toBe('configurable')
109
111
  expect(decoded).toEqual(
110
- core_TransactionRequest.fromRpc({ ...rpc, keyType: 'multisig' }),
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('multisig')
119
+ expect(encoded.keyType).toBe('configurableAccount')
115
120
  expect(encoded).toEqual(core_TransactionRequest.toRpc(decoded))
116
121
  })
117
122