Skip to content

Commit

Permalink
Ccip/add hex error messages (#1886)
Browse files Browse the repository at this point in the history
* add error selectors

* add error selectors

* errors

* errors

* errors
  • Loading branch information
aelmanaa authored Apr 17, 2024
1 parent 07579fe commit d00edb8
Show file tree
Hide file tree
Showing 12 changed files with 454 additions and 35 deletions.
12 changes: 12 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"focus-trap-react": "^10.2.3",
"github-slugger": "^2.0.0",
"lodash": "^4.17.21",
"marked": "^12.0.1",
"nanostores": "^0.9.5",
"preact": "^10.20.1",
"react-instantsearch": "^7.7.0",
Expand Down
15 changes: 15 additions & 0 deletions src/config/data/ccip/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
TokensConfig,
Environment,
Version,
CCIPSendErrorEntry,
SupportedTokenConfig,
determineTokenMechanism,
TokenMechanism,
Expand All @@ -21,12 +22,26 @@ import chainsTestnetv120 from "@config/data/ccip/v1_2_0/testnet/chains.json"
import lanesTestnetv120 from "@config/data/ccip/v1_2_0/testnet/lanes.json"
import tokensTestnetv120 from "@config/data/ccip/v1_2_0/testnet/tokens.json"

// errors

import erc20CCIPSendErrors from "@config/data/ccip/errors/erc20.json"
import routerCCIPSendErrors from "@config/data/ccip/errors/router.json"
import onrampCCIPSendErrors from "@config/data/ccip/errors/onramp.json"
import ratelimiterCCIPSendErrors from "@config/data/ccip/errors/ratelimiter.json"
import priceregistryCCIPSendErrors from "@config/data/ccip/errors/priceregistry.json"

import { SupportedChain } from "@config/types"
import { directoryToSupportedChain, supportedChainToChainInRdd } from "@features/utils"

export const getAllEnvironments = () => [Environment.Mainnet, Environment.Testnet]
export const getAllVersions = () => [Version.V1_2_0]

export const erc20Errors: CCIPSendErrorEntry[] = erc20CCIPSendErrors
export const routerErrors: CCIPSendErrorEntry[] = routerCCIPSendErrors
export const onrampErrors: CCIPSendErrorEntry[] = onrampCCIPSendErrors
export const ratelimiterErrors: CCIPSendErrorEntry[] = ratelimiterCCIPSendErrors
export const priceRegistryErrors: CCIPSendErrorEntry[] = priceregistryCCIPSendErrors

export const networkFees: NetworkFees = {
tokenTransfers: {
[TokenMechanism.LockAndUnlock]: {
Expand Down
10 changes: 10 additions & 0 deletions src/config/data/ccip/errors/erc20.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"error": "ERC20: burn amount exceeds balance",
"description": "Thrown when the amount to be burned exceeds the pool balance."
},
{
"error": "ERC20: transfer amount exceeds allowance",
"description": "Thrown when the transfer amount exceeds the allowance."
}
]
114 changes: 114 additions & 0 deletions src/config/data/ccip/errors/onramp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
[
{
"error": "CannotSendZeroTokens",
"parameters": [],
"errorSelector": "0x5cf04449",
"description": "Thrown when the user tries to send a zero amount of tokens."
},
{
"error": "InvalidAddress",
"parameters": [
{
"type": "bytes",
"name": "encodedAddress"
}
],
"errorSelector": "0x370d875f",
"description": "Thrown when the receiver address is invalid."
},
{
"error": "InvalidChainSelector",
"parameters": [
{
"type": "uint64",
"name": "chainSelector"
}
],
"errorSelector": "0xd9a9cd68",
"description": "Thrown when an invalid destination chain selector is used."
},
{
"error": "InvalidExtraArgsTag",
"parameters": [],
"errorSelector": "0x5247fdce",
"description": "Thrown when an invalid extra arguments tag is used."
},
{
"error": "MaxFeeBalanceReached",
"parameters": [],
"errorSelector": "0xe5c7a491",
"description": "Thrown when the onRamp has reached its maximum fee storage capacity. If it is full, it cannot process new transactions."
},
{
"error": "MessageGasLimitTooHigh",
"parameters": [],
"errorSelector": "0x4c4fc93a",
"description": "Thrown when the gas limit is too high."
},
{
"error": "MessageTooLarge",
"parameters": [
{
"type": "uint256",
"name": "maxSize"
},
{
"type": "uint256",
"name": "actualSize"
}
],
"errorSelector": "0x86933789",
"description": "Thrown when the message size exceeds the maximum allowed size."
},
{
"error": "MustBeCalledByRouter",
"parameters": [],
"errorSelector": "0x1c0a3529",
"description": "This error should never be thrown as the router always makes the call."
},
{
"error": "NotAFeeToken",
"parameters": [
{
"type": "address",
"name": "token"
}
],
"errorSelector": "0xa7499d20",
"description": "Thrown when an unsupported fee token is used."
},
{
"error": "RouterMustSetOriginalSender",
"parameters": [],
"errorSelector": "0xa4ec7479",
"description": "This error should never be thrown as the router always sets the sender."
},
{
"error": "SenderNotAllowed",
"parameters": [
{
"type": "address",
"name": "sender"
}
],
"errorSelector": "0xd0d25976",
"description": "Thrown when the sender is not allowlisted."
},
{
"error": "UnsupportedNumberOfTokens",
"parameters": [],
"errorSelector": "0x4c056b6a",
"description": "Thrown when too many tokens are involved in the transfer."
},
{
"error": "UnsupportedToken",
"parameters": [
{
"type": "IERC20",
"name": "token"
}
],
"errorSelector": "0xbf16aab6",
"description": "Thrown when an unsupported transfer token is used."
}
]
62 changes: 62 additions & 0 deletions src/config/data/ccip/errors/priceregistry.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
[
{
"error": "ChainNotSupported",
"parameters": [
{
"type": "uint64",
"name": "chain"
}
],
"errorSelector": "0x2e59db3a",
"description": "Thrown when a chain is not supported."
},
{
"error": "StaleGasPrice",
"parameters": [
{
"type": "uint64",
"name": "destChainSelector"
},
{
"type": "uint256",
"name": "threshold"
},
{
"type": "uint256",
"name": "timePassed"
}
],
"errorSelector": "0xf08bcb3e",
"description": "Thrown when the gas price is stale."
},
{
"error": "TokenNotSupported",
"parameters": [
{
"type": "address",
"name": "token"
}
],
"errorSelector": "0x06439c6b",
"description": "Thrown when a token is not supported."
},
{
"error": "StaleTokenPrice",
"parameters": [
{
"type": "address",
"name": "token"
},
{
"type": "uint256",
"name": "threshold"
},
{
"type": "uint256",
"name": "timePassed"
}
],
"errorSelector": "0xc65fdfca",
"description": "Thrown when the price of a token is stale."
}
]
87 changes: 87 additions & 0 deletions src/config/data/ccip/errors/ratelimiter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
[
{
"error": "AggregateValueMaxCapacityExceeded",
"parameters": [
{
"type": "uint256",
"name": "capacity"
},
{
"type": "uint256",
"name": "requested"
}
],
"errorSelector": "0xf94ebcd1",
"description": "Thrown when the user requests to transfer more value than the capacity of the aggregate rate limit bucket."
},
{
"error": "AggregateValueRateLimitReached",
"parameters": [
{
"type": "uint256",
"name": "minWaitInSeconds"
},
{
"type": "uint256",
"name": "available"
}
],
"errorSelector": "0x15279c08",
"description": "Thrown when the user requests to transfer more value than currently available in the bucket. The user might have to wait for at least `minWaitInSeconds` for enough availability or transfer the currently `available` amount."
},
{
"error": "BucketOverfilled",
"parameters": [],
"errorSelector": "0x9725942a",
"description": "This error should never be thrown as it indicates an invalid bucket state."
},
{
"error": "PriceNotFoundForToken",
"parameters": [
{
"type": "address",
"name": "token"
}
],
"errorSelector": "0x9a655f7b",
"description": "Thrown when a price cannot be found for a specific token."
},
{
"error": "TokenMaxCapacityExceeded",
"parameters": [
{
"type": "uint256",
"name": "capacity"
},
{
"type": "uint256",
"name": "requested"
},
{
"type": "address",
"name": "tokenAddress"
}
],
"errorSelector": "0x1a76572a",
"description": "Thrown when the user requests to transfer more of a token than the capacity of the bucket."
},
{
"error": "TokenRateLimitReached",
"parameters": [
{
"type": "uint256",
"name": "minWaitInSeconds"
},
{
"type": "uint256",
"name": "available"
},
{
"type": "address",
"name": "tokenAddress"
}
],
"errorSelector": "0xd0c8d23a",
"description": "Thrown when the user requests to transfer more of a token than currently available in the bucket. The user might have to wait at least `minWaitInSeconds` for enough availability, or transfer the currently `available` amount."
}
]
25 changes: 25 additions & 0 deletions src/config/data/ccip/errors/router.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[
{
"error": "UnsupportedDestinationChain",
"parameters": [
{
"type": "uint64",
"name": "destChainSelector"
}
],
"errorSelector": "0xae236d9c",
"description": "Thrown when the destination chain is not supported."
},
{
"error": "InsufficientFeeTokenAmount",
"parameters": [],
"errorSelector": "0x07da6ee6",
"description": "Thrown when the CCIP fees are paid with native tokens, but not enough is sent with the transaction."
},
{
"error": "InvalidMsgValue",
"parameters": [],
"errorSelector": "0x1841b4e1",
"description": "Thrown when the CCIP fees are _not_ paid in native tokens, but `msg.value` is non-zero."
}
]
10 changes: 10 additions & 0 deletions src/config/data/ccip/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,13 @@ export enum Environment {
export enum Version {
V1_2_0 = "1.2.0",
}

export interface CCIPSendErrorEntry {
error: string
parameters?: Array<{
type: string
name: string
}>
errorSelector?: string
description: string
}
Loading

0 comments on commit d00edb8

Please sign in to comment.