ox 0.14.56 → 0.14.58

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 (73) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/_cjs/core/AbiEvent.js +16 -4
  3. package/_cjs/core/AbiEvent.js.map +1 -1
  4. package/_cjs/core/Hex.js +5 -3
  5. package/_cjs/core/Hex.js.map +1 -1
  6. package/_cjs/core/RpcTransport.js +32 -19
  7. package/_cjs/core/RpcTransport.js.map +1 -1
  8. package/_cjs/core/TypedData.js +1 -1
  9. package/_cjs/core/TypedData.js.map +1 -1
  10. package/_cjs/core/internal/abiItem.js +46 -14
  11. package/_cjs/core/internal/abiItem.js.map +1 -1
  12. package/_cjs/tempo/AccountConfig.js +16 -5
  13. package/_cjs/tempo/AccountConfig.js.map +1 -1
  14. package/_cjs/tempo/AccountSimulation.js +13 -4
  15. package/_cjs/tempo/AccountSimulation.js.map +1 -1
  16. package/_cjs/tempo/KeyAuthorization.js +2 -11
  17. package/_cjs/tempo/KeyAuthorization.js.map +1 -1
  18. package/_cjs/tempo/TransactionRequest.js +7 -5
  19. package/_cjs/tempo/TransactionRequest.js.map +1 -1
  20. package/_cjs/version.js +1 -1
  21. package/_esm/core/AbiEvent.js +19 -4
  22. package/_esm/core/AbiEvent.js.map +1 -1
  23. package/_esm/core/Hex.js +5 -3
  24. package/_esm/core/Hex.js.map +1 -1
  25. package/_esm/core/RpcTransport.js +38 -19
  26. package/_esm/core/RpcTransport.js.map +1 -1
  27. package/_esm/core/TypedData.js +1 -1
  28. package/_esm/core/TypedData.js.map +1 -1
  29. package/_esm/core/internal/abiItem.js +51 -17
  30. package/_esm/core/internal/abiItem.js.map +1 -1
  31. package/_esm/tempo/AccountConfig.js +58 -9
  32. package/_esm/tempo/AccountConfig.js.map +1 -1
  33. package/_esm/tempo/AccountSimulation.js +15 -5
  34. package/_esm/tempo/AccountSimulation.js.map +1 -1
  35. package/_esm/tempo/KeyAuthorization.js +8 -12
  36. package/_esm/tempo/KeyAuthorization.js.map +1 -1
  37. package/_esm/tempo/TransactionRequest.js +7 -5
  38. package/_esm/tempo/TransactionRequest.js.map +1 -1
  39. package/_esm/version.js +1 -1
  40. package/_types/core/AbiEvent.d.ts.map +1 -1
  41. package/_types/core/Hex.d.ts +13 -1
  42. package/_types/core/Hex.d.ts.map +1 -1
  43. package/_types/core/RpcTransport.d.ts.map +1 -1
  44. package/_types/core/internal/abiItem.d.ts.map +1 -1
  45. package/_types/tempo/AccountConfig.d.ts +46 -3
  46. package/_types/tempo/AccountConfig.d.ts.map +1 -1
  47. package/_types/tempo/AccountSimulation.d.ts +6 -2
  48. package/_types/tempo/AccountSimulation.d.ts.map +1 -1
  49. package/_types/tempo/KeyAuthorization.d.ts +18 -13
  50. package/_types/tempo/KeyAuthorization.d.ts.map +1 -1
  51. package/_types/tempo/TransactionRequest.d.ts +3 -3
  52. package/_types/tempo/TransactionRequest.d.ts.map +1 -1
  53. package/_types/version.d.ts +1 -1
  54. package/core/AbiEvent.ts +24 -3
  55. package/core/Hex.ts +17 -3
  56. package/core/RpcTransport.ts +40 -22
  57. package/core/TypedData.ts +1 -1
  58. package/core/internal/abiItem.ts +70 -21
  59. package/package.json +1 -1
  60. package/tempo/AccountConfig.test-d.ts +10 -0
  61. package/tempo/AccountConfig.test.ts +143 -10
  62. package/tempo/AccountConfig.ts +80 -9
  63. package/tempo/AccountOperation.test.ts +32 -32
  64. package/tempo/AccountSimulation.test.ts +44 -0
  65. package/tempo/AccountSimulation.ts +19 -5
  66. package/tempo/KeyAuthorization.test-d.ts +8 -18
  67. package/tempo/KeyAuthorization.test.ts +95 -39
  68. package/tempo/KeyAuthorization.ts +20 -43
  69. package/tempo/RpcSchemaTempo.test-d.ts +2 -2
  70. package/tempo/TransactionRequest.test-d.ts +3 -3
  71. package/tempo/TransactionRequest.test.ts +10 -8
  72. package/tempo/TransactionRequest.ts +10 -8
  73. package/version.ts +1 -1
