-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f101e0
commit d080e51
Showing
5 changed files
with
194 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule axelar-gmp-sdk-solidity
added at
3157ba
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
// SPDX-License-Identifier: GPL-3.0-only | ||
pragma solidity ^0.8.20; | ||
|
||
import {console, Script} from "forge-std/Script.sol"; | ||
import {AxelarBridgedGovernor, BridgedGovernorProxy, Call} from "src/BridgedGovernor.sol"; | ||
import {IAxelarGasService} from "axelar/interfaces/IAxelarGasService.sol"; | ||
import {IAxelarGMPGateway} from "axelar/interfaces/IAxelarGMPGateway.sol"; | ||
import {AddressToString} from "axelar/libs/AddressString.sol"; | ||
|
||
string constant SEPOLIA_CHAIN_NAME = "ethereum-sepolia"; | ||
string constant BSC_TESTNET_CHAIN_NAME = "binance"; | ||
|
||
IAxelarGMPGateway constant SEPOLIA_GATEWAY = | ||
IAxelarGMPGateway(0xe432150cce91c13a887f7D836923d5597adD8E31); | ||
IAxelarGasService constant BSC_TESTNET_GAS_SERVICE = | ||
IAxelarGasService(0xbE406F0189A0B4cf3A05C286473D23791Dd44Cc6); | ||
IAxelarGMPGateway constant BSC_TESTNET_GATEWAY = | ||
IAxelarGMPGateway(0x4D147dCb984e6affEEC47e44293DA442580A3Ec0); | ||
|
||
// forge script scripts/DeployAxelarBridgedGovernor.s.sol:DeployToBscTestnet $WALLET_ARGS -f "$ETH_RPC_URL" | ||
|
||
// contract DeployToBscTestnet is Script { | ||
// function run() public { | ||
// address owner = vm.envOr("OWNER", msg.sender); | ||
|
||
// require(block.chainid == 97, "Must be run on BSC testnet"); | ||
// vm.startBroadcast(); | ||
// AxelarBridgedGovernor logic = | ||
// new AxelarBridgedGovernor(BSC_TESTNET_GATEWAY, SEPOLIA_CHAIN_NAME, owner); | ||
// BridgedGovernorProxy governor = new BridgedGovernorProxy(address(logic), new Call[](0)); | ||
// vm.stopBroadcast(); | ||
// console.log("Deployed AxelarBridgedGovernor:", address(governor)); | ||
// } | ||
// } | ||
|
||
|
||
// Gateway and ddresses taken from https://docs.axelar.dev/resources/contract-addresses/testnet | ||
|
||
// Run on BSC testnet | ||
// forge create $WALLET_ARGS scripts/DeployAxelarBridgedGovernor.s.sol:ContractCaller \ | ||
// --constructor-args 0x4D147dCb984e6affEEC47e44293DA442580A3Ec0 0xbE406F0189A0B4cf3A05C286473D23791Dd44Cc6 | ||
|
||
// Run on Sepolia | ||
// OWNER=0xdACfE6Bf5A06953EccC3755758C5aDFfed94e147 \ | ||
// GATEWAY=0xe432150cce91c13a887f7D836923d5597adD8E31 \ | ||
// SOURCE_CHAIN=binance \ | ||
// forge script scripts/DeployAxelarBridgedGovernor.s.sol:DeployGovernor $WALLET_ARGS -f "$ETH_RPC_URL" | ||
|
||
// Run on BSC testnet | ||
// cast send $WALLET_ARGS 0xdACfE6Bf5A06953EccC3755758C5aDFfed94e147 \ | ||
// 'setRecipient(string,address)' ethereum-sepolia 0x78EeC20c86e5f40Ceb1b651c38072DF528AE6407 | ||
|
||
// Run on BSC testnet | ||
// CALLER=0xdACfE6Bf5A06953EccC3755758C5aDFfed94e147 \ | ||
// FEE=$(cast to-wei 0.00 eth) \ | ||
// NONCE=2 \ | ||
// forge script scripts/DeployAxelarBridgedGovernor.s.sol:ContractCall $WALLET_ARGS -f "$ETH_RPC_URL" | ||
|
||
contract DeployGovernor is Script { | ||
function run() public { | ||
address owner = vm.envOr("OWNER", msg.sender); | ||
IAxelarGMPGateway gateway = IAxelarGMPGateway(vm.envAddress("GATEWAY")); | ||
string memory sourceChain = vm.envString("SOURCE_CHAIN"); | ||
|
||
vm.startBroadcast(); | ||
AxelarBridgedGovernor logic = new AxelarBridgedGovernor(gateway, sourceChain, owner); | ||
BridgedGovernorProxy governor = new BridgedGovernorProxy(address(logic), new Call[](0)); | ||
vm.stopBroadcast(); | ||
console.log("Deployed AxelarBridgedGovernor:", address(governor)); | ||
} | ||
} | ||
|
||
contract ContractCaller { | ||
address public immutable owner; | ||
IAxelarGMPGateway public immutable gateway; | ||
IAxelarGasService public immutable gasService; | ||
|
||
string public destinationChain; | ||
address public recipient; | ||
|
||
constructor(IAxelarGMPGateway gateway_, IAxelarGasService gasService_) { | ||
owner = msg.sender; | ||
gateway = gateway_; | ||
gasService = gasService_; | ||
} | ||
|
||
function setRecipient(string calldata destinationChain_, address recipient_) public { | ||
require(msg.sender == owner, "Only owner"); | ||
destinationChain = destinationChain_; | ||
recipient = recipient_; | ||
} | ||
|
||
function callContract(bytes calldata payload) payable public { | ||
require(msg.sender == owner, "Only owner"); | ||
string memory recipient_ = AddressToString.toString(recipient); | ||
if (msg.value > 0) { | ||
gasService.payNativeGasForContractCall{value: msg.value}( | ||
address(this), destinationChain, recipient_, payload, owner | ||
); | ||
} | ||
gateway.callContract(destinationChain, recipient_, payload); | ||
} | ||
} | ||
|
||
|
||
contract ContractCall is Script { | ||
function run() public { | ||
ContractCaller caller = ContractCaller(vm.envAddress("CALLER")); | ||
uint256 fee = vm.envOr("FEE", uint(0)); | ||
uint256 nonce = vm.envUint("NONCE"); | ||
|
||
Call[] memory calls = new Call[](1); | ||
calls[0] = Call({ | ||
target: 0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14, | ||
data: abi.encodeWithSignature("approve(address,uint256)", address(0x1234), 100 + nonce), | ||
value: 0 | ||
}); | ||
// calls[0] = Call({ | ||
// target: 0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14, | ||
// data: abi.encodeWithSignature("transferFrom(address,address,uint256)", | ||
// msg.sender, address(0xdead), 1234), | ||
// value: 0 | ||
// }); | ||
|
||
vm.broadcast(); | ||
caller.callContract{value: fee}(abi.encode(AxelarBridgedGovernor.Message(nonce, calls))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters