viem 2.57.5 → 2.57.6

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 (178) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/_cjs/errors/version.js +1 -1
  3. package/_cjs/tempo/Abis.js +297 -1
  4. package/_cjs/tempo/Abis.js.map +1 -1
  5. package/_cjs/tempo/Addresses.js +2 -1
  6. package/_cjs/tempo/Addresses.js.map +1 -1
  7. package/_cjs/tempo/Decorator.js.map +1 -1
  8. package/_cjs/tempo/ExecutionError.js +94 -3
  9. package/_cjs/tempo/ExecutionError.js.map +1 -1
  10. package/_cjs/tempo/actions/accessKey.js +382 -10
  11. package/_cjs/tempo/actions/accessKey.js.map +1 -1
  12. package/_cjs/tempo/actions/accounts.js +3 -2
  13. package/_cjs/tempo/actions/accounts.js.map +1 -1
  14. package/_cjs/tempo/actions/amm.js +90 -4
  15. package/_cjs/tempo/actions/amm.js.map +1 -1
  16. package/_cjs/tempo/actions/channel.js +183 -7
  17. package/_cjs/tempo/actions/channel.js.map +1 -1
  18. package/_cjs/tempo/actions/dex.js +507 -14
  19. package/_cjs/tempo/actions/dex.js.map +1 -1
  20. package/_cjs/tempo/actions/earn/deployment.js +4 -3
  21. package/_cjs/tempo/actions/earn/deployment.js.map +1 -1
  22. package/_cjs/tempo/actions/earn.js +22 -21
  23. package/_cjs/tempo/actions/earn.js.map +1 -1
  24. package/_cjs/tempo/actions/fee.js +85 -5
  25. package/_cjs/tempo/actions/fee.js.map +1 -1
  26. package/_cjs/tempo/actions/nonce.js +54 -1
  27. package/_cjs/tempo/actions/nonce.js.map +1 -1
  28. package/_cjs/tempo/actions/policy.js +35 -6
  29. package/_cjs/tempo/actions/policy.js.map +1 -1
  30. package/_cjs/tempo/actions/propAmm.js +18 -8
  31. package/_cjs/tempo/actions/propAmm.js.map +1 -1
  32. package/_cjs/tempo/actions/receivePolicy.js +7 -6
  33. package/_cjs/tempo/actions/receivePolicy.js.map +1 -1
  34. package/_cjs/tempo/actions/reward.js +7 -6
  35. package/_cjs/tempo/actions/reward.js.map +1 -1
  36. package/_cjs/tempo/actions/token.js +433 -22
  37. package/_cjs/tempo/actions/token.js.map +1 -1
  38. package/_cjs/tempo/actions/validator.js +12 -11
  39. package/_cjs/tempo/actions/validator.js.map +1 -1
  40. package/_cjs/tempo/actions/virtualAddress.js +3 -2
  41. package/_cjs/tempo/actions/virtualAddress.js.map +1 -1
  42. package/_cjs/tempo/actions/zone.js +12 -11
  43. package/_cjs/tempo/actions/zone.js.map +1 -1
  44. package/_cjs/tempo/errors.js +57 -1
  45. package/_cjs/tempo/errors.js.map +1 -1
  46. package/_cjs/tempo/internal/errors.js +46 -0
  47. package/_cjs/tempo/internal/errors.js.map +1 -0
  48. package/_cjs/tempo/internal/resolveError.js +128 -0
  49. package/_cjs/tempo/internal/resolveError.js.map +1 -0
  50. package/_cjs/tempo/internal/utils.js +1 -0
  51. package/_cjs/tempo/internal/utils.js.map +1 -1
  52. package/_esm/errors/version.js +1 -1
  53. package/_esm/tempo/Abis.js +297 -0
  54. package/_esm/tempo/Abis.js.map +1 -1
  55. package/_esm/tempo/Addresses.js +1 -0
  56. package/_esm/tempo/Addresses.js.map +1 -1
  57. package/_esm/tempo/Decorator.js.map +1 -1
  58. package/_esm/tempo/ExecutionError.js +95 -2
  59. package/_esm/tempo/ExecutionError.js.map +1 -1
  60. package/_esm/tempo/actions/accessKey.js +406 -10
  61. package/_esm/tempo/actions/accessKey.js.map +1 -1
  62. package/_esm/tempo/actions/accounts.js +3 -2
  63. package/_esm/tempo/actions/accounts.js.map +1 -1
  64. package/_esm/tempo/actions/amm.js +95 -4
  65. package/_esm/tempo/actions/amm.js.map +1 -1
  66. package/_esm/tempo/actions/channel.js +191 -7
  67. package/_esm/tempo/actions/channel.js.map +1 -1
  68. package/_esm/tempo/actions/dex.js +537 -14
  69. package/_esm/tempo/actions/dex.js.map +1 -1
  70. package/_esm/tempo/actions/earn/deployment.js +4 -3
  71. package/_esm/tempo/actions/earn/deployment.js.map +1 -1
  72. package/_esm/tempo/actions/earn.js +22 -21
  73. package/_esm/tempo/actions/earn.js.map +1 -1
  74. package/_esm/tempo/actions/fee.js +90 -6
  75. package/_esm/tempo/actions/fee.js.map +1 -1
  76. package/_esm/tempo/actions/nonce.js +57 -1
  77. package/_esm/tempo/actions/nonce.js.map +1 -1
  78. package/_esm/tempo/actions/policy.js +36 -6
  79. package/_esm/tempo/actions/policy.js.map +1 -1
  80. package/_esm/tempo/actions/propAmm.js +18 -8
  81. package/_esm/tempo/actions/propAmm.js.map +1 -1
  82. package/_esm/tempo/actions/receivePolicy.js +7 -6
  83. package/_esm/tempo/actions/receivePolicy.js.map +1 -1
  84. package/_esm/tempo/actions/reward.js +7 -6
  85. package/_esm/tempo/actions/reward.js.map +1 -1
  86. package/_esm/tempo/actions/token.js +461 -22
  87. package/_esm/tempo/actions/token.js.map +1 -1
  88. package/_esm/tempo/actions/validator.js +12 -11
  89. package/_esm/tempo/actions/validator.js.map +1 -1
  90. package/_esm/tempo/actions/virtualAddress.js +3 -2
  91. package/_esm/tempo/actions/virtualAddress.js.map +1 -1
  92. package/_esm/tempo/actions/zone.js +12 -11
  93. package/_esm/tempo/actions/zone.js.map +1 -1
  94. package/_esm/tempo/errors.js +63 -0
  95. package/_esm/tempo/errors.js.map +1 -1
  96. package/_esm/tempo/internal/errors.js +51 -0
  97. package/_esm/tempo/internal/errors.js.map +1 -0
  98. package/_esm/tempo/internal/resolveError.js +130 -0
  99. package/_esm/tempo/internal/resolveError.js.map +1 -0
  100. package/_esm/tempo/internal/utils.js +2 -0
  101. package/_esm/tempo/internal/utils.js.map +1 -1
  102. package/_types/errors/version.d.ts +1 -1
  103. package/_types/tempo/Abis.d.ts +807 -0
  104. package/_types/tempo/Abis.d.ts.map +1 -1
  105. package/_types/tempo/Addresses.d.ts +1 -0
  106. package/_types/tempo/Addresses.d.ts.map +1 -1
  107. package/_types/tempo/Decorator.d.ts +1 -1
  108. package/_types/tempo/Decorator.d.ts.map +1 -1
  109. package/_types/tempo/ExecutionError.d.ts +3 -1
  110. package/_types/tempo/ExecutionError.d.ts.map +1 -1
  111. package/_types/tempo/actions/accessKey.d.ts +155 -8
  112. package/_types/tempo/actions/accessKey.d.ts.map +1 -1
  113. package/_types/tempo/actions/accounts.d.ts +3 -1
  114. package/_types/tempo/actions/accounts.d.ts.map +1 -1
  115. package/_types/tempo/actions/amm.d.ts +39 -0
  116. package/_types/tempo/actions/amm.d.ts.map +1 -1
  117. package/_types/tempo/actions/channel.d.ts +77 -7
  118. package/_types/tempo/actions/channel.d.ts.map +1 -1
  119. package/_types/tempo/actions/dex.d.ts +222 -16
  120. package/_types/tempo/actions/dex.d.ts.map +1 -1
  121. package/_types/tempo/actions/earn/deployment.d.ts +7 -6
  122. package/_types/tempo/actions/earn/deployment.d.ts.map +1 -1
  123. package/_types/tempo/actions/earn.d.ts +15 -14
  124. package/_types/tempo/actions/earn.d.ts.map +1 -1
  125. package/_types/tempo/actions/fee.d.ts +32 -6
  126. package/_types/tempo/actions/fee.d.ts.map +1 -1
  127. package/_types/tempo/actions/nonce.d.ts +35 -0
  128. package/_types/tempo/actions/nonce.d.ts.map +1 -1
  129. package/_types/tempo/actions/policy.d.ts +29 -8
  130. package/_types/tempo/actions/policy.d.ts.map +1 -1
  131. package/_types/tempo/actions/propAmm.d.ts +9 -1
  132. package/_types/tempo/actions/propAmm.d.ts.map +1 -1
  133. package/_types/tempo/actions/receivePolicy.d.ts +10 -6
  134. package/_types/tempo/actions/receivePolicy.d.ts.map +1 -1
  135. package/_types/tempo/actions/reward.d.ts +7 -3
  136. package/_types/tempo/actions/reward.d.ts.map +1 -1
  137. package/_types/tempo/actions/token.d.ts +200 -32
  138. package/_types/tempo/actions/token.d.ts.map +1 -1
  139. package/_types/tempo/actions/validator.d.ts +17 -5
  140. package/_types/tempo/actions/validator.d.ts.map +1 -1
  141. package/_types/tempo/actions/virtualAddress.d.ts +4 -3
  142. package/_types/tempo/actions/virtualAddress.d.ts.map +1 -1
  143. package/_types/tempo/actions/zone.d.ts +10 -9
  144. package/_types/tempo/actions/zone.d.ts.map +1 -1
  145. package/_types/tempo/errors.d.ts +63 -1
  146. package/_types/tempo/errors.d.ts.map +1 -1
  147. package/_types/tempo/internal/errors.d.ts +59 -0
  148. package/_types/tempo/internal/errors.d.ts.map +1 -0
  149. package/_types/tempo/internal/resolveError.d.ts +8 -0
  150. package/_types/tempo/internal/resolveError.d.ts.map +1 -0
  151. package/_types/tempo/internal/utils.d.ts.map +1 -1
  152. package/errors/version.ts +1 -1
  153. package/package.json +1 -1
  154. package/tempo/Abis.ts +298 -0
  155. package/tempo/Addresses.ts +1 -0
  156. package/tempo/Decorator.ts +5 -3
  157. package/tempo/ExecutionError.ts +101 -3
  158. package/tempo/actions/accessKey.ts +496 -25
  159. package/tempo/actions/accounts.ts +7 -3
  160. package/tempo/actions/amm.ts +126 -4
  161. package/tempo/actions/channel.ts +248 -14
  162. package/tempo/actions/dex.ts +599 -33
  163. package/tempo/actions/earn/deployment.ts +11 -9
  164. package/tempo/actions/earn.ts +40 -35
  165. package/tempo/actions/fee.ts +111 -9
  166. package/tempo/actions/nonce.ts +86 -1
  167. package/tempo/actions/policy.ts +66 -14
  168. package/tempo/actions/propAmm.ts +36 -9
  169. package/tempo/actions/receivePolicy.ts +26 -15
  170. package/tempo/actions/reward.ts +17 -9
  171. package/tempo/actions/token.ts +519 -54
  172. package/tempo/actions/validator.ts +40 -16
  173. package/tempo/actions/virtualAddress.ts +7 -5
  174. package/tempo/actions/zone.ts +25 -20
  175. package/tempo/errors.ts +114 -1
  176. package/tempo/internal/errors.ts +110 -0
  177. package/tempo/internal/resolveError.ts +169 -0
  178. package/tempo/internal/utils.ts +2 -0
