Skip to content

Commit

Permalink
feat: add executeAbort to gatewayZEVM (#452)
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis authored Feb 25, 2025
1 parent e9fdc48 commit d46f98d
Show file tree
Hide file tree
Showing 23 changed files with 1,010 additions and 149 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
run: |
yarn install
forge soldeer update
- name: Test
run: yarn test

Expand Down
20 changes: 19 additions & 1 deletion contracts/zevm/GatewayZEVM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity 0.8.26;
import { CallOptions, IGatewayZEVM } from "./interfaces/IGatewayZEVM.sol";

import { INotSupportedMethods } from "../../contracts/Errors.sol";
import { RevertContext, RevertOptions, Revertable } from "../../contracts/Revert.sol";
import { AbortContext, Abortable, RevertContext, RevertOptions, Revertable } from "../../contracts/Revert.sol";
import "./interfaces/IWZETA.sol";
import { IZRC20 } from "./interfaces/IZRC20.sol";
import { MessageContext, UniversalContract } from "./interfaces/UniversalContract.sol";
Expand Down Expand Up @@ -439,4 +439,22 @@ contract GatewayZEVM is
if (!IZRC20(zrc20).deposit(target, amount)) revert ZRC20DepositFailed();
Revertable(target).onRevert(revertContext);
}

/// @notice Call onAbort on a user-specified contract on ZEVM.
/// this function doesn't deposit the asset to the target contract. This operation is done directly by the protocol.
/// the assets are deposited to the target contract even if onAbort reverts.
/// @param target The target contract to call.
/// @param abortContext Abort context to pass to onAbort.
function executeAbort(
address target,
AbortContext calldata abortContext
)
external
nonReentrant
onlyProtocol
whenNotPaused
{
if (target == address(0)) revert ZeroAddress();
Abortable(target).onAbort(abortContext);
}
}
121 changes: 121 additions & 0 deletions data/addresses.mainnet.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


[
{
"address": "0x000007Cf399229b2f5A4D043F20E90C9C98B7C6a",
Expand Down Expand Up @@ -195,6 +197,19 @@
"address": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf",
"type": "zetaToken"
},
{
"address": "0x0327f0660525b15Cdb8f1f5FBF0dD7Cd5Ba182aD",
"asset": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
"category": "omnichain",
"chain_id": 7000,
"chain_name": "zeta_mainnet",
"coin_type": "erc20",
"decimals": 6,
"description": "ZetaChain ZRC20 USDC on Arbitrum One",
"foreign_chain_id": "42161",
"symbol": "USDC.ARB",
"type": "zrc20"
},
{
"address": "0x05BA149A7bd6dC1F937fA9046A9e05C05f3b18b0",
"asset": "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",
Expand All @@ -208,6 +223,19 @@
"symbol": "USDC.BSC",
"type": "zrc20"
},
{
"address": "0x0ca762FA958194795320635c11fF0C45C6412958",
"asset": "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
"category": "omnichain",
"chain_id": 7000,
"chain_name": "zeta_mainnet",
"coin_type": "erc20",
"decimals": 6,
"description": "ZetaChain ZRC20 USDT on Arbitrum One",
"foreign_chain_id": "42161",
"symbol": "USDT.ARB",
"type": "zrc20"
},
{
"address": "0x0cbe0dF132a6c6B4a2974Fa1b7Fb953CF0Cc798a",
"asset": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
Expand Down Expand Up @@ -260,6 +288,19 @@
"symbol": "PEPE.ETH",
"type": "zrc20"
},
{
"address": "0x2Db395976CDb9eeFCc8920F4F2f0736f1D575794",
"asset": "0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7",
"category": "omnichain",
"chain_id": 7000,
"chain_name": "zeta_mainnet",
"coin_type": "erc20",
"decimals": 6,
"description": "ZetaChain ZRC20 USDT on Avalanche C-Chain",
"foreign_chain_id": "43114",
"symbol": "USDT.AVAX",
"type": "zrc20"
},
{
"address": "0x3e128c169564DD527C8e9bd85124BF6A890E5a5f",
"asset": "0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf",
Expand Down Expand Up @@ -377,6 +418,32 @@
"symbol": "USDC.BASE",
"type": "zrc20"
},
{
"address": "0xa52Ad01A1d62b408fFe06C2467439251da61E4a9",
"asset": "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
"category": "omnichain",
"chain_id": 7000,
"chain_name": "zeta_mainnet",
"coin_type": "erc20",
"decimals": 6,
"description": "ZetaChain ZRC20 USDC on Avalanche C-Chain",
"foreign_chain_id": "43114",
"symbol": "USDC.AVAX",
"type": "zrc20"
},
{
"address": "0xA614Aebf7924A3Eb4D066aDCA5595E4980407f1d",
"asset": "",
"category": "omnichain",
"chain_id": 7000,
"chain_name": "zeta_mainnet",
"coin_type": "gas",
"decimals": 18,
"description": "ZetaChain ZRC20 Arbitrum One ETH",
"foreign_chain_id": "42161",
"symbol": "ETH.ARB",
"type": "zrc20"
},
{
"address": "0xADF73ebA3Ebaa7254E859549A44c74eF7cff7501",
"asset": "",
Expand Down Expand Up @@ -455,6 +522,19 @@
"symbol": "USDT.POL",
"type": "zrc20"
},
{
"address": "0xe1A4f44b12eb72DC6da556Be9Ed1185141d7C23c",
"asset": "0x8eD97a637A790Be1feff5e888d43629dc05408F6",
"category": "omnichain",
"chain_id": 7000,
"chain_name": "zeta_mainnet",
"coin_type": "erc20",
"decimals": 18,
"description": "ZetaChain ZRC20 NPC on Ethereum Mainnet",
"foreign_chain_id": "1",
"symbol": "NPC.ETH",
"type": "zrc20"
},
{
"address": "0xe573a6e11f8506620F123DBF930222163D46BCB6",
"asset": "0x0E7779e698052f8fe56C415C3818FCf89de9aC6D",
Expand All @@ -481,6 +561,19 @@
"symbol": "CBBTC.BASE",
"type": "zrc20"
},
{
"address": "0xE8d7796535F1cd63F0fe8D631E68eACe6839869B",
"asset": "",
"category": "omnichain",
"chain_id": 7000,
"chain_name": "zeta_mainnet",
"coin_type": "gas",
"decimals": 18,
"description": "ZetaChain ZRC20 Avalanche C-Chain AVAX",
"foreign_chain_id": "43114",
"symbol": "AVAX.AVAX",
"type": "zrc20"
},
{
"address": "0xEe9CC614D03e7Dbe994b514079f4914a605B4719",
"asset": "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",
Expand Down Expand Up @@ -548,5 +641,33 @@
"chain_id": 8453,
"chain_name": "base_mainnet",
"type": "zetaToken"
},
{
"address": "0xECe33274237E6422f2668eD7dEE5901b16336aA0",
"category": "omnichain",
"chain_id": 42161,
"chain_name": "empty",
"type": "erc20Custody"
},
{
"address": "0x70e967acFcC17c3941E87562161406d41676FD83",
"category": "omnichain",
"chain_id": 42161,
"chain_name": "arbitrum_mainnet",
"type": "tss"
},
{
"address": "0xECe33274237E6422f2668eD7dEE5901b16336aA0",
"category": "omnichain",
"chain_id": 43114,
"chain_name": "empty",
"type": "erc20Custody"
},
{
"address": "0x70e967acFcC17c3941E87562161406d41676FD83",
"category": "omnichain",
"chain_id": 43114,
"chain_name": "avalanche_mainnet",
"type": "tss"
}
]
16 changes: 16 additions & 0 deletions data/addresses.testnet.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