@@ -77,14 +77,14 @@ export type KeyAuthorization<
77
77
  witness?: Hex.Hex | undefined
78
78
  } & (
79
79
  | {
80
- /** Optional account address binding. */
80
+ /** Account address this authorization is bound to. Required when an admin access key signs the grant (TIP-1049). */
81
81
  account?: addressType | undefined
82
82
  /** Primitive key type. */
83
83
  type: SignatureEnvelope.Type
84
84
  }
85
85
  | {
86
- /** Required parent account binding for a configurable account grant. */
87
- account: addressType
86
+ /** Account address this authorization is bound to. Required when an admin access key signs the grant (TIP-1049). */
87
+ account?: addressType | undefined
88
88
  /** Configurable account key type. */
89
89
  type: 'configurable'
90
90
  }
@@ -146,10 +146,10 @@ export type Rpc = {
146
146
  keyType: SignatureEnvelope.Type
147
147
  }
148
148
  | {
149
- /** Required parent account binding for a configurable account grant. */
150
- account: Address.Address
151
- /** Configurable account key type, named `multisig` by the node. */
152
- keyType: 'multisig'
149
+ /** Optional account address binding (TIP-1049). */
150
+ account?: Address.Address | null | undefined
151
+ /** Configurable account key type, named `configurableAccount` by the node. */
152
+ keyType: 'configurableAccount'
153
153
  }
154
154
  )
155
155
 
@@ -449,7 +449,6 @@ export function from<
449
449
  options: from.Options<signature> = {},