@@ -8,7 +8,7 @@ import { formatAbiItem } from '../utils/abi/formatAbiItem.js'
8
8
  import { toFunctionSelector } from '../utils/hash/toFunctionSelector.js'
9
9
  import * as Abis from './Abis.js'
10
10
 
11
- type AllAbis = typeof Abis.core
11
+ type AllAbis = typeof Abis.coreErrors
12
12
  type AbiErrorName = Extract<AllAbis[number], { type: 'error' }>['name']
13
13
 
14
14
  type DecodedError<error = DecodeErrorResultReturnType<AllAbis>> =
@@ -230,6 +230,88 @@ export const messages: Record<`${AbiErrorName}(${string})`, string> = {
230
230
  'ZeroPublicKey()': 'Public key cannot be zero.',
231
231
  }
232
232
 
233
+ /** Steps to resolve an error, keyed by error signature in `Abis.core`. */
234
+ export const hints: Partial<Record<keyof typeof messages, readonly string[]>> =
235
+ {
236
+ 'CallNotAllowed()': [
237
+ "The access key's scopes do not allow this target, selector, or recipient.",
238
+ 'Authorize an access key whose scopes include this call.',
239
+ ],
240
+ 'ContractPaused()': [
241
+ 'The token is paused. An account with the unpause role can unpause it.',
242
+ ],
243
+ 'ExpiringNonceReplay()': ['Resend the transaction with a new nonce.'],
244
+ 'ExpiryInPast()': ['Set the expiry to a future time.'],
245
+ 'InsufficientAllowance()': [
246
+ 'Approve the spender for at least this amount.',
247
+ ],
248
+ 'InsufficientBalance(uint256,uint256,address)': [
249
+ 'Fund the account or lower the amount.',
250
+ ],
251
+ 'InsufficientFeeTokenBalance()': [
252
+ 'Fund the account with the fee token, or pay fees with another token.',
253
+ ],
254
+ 'KeyAlreadyExists()': ['Use a new access key, or revoke the existing one.'],
255
+ 'KeyAlreadyRevoked()': [
256
+ 'Revoked access keys cannot be used or re-authorized. Authorize a new access key.',
257
+ ],
258
+ 'KeyExpired()': ['Authorize a new access key.'],
259
+ 'KeyNotFound()': [
260
+ 'Authorize the access key first, or authorize it in the same transaction with a key authorization.',
261
+ ],
262
+ 'PolicyForbids()': [
263
+ 'The token transfer policy forbids this sender or recipient.',
264
+ ],
265
+ 'SpendingLimitExceeded()': [
266
+ 'Raise the spending limit, or wait for a periodic limit to reset.',
267
+ ],
268
+ 'UnauthorizedCaller()': ['Sign with the root key or an admin access key.'],
269
+ 'AmountExceedsDeposit()': [
270
+ 'Top up the channel, or use a voucher for a smaller amount.',
271
+ ],
272
+ 'AmountNotIncreasing()': [
273
+ 'Use a voucher with a higher cumulative amount than the amount already settled.',
274
+ ],
275
+ 'BelowMinimumOrderSize(uint128)': ['Place a larger order.'],
276
+ 'ChannelNotFound()': [
277
+ 'Check the channel details, or open the channel first.',
278
+ ],
279
+ 'CloseNotReady()': [
280
+ 'Request a close, then wait for the grace period to end before withdrawing.',
281
+ ],
282
+ 'InsufficientBalance()': [
283
+ 'Deposit more of the token, or lower the amount.',
284
+ ],
285
+ 'InsufficientLiquidity()': ['Use a smaller amount.'],
286
+ 'InsufficientOutput()': [
287
+ 'Lower the minimum output amount, or sell a smaller amount.',
288
+ ],
289
+ 'InsufficientReserves()': ['Use a smaller amount.'],
290
+ 'InvalidExpiringNonceExpiry()': [
291
+ 'Set the transaction expiry to a time in the near future.',
292
+ ],
293
+ 'InvalidFlipTick()': [
294
+ 'Choose a flip tick on the correct side of the order tick.',
295
+ ],
296
+ 'MaxInputExceeded()': [
297
+ 'Raise the maximum input amount, or buy a smaller amount.',
298
+ ],
299
+ 'OrderDoesNotExist()': [
300
+ 'Check the order ID. Filled and cancelled orders no longer exist.',
301
+ ],
302
+ 'OrderNotStale()': [
303
+ 'Only orders whose maker lost authorization can be cancelled as stale.',
304
+ ],
305
+ 'PairDoesNotExist()': ['Create the trading pair first.'],
306
+ 'PolicyNotFound()': ['Check the policy ID, or create the policy first.'],
307
+ 'SignatureTypeMismatch(uint8,uint8)': [
308
+ 'Sign with the same key type the access key was authorized with.',
309
+ ],
310
+ 'SupplyCapExceeded()': ['Mint a smaller amount, or raise the supply cap.'],
311
+ 'TickOutOfBounds(int16)': ['Use a tick within the allowed range.'],
312
+ 'Unauthorized()': ['The account lacks the permission this call requires.'],
313
+ }
314
+
233
315
  /** Interpolate `{0}`, `{1}`, … placeholders with args. */
