viem 2.56.9 → 2.57.0
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 +40 -0
- package/_cjs/actions/public/waitForTransactionReceipt.js +12 -1
- package/_cjs/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/_cjs/chains/definitions/blockdag.js +23 -0
- package/_cjs/chains/definitions/blockdag.js.map +1 -0
- package/_cjs/chains/definitions/candyChain.js +29 -0
- package/_cjs/chains/definitions/candyChain.js.map +1 -0
- package/_cjs/chains/definitions/creditCoin3Devnet.js +6 -0
- package/_cjs/chains/definitions/creditCoin3Devnet.js.map +1 -1
- package/_cjs/chains/definitions/creditCoin3Mainnet.js +6 -0
- package/_cjs/chains/definitions/creditCoin3Mainnet.js.map +1 -1
- package/_cjs/chains/definitions/creditCoin3Testnet.js +6 -0
- package/_cjs/chains/definitions/creditCoin3Testnet.js.map +1 -1
- package/_cjs/chains/definitions/kortana.js +23 -0
- package/_cjs/chains/definitions/kortana.js.map +1 -0
- package/_cjs/chains/index.js +20 -14
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/clients/createClientResolver.js +45 -0
- package/_cjs/clients/createClientResolver.js.map +1 -0
- package/_cjs/errors/version.js +1 -1
- package/_cjs/index.js +13 -9
- package/_cjs/index.js.map +1 -1
- package/_cjs/op-stack/actions/getGame.js +1 -1
- package/_cjs/op-stack/actions/getGame.js.map +1 -1
- package/_cjs/op-stack/actions/getGames.js +1 -1
- package/_cjs/op-stack/actions/getGames.js.map +1 -1
- package/_cjs/op-stack/actions/getTimeToNextGame.js +1 -1
- package/_cjs/op-stack/actions/getTimeToNextGame.js.map +1 -1
- package/_cjs/op-stack/actions/getTimeToNextL2Output.js +1 -1
- package/_cjs/op-stack/actions/getTimeToNextL2Output.js.map +1 -1
- package/_cjs/tempo/Client.js +2 -10
- package/_cjs/tempo/Client.js.map +1 -1
- package/_cjs/tempo/ExecutionError.js +290 -0
- package/_cjs/tempo/ExecutionError.js.map +1 -0
- package/_cjs/tempo/Relay.js +88 -0
- package/_cjs/tempo/Relay.js.map +1 -0
- package/_cjs/tempo/Transaction.js.map +1 -1
- package/_cjs/tempo/Transport.js +21 -12
- package/_cjs/tempo/Transport.js.map +1 -1
- package/_cjs/tempo/chainConfig.js +3 -0
- package/_cjs/tempo/chainConfig.js.map +1 -1
- package/_cjs/tempo/index.js +3 -3
- package/_cjs/tempo/index.js.map +1 -1
- package/_cjs/tempo/internal/relay/cache.js +74 -0
- package/_cjs/tempo/internal/relay/cache.js.map +1 -0
- package/_cjs/tempo/internal/relay/deadline.js +35 -0
- package/_cjs/tempo/internal/relay/deadline.js.map +1 -0
- package/_cjs/tempo/internal/relay/error.js +102 -0
- package/_cjs/tempo/internal/relay/error.js.map +1 -0
- package/_cjs/tempo/internal/relay/feePayer.js +426 -0
- package/_cjs/tempo/internal/relay/feePayer.js.map +1 -0
- package/_cjs/tempo/internal/relay/feeToken.js +143 -0
- package/_cjs/tempo/internal/relay/feeToken.js.map +1 -0
- package/_cjs/tempo/{Multisig.js → internal/relay/multisig.js} +132 -122
- package/_cjs/tempo/internal/relay/multisig.js.map +1 -0
- package/_cjs/tempo/internal/relay/plugin.js +13 -0
- package/_cjs/tempo/internal/relay/plugin.js.map +1 -0
- package/_cjs/tempo/internal/relay/preflight.js +58 -0
- package/_cjs/tempo/internal/relay/preflight.js.map +1 -0
- package/_cjs/tempo/internal/relay/request.js +319 -0
- package/_cjs/tempo/internal/relay/request.js.map +1 -0
- package/_cjs/tempo/internal/relay/simulate.js +267 -0
- package/_cjs/tempo/internal/relay/simulate.js.map +1 -0
- package/_cjs/tempo/internal/relay/utils.js +174 -0
- package/_cjs/tempo/internal/relay/utils.js.map +1 -0
- package/_cjs/tempo/internal/relay/virtualAddress.js +78 -0
- package/_cjs/tempo/internal/relay/virtualAddress.js.map +1 -0
- package/_cjs/tempo/internal/relay.js +139 -0
- package/_cjs/tempo/internal/relay.js.map +1 -0
- package/_cjs/tempo/multisig/Config.js +0 -2
- package/_cjs/tempo/multisig/Config.js.map +1 -1
- package/_cjs/tempo/multisig/Operation.js +1 -2
- package/_cjs/tempo/multisig/Operation.js.map +1 -1
- package/_cjs/utils/siwe/parseSiweMessage.js +3 -3
- package/_cjs/utils/siwe/parseSiweMessage.js.map +1 -1
- package/_esm/actions/public/waitForTransactionReceipt.js +15 -1
- package/_esm/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/_esm/chains/definitions/blockdag.js +20 -0
- package/_esm/chains/definitions/blockdag.js.map +1 -0
- package/_esm/chains/definitions/candyChain.js +26 -0
- package/_esm/chains/definitions/candyChain.js.map +1 -0
- package/_esm/chains/definitions/creditCoin3Devnet.js +6 -0
- package/_esm/chains/definitions/creditCoin3Devnet.js.map +1 -1
- package/_esm/chains/definitions/creditCoin3Mainnet.js +6 -0
- package/_esm/chains/definitions/creditCoin3Mainnet.js.map +1 -1
- package/_esm/chains/definitions/creditCoin3Testnet.js +6 -0
- package/_esm/chains/definitions/creditCoin3Testnet.js.map +1 -1
- package/_esm/chains/definitions/kortana.js +20 -0
- package/_esm/chains/definitions/kortana.js.map +1 -0
- package/_esm/chains/index.js +3 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/clients/createClientResolver.js +64 -0
- package/_esm/clients/createClientResolver.js.map +1 -0
- package/_esm/errors/version.js +1 -1
- package/_esm/index.js +2 -0
- package/_esm/index.js.map +1 -1
- package/_esm/op-stack/actions/getGame.js +1 -1
- package/_esm/op-stack/actions/getGame.js.map +1 -1
- package/_esm/op-stack/actions/getGames.js +1 -1
- package/_esm/op-stack/actions/getGames.js.map +1 -1
- package/_esm/op-stack/actions/getTimeToNextGame.js +2 -2
- package/_esm/op-stack/actions/getTimeToNextGame.js.map +1 -1
- package/_esm/op-stack/actions/getTimeToNextL2Output.js +2 -2
- package/_esm/op-stack/actions/getTimeToNextL2Output.js.map +1 -1
- package/_esm/tempo/Client.js +8 -14
- package/_esm/tempo/Client.js.map +1 -1
- package/_esm/tempo/ExecutionError.js +306 -0
- package/_esm/tempo/ExecutionError.js.map +1 -0
- package/_esm/tempo/Relay.js +170 -0
- package/_esm/tempo/Relay.js.map +1 -0
- package/_esm/tempo/Transaction.js.map +1 -1
- package/_esm/tempo/Transport.js +21 -46
- package/_esm/tempo/Transport.js.map +1 -1
- package/_esm/tempo/chainConfig.js +4 -0
- package/_esm/tempo/chainConfig.js.map +1 -1
- package/_esm/tempo/index.js +8 -3
- package/_esm/tempo/index.js.map +1 -1
- package/_esm/tempo/internal/relay/cache.js +72 -0
- package/_esm/tempo/internal/relay/cache.js.map +1 -0
- package/_esm/tempo/internal/relay/deadline.js +34 -0
- package/_esm/tempo/internal/relay/deadline.js.map +1 -0
- package/_esm/tempo/internal/relay/error.js +101 -0
- package/_esm/tempo/internal/relay/error.js.map +1 -0
- package/_esm/tempo/internal/relay/feePayer.js +442 -0
- package/_esm/tempo/internal/relay/feePayer.js.map +1 -0
- package/_esm/tempo/internal/relay/feeToken.js +143 -0
- package/_esm/tempo/internal/relay/feeToken.js.map +1 -0
- package/_esm/tempo/{Multisig.js → internal/relay/multisig.js} +133 -129
- package/_esm/tempo/internal/relay/multisig.js.map +1 -0
- package/_esm/tempo/internal/relay/plugin.js +10 -0
- package/_esm/tempo/internal/relay/plugin.js.map +1 -0
- package/_esm/tempo/internal/relay/preflight.js +57 -0
- package/_esm/tempo/internal/relay/preflight.js.map +1 -0
- package/_esm/tempo/internal/relay/request.js +321 -0
- package/_esm/tempo/internal/relay/request.js.map +1 -0
- package/_esm/tempo/internal/relay/simulate.js +277 -0
- package/_esm/tempo/internal/relay/simulate.js.map +1 -0
- package/_esm/tempo/internal/relay/utils.js +174 -0
- package/_esm/tempo/internal/relay/utils.js.map +1 -0
- package/_esm/tempo/internal/relay/virtualAddress.js +73 -0
- package/_esm/tempo/internal/relay/virtualAddress.js.map +1 -0
- package/_esm/tempo/internal/relay.js +138 -0
- package/_esm/tempo/internal/relay.js.map +1 -0
- package/_esm/tempo/multisig/Config.js +2 -1
- package/_esm/tempo/multisig/Config.js.map +1 -1
- package/_esm/tempo/multisig/Operation.js +1 -1
- package/_esm/tempo/multisig/Operation.js.map +1 -1
- package/_esm/utils/siwe/parseSiweMessage.js +3 -3
- package/_esm/utils/siwe/parseSiweMessage.js.map +1 -1
- package/_types/actions/public/waitForTransactionReceipt.d.ts.map +1 -1
- package/_types/chains/definitions/blockdag.d.ts +51 -0
- package/_types/chains/definitions/blockdag.d.ts.map +1 -0
- package/_types/chains/definitions/candyChain.d.ts +48 -0
- package/_types/chains/definitions/candyChain.d.ts.map +1 -0
- package/_types/chains/definitions/creditCoin3Devnet.d.ts +6 -9
- package/_types/chains/definitions/creditCoin3Devnet.d.ts.map +1 -1
- package/_types/chains/definitions/creditCoin3Mainnet.d.ts +6 -9
- package/_types/chains/definitions/creditCoin3Mainnet.d.ts.map +1 -1
- package/_types/chains/definitions/creditCoin3Testnet.d.ts +6 -9
- package/_types/chains/definitions/creditCoin3Testnet.d.ts.map +1 -1
- package/_types/chains/definitions/kortana.d.ts +51 -0
- package/_types/chains/definitions/kortana.d.ts.map +1 -0
- package/_types/chains/index.d.ts +3 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/clients/createClientResolver.d.ts +76 -0
- package/_types/clients/createClientResolver.d.ts.map +1 -0
- package/_types/errors/version.d.ts +1 -1
- package/_types/index.d.ts +2 -0
- package/_types/index.d.ts.map +1 -1
- package/_types/op-stack/actions/getGame.d.ts.map +1 -1
- package/_types/tempo/Capabilities.d.ts +7 -28
- package/_types/tempo/Capabilities.d.ts.map +1 -1
- package/_types/tempo/Client.d.ts +6 -15
- package/_types/tempo/Client.d.ts.map +1 -1
- package/_types/tempo/ExecutionError.d.ts +79 -0
- package/_types/tempo/ExecutionError.d.ts.map +1 -0
- package/_types/tempo/Relay.d.ts +302 -0
- package/_types/tempo/Relay.d.ts.map +1 -0
- package/_types/tempo/Transaction.d.ts +2 -1
- package/_types/tempo/Transaction.d.ts.map +1 -1
- package/_types/tempo/Transport.d.ts +15 -29
- package/_types/tempo/Transport.d.ts.map +1 -1
- package/_types/tempo/chainConfig.d.ts.map +1 -1
- package/_types/tempo/index.d.ts +8 -3
- package/_types/tempo/index.d.ts.map +1 -1
- package/_types/tempo/internal/relay/cache.d.ts +9 -0
- package/_types/tempo/internal/relay/cache.d.ts.map +1 -0
- package/_types/tempo/internal/relay/deadline.d.ts +4 -0
- package/_types/tempo/internal/relay/deadline.d.ts.map +1 -0
- package/_types/tempo/internal/relay/error.d.ts +47 -0
- package/_types/tempo/internal/relay/error.d.ts.map +1 -0
- package/_types/tempo/internal/relay/feePayer.d.ts +70 -0
- package/_types/tempo/internal/relay/feePayer.d.ts.map +1 -0
- package/_types/tempo/internal/relay/feeToken.d.ts +38 -0
- package/_types/tempo/internal/relay/feeToken.d.ts.map +1 -0
- package/_types/tempo/internal/relay/multisig.d.ts +4 -0
- package/_types/tempo/internal/relay/multisig.d.ts.map +1 -0
- package/_types/tempo/internal/relay/plugin.d.ts +5 -0
- package/_types/tempo/internal/relay/plugin.d.ts.map +1 -0
- package/_types/tempo/internal/relay/preflight.d.ts +17 -0
- package/_types/tempo/internal/relay/preflight.d.ts.map +1 -0
- package/_types/tempo/internal/relay/request.d.ts +16 -0
- package/_types/tempo/internal/relay/request.d.ts.map +1 -0
- package/_types/tempo/internal/relay/simulate.d.ts +59 -0
- package/_types/tempo/internal/relay/simulate.d.ts.map +1 -0
- package/_types/tempo/internal/relay/utils.d.ts +294 -0
- package/_types/tempo/internal/relay/utils.d.ts.map +1 -0
- package/_types/tempo/internal/relay/virtualAddress.d.ts +9 -0
- package/_types/tempo/internal/relay/virtualAddress.d.ts.map +1 -0
- package/_types/tempo/internal/relay.d.ts +4 -0
- package/_types/tempo/internal/relay.d.ts.map +1 -0
- package/_types/tempo/multisig/Config.d.ts +0 -13
- package/_types/tempo/multisig/Config.d.ts.map +1 -1
- package/_types/tempo/multisig/Operation.d.ts +0 -5
- package/_types/tempo/multisig/Operation.d.ts.map +1 -1
- package/_types/utils/siwe/parseSiweMessage.d.ts.map +1 -1
- package/actions/public/waitForTransactionReceipt.ts +16 -2
- package/chains/definitions/blockdag.ts +20 -0
- package/chains/definitions/candyChain.ts +26 -0
- package/chains/definitions/creditCoin3Devnet.ts +6 -0
- package/chains/definitions/creditCoin3Mainnet.ts +6 -0
- package/chains/definitions/creditCoin3Testnet.ts +6 -0
- package/chains/definitions/kortana.ts +20 -0
- package/chains/index.ts +3 -0
- package/clients/createClientResolver.ts +191 -0
- package/errors/version.ts +1 -1
- package/index.ts +6 -0
- package/op-stack/actions/getGame.ts +3 -1
- package/op-stack/actions/getGames.ts +1 -1
- package/op-stack/actions/getTimeToNextGame.ts +2 -2
- package/op-stack/actions/getTimeToNextL2Output.ts +2 -2
- package/package.json +1 -1
- package/tempo/Capabilities.ts +7 -29
- package/tempo/Client.ts +8 -38
- package/tempo/ExecutionError.ts +418 -0
- package/tempo/Relay.ts +428 -0
- package/tempo/Transaction.ts +2 -1
- package/tempo/Transport.ts +69 -60
- package/tempo/chainConfig.ts +4 -0
- package/tempo/index.ts +7 -3
- package/tempo/internal/relay/cache.ts +82 -0
- package/tempo/internal/relay/deadline.ts +45 -0
- package/tempo/internal/relay/error.ts +128 -0
- package/tempo/internal/relay/feePayer.ts +692 -0
- package/tempo/internal/relay/feeToken.ts +190 -0
- package/tempo/{Multisig.ts → internal/relay/multisig.ts} +162 -193
- package/tempo/internal/relay/plugin.ts +13 -0
- package/tempo/internal/relay/preflight.ts +81 -0
- package/tempo/internal/relay/request.ts +391 -0
- package/tempo/internal/relay/simulate.ts +367 -0
- package/tempo/internal/relay/utils.ts +202 -0
- package/tempo/internal/relay/virtualAddress.ts +95 -0
- package/tempo/internal/relay.ts +158 -0
- package/tempo/multisig/Config.ts +3 -2
- package/tempo/multisig/Operation.ts +1 -1
- package/utils/siwe/parseSiweMessage.ts +21 -13
- package/_cjs/tempo/Multisig.js.map +0 -1
- package/_esm/tempo/Multisig.js.map +0 -1
- package/_types/tempo/Multisig.d.ts +0 -37
- package/_types/tempo/Multisig.d.ts.map +0 -1
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
import type { Hex } from '../types/misc.js'
|
|
2
|
+
import type { UnionOmit } from '../types/utils.js'
|
|
3
|
+
import {
|
|
4
|
+
type DecodeErrorResultReturnType,
|
|
5
|
+
decodeErrorResult,
|
|
6
|
+
} from '../utils/abi/decodeErrorResult.js'
|
|
7
|
+
import { formatAbiItem } from '../utils/abi/formatAbiItem.js'
|
|
8
|
+
import { toFunctionSelector } from '../utils/hash/toFunctionSelector.js'
|
|
9
|
+
import * as Abis from './Abis.js'
|
|
10
|
+
|
|
11
|
+
type AllAbis = typeof Abis.core
|
|
12
|
+
type AbiErrorName = Extract<AllAbis[number], { type: 'error' }>['name']
|
|
13
|
+
|
|
14
|
+
type DecodedError<error = DecodeErrorResultReturnType<AllAbis>> =
|
|
15
|
+
error extends DecodeErrorResultReturnType<AllAbis>
|
|
16
|
+
? Omit<error, 'args'> & {
|
|
17
|
+
args: error['args'] | undefined
|
|
18
|
+
data: Hex
|
|
19
|
+
message: string
|
|
20
|
+
}
|
|
21
|
+
: never
|
|
22
|
+
|
|
23
|
+
/** Decoded execution error from a Tempo precompile revert or selector. */
|
|
24
|
+
export type ExecutionError =
|
|
25
|
+
| DecodedError
|
|
26
|
+
| { errorName: 'unknown'; message: string }
|
|
27
|
+
|
|
28
|
+
/** Execution error metadata suitable for JSON serialization. */
|
|
29
|
+
export type Rpc =
|
|
30
|
+
| UnionOmit<DecodedError, 'args'>
|
|
31
|
+
| Extract<ExecutionError, { errorName: 'unknown' }>
|
|
32
|
+
|
|
33
|
+
/** Human-readable templates keyed by error signature in `Abis.core`, with positional `{0}` placeholders. */
|
|
34
|
+
export const messages: Record<`${AbiErrorName}(${string})`, string> = {
|
|
35
|
+
'AbdicationAlreadyScheduled(uint8)':
|
|
36
|
+
'Abdication is already scheduled for capability {0}.',
|
|
37
|
+
'AccountNotAllowed(address)': 'Account {0} is not allowed.',
|
|
38
|
+
'ActiveLeaderRemoved()': 'The active leader cannot be removed.',
|
|
39
|
+
'AddressAlreadyHasValidator()': 'This address already has a validator.',
|
|
40
|
+
'AddressNotReserved()': 'Address is not reserved.',
|
|
41
|
+
'AddressReserved()': 'Address is reserved.',
|
|
42
|
+
'AlreadyInitialized()': 'Already initialized.',
|
|
43
|
+
'AmountExceedsDeposit()': 'Amount exceeds deposit.',
|
|
44
|
+
'AmountNotIncreasing()': 'Amount is not increasing.',
|
|
45
|
+
'BelowMinimumOrderSize(uint128)':
|
|
46
|
+
'Order size is below the minimum allowed ({0}).',
|
|
47
|
+
'CallNotAllowed()': 'This call is not allowed.',
|
|
48
|
+
'CallbackDidNotReturnToZone()': 'The callback did not return to the zone.',
|
|
49
|
+
'CallbackRejected()': 'The callback was rejected.',
|
|
50
|
+
'CannotChangeWithinBlock()': 'Cannot change within the same block.',
|
|
51
|
+
'CapabilityAbdicated(uint8)': 'Capability {0} has been abdicated.',
|
|
52
|
+
'CaptureAmountInvalid()': 'Capture amount is invalid.',
|
|
53
|
+
'ChannelAlreadyExists()': 'Channel already exists.',
|
|
54
|
+
'ChannelNotFound()': 'Channel not found.',
|
|
55
|
+
'CloseNotReady()': 'Channel is not ready to close.',
|
|
56
|
+
'ContractPaused()': 'Contract is paused.',
|
|
57
|
+
'DepositBlockCapacityExceeded(uint64)':
|
|
58
|
+
'The deposit capacity per block exceeds the maximum ({0}).',
|
|
59
|
+
'DepositOverflow()': 'Deposit overflow.',
|
|
60
|
+
'DepositTooSmall()': 'The deposit is too small.',
|
|
61
|
+
'DepositsNotActive()': 'Deposits are not active.',
|
|
62
|
+
'DivisionByZero()': 'Division by zero.',
|
|
63
|
+
'DuplicateAllowedAccount()': 'The allowed account is duplicated.',
|
|
64
|
+
'DuplicateOwner()': 'The owner is duplicated.',
|
|
65
|
+
'DuplicateZoneGateway()': 'The zone gateway is duplicated.',
|
|
66
|
+
'EmptyV1ValidatorSet()': 'Validator set is empty.',
|
|
67
|
+
'EncryptionKeyExpired(uint256,uint64,uint64)':
|
|
68
|
+
'Encryption key {0} has expired.',
|
|
69
|
+
'ExpiringNonceHashNotSet()': 'Expiring nonce hash is not set.',
|
|
70
|
+
'ExpiringNonceReplay()': 'Expiring nonce has already been used.',
|
|
71
|
+
'ExpiringNonceSetFull()': 'Expiring nonce set is full.',
|
|
72
|
+
'ExpiryInPast()': 'Expiry is in the past.',
|
|
73
|
+
'GasFeeRateTooHigh()': 'The gas fee rate is too high.',
|
|
74
|
+
'IdenticalAddresses()': 'Addresses must be different.',
|
|
75
|
+
'IdenticalTokens()':
|
|
76
|
+
'Cannot swap a token for itself — input and output tokens must be different.',
|
|
77
|
+
'IncompatiblePolicyType()': 'Incompatible policy type.',
|
|
78
|
+
'IndexAlreadySet()': 'The index is already set.',
|
|
79
|
+
'IngressAlreadyExists(string)': 'Ingress "{0}" already exists.',
|
|
80
|
+
'InsufficientAllowance()': 'Insufficient allowance.',
|
|
81
|
+
'InsufficientBalance()': 'Insufficient balance.',
|
|
82
|
+
'InsufficientBalance(uint256,uint256,address)':
|
|
83
|
+
'Insufficient balance. Required: {1}, available: {0}.',
|
|
84
|
+
'InsufficientFeeTokenBalance()': 'Insufficient fee token balance.',
|
|
85
|
+
'InsufficientLiquidity()':
|
|
86
|
+
'Not enough liquidity in the order book to fill this trade.',
|
|
87
|
+
'InsufficientOutput()':
|
|
88
|
+
'The output amount is below the slippage minimum — try increasing slippage tolerance.',
|
|
89
|
+
'InsufficientReserves()': 'Insufficient reserves.',
|
|
90
|
+
'InvalidAccount()': 'Invalid account.',
|
|
91
|
+
'InvalidAdmin()': 'Invalid administrator.',
|
|
92
|
+
'InvalidAmount()': 'Invalid amount.',
|
|
93
|
+
'InvalidBaseToken()':
|
|
94
|
+
'This token is not a valid base token for the requested pair.',
|
|
95
|
+
'InvalidBouncebackRecipient()': 'Invalid bounceback recipient.',
|
|
96
|
+
'InvalidCallScope()': 'Invalid call scope.',
|
|
97
|
+
'InvalidCallbackTarget()': 'Invalid callback target.',
|
|
98
|
+
'InvalidCiphertextLength(uint256,uint256)':
|
|
99
|
+
'Invalid ciphertext length. Expected {1}, got {0}.',
|
|
100
|
+
'InvalidClaimAddress()': 'Invalid claim address.',
|
|
101
|
+
'InvalidClosedLoopConfig()': 'Invalid closed-loop configuration.',
|
|
102
|
+
'InvalidConfig()': 'Invalid configuration.',
|
|
103
|
+
'InvalidCurrency()': 'Invalid currency.',
|
|
104
|
+
'InvalidDepositTransition()': 'Invalid deposit transition.',
|
|
105
|
+
'InvalidEncryptionKeyIndex(uint256)': 'Invalid encryption key index ({0}).',
|
|
106
|
+
'InvalidEphemeralPubkey()': 'Invalid ephemeral public key.',
|
|
107
|
+
'InvalidExpiringNonceExpiry()': 'Invalid expiring nonce expiry.',
|
|
108
|
+
'InvalidFlipTick()': 'The flip-order price tick is invalid.',
|
|
109
|
+
'InvalidFormat()': 'Invalid format.',
|
|
110
|
+
'InvalidKeyAuthorizationWitness()': 'Invalid key authorization witness.',
|
|
111
|
+
'InvalidKeyId()': 'Invalid key ID.',
|
|
112
|
+
'InvalidLeader()': 'Invalid leader.',
|
|
113
|
+
'InvalidLogoURI()': 'Invalid logo URI.',
|
|
114
|
+
'InvalidMasterAddress()': 'Invalid master address.',
|
|
115
|
+
'InvalidMigrationIndex()': 'Invalid migration index.',
|
|
116
|
+
'InvalidMode()': 'Invalid mode.',
|
|
117
|
+
'InvalidMultisigOwner()': 'Invalid multisig owner.',
|
|
118
|
+
'InvalidNonceKey()': 'Invalid nonce key.',
|
|
119
|
+
'InvalidOwner()': 'Invalid owner.',
|
|
120
|
+
'InvalidOwnerOrder()': 'Invalid owner order.',
|
|
121
|
+
'InvalidPayee()': 'Invalid payee.',
|
|
122
|
+
'InvalidPayload()': 'Invalid payload.',
|
|
123
|
+
'InvalidPolicyType()': 'Invalid policy type.',
|
|
124
|
+
'InvalidProof()': 'Invalid proof.',
|
|
125
|
+
'InvalidProofOfPossession()': 'Invalid proof of possession.',
|
|
126
|
+
'InvalidPublicKey()': 'Invalid public key.',
|
|
127
|
+
'InvalidQuorumCertificate()': 'Invalid quorum certificate.',
|
|
128
|
+
'InvalidQuoteToken()': 'Invalid quote token.',
|
|
129
|
+
'InvalidReceipt()': 'Invalid receipt.',
|
|
130
|
+
'InvalidReceivePolicyType()': 'Invalid receive policy type.',
|
|
131
|
+
'InvalidRecipient()': 'Invalid recipient.',
|
|
132
|
+
'InvalidRecoveryAuthority()': 'Invalid recovery authority.',
|
|
133
|
+
'InvalidSequencerSet()': 'Invalid sequencer set.',
|
|
134
|
+
'InvalidSignature()': 'Invalid signature.',
|
|
135
|
+
'InvalidSignatureFormat()': 'Invalid signature format.',
|
|
136
|
+
'InvalidSignatureType()': 'Invalid signature type.',
|
|
137
|
+
'InvalidSpendingLimit()': 'Invalid spending limit.',
|
|
138
|
+
'InvalidSupplyCap()': 'Invalid supply cap.',
|
|
139
|
+
'InvalidSwapCalculation()': 'Invalid swap calculation.',
|
|
140
|
+
'InvalidTempoBlockNumber()': 'Invalid Tempo block number.',
|
|
141
|
+
'InvalidThreshold()': 'Invalid threshold.',
|
|
142
|
+
'InvalidTick()': 'The price tick is invalid.',
|
|
143
|
+
'InvalidToken()': 'This token is not supported on the exchange.',
|
|
144
|
+
'InvalidTransferPolicyId()': 'Invalid transfer policy.',
|
|
145
|
+
'InvalidValidatorAddress()': 'Invalid validator address.',
|
|
146
|
+
'InvalidWeight()': 'Invalid weight.',
|
|
147
|
+
'KeyAlreadyExists()': 'Key already exists.',
|
|
148
|
+
'KeyAlreadyRevoked()': 'Key has already been revoked.',
|
|
149
|
+
'KeyAuthorizationWitnessAlreadyBurned()':
|
|
150
|
+
'Key authorization witness has already been burned.',
|
|
151
|
+
'KeyExpired()': 'Key has expired.',
|
|
152
|
+
'KeyNotFound()': 'Key not found.',
|
|
153
|
+
'LeaderAlreadyUpdatedThisBlock()':
|
|
154
|
+
'The leader has already been updated in this block.',
|
|
155
|
+
'LegacyAuthorizeKeySelectorChanged(bytes4)':
|
|
156
|
+
'Legacy authorize key selector changed to {0}.',
|
|
157
|
+
'LogoURITooLong()': 'Logo URI is too long.',
|
|
158
|
+
'MasterIdCollision(address)': 'Master ID collision with {0}.',
|
|
159
|
+
'MaxInputExceeded()':
|
|
160
|
+
'The required input exceeds the slippage maximum — try increasing slippage tolerance.',
|
|
161
|
+
'MigrationNotComplete()': 'Migration is not complete.',
|
|
162
|
+
'MustDelegateCall()': 'A delegate call is required.',
|
|
163
|
+
'NoEncryptionKeyAtBlock(uint64)': 'No encryption key exists at block {0}.',
|
|
164
|
+
'NoEncryptionKeySet()': 'No encryption key is set.',
|
|
165
|
+
'NoOptedInSupply()': 'No opted-in supply.',
|
|
166
|
+
'NonceOverflow()': 'Nonce overflow.',
|
|
167
|
+
'NotAdmin()': 'The caller is not the administrator.',
|
|
168
|
+
'NotFactory()': 'The caller is not the factory.',
|
|
169
|
+
'NotHostPort(string,string,string)':
|
|
170
|
+
'"{1}" is not a valid host:port for {0}.',
|
|
171
|
+
'NotInitialized()': 'Not initialized.',
|
|
172
|
+
'NotIp(string,string)': '"{0}" is not a valid IP address.',
|
|
173
|
+
'NotIpPort(string,string)': '"{0}" is not a valid IP:port.',
|
|
174
|
+
'NotIpPort(string,string,string)': '"{1}" is not a valid IP:port for {0}.',
|
|
175
|
+
'NotOwner()': 'The caller is not an owner.',
|
|
176
|
+
'NotPauseAuthority()': 'The caller is not the pause authority.',
|
|
177
|
+
'NotPayeeOrOperator()': 'Not payee or operator.',
|
|
178
|
+
'NotPayer()': 'Not payer.',
|
|
179
|
+
'NotPendingAdmin()': 'The caller is not the pending administrator.',
|
|
180
|
+
'NotSelf()': 'The caller must be the contract itself.',
|
|
181
|
+
'NotSequencer()': 'The caller is not a sequencer.',
|
|
182
|
+
'OnlyDirectCall()': 'A direct call is required.',
|
|
183
|
+
'OrderDoesNotExist()': 'No order exists with the given ID.',
|
|
184
|
+
'OrderNotStale()': 'This order is not yet eligible for stale-cleanup.',
|
|
185
|
+
'PairAlreadyExists()':
|
|
186
|
+
'A trading pair for these tokens has already been created.',
|
|
187
|
+
'PairDoesNotExist()': 'No trading pair exists for these tokens.',
|
|
188
|
+
'PermitExpired()': 'Permit has expired.',
|
|
189
|
+
'PolicyForbids()': 'Forbidden by policy.',
|
|
190
|
+
'PolicyNotFound()': 'Policy not found.',
|
|
191
|
+
'PolicyNotSimple()': 'Policy is not a simple policy.',
|
|
192
|
+
'PortalIsPaused()': 'The portal is paused.',
|
|
193
|
+
'ProofOfWorkFailed()': 'Proof of work failed.',
|
|
194
|
+
'ProtectedAddress()': 'Address is protected.',
|
|
195
|
+
'ProtocolNonceNotSupported()': 'Protocol nonce is not supported.',
|
|
196
|
+
'PublicKeyAlreadyExists()': 'Public key already exists.',
|
|
197
|
+
'ReentrantWithdrawal()': 'Reentrant withdrawals are not allowed.',
|
|
198
|
+
'SequencerConfigurationUnchanged()':
|
|
199
|
+
'The sequencer configuration is unchanged.',
|
|
200
|
+
'SignatureTypeMismatch(uint8,uint8)':
|
|
201
|
+
'Signature type mismatch. Expected {0}, got {1}.',
|
|
202
|
+
'SpendingLimitExceeded()': 'Spending limit exceeded.',
|
|
203
|
+
'StaleLeadershipEpoch(uint64,uint64)':
|
|
204
|
+
'Stale leadership epoch. Expected {0}, got {1}.',
|
|
205
|
+
'SupplyCapExceeded()': 'Supply cap exceeded.',
|
|
206
|
+
'TickOutOfBounds(int16)': 'Price tick {0} is outside the allowed range.',
|
|
207
|
+
'TokenAlreadyEnabled()': 'The token is already enabled.',
|
|
208
|
+
'TokenAlreadyExists(address)': 'Token {0} already exists.',
|
|
209
|
+
'TokenEnablementBlockCapacityExceeded(uint64)':
|
|
210
|
+
'The token enablement capacity per block exceeds the maximum ({0}).',
|
|
211
|
+
'TokenMetadataTooLong()': 'Token metadata is too long.',
|
|
212
|
+
'TokenNotEnabled()': 'The token is not enabled.',
|
|
213
|
+
'TokenTransferPolicyNotSet()': 'The token transfer policy is not set.',
|
|
214
|
+
'TooManyOwners()': 'There are too many owners.',
|
|
215
|
+
'TransferFailed()': 'The transfer failed.',
|
|
216
|
+
'Unauthorized()': 'Unauthorized.',
|
|
217
|
+
'UnauthorizedCaller()': 'Unauthorized caller.',
|
|
218
|
+
'UnauthorizedClaimer()': 'Unauthorized claimer.',
|
|
219
|
+
'UnauthorizedMultisigCaller()': 'Unauthorized multisig caller.',
|
|
220
|
+
'Uninitialized()': 'Uninitialized.',
|
|
221
|
+
'ValidatorAlreadyDeactivated()': 'Validator is already deactivated.',
|
|
222
|
+
'ValidatorAlreadyExists()': 'Validator already exists.',
|
|
223
|
+
'ValidatorNotFound()': 'Validator not found.',
|
|
224
|
+
'VirtualAddressNotAllowed()': 'Virtual address is not allowed.',
|
|
225
|
+
'VirtualAddressUnregistered()': 'Virtual address is not registered.',
|
|
226
|
+
'ZeroDeposit()': 'Deposit cannot be zero.',
|
|
227
|
+
'ZeroPublicKey()': 'Public key cannot be zero.',
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** Interpolate `{0}`, `{1}`, … placeholders with args. */
|
|
231
|
+
function interpolate(template: string, args?: readonly unknown[]): string {
|
|
232
|
+
if (!args) return template
|
|
233
|
+
return template.replace(/\{(\d+)\}/g, (_, i) => {
|
|
234
|
+
const v = args[Number(i)]
|
|
235
|
+
return v === undefined ? `{${i}}` : String(v)
|
|
236
|
+
})
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Decorates a copy of an error with decoded Tempo execution details.
|
|
241
|
+
*
|
|
242
|
+
* Preserves the input's prototype, stack, cause, and custom properties.
|
|
243
|
+
* Hex input can be a selector or full revert data. Without arguments,
|
|
244
|
+
* message placeholders remain uninterpolated.
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* ```ts
|
|
248
|
+
* import { ExecutionError } from 'viem/tempo'
|
|
249
|
+
*
|
|
250
|
+
* const error = ExecutionError.from('0x82b42900')
|
|
251
|
+
* error.message
|
|
252
|
+
* // @log: 'Unauthorized.'
|
|
253
|
+
* ```
|
|
254
|
+
*
|
|
255
|
+
* @param error - Error instance, plain error object, selector, or revert data.
|
|
256
|
+
* @returns A decorated copy, leaving the original input unchanged.
|
|
257
|
+
*/
|
|
258
|
+
export function from<error extends from.Parameters>(
|
|
259
|
+
error: error,
|
|
260
|
+
): from.ReturnType<error>
|
|
261
|
+
export function from(error: from.Parameters): from.ReturnType {
|
|
262
|
+
const source =
|
|
263
|
+
typeof error === 'string'
|
|
264
|
+
? { data: error, message: 'Unknown execution error.' }
|
|
265
|
+
: error
|
|
266
|
+
const decoded = parse(source)
|
|
267
|
+
const descriptors: PropertyDescriptorMap =
|
|
268
|
+
Object.getOwnPropertyDescriptors(source)
|
|
269
|
+
|
|
270
|
+
// Native stack accessors depend on the original error's internal state.
|
|
271
|
+
if ('stack' in source)
|
|
272
|
+
descriptors.stack = {
|
|
273
|
+
configurable: descriptors.stack?.configurable ?? true,
|
|
274
|
+
enumerable: descriptors.stack?.enumerable ?? false,
|
|
275
|
+
value: source.stack,
|
|
276
|
+
writable: descriptors.stack?.writable ?? true,
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
for (const [key, descriptor] of Object.entries(
|
|
280
|
+
Object.getOwnPropertyDescriptors(decoded),
|
|
281
|
+
))
|
|
282
|
+
descriptors[key] = {
|
|
283
|
+
...descriptor,
|
|
284
|
+
enumerable: descriptors[key]?.enumerable ?? true,
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
return Object.create(Object.getPrototypeOf(source), descriptors)
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export declare namespace from {
|
|
291
|
+
/** Error instance, plain error object, or ABI-encoded selector or revert data. */
|
|
292
|
+
export type Parameters =
|
|
293
|
+
| Error
|
|
294
|
+
| Hex
|
|
295
|
+
| {
|
|
296
|
+
/** ABI-encoded revert data. */
|
|
297
|
+
data?: Hex | { data: Hex } | undefined
|
|
298
|
+
/** Fallback message when revert data cannot be decoded. */
|
|
299
|
+
message: string
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/** Original properties with decoded execution fields taking precedence. */
|
|
303
|
+
export type ReturnType<
|
|
304
|
+
error extends Parameters = Parameters,
|
|
305
|
+
result extends ExecutionError = ExecutionError,
|
|
306
|
+
> = result extends ExecutionError
|
|
307
|
+
? Omit<error extends Hex ? { data: error } : error, keyof result> & result
|
|
308
|
+
: never
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Selects execution metadata for JSON serialization.
|
|
313
|
+
*
|
|
314
|
+
* Omits decoded arguments and original error properties, including the stack and cause.
|
|
315
|
+
*
|
|
316
|
+
* @example
|
|
317
|
+
* ```ts
|
|
318
|
+
* import { ExecutionError } from 'viem/tempo'
|
|
319
|
+
*
|
|
320
|
+
* const error = ExecutionError.from(new Error('execution reverted: failed'))
|
|
321
|
+
* const rpc = ExecutionError.serialize(error)
|
|
322
|
+
* // { errorName: 'unknown', message: 'failed' }
|
|
323
|
+
* ```
|
|
324
|
+
*
|
|
325
|
+
* @param preimage - Decorated execution error.
|
|
326
|
+
* @returns Execution error without decoded arguments.
|
|
327
|
+
*/
|
|
328
|
+
export function serialize(preimage: ExecutionError): Rpc {
|
|
329
|
+
if (preimage.errorName === 'unknown')
|
|
330
|
+
return { errorName: 'unknown', message: preimage.message }
|
|
331
|
+
return {
|
|
332
|
+
errorName: preimage.errorName,
|
|
333
|
+
abiItem: preimage.abiItem,
|
|
334
|
+
message: preimage.message,
|
|
335
|
+
data: preimage.data,
|
|
336
|
+
} as never
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function extractRevertData(
|
|
340
|
+
error: unknown,
|
|
341
|
+
seen = new Set<unknown>(),
|
|
342
|
+
): Hex | null {
|
|
343
|
+
if (!error || typeof error !== 'object' || seen.has(error)) return null
|
|
344
|
+
seen.add(error)
|
|
345
|
+
const e = error as Record<string, unknown>
|
|
346
|
+
if (typeof e.data === 'string' && /^0x(?:[\da-f]{2})*$/i.test(e.data))
|
|
347
|
+
return e.data as Hex
|
|
348
|
+
for (const inner of [e.data, e.cause, e.error]) {
|
|
349
|
+
const data = extractRevertData(inner, seen)
|
|
350
|
+
if (data) return data
|
|
351
|
+
}
|
|
352
|
+
if (typeof e.walk === 'function') {
|
|
353
|
+
const inner = (
|
|
354
|
+
e as { walk: (fn: (e: unknown) => boolean) => unknown }
|
|
355
|
+
).walk((e) => typeof (e as Record<string, unknown>).data === 'string')
|
|
356
|
+
if (inner) return extractRevertData(inner, seen)
|
|
357
|
+
}
|
|
358
|
+
return null
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
function parse(error: Exclude<from.Parameters, Hex>): ExecutionError {
|
|
362
|
+
const raw =
|
|
363
|
+
(error as { details?: string }).details ??
|
|
364
|
+
(error as { shortMessage?: string }).shortMessage ??
|
|
365
|
+
error.message
|
|
366
|
+
|
|
367
|
+
const data = extractRevertData(error)
|
|
368
|
+
if (data) {
|
|
369
|
+
try {
|
|
370
|
+
const decoded = decodeErrorResult({ abi: Abis.core, data })
|
|
371
|
+
const template =
|
|
372
|
+
messages[formatAbiItem(decoded.abiItem) as keyof typeof messages]
|
|
373
|
+
return {
|
|
374
|
+
...decoded,
|
|
375
|
+
data,
|
|
376
|
+
message: template
|
|
377
|
+
? interpolate(template, decoded.args as readonly unknown[])
|
|
378
|
+
: raw.replace(/^execution reverted:\s*/i, ''),
|
|
379
|
+
} as never
|
|
380
|
+
} catch {
|
|
381
|
+
if (data.length === 10) {
|
|
382
|
+
const abiItem = Abis.core.find(
|
|
383
|
+
(item) =>
|
|
384
|
+
item.type === 'error' &&
|
|
385
|
+
toFunctionSelector(formatAbiItem(item)) === data.toLowerCase(),
|
|
386
|
+
)
|
|
387
|
+
if (abiItem?.type === 'error')
|
|
388
|
+
return {
|
|
389
|
+
abiItem,
|
|
390
|
+
args: undefined,
|
|
391
|
+
data,
|
|
392
|
+
errorName: abiItem.name,
|
|
393
|
+
message: messages[formatAbiItem(abiItem) as keyof typeof messages]!,
|
|
394
|
+
} as DecodedError
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// Human-readable names cannot distinguish overloads with different templates.
|
|
400
|
+
const nameMatch = /:\s*(\w+)\(([^)]*)\)/.exec(raw)
|
|
401
|
+
if (nameMatch) {
|
|
402
|
+
const templates = Object.entries(messages).filter(([signature]) =>
|
|
403
|
+
signature.startsWith(`${nameMatch[1]}(`),
|
|
404
|
+
)
|
|
405
|
+
const template =
|
|
406
|
+
nameMatch[2] === ''
|
|
407
|
+
? messages[`${nameMatch[1]}()` as keyof typeof messages]
|
|
408
|
+
: templates.length === 1
|
|
409
|
+
? templates[0]?.[1]
|
|
410
|
+
: undefined
|
|
411
|
+
if (template) return { errorName: 'unknown', message: template }
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
return {
|
|
415
|
+
errorName: 'unknown',
|
|
416
|
+
message: raw.replace(/^execution reverted:\s*/i, ''),
|
|
417
|
+
}
|
|
418
|
+
}
|