450
450
  ): from.ReturnType<authorization, signature> {
451
451
  if ('keyId' in authorization) return fromRpc(authorization as Rpc) as never
452
- assertAccountBinding(authorization.type, authorization.account)
453
452
  const auth = authorization as KeyAuthorization & {
454
453
  limits?: readonly { token: TempoAddress.Address; limit: bigint }[]
455
454
  scopes?: readonly {
@@ -535,10 +534,7 @@ export declare namespace from {
535
534
  >
536
535
  >
537
536
 
538
- type ErrorType =
539
- | InvalidSignatureTypeError
540
- | MissingAccountError
541
- | Errors.GlobalErrorType
537
+ type ErrorType = InvalidSignatureTypeError | Errors.GlobalErrorType
542
538
  }
543
539
 
544
540
  /**
@@ -572,8 +568,7 @@ export function fromRpc(authorization: Rpc): Signed {
572
568
  const witness = authorization.witness ?? undefined
573
569
  const isAdmin = authorization.isAdmin ?? undefined
574
570
  const account = authorization.account ?? undefined
575
- const type = keyType === 'multisig' ? 'configurable' : keyType
576
- assertAccountBinding(type, account)
571
+ const type = keyType === 'configurableAccount' ? 'configurable' : keyType
577
572
  const signature = SignatureEnvelope.fromRpc(authorization.signature)
578
573
  assertSignature(signature)
579
574
  if (witness !== undefined) assertWitness(witness)
@@ -616,10 +611,7 @@ export function fromRpc(authorization: Rpc): Signed {
616
611
  }
617
612
 
618
613
  export declare namespace fromRpc {
619
- type ErrorType =
620
- | InvalidSignatureTypeError
621
- | MissingAccountError
622
- | Errors.GlobalErrorType
614
+ type ErrorType = InvalidSignatureTypeError | Errors.GlobalErrorType
623
615
  }
624
616
 
625
617
  /**
@@ -739,7 +731,6 @@ export function fromTuple<const tuple extends Tuple>(
739
731
  const account = isAbsent(rawAccount)
740
732
  ? undefined
741
733
  : (rawAccount as Address.Address)
742
- assertAccountBinding(keyType, account)
743
734
  const args: KeyAuthorization = {
744
735
  address: keyId,
745
736
  chainId: chainId === '0x' ? 0n : Hex.toBigInt(chainId),
@@ -766,10 +757,7 @@ export declare namespace fromTuple {
766
757
  KeyAuthorization<authorization extends Tuple<true> ? true : false>
767
758
  >
768
759
 
769
- type ErrorType =
770
- | InvalidSignatureTypeError
771
- | MissingAccountError
772
- | Errors.GlobalErrorType
760
+ type ErrorType = InvalidSignatureTypeError | Errors.GlobalErrorType
773
761
  }
774
762
 
775
763
  /**
@@ -961,7 +949,6 @@ export declare namespace serialize {
961
949
  * @returns An RPC-formatted Key Authorization.
962
950
  */
963
951
  export function toRpc(authorization: Signed): Rpc {
964
- assertAccountBinding(authorization.type, authorization.account)
965
952
  const {
966
953
  address,
967
954
  scopes,
@@ -1006,7 +993,7 @@ export function toRpc(authorization: Signed): Rpc {
1006
993
  expiry: typeof expiry === 'number' ? Hex.fromNumber(expiry) : null,
1007
994
  keyId: TempoAddress.resolve(address),
1008
995
  ...(type === 'configurable'
1009
- ? { account, keyType: 'multisig' as const }
996
+ ? { account, keyType: 'configurableAccount' as const }
1010
997
  : { keyType: type }),
1011
998
  limits: limits?.map(({ token, limit, period }) => ({
1012
999
  token,
@@ -1024,10 +1011,7 @@ export function toRpc(authorization: Signed): Rpc {
1024
1011
  }
1025
1012
 
1026
1013
  export declare namespace toRpc {
1027
- type ErrorType =
1028
- | InvalidSignatureTypeError
1029
- | MissingAccountError
1030
- | Errors.GlobalErrorType
1014
+ type ErrorType = InvalidSignatureTypeError | Errors.GlobalErrorType
1031
1015
  }
1032
1016
 
1033
1017
  /**
@@ -1064,7 +1048,6 @@ export declare namespace toRpc {
1064
1048
  export function toTuple<const authorization extends KeyAuthorization>(
1065
1049
  authorization: authorization,
1066
1050
  ): toTuple.ReturnType<authorization> {
1067
- assertAccountBinding(authorization.type, authorization.account)
1068
1051
  const {
1069
1052
  address,
1070
1053
  chainId,
@@ -1173,10 +1156,7 @@ export declare namespace toTuple {
1173
1156
  type ReturnType<authorization extends KeyAuthorization = KeyAuthorization> =
1174
1157
  Compute<Tuple<authorization extends KeyAuthorization<true> ? true : false>>
1175
1158
 
1176
- type ErrorType =
1177
- | InvalidSignatureTypeError
1178
- | MissingAccountError
1179
- | Errors.GlobalErrorType
1159
+ type ErrorType = InvalidSignatureTypeError | Errors.GlobalErrorType
1180
1160
  }
1181
1161
 
1182
1162
  function bigintToHex(value: bigint): Hex.Hex {
@@ -1210,14 +1190,6 @@ function resolveSelector(
1210
1190
  return AbiItem.getSelector(selector)
1211
1191
  }
1212
1192
 
1213
- function assertAccountBinding(
1214
- type: KeyAuthorization['type'],
1215
- account: TempoAddress.Address | null | undefined,
1216
- ): void {
1217
- if (type === 'configurable' && account == null)
1218
- throw new MissingAccountError()
1219
- }
1220
-
1221
1193
  function assertWitness(witness: Hex.Hex): void {
1222
1194
  if (Hex.size(witness) !== 32) throw new InvalidWitnessSizeError(witness)
1223
1195
  }
@@ -1263,7 +1235,12 @@ export class InvalidSignatureTypeError extends Error {
1263
1235
  }
1264
1236
  }
1265
1237
 
1266
- /** Thrown when a configurable account key grant omits its parent account binding. */
1238
+ /**
1239
+ * Thrown when a configurable account key grant omits its parent account binding.
1240
+ *
1241
+ * @deprecated No longer thrown. The Tempo node only requires `account` on grants
1242
+ * signed by an admin access key, which it checks against the transaction sender.
1243
+ */
1267
1244
  export class MissingAccountError extends Error {
1268
1245
  override readonly name = 'KeyAuthorization.MissingAccountError'
1269
1246
  constructor() {
@@ -17,7 +17,7 @@ declare const tempoProvider: Provider.Provider<{
17
17
  declare const address: Address.Address
18
18
  declare const hash: Hex.Hex
19
19
  declare const keyAuthorization: KeyAuthorization.Rpc
20
- declare const multisigSimulation: AccountSimulation.Rpc
20
+ declare const configurableAccountSimulation: AccountSimulation.Rpc
21
21
  declare const serializedTransaction: Hex.Hex
22
22
  declare const signature: Hex.Hex
23
23
 
@@ -79,7 +79,7 @@ test('tempo simulation accepts account simulation specs', () => {
79
79
  {
80
80
  calls: [
81
81
  {
82
- multisigSimulation,
82
+ configurableAccountSimulation,
83
83
  },
84
84
  ],
85
85
  },
@@ -19,16 +19,16 @@ test('transaction requests use domain account simulation specs', () => {
19
19
  })
20
20
 
21
21
  test('RPC requests use encoded account configurations', () => {
22
- expectTypeOf(rpc.multisigSimulation?.config).toEqualTypeOf<
22
+ expectTypeOf(rpc.configurableAccountSimulation?.config).toEqualTypeOf<
23
23
  `0x${string}` | undefined
24
24
  >()
25
25
  })
26
26
 
27
- test('maps the configurable key type to the RPC multisig key type', () => {
27
+ test('maps the configurable key type to the RPC configurableAccount key type', () => {
28
28
  expectTypeOf(request.keyType).toEqualTypeOf<
29
29
  'configurable' | 'p256' | 'secp256k1' | 'webAuthn' | undefined
30
30
  >()
31
31
  expectTypeOf(rpc.keyType).toEqualTypeOf<
32
- 'multisig' | 'p256' | 'secp256k1' | 'webAuthn' | undefined
32
+ 'configurableAccount' | 'p256' | 'secp256k1' | 'webAuthn' | undefined
33
33
  >()
34
34
  })
@@ -109,9 +109,9 @@ describe('fromRpc', () => {
109
109
  expect(request.nonceKey).toBe(255n)
110
110
  })
111
111
 
112
- test('behavior: multisig key type decodes as configurable', () => {
112
+ test('behavior: configurableAccount key type decodes as configurable', () => {
113
113
  const request = TransactionRequest.fromRpc({
114
- keyType: 'multisig',
114
+ keyType: 'configurableAccount',
115
115
  type: '0x76',
116
116
  })
117
117
  expect(request.keyType).toMatchInlineSnapshot(`"configurable"`)
@@ -120,7 +120,7 @@ describe('fromRpc', () => {
120
120
  test('behavior: account simulation', () => {
121
121
  const request = TransactionRequest.fromRpc({
122
122
  from: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
123
- multisigSimulation: accountSimulationRpc,
123
+ configurableAccountSimulation: accountSimulationRpc,
124
124
  type: '0x76',
125
125
  })
126
126
 
@@ -214,8 +214,7 @@ describe('toRpc', () => {
214
214
 
215
215
  expect(request).toMatchInlineSnapshot(`
216
216
  {
217
- "from": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
218
- "multisigSimulation": {
217
+ "configurableAccountSimulation": {
219
218
  "approvals": [
220
219
  {
221
220
  "keyData": "0x0005",
@@ -225,9 +224,10 @@ describe('toRpc', () => {
225
224
  ],
226
225
  "config": "0xf852a011111111111111111111111111111111111111111111111111111111111111118002eed694111111111111111111111111111111111111111101d694bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb01",
227
226
  },
227
+ "from": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
228
228
  "type": "0x76",
229
229
  }
230
- `)
230
+ `)
231
231
  })
232
232
  })
233
233
 
@@ -295,7 +295,7 @@ describe('roundtrip', () => {
295
295
  nonceKey: '0xff',
296
296
  gas: '0x186a0',
297
297
  keyAuthorizationSimulation: accountSimulationRpc,
298
- multisigSimulation: accountSimulationRpc,
298
+ configurableAccountSimulation: accountSimulationRpc,
299
299
  type: '0x76',
300
300
  }
301
301
 
@@ -311,7 +311,9 @@ describe('roundtrip', () => {
311
311
  expect(rpc.keyAuthorizationSimulation).toEqual(
312
312
  original.keyAuthorizationSimulation,
313
313
  )
314
- expect(rpc.multisigSimulation).toEqual(original.multisigSimulation)
314
+ expect(rpc.configurableAccountSimulation).toEqual(
315
+ original.configurableAccountSimulation,
316
+ )
315
317
  expect(rpc.type).toBe('0x76')
316
318
  })
317
319
  })
@@ -62,9 +62,9 @@ export type Rpc = Omit<
62
62
  feeToken?: Hex.Hex | undefined
63
63
  keyAuthorization?: KeyAuthorization.Rpc | undefined
64
64
  keyAuthorizationSimulation?: AccountSimulation.Rpc | undefined
65
- /** Key type. Configurable accounts use the node's `multisig` key type. */
66
- keyType?: SignatureEnvelope.Type | 'multisig' | undefined
67
- multisigSimulation?: AccountSimulation.Rpc | undefined
65
+ /** Key type. Configurable accounts use the node's `configurableAccount` key type. */
66
+ keyType?: SignatureEnvelope.Type | 'configurableAccount' | undefined
67
+ configurableAccountSimulation?: AccountSimulation.Rpc | undefined
68
68
  nonceKey?: Hex.Hex | undefined
69
69
  }
70
70
 
@@ -93,7 +93,7 @@ export function fromRpc(request: Rpc): TransactionRequest {
93
93
  authorizationList: _,
94
94
  keyAuthorizationSimulation: __,
95
95
  keyType: ___,
96
- multisigSimulation: ____,
96
+ configurableAccountSimulation: ____,
97
97
  ...rest
98
98
  } = request
99
99
  const request_ = ox_TransactionRequest.fromRpc(
@@ -132,10 +132,12 @@ export function fromRpc(request: Rpc): TransactionRequest {
132
132
  )
133
133
  if (typeof request.keyType !== 'undefined')
134
134
  request_.keyType =
135
- request.keyType === 'multisig' ? 'configurable' : request.keyType
136
- if (request.multisigSimulation)
135
+ request.keyType === 'configurableAccount'
136
+ ? 'configurable'
137
+ : request.keyType
138
+ if (request.configurableAccountSimulation)
137
139
  request_.accountSimulation = AccountSimulation.fromRpc(
138
- request.multisigSimulation,
140
+ request.configurableAccountSimulation,
139
141
  )
140
142
  if (typeof request.validBefore !== 'undefined')
141
143
  request_.validBefore = Hex.toNumber(request.validBefore as Hex.Hex)
@@ -240,7 +242,7 @@ export function toRpc(request: TransactionRequest): Rpc {
240
242
  request.keyAuthorizationSimulation,
241
243
  )
242
244
  if (request.accountSimulation)
243
- request_rpc.multisigSimulation = AccountSimulation.toRpc(
245
+ request_rpc.configurableAccountSimulation = AccountSimulation.toRpc(
244
246
  request.accountSimulation,
245
247
  )
246
248
  if (typeof request.validBefore !== 'undefined')
package/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  /** @internal */
2
- export const version = '0.14.56'
2
+ export const version = '0.14.58'