[
{
"address": "0x0000ecb8cdd25a18f12daa23f6422e07fbf8b9e1",
Expand Down Expand Up @@ -313,6 +315,13 @@
"chain_name": "empty",
"type": "erc20Custody"
},
{
"address": "0x8531a5aB847ff5B22D855633C25ED1DA3255247e",
"category": "omnichain",
"chain_id": 43113,
"chain_name": "avalanche_testnet",
"type": "tss"
},
{
"address": "0x60E6b70bC2761f878Ff992276612F67FbABC1761",
"category": "messaging",
Expand Down Expand Up @@ -404,6 +413,13 @@
"chain_name": "empty",
"type": "erc20Custody"
},
{
"address": "0x8531a5aB847ff5B22D855633C25ED1DA3255247e",
"category": "omnichain",
"chain_id": 421614,
"chain_name": "arbitrum_sepolia",
"type": "tss"
},
{
"address": "0x3963341dad121c9CD33046089395D66eBF20Fb03",
"category": "messaging",
Expand Down
1 change: 1 addition & 0 deletions docs/book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ title = ""
no-section-label = true
additional-js = ["solidity.min.js"]
additional-css = ["book.css"]
mathjax-support = true
git-repository-url = "https://github.com/zeta-chain/protocol-contracts"

[output.html.fold]
Expand Down
25 changes: 25 additions & 0 deletions docs/src/contracts/zevm/GatewayZEVM.sol/contract.GatewayZEVM.md
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,31 @@ function depositAndRevert(
|`revertContext`|`RevertContext`|Revert context to pass to onRevert.|


### executeAbort

Call onAbort on a user-specified contract on ZEVM.
this function doesn't deposit the asset to the target contract. This operation is done directly by the protocol.
the assets are deposited to the target contract even if onAbort reverts.


```solidity
function executeAbort(
address target,
AbortContext calldata abortContext
)
external
nonReentrant
onlyProtocol
whenNotPaused;
```
**Parameters**

|Name|Type|Description|
|----|----|-----------|
|`target`|`address`|The target contract to call.|
|`abortContext`|`AbortContext`|Abort context to pass to onAbort.|


## Errors
### ZeroAddress
Error indicating a zero address was provided.
Expand Down
4 changes: 2 additions & 2 deletions lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type ParamSymbol = "USDC.BSC" | "USDC.ETH" | "BTC.BTC" | "ETH.BASE" | "PEPE.ETH" | "CBBTC.ETH" | "BNB.BSC" | "SOL.SOL" | "CBBTC.SOL" | "SHIB.ETH" | "USDT.ETH" | "USDC.SOL" | "USDT.BSC" | "USDC.BASE" | "POL.POLYGON" | "DAI.ETH" | "WBTC.ETH" | "ULTI.BSC" | "ETH.ETH" | "USDT.POL" | "ULTI.ETH" | "CBBTC.BASE" | "USDT.SOL" | "USDC.POL" | "sETH.SEPOLIA" | "ETH.ARBSEP" | "ETH.BASESEPOLIA" | "USDC.ARBSEP" | "MATIC.AMOY" | "USDC" | "USDC.FUJI" | "AVAX.FUJI" | "SOL.SOLANA" | "USDC.SEPOLIA" | "tBNB" | "sBTC" | "USDC.AMOY" | "tBTC";
export type ParamChainName = "eth_mainnet" | "bsc_mainnet" | "polygon_mainnet" | "solana_mainnet" | "zeta_mainnet" | "btc_mainnet" | "base_mainnet" | "bsc_testnet" | "solana_devnet" | "zeta_testnet" | "btc_signet_testnet" | "btc_testnet4" | "empty" | "amoy_testnet" | "base_sepolia" | "sepolia_testnet";
export type ParamSymbol = "USDC.ARB" | "USDC.BSC" | "USDT.ARB" | "USDC.ETH" | "BTC.BTC" | "ETH.BASE" | "PEPE.ETH" | "USDT.AVAX" | "CBBTC.ETH" | "BNB.BSC" | "SOL.SOL" | "CBBTC.SOL" | "SHIB.ETH" | "USDT.ETH" | "USDC.SOL" | "USDT.BSC" | "USDC.BASE" | "USDC.AVAX" | "ETH.ARB" | "POL.POLYGON" | "DAI.ETH" | "WBTC.ETH" | "ULTI.BSC" | "ETH.ETH" | "USDT.POL" | "NPC.ETH" | "ULTI.ETH" | "CBBTC.BASE" | "AVAX.AVAX" | "USDT.SOL" | "USDC.POL" | "sETH.SEPOLIA" | "ETH.ARBSEP" | "ETH.BASESEPOLIA" | "USDC.ARBSEP" | "MATIC.AMOY" | "USDC" | "USDC.FUJI" | "AVAX.FUJI" | "SOL.SOLANA" | "USDC.SEPOLIA" | "tBNB" | "sBTC" | "USDC.AMOY" | "tBTC";
export type ParamChainName = "eth_mainnet" | "bsc_mainnet" | "polygon_mainnet" | "solana_mainnet" | "zeta_mainnet" | "btc_mainnet" | "base_mainnet" | "empty" | "arbitrum_mainnet" | "avalanche_mainnet" | "bsc_testnet" | "solana_devnet" | "zeta_testnet" | "btc_signet_testnet" | "btc_testnet4" | "avalanche_testnet" | "amoy_testnet" | "base_sepolia" | "arbitrum_sepolia" | "sepolia_testnet";
export type ParamType = "connector" | "erc20Custody" | "gateway" | "tss" | "uniswapV2Factory" | "uniswapV2Router02" | "uniswapV3Factory" | "uniswapV3Router" | "weth9" | "zetaToken" | "fungibleModule" | "systemContract" | "zrc20" | "custody";

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"lint": "npx eslint . --ignore-pattern coverage/ --ignore-pattern coverage.json --ignore-pattern lib/ --ignore-pattern out --ignore-pattern cache_forge/",
"lint:fix": "npx eslint . --fix --ignore-pattern coverage/ --ignore-pattern coverage.json --ignore-pattern lib/ --ignore-pattern out --ignore-pattern cache_forge/",
"test": "forge clean && forge test -vvv",
"coverage": "forge clean && forge coverage --no-match-coverage \"(script|test|legacy)\" --report lcov",
"coverage": "forge coverage --no-match-coverage \"(script|test|legacy)\" --report lcov",
"typechain": "npx typechain --target ethers-v6 \"out/**/!(*.t|test).sol/!(*.abi).json\" --out-dir types",
"generate": "forge clean && forge build && forge fmt && ./scripts/generate_go.sh || true && ./scripts/generate_addresses.sh && yarn lint:fix && yarn typechain && yarn docs && del-cli dist && tsc || true",
"prepublishOnly": "copyfiles -u 1 'out/**/*' 'abi'",
Expand Down
220 changes: 110 additions & 110 deletions pkg/gatewayevm.t.sol/gatewayevminboundtest.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/gatewayevm.t.sol/gatewayevmtest.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/gatewayevmzevm.t.sol/gatewayevmzevmtest.go

Large diffs are not rendered by default.

35 changes: 33 additions & 2 deletions pkg/gatewayzevm.sol/gatewayzevm.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/gatewayzevm.t.sol/gatewayzevminboundtest.go

Large diffs are not rendered by default.

190 changes: 188 additions & 2 deletions pkg/gatewayzevm.t.sol/gatewayzevmoutboundtest.go

Large diffs are not rendered by default.

Loading

0 comments on commit d46f98d

Please sign in to comment.