Skip to content

Commit acbec1c

Browse files
committed
chore: update axelar briding logic
1 parent 19c8b09 commit acbec1c

File tree

4 files changed

+35
-24
lines changed

4 files changed

+35
-24
lines changed

lib/axelar-gmp-sdk-solidity

lib/interchain-token-service

script/Bridge.s.sol

+33
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pragma solidity ^0.8.26;
44
import {Recall} from "../src/token/Recall.sol";
55
import {IInterchainTokenService} from
66
"@axelar-network/interchain-token-service/contracts/interfaces/IInterchainTokenService.sol";
7+
import {ITokenManagerType} from "@axelar-network/interchain-token-service/contracts/interfaces/ITokenManagerType.sol";
78
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
89
import {Script, console} from "forge-std/Script.sol";
910

@@ -50,6 +51,38 @@ you want to transfer 1 token, use 1000000000000000000.*/
5051
contract BridgeOps is Script {
5152
using Strings for string;
5253

54+
/// @notice Step 1 of the linkToken process
55+
/// @dev This function should be called on the source chain (e.g. Base) to link a token
56+
/// already deployed on a destination chain (e.g. Ethereum)
57+
/// @param recallAddress The address of the recall contract on the destination chain
58+
/// @param network The network to link the token to
59+
function linkTokenStep1(address recallAddress, string memory network) public {
60+
bytes32 itsSalt = keccak256("RECALL_SALT");
61+
IInterchainTokenService itsContract = IInterchainTokenService(INTERCHAIN_TOKEN_SERVICE);
62+
63+
bytes memory params = abi.encodePacked(msg.sender);
64+
bytes memory addressBytes = abi.encodePacked(recallAddress);
65+
66+
itsContract.linkToken(
67+
itsSalt, network, addressBytes, ITokenManagerType.TokenManagerType.MINT_BURN_FROM, params, 0
68+
);
69+
}
70+
71+
/// @notice Step 2 of the linkToken process
72+
/// @dev This function should be called on the destination chain (e.g. Ethereum) after the
73+
/// x-chain link has been finalized from step 1
74+
/// @param recallAddress The address of the recall contract on the destination chain
75+
/// @param recallItsTokenId The interchain token ID of the recall contract on the source chain
76+
function linkTokenStep2(address recallAddress, bytes32 recallItsTokenId) public {
77+
Recall recall = Recall(recallAddress);
78+
IInterchainTokenService itsContract = IInterchainTokenService(INTERCHAIN_TOKEN_SERVICE);
79+
address tokenManager = itsContract.tokenManagerAddress(recallItsTokenId);
80+
console.log("Token manager: ", tokenManager);
81+
82+
// Grant minter role to token manager
83+
recall.grantRole(recall.MINTER_ROLE(), tokenManager);
84+
}
85+
5386
function isMinter(address proxyAddress, address addressToCheck) public view {
5487
console.log("Proxy address: ", proxyAddress);
5588

script/Recall.s.sol

-22
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
pragma solidity ^0.8.26;
44

55
import {Recall} from "../src/token/Recall.sol";
6-
import {IInterchainTokenService} from
7-
"@axelar-network/interchain-token-service/contracts/interfaces/IInterchainTokenService.sol";
8-
import {ITokenManagerType} from "@axelar-network/interchain-token-service/contracts/interfaces/ITokenManagerType.sol";
9-
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
106
import {Options, Upgrades} from "@openzeppelin/foundry-upgrades/Upgrades.sol";
117
import {Script, console} from "forge-std/Script.sol";
128

@@ -35,24 +31,6 @@ contract DeployScript is Script {
3531

3632
console.log("Deployer: ", recall.deployer());
3733

38-
if (
39-
Strings.equal(network, "filecoin") || Strings.equal(network, "ethereum") || Strings.equal(network, "base")
40-
|| Strings.equal(network, "filecoin-2") // Calibration testnet
41-
|| Strings.equal(network, "base-sepolia") // Base sepolia testnet
42-
) {
43-
console.log("Deploying token manager");
44-
IInterchainTokenService itsContract = IInterchainTokenService(INTERCHAIN_TOKEN_SERVICE);
45-
bytes memory params = abi.encode(abi.encodePacked(recall.deployer()), address(recall));
46-
itsContract.deployTokenManager(itsSalt, "", ITokenManagerType.TokenManagerType.MINT_BURN_FROM, params, 0);
47-
bytes32 itsTokenId = recall.interchainTokenId();
48-
49-
console.log("Recall Interchain Token ID: ", Strings.toHexString(uint256(itsTokenId), 32));
50-
address tokenManager = itsContract.tokenManagerAddress(itsTokenId);
51-
console.log("Token manager: ", tokenManager);
52-
53-
// Grant minter role to token manager
54-
recall.grantRole(recall.MINTER_ROLE(), tokenManager);
55-
}
5634
vm.stopBroadcast();
5735

5836
return recall;

0 commit comments

Comments
 (0)