Skip to content

Commit 43e425c

Browse files
Foivosnik-surimilapsheth
authored
feat: axelar transceiver (#9)
* add axelar tranceiver * Added the rest of the files * added a proxy as well * trying to add some tests * forge install: axelar-cgp-solidity v6.3.1 * added some tests * fix the test * using Transceiver abstract contract * downgrade to oz v4.8.1 * rename storage_ to slot * change oz to an older version * Tests work * remove the proxy * using axelar gmp executable * address some comments * remove cgp-solidity as it is unused * some more comments addressed * fixed a naminginconsistency * using the gas service estimateGasFee * using payGas instead of payNativeGasForContractCall * Update src/axelar/AxelarTransceiver.sol Co-authored-by: Milap Sheth <[email protected]> * Update src/axelar/AxelarTransceiver.sol Co-authored-by: Milap Sheth <[email protected]> * change some names * update tests a bit * Fix OZ contracts issue * Fix CI and format * added a deployment script * update deployment script * add readme and rename dir * moved some errors * added some natspec * remove unecesairy modifier * checking for immutable immutables * correct decoding of message * Update src/axelar/AxelarTransceiver.sol * Update script/README.md * Update script/README.md * added a script to set remote siblings * Added a receiving token test * added a fail test if the address is not trusted. * update readme * try to fix CI * try to fix CI again * remove unused var * run forge fmt * run forge fmt again * tests now prperly check for reverts * added a constant for easy identification * forge fmt * added more destriptive error message --------- Co-authored-by: Nikhil Suri <[email protected]> Co-authored-by: Milap Sheth <[email protected]>
1 parent c4361e7 commit 43e425c

18 files changed

+1370
-273
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,9 @@ jobs:
2727
with:
2828
version: nightly
2929

30-
- name: Run Forge build
31-
run: |
32-
make test-push0
33-
id: build
34-
3530
- name: Run Forge tests
3631
run: |
37-
make test-evm
32+
make test
3833
id: test
3934

4035
- name: Run Forge fmt

lib/axelar-gmp-sdk-solidity

lib/example-native-token-transfers

lib/openzeppelin-contracts

remappings.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
@axelar-network/axelar-gmp-sdk-solidity=lib/axelar-gmp-sdk-solidity/
2-
@wormhole-foundation/native_token_transfer=lib/example-native-token-transfers/src
2+
@wormhole-foundation/native_token_transfer=lib/example-native-token-transfers/evm/src

script/DeployAxelarTransceiver.sol

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// SPDX-License-Identifier: Apache 2
2+
pragma solidity >=0.8.8 <0.9.0;
3+
4+
import {console2} from "forge-std/Script.sol";
5+
import {AxelarTransceiver} from "../src/axelar/AxelarTransceiver.sol";
6+
import {TransceiverStructs} from
7+
"@wormhole-foundation/native_token_transfer/libraries/TransceiverStructs.sol";
8+
import {NttManager} from "@wormhole-foundation/native_token_transfer/NttManager/NttManager.sol";
9+
import {INttManager} from "@wormhole-foundation/native_token_transfer/interfaces/INttManager.sol";
10+
import {IManagerBase} from "@wormhole-foundation/native_token_transfer/interfaces/IManagerBase.sol";
11+
import {ERC1967Proxy} from "openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Proxy.sol";
12+
import {ParseNttConfig} from
13+
"@wormhole-foundation/native_token_transfer/../script/helpers/ParseNttConfig.sol";
14+
15+
contract DeployAxelarTransceiver is ParseNttConfig {
16+
struct DeploymentParams {
17+
address axelarGatewayAddress;
18+
address axelarGasServiceAddress;
19+
address nttManagerAddress;
20+
}
21+
22+
function run() public returns (address) {
23+
DeploymentParams memory params = _readEnvVariables();
24+
// Deploy the Wormhole Transceiver.
25+
AxelarTransceiver implementation = new AxelarTransceiver(
26+
params.axelarGatewayAddress, params.axelarGasServiceAddress, params.nttManagerAddress
27+
);
28+
29+
AxelarTransceiver transceiverProxy =
30+
AxelarTransceiver(address(new ERC1967Proxy(address(implementation), "")));
31+
32+
transceiverProxy.initialize();
33+
34+
console2.log("Axelar Transceiver deployed at: ");
35+
console2.logBytes32(toUniversalAddress(address(transceiverProxy)));
36+
37+
return address(transceiverProxy);
38+
}
39+
40+
function _readEnvVariables() internal view returns (DeploymentParams memory params) {
41+
// Axelar Gateway.
42+
params.axelarGatewayAddress = vm.envAddress("AXELAR_GATEWAY");
43+
require(params.axelarGatewayAddress != address(0), "Invalid axelar gateway address");
44+
45+
// Axelar Gateway.
46+
params.axelarGasServiceAddress = vm.envAddress("AXELAR_GAS_SERVICE");
47+
require(params.axelarGasServiceAddress != address(0), "Invalid axelar gas service address");
48+
49+
// Axelar Gateway.
50+
params.nttManagerAddress = vm.envAddress("NTT_MANAGER");
51+
require(params.nttManagerAddress != address(0), "Invalid ntt manager address address");
52+
}
53+
}

script/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## Deploying the Axelar Transceiver
2+
3+
First create a `.env` file in the root directory and add the following 3 parameters corresponding to the deployments on target chain.
4+
- AXELAR_GATEWAY: The address of the Axelar gateway on this chain.
5+
- AXELAR_GAS_SERVICE: The address of the Axelar Gas Service on this chain.
6+
- NTT_MANAGER: The address of the NttManager on this chain.
7+
8+
Axelar contract addresses can be found [here](https://docs.axelar.dev/resources/contract-addresses/mainnet) (switch to mainnet/testnet appropriately). Chain name strings registered on Axelar can also be found there. For e.g. Ethereum is registered as `Ethereum` on mainnet, and `ethereum-sepolia` on testnet, and BSC smart chain is registered as `binance` on mainnet and testnet. These chain names should be used when setting the mapping between Wormhole chain ids and Axelar chain ids. For setting the Axelar transceiver addresses on different chains, [ERC-55](https://eips.ethereum.org/EIPS/eip-55) case sensitive representation should be used (shown by default on explorers).
9+
10+
Then run `forge script --chain {chain_name} DeployAxelarTransceiver.sol` to deploy the Axelar Transceiver.
11+
12+
## Setting Remote Chain Information
13+
14+
Add to the `.env` file in the root directory the following variables:
15+
- AXELAR_TRANSCEIVER: The address of the axelar tranceiver on the current chain
16+
- CHAIN_ID: The chain id of the remote chain
17+
- AXELAR_CHAIN_ID: The name of the remote chain that Axelar understands.
18+
- TRANSCEIVER_ADDRESS: The address of the remote transceiver that Axelar understands (0x prefixed string representation).

script/SetAxelarChainId.sol

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// SPDX-License-Identifier: Apache 2
2+
pragma solidity >=0.8.8 <0.9.0;
3+
4+
import {console2} from "forge-std/Script.sol";
5+
import {IAxelarTransceiver} from "../src/axelar/interfaces/IAxelarTransceiver.sol";
6+
import {ParseNttConfig} from
7+
"@wormhole-foundation/native_token_transfer/../script/helpers/ParseNttConfig.sol";
8+
9+
contract DeployAxelarTransceiver is ParseNttConfig {
10+
struct SetAxelarChainIdParams {
11+
IAxelarTransceiver axelarTransceiver;
12+
uint16 chainId;
13+
string axelarChainId;
14+
string transceiverAddress;
15+
}
16+
17+
function run() public {
18+
SetAxelarChainIdParams memory params = _readEnvVariables();
19+
// Deploy the Wormhole Transceiver.
20+
21+
params.axelarTransceiver.setAxelarChainId(
22+
params.chainId, params.axelarChainId, params.transceiverAddress
23+
);
24+
25+
console2.log("Axelar Transceiver Address Updated");
26+
console2.log("ChainId: %s", params.chainId);
27+
console2.log("Axelar Chain Name: %s", params.axelarChainId);
28+
console2.log("Transceiver Address: %s", params.chainId);
29+
}
30+
31+
function _readEnvVariables() internal view returns (SetAxelarChainIdParams memory params) {
32+
// Axelar Gateway.
33+
params.axelarTransceiver = IAxelarTransceiver(vm.envAddress("AXELAR_TRANSCEIVER"));
34+
require(
35+
address(params.axelarTransceiver) != address(0), "Invalid axelar transceiver address"
36+
);
37+
38+
// Chain Id.
39+
params.chainId = uint16(vm.envUint("CHAIN_ID"));
40+
41+
// Axelar Chain Id.
42+
params.axelarChainId = vm.envString("AXELAR_CHAIN_ID");
43+
require(bytes(params.axelarChainId).length != 0, "Empty axelar chain id");
44+
45+
// Remote Transceiver Address.
46+
params.transceiverAddress = vm.envString("TRANSCEIVER_ADDRESS");
47+
require(bytes(params.transceiverAddress).length != 0, "Empty transceiver address");
48+
}
49+
}

src/axelar/AxelarEndpoint.sol

Lines changed: 0 additions & 119 deletions
This file was deleted.

0 commit comments

Comments
 (0)