Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: deployment script updated #100

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions contracts/evm/xcall/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
PRIVATE_KEY=""
OWNER_ADDRESS=

PROTOCOL_FEE=0

# BINANCE TESTNET NETWORK SETUP
BINANCE_TESTNET_RPC_URL=http://127.0.0.1:9545/
BSC_NID=*
BSC_SCAN_API_KEY=

# BMC ADDRESS FOR ICON BERLIN TESTNET
ICON_NID=*
BMC_ADDRESS="cx000"


# BINANCE MAINNET NETWORK SETUP
BINANCE_MAINNET_RPC_URL=http://127.0.0.1:9545/
BSC_NID=*
BSC_SCAN_API_KEY=

# BMC ADDRESS FOR ICON MAINNET
ICON_NID=*
BMC_ADDRESS="cx000"
2 changes: 2 additions & 0 deletions contracts/evm/xcall/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ docs/

# Dotenv file
.env

broadcast
4 changes: 4 additions & 0 deletions contracts/evm/xcall/contracts/CallService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,10 @@ contract CallService is IBSH, ICallService, IFeeManage, Initializable {
defaultConnections[nid] = connection;
}

function getDefaultConnection(string memory nid) external view returns (address) {
return defaultConnections[nid];
}

function setProtocolFee(
uint256 _value
) external override onlyAdmin {
Expand Down
24 changes: 24 additions & 0 deletions contracts/evm/xcall/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
source .env

if [ $# -eq 0 ]; then
echo "No arguments supplied: Pass --help for details"
elif [ "$1" == "--rpc-url" ]; then
if [ $# -lt 2 ]; then
echo "Missing RPC URL argument. Usage: $0 --rpc-url <RPC_URL>"
else
rpc_url="$2"
if [ $# -eq 4 ] && [ "$3" == "--api-key" ]; then
api_key="$4"
echo "Deploying CallService.sol to $rpc_url with etherscan API key $api_key"
forge script script/CallService.s.sol:CallServiceScript --fork-url $2 --broadcast --verify --etherscan-api-key $4
echo "done"
else
echo "Deploying CallService.sol to $rpc_url"
forge script script/CallService.s.sol:CallServiceScript --fork-url $2 --broadcast
echo "done"
fi
fi
else
echo "Invalid arguments. Usage: $0 --rpc-url <RPC_URL> [--api-key <API_KEY>]"
fi
7 changes: 6 additions & 1 deletion contracts/evm/xcall/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@ src = "contracts"
out = "out"
libs = ["lib"]

remappings = ["@iconfoundation/btp2-solidity-library=../library","@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/"]
remappings = ["@iconfoundation/btp2-solidity-library=../library","@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/"]


[rpc_endpoints]
binance_testnet = "${BINANCE_TESTNET_RPC_URL}"

18 changes: 15 additions & 3 deletions contracts/evm/xcall/script/CallService.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,20 @@ contract CallServiceScript is Script {
function setUp() public {}

function run() public {
vm.broadcast();
new CallService();

uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
string memory nid = vm.envString("BSC_NID");
string memory iconNid = vm.envString("ICON_NID");
address connection = vm.envAddress("BMC_ADDRESS");

vm.startBroadcast(deployerPrivateKey);
CallService xcall = new CallService();
xcall.initialize(nid);

xcall.setProtocolFee(vm.envUint("PROTOCOL_FEE"));
xcall.setProtocolFeeHandler(vm.envAddress("OWNER_ADDRESS"));

xcall.setDefaultConnection(iconNid, connection);
vm.stopBroadcast();

}
}