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.
- package/CHANGELOG.md +8 -0
- package/_cjs/errors/version.js +1 -1
- package/_cjs/tempo/Abis.js +297 -1
- package/_cjs/tempo/Abis.js.map +1 -1
- package/_cjs/tempo/Addresses.js +2 -1
- package/_cjs/tempo/Addresses.js.map +1 -1
- package/_cjs/tempo/Decorator.js.map +1 -1
- package/_cjs/tempo/ExecutionError.js +94 -3
- package/_cjs/tempo/ExecutionError.js.map +1 -1
- package/_cjs/tempo/actions/accessKey.js +382 -10
- package/_cjs/tempo/actions/accessKey.js.map +1 -1
- package/_cjs/tempo/actions/accounts.js +3 -2
- package/_cjs/tempo/actions/accounts.js.map +1 -1
- package/_cjs/tempo/actions/amm.js +90 -4
- package/_cjs/tempo/actions/amm.js.map +1 -1
- package/_cjs/tempo/actions/channel.js +183 -7
- package/_cjs/tempo/actions/channel.js.map +1 -1
- package/_cjs/tempo/actions/dex.js +507 -14
- package/_cjs/tempo/actions/dex.js.map +1 -1
- package/_cjs/tempo/actions/earn/deployment.js +4 -3
- package/_cjs/tempo/actions/earn/deployment.js.map +1 -1
- package/_cjs/tempo/actions/earn.js +22 -21
- package/_cjs/tempo/actions/earn.js.map +1 -1
- package/_cjs/tempo/actions/fee.js +85 -5
- package/_cjs/tempo/actions/fee.js.map +1 -1
- package/_cjs/tempo/actions/nonce.js +54 -1
- package/_cjs/tempo/actions/nonce.js.map +1 -1
- package/_cjs/tempo/actions/policy.js +35 -6
- package/_cjs/tempo/actions/policy.js.map +1 -1
- package/_cjs/tempo/actions/propAmm.js +18 -8
- package/_cjs/tempo/actions/propAmm.js.map +1 -1
- package/_cjs/tempo/actions/receivePolicy.js +7 -6
- package/_cjs/tempo/actions/receivePolicy.js.map +1 -1
- package/_cjs/tempo/actions/reward.js +7 -6
- package/_cjs/tempo/actions/reward.js.map +1 -1
- package/_cjs/tempo/actions/token.js +433 -22
- package/_cjs/tempo/actions/token.js.map +1 -1
- package/_cjs/tempo/actions/validator.js +12 -11
- package/_cjs/tempo/actions/validator.js.map +1 -1
- package/_cjs/tempo/actions/virtualAddress.js +3 -2
- package/_cjs/tempo/actions/virtualAddress.js.map +1 -1
- package/_cjs/tempo/actions/zone.js +12 -11
- package/_cjs/tempo/actions/zone.js.map +1 -1
- package/_cjs/tempo/errors.js +57 -1
- package/_cjs/tempo/errors.js.map +1 -1
- package/_cjs/tempo/internal/errors.js +46 -0
- package/_cjs/tempo/internal/errors.js.map +1 -0
- package/_cjs/tempo/internal/resolveError.js +128 -0
- package/_cjs/tempo/internal/resolveError.js.map +1 -0
- package/_cjs/tempo/internal/utils.js +1 -0
- package/_cjs/tempo/internal/utils.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/tempo/Abis.js +297 -0
- package/_esm/tempo/Abis.js.map +1 -1
- package/_esm/tempo/Addresses.js +1 -0
- package/_esm/tempo/Addresses.js.map +1 -1
- package/_esm/tempo/Decorator.js.map +1 -1
- package/_esm/tempo/ExecutionError.js +95 -2
- package/_esm/tempo/ExecutionError.js.map +1 -1
- package/_esm/tempo/actions/accessKey.js +406 -10
- package/_esm/tempo/actions/accessKey.js.map +1 -1
- package/_esm/tempo/actions/accounts.js +3 -2
- package/_esm/tempo/actions/accounts.js.map +1 -1
- package/_esm/tempo/actions/amm.js +95 -4
- package/_esm/tempo/actions/amm.js.map +1 -1
- package/_esm/tempo/actions/channel.js +191 -7
- package/_esm/tempo/actions/channel.js.map +1 -1
- package/_esm/tempo/actions/dex.js +537 -14
- package/_esm/tempo/actions/dex.js.map +1 -1
- package/_esm/tempo/actions/earn/deployment.js +4 -3
- package/_esm/tempo/actions/earn/deployment.js.map +1 -1
- package/_esm/tempo/actions/earn.js +22 -21
- package/_esm/tempo/actions/earn.js.map +1 -1
- package/_esm/tempo/actions/fee.js +90 -6
- package/_esm/tempo/actions/fee.js.map +1 -1
- package/_esm/tempo/actions/nonce.js +57 -1
- package/_esm/tempo/actions/nonce.js.map +1 -1
- package/_esm/tempo/actions/policy.js +36 -6
- package/_esm/tempo/actions/policy.js.map +1 -1
- package/_esm/tempo/actions/propAmm.js +18 -8
- package/_esm/tempo/actions/propAmm.js.map +1 -1
- package/_esm/tempo/actions/receivePolicy.js +7 -6
- package/_esm/tempo/actions/receivePolicy.js.map +1 -1
- package/_esm/tempo/actions/reward.js +7 -6
- package/_esm/tempo/actions/reward.js.map +1 -1
- package/_esm/tempo/actions/token.js +461 -22
- package/_esm/tempo/actions/token.js.map +1 -1
- package/_esm/tempo/actions/validator.js +12 -11
- package/_esm/tempo/actions/validator.js.map +1 -1
- package/_esm/tempo/actions/virtualAddress.js +3 -2
- package/_esm/tempo/actions/virtualAddress.js.map +1 -1
- package/_esm/tempo/actions/zone.js +12 -11
- package/_esm/tempo/actions/zone.js.map +1 -1
- package/_esm/tempo/errors.js +63 -0
- package/_esm/tempo/errors.js.map +1 -1
- package/_esm/tempo/internal/errors.js +51 -0
- package/_esm/tempo/internal/errors.js.map +1 -0
- package/_esm/tempo/internal/resolveError.js +130 -0
- package/_esm/tempo/internal/resolveError.js.map +1 -0
- package/_esm/tempo/internal/utils.js +2 -0
- package/_esm/tempo/internal/utils.js.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/tempo/Abis.d.ts +807 -0
- package/_types/tempo/Abis.d.ts.map +1 -1
- package/_types/tempo/Addresses.d.ts +1 -0
- package/_types/tempo/Addresses.d.ts.map +1 -1
- package/_types/tempo/Decorator.d.ts +1 -1
- package/_types/tempo/Decorator.d.ts.map +1 -1
- package/_types/tempo/ExecutionError.d.ts +3 -1
- package/_types/tempo/ExecutionError.d.ts.map +1 -1
- package/_types/tempo/actions/accessKey.d.ts +155 -8
- package/_types/tempo/actions/accessKey.d.ts.map +1 -1
- package/_types/tempo/actions/accounts.d.ts +3 -1
- package/_types/tempo/actions/accounts.d.ts.map +1 -1
- package/_types/tempo/actions/amm.d.ts +39 -0
- package/_types/tempo/actions/amm.d.ts.map +1 -1
- package/_types/tempo/actions/channel.d.ts +77 -7
- package/_types/tempo/actions/channel.d.ts.map +1 -1
- package/_types/tempo/actions/dex.d.ts +222 -16
- package/_types/tempo/actions/dex.d.ts.map +1 -1
- package/_types/tempo/actions/earn/deployment.d.ts +7 -6
- package/_types/tempo/actions/earn/deployment.d.ts.map +1 -1
- package/_types/tempo/actions/earn.d.ts +15 -14
- package/_types/tempo/actions/earn.d.ts.map +1 -1
- package/_types/tempo/actions/fee.d.ts +32 -6
- package/_types/tempo/actions/fee.d.ts.map +1 -1
- package/_types/tempo/actions/nonce.d.ts +35 -0
- package/_types/tempo/actions/nonce.d.ts.map +1 -1
- package/_types/tempo/actions/policy.d.ts +29 -8
- package/_types/tempo/actions/policy.d.ts.map +1 -1
- package/_types/tempo/actions/propAmm.d.ts +9 -1
- package/_types/tempo/actions/propAmm.d.ts.map +1 -1
- package/_types/tempo/actions/receivePolicy.d.ts +10 -6
- package/_types/tempo/actions/receivePolicy.d.ts.map +1 -1
- package/_types/tempo/actions/reward.d.ts +7 -3
- package/_types/tempo/actions/reward.d.ts.map +1 -1
- package/_types/tempo/actions/token.d.ts +200 -32
- package/_types/tempo/actions/token.d.ts.map +1 -1
- package/_types/tempo/actions/validator.d.ts +17 -5
- package/_types/tempo/actions/validator.d.ts.map +1 -1
- package/_types/tempo/actions/virtualAddress.d.ts +4 -3
- package/_types/tempo/actions/virtualAddress.d.ts.map +1 -1
- package/_types/tempo/actions/zone.d.ts +10 -9
- package/_types/tempo/actions/zone.d.ts.map +1 -1
- package/_types/tempo/errors.d.ts +63 -1
- package/_types/tempo/errors.d.ts.map +1 -1
- package/_types/tempo/internal/errors.d.ts +59 -0
- package/_types/tempo/internal/errors.d.ts.map +1 -0
- package/_types/tempo/internal/resolveError.d.ts +8 -0
- package/_types/tempo/internal/resolveError.d.ts.map +1 -0
- package/_types/tempo/internal/utils.d.ts.map +1 -1
- package/errors/version.ts +1 -1
- package/package.json +1 -1
- package/tempo/Abis.ts +298 -0
- package/tempo/Addresses.ts +1 -0
- package/tempo/Decorator.ts +5 -3
- package/tempo/ExecutionError.ts +101 -3
- package/tempo/actions/accessKey.ts +496 -25
- package/tempo/actions/accounts.ts +7 -3
- package/tempo/actions/amm.ts +126 -4
- package/tempo/actions/channel.ts +248 -14
- package/tempo/actions/dex.ts +599 -33
- package/tempo/actions/earn/deployment.ts +11 -9
- package/tempo/actions/earn.ts +40 -35
- package/tempo/actions/fee.ts +111 -9
- package/tempo/actions/nonce.ts +86 -1
- package/tempo/actions/policy.ts +66 -14
- package/tempo/actions/propAmm.ts +36 -9
- package/tempo/actions/receivePolicy.ts +26 -15
- package/tempo/actions/reward.ts +17 -9
- package/tempo/actions/token.ts +519 -54
- package/tempo/actions/validator.ts +40 -16
- package/tempo/actions/virtualAddress.ts +7 -5
- package/tempo/actions/zone.ts +25 -20
- package/tempo/errors.ts +114 -1
- package/tempo/internal/errors.ts +110 -0
- package/tempo/internal/resolveError.ts +169 -0
- package/tempo/internal/utils.ts +2 -0
package/tempo/ExecutionError.ts
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
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) {
|