234
316
  function interpolate(template: string, args?: readonly unknown[]): string {
235
317
  if (!args) return template
@@ -370,7 +452,7 @@ function parse(error: Exclude<from.Parameters, Hex>): ExecutionError {
370
452
  const data = extractRevertData(error)
371
453
  if (data) {
372
454
  try {
373
- const decoded = decodeErrorResult({ abi: Abis.core, data })
455
+ const decoded = decodeErrorResult({ abi: Abis.coreErrors, data })
374
456
  const template =
375
457
  messages[formatAbiItem(decoded.abiItem) as keyof typeof messages]
376
458
  return {
@@ -382,7 +464,7 @@ function parse(error: Exclude<from.Parameters, Hex>): ExecutionError {
382
464
  } as never
383
465
  } catch {
384
466
  if (data.length === 10) {
385
- const abiItem = Abis.core.find(
467
+ const abiItem = Abis.coreErrors.find(
386
468
  (item) =>
387
469
  item.type === 'error' &&
388
470
  toFunctionSelector(formatAbiItem(item)) === data.toLowerCase(),
@@ -399,6 +481,22 @@ function parse(error: Exclude<from.Parameters, Hex>): ExecutionError {
399
481
  }
400
482
  }
401
483
 
484
+ // Nodes print zero-argument errors as `Name(Name)`, whose revert data is the selector alone.
485
+ const debugMatch = /\b(\w+)\(\1\)/.exec(raw)
486
+ const abiItem = debugMatch
487
+ ? Abis.coreErrors.find(
488
+ (item) => item.name === debugMatch[1] && item.inputs.length === 0,
489
+ )
490
+ : undefined
491
+ if (abiItem)
492
+ return {
493
+ abiItem,
494
+ args: undefined,
495
+ data: toFunctionSelector(formatAbiItem(abiItem)),
496
+ errorName: abiItem.name,
497
+ message: messages[formatAbiItem(abiItem) as keyof typeof messages]!,
498
+ } as DecodedError
499
+
402
500
  // Human-readable names cannot distinguish overloads with different templates.
403
501
  const nameMatch = /:\s*(\w+)\(([^)]*)\)/.exec(raw)
404
502
  if (nameMatch) {