diff --git a/smart-contracts/script/bsc-testnet/bridgeTokens.s.sol b/smart-contracts/script/bsc-testnet/bridgeTokens.s.sol index 245c5b5..e4ecc62 100644 --- a/smart-contracts/script/bsc-testnet/bridgeTokens.s.sol +++ b/smart-contracts/script/bsc-testnet/bridgeTokens.s.sol @@ -5,18 +5,19 @@ import {Script} from "forge-std/Script.sol"; import {MintAndBurnTokenManagerUpgradeable} from "contracts/periphery/MintAndBurnTokenManagerUpgradeable.sol"; import {ITokenManagerStructs} from "contracts/periphery/TokenManagerUpgradeable.sol"; import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; +import { TestnetConfig } from "script/testnetConfig.s.sol"; import "forge-std/console.sol"; -contract Transfer is Script { +contract Transfer is Script,TestnetConfig { function run() external { uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY_TESTNET"); address owner = vm.addr(deployerPrivateKey); console.log("Owner is %s", owner); - address tokenManagerAddress = 0xd10077bCE4A9D19068965dE519CED8a2fC1B096C; - address tokenAddress = 0x6d78c86D66DfE5Be5F55FBAA8B1d3FD28edfF396; + address tokenManagerAddress = bscMintAndBurnTokenManagerAddress; + address tokenAddress = bscTestTokenAddress; - uint remoteChainId = 33101; + uint remoteChainId = zqChainId; address remoteRecipient = owner; uint amount = 10; diff --git a/smart-contracts/script/bsc-testnet/deployBridge.s.sol b/smart-contracts/script/bsc-testnet/deployBridge.s.sol index 8a7fa63..4ac3755 100644 --- a/smart-contracts/script/bsc-testnet/deployBridge.s.sol +++ b/smart-contracts/script/bsc-testnet/deployBridge.s.sol @@ -8,6 +8,7 @@ import {MintAndBurnTokenManagerUpgradeable} from "contracts/periphery/MintAndBur import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; import {ChainGateway} from "contracts/core/ChainGateway.sol"; import "forge-std/console.sol"; +import { TestnetConfig } from "script/testnetConfig.s.sol"; contract Deployment is Script { function run() external { @@ -31,6 +32,8 @@ contract Deployment is Script { validatorManager.isValidator(validators[0]), validatorManager.validatorsSize() ); + console.log( + " address public constant bscValidatorManagerAddress = %s", address(validatorManager)); // Deploy Chain Gateway ChainGateway chainGateway = new ChainGateway{salt: "zilliqa"}( @@ -42,6 +45,8 @@ contract Deployment is Script { address(chainGateway), address(chainGateway.validatorManager()) ); + console.log( + " address public constant bscChainGatewayAddress = %s", address(chainGateway)); // Deploy MintAndBurnTokenManager address implementation = address( @@ -51,7 +56,6 @@ contract Deployment is Script { MintAndBurnTokenManagerUpgradeable.initialize, address(chainGateway) ); - address proxy = address( new ERC1967Proxy(implementation, initializeData) ); @@ -65,6 +69,9 @@ contract Deployment is Script { tokenManager.owner(), tokenManager.getGateway() ); + console.log( + " address public constant bscMintAndBurnTokenManagerAddress = %s", address(tokenManager)); + // Register TokenManager to ChainGateway chainGateway.register(proxy); diff --git a/smart-contracts/script/bsc-testnet/deployBridgeToken.s.sol b/smart-contracts/script/bsc-testnet/deployBridgeToken.s.sol index 0adde26..4b64a81 100644 --- a/smart-contracts/script/bsc-testnet/deployBridgeToken.s.sol +++ b/smart-contracts/script/bsc-testnet/deployBridgeToken.s.sol @@ -5,23 +5,24 @@ import {Script} from "forge-std/Script.sol"; import {MintAndBurnTokenManagerUpgradeable} from "contracts/periphery/MintAndBurnTokenManagerUpgradeable.sol"; import {ITokenManagerStructs} from "contracts/periphery/TokenManagerUpgradeable.sol"; import {BridgedToken} from "contracts/periphery/BridgedToken.sol"; +import { TestnetConfig } from "script/testnetConfig.s.sol"; import "forge-std/console.sol"; -contract Deployment is Script { +contract Deployment is Script, TestnetConfig { function run() external { uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY_TESTNET"); address owner = vm.addr(deployerPrivateKey); console.log("Owner is %s", owner); - address tokenManagerAddress = 0xA6D73210AF20a59832F264fbD991D2abf28401d0; + address tokenManagerAddress = bscMintAndBurnTokenManagerAddress; string memory tokenName = "test token"; string memory tokenSymbol = "TST"; uint8 tokenDecimals = 3; - address remoteToken = 0x8618d39a8276D931603c6Bc7306af6A53aD2F1F3; - address remoteTokenManager = 0x1509988c41f02014aA59d455c6a0D67b5b50f129; - uint remoteChainId = 33101; + address remoteToken = zqLegacyTestTokenAddress; + address remoteTokenManager = zqLockAndReleaseTokenManagerAddress; + uint remoteChainId = zqChainId; MintAndBurnTokenManagerUpgradeable tokenManager = MintAndBurnTokenManagerUpgradeable( tokenManagerAddress diff --git a/smart-contracts/script/bsc-testnet/deployCoreUpgradeable.s.sol b/smart-contracts/script/bsc-testnet/deployCoreUpgradeable.s.sol index f8d5b14..e8541da 100644 --- a/smart-contracts/script/bsc-testnet/deployCoreUpgradeable.s.sol +++ b/smart-contracts/script/bsc-testnet/deployCoreUpgradeable.s.sol @@ -6,15 +6,16 @@ import {ValidatorManagerUpgradeable} from "contracts/core-upgradeable/ValidatorM import {ChainGatewayUpgradeable} from "contracts/core-upgradeable/ChainGatewayUpgradeable.sol"; import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; import "forge-std/console.sol"; +import { TestnetConfig } from "script/testnetConfig.s.sol"; -contract Deployment is Script { +contract Deployment is Script, TestnetConfig { function run() external { uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY_TESTNET"); address owner = vm.addr(deployerPrivateKey); console.log("Owner is %s", owner); address[] memory validators = new address[](1); - address tokenManager = 0xA6D73210AF20a59832F264fbD991D2abf28401d0; + address tokenManager = bscMintAndBurnTokenManagerAddress; validators[0] = owner; vm.startBroadcast(deployerPrivateKey); @@ -40,6 +41,8 @@ contract Deployment is Script { validatorManager.isValidator(validators[0]), validatorManager.validatorsSize() ); + console.log( + " address public constant bscValidatorManagerAddress = %s", address(validatorManager)); // Deploy Chain Gateway address cgImplementation = address( @@ -59,6 +62,8 @@ contract Deployment is Script { address(chainGateway), address(chainGateway.validatorManager()) ); + console.log( + " address public constant bscChainGatewayAddress = %s", address(chainGateway)); // Register TokenManager to ChainGateway chainGateway.register(tokenManager); diff --git a/smart-contracts/script/bsc-testnet/deployMockZilBridge.s.sol b/smart-contracts/script/bsc-testnet/deployMockZilBridge.s.sol index fa366ac..80fd623 100644 --- a/smart-contracts/script/bsc-testnet/deployMockZilBridge.s.sol +++ b/smart-contracts/script/bsc-testnet/deployMockZilBridge.s.sol @@ -12,12 +12,10 @@ import { EthCrossChainData } from "contracts/zilbridge/1/ethCrossChainData.sol"; import { EthExtendCrossChainManager } from "contracts/zilbridge/2/ccmExtendCrossChainManager.sol"; import { LockProxyTokenManagerUpgradeableV3 } from "contracts/zilbridge/2/LockProxyTokenManagerUpgradeableV3.sol"; import { LockProxyTokenManagerDeployer } from "test/zilbridge/TokenManagerDeployers/LockProxyTokenManagerDeployer.sol"; +import { TestnetConfig } from "script/testnetConfig.s.sol"; /*** @notice does what ZilBridgeFixture::deployOriginalContracts() does */ -contract deployMockZilBridge is Script { - uint64 constant CHAIN_ID=6; - uint64 constant COUNTERPART_CHAIN_ID=18; - +contract deployMockZilBridge is Script, TestnetConfig { function run() external { EthCrossChainManager ccm; EthCrossChainManagerProxy ccmProxy; @@ -31,14 +29,18 @@ contract deployMockZilBridge is Script { vm.startBroadcast(deployerPrivateKey); console.log("Owner: %s", owner); eccd = new EthCrossChainData(); - console.log("ECCD: %s", address(eccd)); - ccm = new EthCrossChainManager(address(eccd), CHAIN_ID, a, b); - console.log("CCM: %s", address(ccm)); + console.log( + " address public constant bscEthCrossChainDataAddress = %s", address(eccd)); + ccm = new EthCrossChainManager(address(eccd), zbBscChainId, a, b); + console.log( + " address public constant bscCCMAddress = %s", address(ccm)); ccmProxy = new EthCrossChainManagerProxy(address(ccm)); - console.log("CCMProxy: %s", address(ccmProxy)); + console.log( + " address public constant bscCCMProxyAddress = %s", address(ccmProxy)); ccm.transferOwnership(address(ccmProxy)); eccd.transferOwnership(address(ccm)); - lockProxy = new LockProxy(address(ccmProxy), COUNTERPART_CHAIN_ID); - console.log("LockProxy: %s",address(lockProxy)); + lockProxy = new LockProxy(address(ccmProxy), zbZilliqaChainId); + console.log( + " address public constant bscLockProxyAddress = %s", address(lockProxy)); } } diff --git a/smart-contracts/script/bsc-testnet/deployXBridgeOverMockZilBridge.s.sol b/smart-contracts/script/bsc-testnet/deployXBridgeOverMockZilBridge.s.sol index ae8b3f5..c3016d9 100644 --- a/smart-contracts/script/bsc-testnet/deployXBridgeOverMockZilBridge.s.sol +++ b/smart-contracts/script/bsc-testnet/deployXBridgeOverMockZilBridge.s.sol @@ -12,15 +12,15 @@ import { EthCrossChainData } from "contracts/zilbridge/1/ethCrossChainData.sol"; import { EthExtendCrossChainManager } from "contracts/zilbridge/2/ccmExtendCrossChainManager.sol"; import { LockProxyTokenManagerUpgradeableV3 } from "contracts/zilbridge/2/LockProxyTokenManagerUpgradeableV3.sol"; import { LockProxyTokenManagerDeployer } from "test/zilbridge/TokenManagerDeployers/LockProxyTokenManagerDeployer.sol"; -import { TestnetConfig } from "script/testnet_config.s.sol"; +import { TestnetConfig } from "script/testnetConfig.s.sol"; /*** @notice ZilBridgeFixture::installExtendCrossManager() */ contract deployXBridgeOverMockZilBridge is Script, TestnetConfig { // Plug in the data from deployMockZilBridge here. - EthCrossChainData public constant eccd = EthCrossChainData(bsc_EthCrossChainData); - EthCrossChainManager public constant ccm = EthCrossChainManager(bsc_ccm); - EthCrossChainManagerProxy public constant ccmProxy = EthCrossChainManagerProxy(bsc_ccmProxy); - LockProxy public constant lockProxy = LockProxy(payable(bsc_lockProxy)); + EthCrossChainData public constant eccd = EthCrossChainData(bscEthCrossChainDataAddress); + EthCrossChainManager public constant ccm = EthCrossChainManager(bscCCMAddress); + EthCrossChainManagerProxy public constant ccmProxy = EthCrossChainManagerProxy(bscCCMProxyAddress); + LockProxy public constant lockProxy = LockProxy(payable(bscLockProxyAddress)); EthExtendCrossChainManager extendCCM; function run() external { @@ -28,12 +28,12 @@ contract deployXBridgeOverMockZilBridge is Script, TestnetConfig { bytes[] memory b = new bytes[](0); uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY_ZILBRIDGE"); vm.startBroadcast(deployerPrivateKey); - // address owner = vm.addr(deployerPrivateKey); extendCCM = new EthExtendCrossChainManager(address(eccd), 2, a, b); ccmProxy.pauseEthCrossChainManager(); extendCCM.transferOwnership(address(ccmProxy)); ccmProxy.upgradeEthCrossChainManager(address(extendCCM)); ccmProxy.unpauseEthCrossChainManager(); - console.log("extendCCM: %s", address(extendCCM)); + console.log( + " address public constant bscExtendCCMAddress = %s", address(extendCCM)); } } diff --git a/smart-contracts/script/bsc-testnet/deployZilBridgeTokenManagers.s.sol b/smart-contracts/script/bsc-testnet/deployZilBridgeTokenManagers.s.sol index d13d347..abfaa48 100644 --- a/smart-contracts/script/bsc-testnet/deployZilBridgeTokenManagers.s.sol +++ b/smart-contracts/script/bsc-testnet/deployZilBridgeTokenManagers.s.sol @@ -19,30 +19,29 @@ import {LockProxyTokenManagerDeployer} from "test/zilbridge/TokenManagerDeployer import {MintAndBurnTokenManagerDeployer} from "test/periphery/TokenManagerDeployers/MintAndBurnTokenManagerDeployer.sol"; import {LockAndReleaseTokenManagerDeployer} from "test/periphery/TokenManagerDeployers/LockAndReleaseTokenManagerDeployer.sol"; import { SwitcheoToken } from "contracts/zilbridge/token/tokens/SwitcheoTokenETH.sol"; -import { TestnetConfig } from "script/testnet_config.s.sol"; +import { TestnetConfig } from "script/testnetConfig.s.sol"; /*** @notice Deploy token managers over the extension manager */ contract deployZilBridgeTokenManagers is Script, LockProxyTokenManagerDeployer, TestnetConfig { - EthExtendCrossChainManager constant extendCCM = EthExtendCrossChainManager(bsc_extendCCM); - ChainGateway constant chainGateway = ChainGateway(bsc_chainGateway); - LockProxy constant lockProxy = LockProxy(payable(bsc_lockProxy)); + EthExtendCrossChainManager constant extendCCM = EthExtendCrossChainManager(bscExtendCCMAddress); + ChainGateway constant chainGateway = ChainGateway(bscChainGatewayAddress); + LockProxy constant lockProxy = LockProxy(payable(bscLockProxyAddress)); // Different from 0.00025 so that we can tell the difference! uint fees = 0.00007 ether; // This has to be 18, because that is what the original (ZilBridge) contracts were // deployed with. The mainnet value is 5. - uint64 constant COUNTERPART_CHAIN_ID = 18; + uint64 constant COUNTERPART_CHAIN_ID = zbZilliqaChainId; function run() external { uint256 validatorPrivateKey = vm.envUint("PRIVATE_KEY_TESTNET"); uint256 bridgePrivateKey = vm.envUint("PRIVATE_KEY_ZILBRIDGE"); - // address validator = vm.addr(validatorPrivateKey); - // address bridgeOwner = vm.addr(bridgePrivateKey); // token managers are apparently not pausable, so .. vm.startBroadcast(validatorPrivateKey); LockProxyTokenManagerUpgradeableV3 tokenManager = deployLatestLockProxyTokenManager(address(chainGateway), address(lockProxy), fees); - console.log("bsc_zilBridgeTokenManager: %s", address(tokenManager)); + console.log( + " address public constant bscLockProxyTokenManagerAddress = %s", address(tokenManager)); vm.stopBroadcast(); vm.startBroadcast(bridgePrivateKey); extendCCM.forciblyAddExtension(address(lockProxy), address(tokenManager), COUNTERPART_CHAIN_ID); diff --git a/smart-contracts/script/bsc-testnet/deployZilBridgeTokens.s.sol b/smart-contracts/script/bsc-testnet/deployZilBridgeTokens.s.sol index 1cdd990..2541a6b 100644 --- a/smart-contracts/script/bsc-testnet/deployZilBridgeTokens.s.sol +++ b/smart-contracts/script/bsc-testnet/deployZilBridgeTokens.s.sol @@ -8,7 +8,7 @@ import {BridgedToken} from "contracts/periphery/BridgedToken.sol"; import { ERC20 } from "openzeppelin-contracts/contracts/token/ERC20/ERC20.sol"; import { SwitcheoToken } from "contracts/zilbridge/token/tokens/SwitcheoTokenETH.sol"; import "forge-std/console.sol"; -import { TestnetConfig } from "script/testnet_config.s.sol"; +import { TestnetConfig } from "script/testnetConfig.s.sol"; contract MyERC20 is ERC20 { constructor(string memory name_, string memory symbol_, uint256 supply_) ERC20(name_, symbol_) { @@ -34,14 +34,17 @@ contract Deployment is Script, TestnetConfig { string memory tokenName = "XTST_token"; string memory tokenSymbol = "XTST"; MyERC20 theContract = new MyERC20(tokenName, tokenSymbol, totalSupply); - console.log("bsc_erc20: %s", address(theContract)); + console.log( + " address public constant bscERC20Address = %s", address(theContract)); // Native on Zilliqa - SwitcheoToken bridgedFromZilliqa = new SwitcheoToken(bsc_lockProxy, "Bridged ZTST", "eZTST", 3); - console.log("bsc_bridgedzrc2: %s", address(bridgedFromZilliqa)); + SwitcheoToken bridgedFromZilliqa = new SwitcheoToken(bscLockProxyAddress, "Bridged ZTST", "eZTST", 3); + console.log( + " address public constant bscBridgedZRC2Address = %s", address(bridgedFromZilliqa)); // Bridged ZIL - SwitcheoToken bridgedZIL = new SwitcheoToken(bsc_lockProxy, "eZIL", "Bridged ZIL", 12); - console.log("bsc_bridgedzil: %s", address(bridgedZIL)); + SwitcheoToken bridgedZIL = new SwitcheoToken(bscLockProxyAddress, "eZIL", "Bridged ZIL", 12); + console.log( + " address public constant bscBridgedZILAddress = %s", address(bridgedZIL)); } } diff --git a/smart-contracts/script/bsc-testnet/pauseBridge.s.sol b/smart-contracts/script/bsc-testnet/pauseBridge.s.sol index f448c33..4df61dc 100644 --- a/smart-contracts/script/bsc-testnet/pauseBridge.s.sol +++ b/smart-contracts/script/bsc-testnet/pauseBridge.s.sol @@ -3,18 +3,22 @@ pragma solidity ^0.8.20; import {Script} from "forge-std/Script.sol"; import {MintAndBurnTokenManagerUpgradeableV3} from "contracts/periphery/TokenManagerV3/MintAndBurnTokenManagerUpgradeableV3.sol"; +import {LockProxyTokenManagerUpgradeableV3} from "contracts/zilbridge/2/LockProxyTokenManagerUpgradeableV3.sol"; +import { TestnetConfig } from "script/testnetConfig.s.sol"; import "forge-std/console.sol"; -contract Pause is Script { + +contract Pause is Script, TestnetConfig { function run() external { uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY_TESTNET"); address owner = vm.addr(deployerPrivateKey); console.log("Deployer is %s", owner); - address tokenManagerAddress = 0xA6D73210AF20a59832F264fbD991D2abf28401d0; + address tokenManagerAddress = bscMintAndBurnTokenManagerAddress; vm.startBroadcast(deployerPrivateKey); - MintAndBurnTokenManagerUpgradeableV3 tokenManager = MintAndBurnTokenManagerUpgradeableV3( + { + MintAndBurnTokenManagerUpgradeableV3 tokenManager = MintAndBurnTokenManagerUpgradeableV3( tokenManagerAddress ); tokenManager.pause(); @@ -23,6 +27,18 @@ contract Pause is Script { tokenManagerAddress, tokenManager.paused() ); + } + { + LockProxyTokenManagerUpgradeableV3 tokenManager = LockProxyTokenManagerUpgradeableV3( + bscLockProxyTokenManagerAddress + ); + tokenManager.pause(); + console.log( + "TokenManager %s, paused: %s", + tokenManagerAddress, + tokenManager.paused() + ); + } vm.stopBroadcast(); } } diff --git a/smart-contracts/script/bsc-testnet/setChainGatewayOnTokenManager.s.sol b/smart-contracts/script/bsc-testnet/setChainGatewayOnTokenManager.s.sol index 2341657..3f446ab 100644 --- a/smart-contracts/script/bsc-testnet/setChainGatewayOnTokenManager.s.sol +++ b/smart-contracts/script/bsc-testnet/setChainGatewayOnTokenManager.s.sol @@ -3,16 +3,17 @@ pragma solidity ^0.8.20; import {Script} from "forge-std/Script.sol"; import {MintAndBurnTokenManagerUpgradeableV3} from "contracts/periphery/TokenManagerV3/MintAndBurnTokenManagerUpgradeableV3.sol"; +import { TestnetConfig } from "script/testnetConfig.s.sol"; import "forge-std/console.sol"; -contract Update is Script { +contract Update is Script, TestnetConfig { function run() external { uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY_TESTNET"); address owner = vm.addr(deployerPrivateKey); console.log("Deployer is %s", owner); - address newChainGateway = 0xa9A14C90e53EdCD89dFd201A3bF94D867f8098fE; // UPDATE; - address tokenManagerAddress = 0xA6D73210AF20a59832F264fbD991D2abf28401d0; + address newChainGateway = bscChainGatewayAddress; + address tokenManagerAddress = bscMintAndBurnTokenManagerAddress; vm.startBroadcast(deployerPrivateKey); MintAndBurnTokenManagerUpgradeableV3 tokenManager = MintAndBurnTokenManagerUpgradeableV3( diff --git a/smart-contracts/script/bsc-testnet/setZilBridgeRouting.s.sol b/smart-contracts/script/bsc-testnet/setZilBridgeRouting.s.sol index a7333ee..5798d03 100644 --- a/smart-contracts/script/bsc-testnet/setZilBridgeRouting.s.sol +++ b/smart-contracts/script/bsc-testnet/setZilBridgeRouting.s.sol @@ -10,7 +10,7 @@ import { SwitcheoToken } from "contracts/zilbridge/token/tokens/SwitcheoTokenETH import "forge-std/console.sol"; import {LockProxyTokenManagerUpgradeable} from "contracts/zilbridge/2/LockProxyTokenManagerUpgradeable.sol"; import {LockAndReleaseTokenManagerUpgradeable} from "contracts/periphery/LockAndReleaseTokenManagerUpgradeable.sol"; -import { TestnetConfig } from "script/testnet_config.s.sol"; +import { TestnetConfig } from "script/testnetConfig.s.sol"; /*** @title Route tokens from the BSC side. */ @@ -20,43 +20,38 @@ contract Deployment is Script, TestnetConfig { address owner = vm.addr(validatorPrivateKey); console.log("Owner is %s", owner); - // The BSC testnet chain id - uint bscChainId = 97; - // Zilliqa chain id - uint zilliqaChainId = 33101; - vm.startBroadcast(validatorPrivateKey); - LockAndReleaseTokenManagerUpgradeable zilliqaTokenManager = LockAndReleaseTokenManagerUpgradeable(zq_lockAndReleaseOrNativeTokenManager); - LockProxyTokenManagerUpgradeable bscTokenManager = LockProxyTokenManagerUpgradeable(bsc_zilBridgeTokenManager); + LockAndReleaseTokenManagerUpgradeable zilliqaTokenManager = LockAndReleaseTokenManagerUpgradeable(zqLockAndReleaseOrNativeTokenManagerAddress); + LockProxyTokenManagerUpgradeable bscTokenManager = LockProxyTokenManagerUpgradeable(bscLockProxyTokenManagerAddress); // OK. Now set up the routing .. // When bscERC20 arrives at bscTokenManager, send it to zilliqaBridgedERC20 on zilliqaTokenManager ITokenManagerStructs.RemoteToken memory sourceBscERC20GasStruct = ITokenManagerStructs.RemoteToken({ - token: address(zq_bridged_erc20_evm), + token: address(zqBridgedERC20EVMAddress), tokenManager: address(zilliqaTokenManager), - chainId: zilliqaChainId}); - bscTokenManager.registerToken(address(bsc_erc20), sourceBscERC20GasStruct); + chainId: zqChainId}); + bscTokenManager.registerToken(address(bscERC20Address), sourceBscERC20GasStruct); // When bscBridgedZRC2FromZilliqa arrives at bscTokenManager, send it to zilliqaZRC2 on zilliqaTokenManager ITokenManagerStructs.RemoteToken memory bridgedZRC2 = ITokenManagerStructs.RemoteToken({ - token: address(zq_zrc2_evm), + token: address(zqZRC2EVMAddress), tokenManager: address(zilliqaTokenManager), - chainId: zilliqaChainId}); - bscTokenManager.registerToken(address(bsc_bridgedzrc2), bridgedZRC2); + chainId: zqChainId}); + bscTokenManager.registerToken(address(bscBridgedZRC2Address), bridgedZRC2); // When bscBridgedZIL arrives at bscTokenManager, send it to 0 on zilliqaTokenManager ITokenManagerStructs.RemoteToken memory bridgedZIL = ITokenManagerStructs.RemoteToken({ token: address(0), tokenManager: address(zilliqaTokenManager), - chainId: zilliqaChainId}); - bscTokenManager.registerToken(address(bsc_bridgedzil), bridgedZIL); + chainId: zqChainId}); + bscTokenManager.registerToken(address(bscBridgedZILAddress), bridgedZIL); // When BNB arrives at bscTokenManager, sent it to zilliqaBridgedBNB on zilliqaTokenManager ITokenManagerStructs.RemoteToken memory bridgedBNB = ITokenManagerStructs.RemoteToken({ - token: address(zq_bridged_bnb_evm), + token: address(zqBridgedBNBEVMAddress), tokenManager: address(zilliqaTokenManager), - chainId: zilliqaChainId}); + chainId: zqChainId}); bscTokenManager.registerToken(address(0), bridgedBNB); } } diff --git a/smart-contracts/script/bsc-testnet/unpauseBridge.s.sol b/smart-contracts/script/bsc-testnet/unpauseBridge.s.sol index 20d95a5..a2caeaf 100644 --- a/smart-contracts/script/bsc-testnet/unpauseBridge.s.sol +++ b/smart-contracts/script/bsc-testnet/unpauseBridge.s.sol @@ -3,26 +3,41 @@ pragma solidity ^0.8.20; import {Script} from "forge-std/Script.sol"; import {MintAndBurnTokenManagerUpgradeableV3} from "contracts/periphery/TokenManagerV3/MintAndBurnTokenManagerUpgradeableV3.sol"; +import {LockProxyTokenManagerUpgradeableV3} from "contracts/zilbridge/2/LockProxyTokenManagerUpgradeableV3.sol"; +import { TestnetConfig } from "script/testnetConfig.s.sol"; import "forge-std/console.sol"; -contract Unpause is Script { +contract Unpause is Script, TestnetConfig { function run() external { uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY_TESTNET"); address owner = vm.addr(deployerPrivateKey); console.log("Deployer is %s", owner); - address tokenManagerAddress = 0xA6D73210AF20a59832F264fbD991D2abf28401d0; + address tokenManagerAddress = bscMintAndBurnTokenManagerAddress; vm.startBroadcast(deployerPrivateKey); - MintAndBurnTokenManagerUpgradeableV3 tokenManager = MintAndBurnTokenManagerUpgradeableV3( + { + MintAndBurnTokenManagerUpgradeableV3 tokenManager = MintAndBurnTokenManagerUpgradeableV3( tokenManagerAddress + ); + tokenManager.unpause(); + console.log( + "TokenManager %s, paused: %s", + tokenManagerAddress, + tokenManager.paused() + ); + } + { + LockProxyTokenManagerUpgradeableV3 tokenManager = LockProxyTokenManagerUpgradeableV3( + bscLockProxyTokenManagerAddress ); - tokenManager.unpause(); - console.log( - "TokenManager %s, paused: %s", - tokenManagerAddress, - tokenManager.paused() - ); + tokenManager.unpause(); + console.log( + "TokenManager %s, paused: %s", + tokenManagerAddress, + tokenManager.paused() + ); + } vm.stopBroadcast(); } } diff --git a/smart-contracts/script/bsc-testnet/upgradeTokenManagerV2.s.sol b/smart-contracts/script/bsc-testnet/upgradeTokenManagerV2.s.sol index d0f32f6..dc86626 100644 --- a/smart-contracts/script/bsc-testnet/upgradeTokenManagerV2.s.sol +++ b/smart-contracts/script/bsc-testnet/upgradeTokenManagerV2.s.sol @@ -4,16 +4,17 @@ pragma solidity ^0.8.20; import {Script} from "forge-std/Script.sol"; import {TokenManagerUpgradeable} from "contracts/periphery/TokenManagerUpgradeable.sol"; import {MintAndBurnTokenManagerUpgradeableV2} from "contracts/periphery/TokenManagerV2/MintAndBurnTokenManagerUpgradeableV2.sol"; +import { TestnetConfig } from "script/testnetConfig.s.sol"; import "forge-std/console.sol"; -contract Upgrade is Script { +contract Upgrade is Script, TestnetConfig { function run() external { uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY_TESTNET"); address owner = vm.addr(deployerPrivateKey); console.log("Signer is %s", owner); // Constants - address tokenManagerAddress = 0xA6D73210AF20a59832F264fbD991D2abf28401d0; + address tokenManagerAddress = bscMintAndBurnTokenManagerAddress; uint fees = 0.00025 ether; // 0.00025 BNB TokenManagerUpgradeable tokenManager = TokenManagerUpgradeable( diff --git a/smart-contracts/script/bsc-testnet/upgradeTokenManagerV3.s.sol b/smart-contracts/script/bsc-testnet/upgradeTokenManagerV3.s.sol index af5a764..09a156c 100644 --- a/smart-contracts/script/bsc-testnet/upgradeTokenManagerV3.s.sol +++ b/smart-contracts/script/bsc-testnet/upgradeTokenManagerV3.s.sol @@ -4,16 +4,17 @@ pragma solidity ^0.8.20; import {Script} from "forge-std/Script.sol"; import {TokenManagerUpgradeable} from "contracts/periphery/TokenManagerUpgradeable.sol"; import {MintAndBurnTokenManagerUpgradeableV3} from "contracts/periphery/TokenManagerV3/MintAndBurnTokenManagerUpgradeableV3.sol"; +import { TestnetConfig } from "script/testnetConfig.s.sol"; import "forge-std/console.sol"; -contract Upgrade is Script { +contract Upgrade is Script, TestnetConfig { function run() external { uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY_TESTNET"); address owner = vm.addr(deployerPrivateKey); console.log("Signer is %s", owner); // Constants - address tokenManagerAddress = 0xA6D73210AF20a59832F264fbD991D2abf28401d0; + address tokenManagerAddress = bscMintAndBurnTokenManagerAddress; TokenManagerUpgradeable tokenManager = TokenManagerUpgradeable( tokenManagerAddress diff --git a/smart-contracts/script/bsc-testnet/zilBridgeTransferERC20.s.sol b/smart-contracts/script/bsc-testnet/zilBridgeTransferERC20.s.sol index bc60963..caae2cf 100644 --- a/smart-contracts/script/bsc-testnet/zilBridgeTransferERC20.s.sol +++ b/smart-contracts/script/bsc-testnet/zilBridgeTransferERC20.s.sol @@ -4,8 +4,9 @@ import {Script} from "forge-std/Script.sol"; import {LockAndReleaseTokenManagerUpgradeable} from "contracts/periphery/LockAndReleaseTokenManagerUpgradeable.sol"; import {ITokenManagerStructs} from "contracts/periphery/TokenManagerUpgradeable.sol"; import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; +import { TestnetConfig } from "script/testnetConfig.s.sol"; import "forge-std/console.sol"; -import "script/testnet_config.s.sol"; + contract Deployment is Script, TestnetConfig { function run() external { @@ -15,7 +16,7 @@ contract Deployment is Script, TestnetConfig { uint256 amount = vm.envUint("ZILBRIDGE_TEST_AMOUNT"); console.log("Owner is %s", validator); vm.startBroadcast(validatorPrivateKey); - ERC20 theContract = ERC20(bsc_erc20); + ERC20 theContract = ERC20(bscERC20Address); // rrw's address for testing. theContract.transfer( recipient, amount ); } diff --git a/smart-contracts/script/testnetConfig.s.sol b/smart-contracts/script/testnetConfig.s.sol new file mode 100644 index 0000000..e3c770b --- /dev/null +++ b/smart-contracts/script/testnetConfig.s.sol @@ -0,0 +1,52 @@ +pragma solidity ^0.8.20; + +/*** @dev Inherit from this contract to get constants that tells you where other testnet contracts are. + * I did consider structuring this a bit more closely, but there is sufficient diversity between + * chains that I haven't, yet. + */ +abstract contract TestnetConfig { + // bsc testnet + address public constant bscEthCrossChainDataAddress = 0xd77a160f954AbF8154f80EA53378ACa55bcAD548; + + uint public constant bscChainId = 97; + // Can't be verified. + address public constant bscCCMAddress = 0x0EDb0830a5a28E60Bc28BCce3f4e1EC23b5E5783; + address public constant bscCCMProxyAddress = 0xE19738378c75cf2b3D704472bE81d7e036F4Ee04; + address public constant bscLockProxyAddress = 0x5B51e17837fc8F01b3C3ef29E882981e9414C159; + // Can't be verified. + address public constant bscExtendCCMAddress = 0x32ffa2C4c670A0fd0e94CF6457ac2FA7Ef007d55; + address public constant bscLockProxyTokenManagerAddress = 0x36b8A9cd6Bf9bfA5984093005cf81CAfB1Bf06F7; + // BSC zilbridge tokens. + address public constant bscERC20Address = 0xa1a47FA4D26137329BB08aC2E5F9a6C32D180fE3; + address public constant bscBridgedZRC2Address = 0x201eDd0521cF4B577399F789e22E05405D500163; + address public constant bscBridgedZILAddress = 0xfA3cF3BBa7f0fA1E8FECeE532512434A7d275d41; + + /// Deployed by the original XBridge testnet deployment (prior to zilBridge) + address public constant bscChainGatewayAddress = 0xa9A14C90e53EdCD89dFd201A3bF94D867f8098fE; + address public constant bscMintAndBurnTokenManagerAddress = 0xd10077bCE4A9D19068965dE519CED8a2fC1B096C; + address public constant bscTestTokenAddress = 0x6d78c86D66DfE5Be5F55FBAA8B1d3FD28edfF396; + + /// Zilliqa testnet + + uint public constant zqChainId = 33101; + address public constant zqChainGatewayAddress = 0x7370e69565BB2313C4dA12F9062C282513919230; + address public constant zqLockAndReleaseTokenManagerAddress = 0x1509988c41f02014aA59d455c6a0D67b5b50f129; + address public constant zqLockAndReleaseOrNativeTokenManagerAddress = 0x5e502559ab6e99949b0eE72d4ebCe05f31E026dC; + + // Scilla contracts. + address public constant zqBridgedERC20Address = address(0x00f281D459E5FdA75f12eEca2D33E3aa03f6456994); + address public constant zqBridgedBNBAddress = address(0x00976050703b8067ab25a56A22e24e404222B07a33); + address public constant zqZRC2Address = address(0x00f1c2F2dadC13d03939c52d7A763dAF188f431AD6); + + // ERC20 fascias for Scilla contracts + address public constant zqBridgedERC20EVMAddress = address(0x2aDFdb71103b8587F609b262b3E7E6161D3f6B1f); + address public constant zqBridgedBNBEVMAddress = address(0x9707F1C6A02c5D8682669d309c046c5Af6c3130e); + address public constant zqZRC2EVMAddress = address(0xCf795CF70C29588fb6885CB8982EAE04354e1BB4); + + // Deployed back in the depths of time; recorded here so we can use them in scripts + address public constant zqLegacyTestTokenAddress = 0x63B6ebD476C84bFDd5DcaCB3f974794FC6C2e721; + + /// ZilBridge constants that we use whilst testing the zilbridge/xbridge integration + uint64 public constant zbZilliqaChainId = 18; + uint64 public constant zbBscChainId = 6; +} diff --git a/smart-contracts/script/testnet_config.s.sol b/smart-contracts/script/testnet_config.s.sol deleted file mode 100644 index 3439914..0000000 --- a/smart-contracts/script/testnet_config.s.sol +++ /dev/null @@ -1,35 +0,0 @@ -pragma solidity ^0.8.20; - -/// Inherit from this contract to get constants that tells you where other testnet contracts are. -abstract contract TestnetConfig { - address public constant bsc_EthCrossChainData = 0xd77a160f954AbF8154f80EA53378ACa55bcAD548; - // Can't be verified. - address public constant bsc_ccm = 0x0EDb0830a5a28E60Bc28BCce3f4e1EC23b5E5783; - address public constant bsc_ccmProxy = 0xE19738378c75cf2b3D704472bE81d7e036F4Ee04; - address public constant bsc_lockProxy = 0x5B51e17837fc8F01b3C3ef29E882981e9414C159; - // Can't be verified. - address public constant bsc_extendCCM = 0x32ffa2C4c670A0fd0e94CF6457ac2FA7Ef007d55; - address public constant bsc_zilBridgeTokenManager = 0x36b8A9cd6Bf9bfA5984093005cf81CAfB1Bf06F7; - - - /// Deployed by XBridge testnet deployment - address public constant bsc_chainGateway = 0xa9A14C90e53EdCD89dFd201A3bF94D867f8098fE; - address public constant zq_chainGateway = 0x7370e69565BB2313C4dA12F9062C282513919230; - address public constant zq_lockAndReleaseTokenManager = 0x1509988c41f02014aA59d455c6a0D67b5b50f129; - address public constant zq_lockAndReleaseOrNativeTokenManager = 0x5e502559ab6e99949b0eE72d4ebCe05f31E026dC; - - // BSC zilbridge tokens. - address public constant bsc_erc20 = 0xa1a47FA4D26137329BB08aC2E5F9a6C32D180fE3; - address public constant bsc_bridgedzrc2 = 0x201eDd0521cF4B577399F789e22E05405D500163; - address public constant bsc_bridgedzil = 0xfA3cF3BBa7f0fA1E8FECeE532512434A7d275d41; - - // Scilla contracts. - address public constant zq_bridged_erc20 = address(0x00f281D459E5FdA75f12eEca2D33E3aa03f6456994); - address public constant zq_bridged_bnb = address(0x00976050703b8067ab25a56A22e24e404222B07a33); - address public constant zq_zrc2 = address(0x00f1c2F2dadC13d03939c52d7A763dAF188f431AD6); - - // ERC20 fascias for Scilla contracts - address public constant zq_bridged_erc20_evm = address(0x2aDFdb71103b8587F609b262b3E7E6161D3f6B1f); - address public constant zq_bridged_bnb_evm = address(0x9707F1C6A02c5D8682669d309c046c5Af6c3130e); - address public constant zq_zrc2_evm = address(0xCf795CF70C29588fb6885CB8982EAE04354e1BB4); -} diff --git a/smart-contracts/script/zq-testnet/bridgeTokens.s.sol b/smart-contracts/script/zq-testnet/bridgeTokens.s.sol index 746b429..2051292 100644 --- a/smart-contracts/script/zq-testnet/bridgeTokens.s.sol +++ b/smart-contracts/script/zq-testnet/bridgeTokens.s.sol @@ -6,17 +6,18 @@ import {LockAndReleaseTokenManagerUpgradeable} from "contracts/periphery/LockAnd import {ITokenManagerStructs} from "contracts/periphery/TokenManagerUpgradeable.sol"; import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "forge-std/console.sol"; +import { TestnetConfig } from "script/testnetConfig.s.sol"; -contract Transfer is Script { +contract Transfer is Script, TestnetConfig { function run() external { uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY_TESTNET"); address owner = vm.addr(deployerPrivateKey); console.log("Owner is %s", owner); - address tokenManagerAddress = 0xd10077bCE4A9D19068965dE519CED8a2fC1B096C; - address tokenAddress = 0x63B6ebD476C84bFDd5DcaCB3f974794FC6C2e721; + address tokenManagerAddress = zqLockAndReleaseTokenManagerAddress; + address tokenAddress = zqLegacyTestTokenAddress; - uint remoteChainId = 97; + uint remoteChainId = bscChainId; address remoteRecipient = owner; uint amount = 10; diff --git a/smart-contracts/script/zq-testnet/deployChainGateway.s.sol b/smart-contracts/script/zq-testnet/deployChainGateway.s.sol index a93ed4f..8b32d8d 100644 --- a/smart-contracts/script/zq-testnet/deployChainGateway.s.sol +++ b/smart-contracts/script/zq-testnet/deployChainGateway.s.sol @@ -6,8 +6,9 @@ import {Relayer} from "contracts/core/Relayer.sol"; import {ValidatorManager} from "contracts/core/ValidatorManager.sol"; import {ChainGateway} from "contracts/core/ChainGateway.sol"; import "forge-std/console.sol"; +import { TestnetConfig } from "script/testnetConfig.s.sol"; -contract Deployment is Script { +contract Deployment is Script, TestnetConfig { function run() external { uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY_TESTNET"); address owner = vm.addr(deployerPrivateKey); @@ -40,6 +41,10 @@ contract Deployment is Script { address(chainGateway), address(chainGateway.validatorManager()) ); + console.log( + " address public constant zqChainGatewayAddress = %s", address(chainGateway)); + console.log( + " address public constant zqValidatorManagerAddress = %s", address(chainGateway.validatorManager())); vm.stopBroadcast(); } diff --git a/smart-contracts/script/zq-testnet/deployCoreUpgradeable.s.sol b/smart-contracts/script/zq-testnet/deployCoreUpgradeable.s.sol index ef641e7..260cb05 100644 --- a/smart-contracts/script/zq-testnet/deployCoreUpgradeable.s.sol +++ b/smart-contracts/script/zq-testnet/deployCoreUpgradeable.s.sol @@ -5,16 +5,17 @@ import {Script} from "forge-std/Script.sol"; import {ValidatorManagerUpgradeable} from "contracts/core-upgradeable/ValidatorManagerUpgradeable.sol"; import {ChainGatewayUpgradeable} from "contracts/core-upgradeable/ChainGatewayUpgradeable.sol"; import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; +import { TestnetConfig } from "script/testnetConfig.s.sol"; import "forge-std/console.sol"; -contract Deployment is Script { +contract Deployment is Script, TestnetConfig { function run() external { uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY_TESTNET"); address owner = vm.addr(deployerPrivateKey); console.log("Owner is %s", owner); address[] memory validators = new address[](1); - address tokenManager = 0x1509988c41f02014aA59d455c6a0D67b5b50f129; + address tokenManager = zqLockAndReleaseTokenManagerAddress; validators[0] = owner; vm.startBroadcast(deployerPrivateKey); @@ -38,6 +39,8 @@ contract Deployment is Script { validatorManager.isValidator(validators[0]), validatorManager.validatorsSize() ); + console.log( + " address public constant zqValidatorManagerAddress = %s", address(validatorManager)); // Deploy Chain Gateway address cgImplementation = address(new ChainGatewayUpgradeable()); @@ -55,6 +58,8 @@ contract Deployment is Script { address(chainGateway), address(chainGateway.validatorManager()) ); + console.log( + " address public constant zqChainGatewayAddress = %s", address(chainGateway)); // Register TokenManager to ChainGateway chainGateway.register(tokenManager); @@ -64,6 +69,8 @@ contract Deployment is Script { address(chainGateway), chainGateway.registered(tokenManager) ); + console.log( + " address public constant zqLockAndReleaseTokenManagerAddress = %s", address(tokenManager)); vm.stopBroadcast(); } diff --git a/smart-contracts/script/zq-testnet/deployNativeTokenManagerV3.s.sol b/smart-contracts/script/zq-testnet/deployNativeTokenManagerV3.s.sol index f61d346..24c4577 100644 --- a/smart-contracts/script/zq-testnet/deployNativeTokenManagerV3.s.sol +++ b/smart-contracts/script/zq-testnet/deployNativeTokenManagerV3.s.sol @@ -6,13 +6,13 @@ import {LockAndReleaseOrNativeTokenManagerUpgradeableV3} from "contracts/periphe import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; import {ChainGateway} from "contracts/core/ChainGateway.sol"; import {LockAndReleaseOrNativeTokenManagerDeployer} from "test/periphery/TokenManagerDeployers/LockAndReleaseOrNativeTokenManagerDeployer.sol"; +import { TestnetConfig } from "script/testnetConfig.s.sol"; import "forge-std/console.sol"; -import "script/testnet_config.s.sol"; contract Deployment is Script, LockAndReleaseOrNativeTokenManagerDeployer,TestnetConfig { function run() external { uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY_TESTNET"); - address chainGatewayAddress = zq_chainGateway; + address chainGatewayAddress = zqChainGatewayAddress; uint fees = 60 ether; // 60 ZIL vm.startBroadcast(deployerPrivateKey); @@ -24,6 +24,8 @@ contract Deployment is Script, LockAndReleaseOrNativeTokenManagerDeployer,Testne tokenManager.owner(), tokenManager.getGateway() ); + console.log( + " address public constant zqLockAndReleaseOrNativeTokenManagerAddress = %s", address(tokenManager)); ChainGateway chainGateway = ChainGateway(chainGatewayAddress); chainGateway.register(address(tokenManager)); diff --git a/smart-contracts/script/zq-testnet/deployTokenManager.s.sol b/smart-contracts/script/zq-testnet/deployTokenManager.s.sol index 147b995..025b2c9 100644 --- a/smart-contracts/script/zq-testnet/deployTokenManager.s.sol +++ b/smart-contracts/script/zq-testnet/deployTokenManager.s.sol @@ -5,12 +5,14 @@ import {Script} from "forge-std/Script.sol"; import {LockAndReleaseTokenManagerUpgradeable} from "contracts/periphery/LockAndReleaseTokenManagerUpgradeable.sol"; import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; import {ChainGateway} from "contracts/core/ChainGateway.sol"; +import { TestnetConfig } from "script/testnetConfig.s.sol"; import "forge-std/console.sol"; -contract Deployment is Script { + +contract Deployment is Script, TestnetConfig { function run() external { uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY_TESTNET"); - address chainGatewayAddress = 0x10917A34FE60eE8364a401a6b1d3adaf80D84eb6; + address chainGatewayAddress = zqChainGatewayAddress; vm.startBroadcast(deployerPrivateKey); @@ -37,6 +39,8 @@ contract Deployment is Script { tokenManager.owner(), tokenManager.getGateway() ); + console.log( + " address public constant zqLockAndReleaseTokenManagerAddress = %s", address(tokenManager)); ChainGateway chainGateway = ChainGateway(chainGatewayAddress); chainGateway.register(proxy); diff --git a/smart-contracts/script/zq-testnet/deployZRC2ERC20.s.sol b/smart-contracts/script/zq-testnet/deployZRC2ERC20.s.sol index 51ba774..80fb968 100644 --- a/smart-contracts/script/zq-testnet/deployZRC2ERC20.s.sol +++ b/smart-contracts/script/zq-testnet/deployZRC2ERC20.s.sol @@ -5,7 +5,7 @@ import {Script} from "forge-std/Script.sol"; import {LockAndReleaseTokenManagerUpgradeable} from "contracts/periphery/LockAndReleaseTokenManagerUpgradeable.sol"; import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; import { ZRC2ProxyForZRC2 } from "test/zilbridge/zrc2erc20/ZRC2ProxyForZRC2.sol"; -import { TestnetConfig } from "script/testnet_config.s.sol"; +import { TestnetConfig } from "script/testnetConfig.s.sol"; import "forge-std/console.sol"; /*** @title Deploy an ERC20 proxy for our ZRC2, so we can set routing with it. @@ -17,16 +17,19 @@ contract Deployment is Script, TestnetConfig { console.log("Owner is %s", validator); vm.startBroadcast(validatorPrivateKey); { - ZRC2ProxyForZRC2 proxy = new ZRC2ProxyForZRC2(zq_bridged_erc20); - console.log("zq_bridged_erc20_evm = %s", address(proxy)); + ZRC2ProxyForZRC2 proxy = new ZRC2ProxyForZRC2(zqBridgedERC20Address); + console.log( + " address public constant zqBridgedERC20EVMAddress = %s", address(proxy)); } { - ZRC2ProxyForZRC2 proxy = new ZRC2ProxyForZRC2(zq_bridged_bnb); - console.log("zq_bridged_bnb_evm = %s", address(proxy)); + ZRC2ProxyForZRC2 proxy = new ZRC2ProxyForZRC2(zqBridgedBNBAddress); + console.log( + " address public constant zqBridgedBNBEVMAddress = %s", address(proxy)); } { - ZRC2ProxyForZRC2 proxy = new ZRC2ProxyForZRC2(zq_zrc2); - console.log("zq_zrc2_evm = %s", address(proxy)); + ZRC2ProxyForZRC2 proxy = new ZRC2ProxyForZRC2(zqZRC2Address); + console.log( + " address public constant zqZRC2EVMAddress = %s", address(proxy)); } } } diff --git a/smart-contracts/script/zq-testnet/dispatchRelay.s.sol b/smart-contracts/script/zq-testnet/dispatchRelay.s.sol index 4a07585..7351acb 100644 --- a/smart-contracts/script/zq-testnet/dispatchRelay.s.sol +++ b/smart-contracts/script/zq-testnet/dispatchRelay.s.sol @@ -5,8 +5,12 @@ import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/Messa import {Script} from "forge-std/Script.sol"; import {ChainGateway} from "contracts/core/ChainGateway.sol"; import {ValidatorManager} from "contracts/core/ValidatorManager.sol"; +import { TestnetConfig } from "script/testnetConfig.s.sol"; -contract Dispatch is Script { +/*** @dev this script contains hardwired addresses - remember to hand-edit them to match the testnet config, + * or it won't work! + */ +contract Dispatch is Script, TestnetConfig { using MessageHashUtils for bytes; function run() external { diff --git a/smart-contracts/script/zq-testnet/pauseBridge.s.sol b/smart-contracts/script/zq-testnet/pauseBridge.s.sol index 626dcfa..40895a2 100644 --- a/smart-contracts/script/zq-testnet/pauseBridge.s.sol +++ b/smart-contracts/script/zq-testnet/pauseBridge.s.sol @@ -3,26 +3,41 @@ pragma solidity ^0.8.20; import {Script} from "forge-std/Script.sol"; import {LockAndReleaseTokenManagerUpgradeableV3} from "contracts/periphery/TokenManagerV3/LockAndReleaseTokenManagerUpgradeableV3.sol"; +import {LockAndReleaseOrNativeTokenManagerUpgradeableV3} from "contracts/periphery/TokenManagerV3/LockAndReleaseOrNativeTokenManagerUpgradeableV3.sol"; +import { TestnetConfig } from "script/testnetConfig.s.sol"; import "forge-std/console.sol"; -contract Pause is Script { +contract Pause is Script, TestnetConfig { function run() external { uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY_TESTNET"); address owner = vm.addr(deployerPrivateKey); console.log("Deployer is %s", owner); - address tokenManagerAddress = 0x1509988c41f02014aA59d455c6a0D67b5b50f129; + address tokenManagerAddress = zqLockAndReleaseTokenManagerAddress; vm.startBroadcast(deployerPrivateKey); - LockAndReleaseTokenManagerUpgradeableV3 tokenManager = LockAndReleaseTokenManagerUpgradeableV3( - tokenManagerAddress - ); - tokenManager.pause(); - console.log( - "TokenManager %s, paused: %s", - tokenManagerAddress, - tokenManager.paused() - ); + { + LockAndReleaseTokenManagerUpgradeableV3 tokenManager = LockAndReleaseTokenManagerUpgradeableV3( + tokenManagerAddress + ); + tokenManager.pause(); + console.log( + "TokenManager %s, paused: %s", + tokenManagerAddress, + tokenManager.paused() + ); + } + { + LockAndReleaseOrNativeTokenManagerUpgradeableV3 tokenManager = LockAndReleaseOrNativeTokenManagerUpgradeableV3( + payable(zqLockAndReleaseOrNativeTokenManagerAddress) + ); + tokenManager.pause(); + console.log( + "LockAndReleaseOrNativeTokenManager %s, paused: %s", + zqLockAndReleaseOrNativeTokenManagerAddress, + tokenManager.paused() + ); + } vm.stopBroadcast(); } } diff --git a/smart-contracts/script/zq-testnet/registerToken.s.sol b/smart-contracts/script/zq-testnet/registerToken.s.sol index 10dbd14..9daea46 100644 --- a/smart-contracts/script/zq-testnet/registerToken.s.sol +++ b/smart-contracts/script/zq-testnet/registerToken.s.sol @@ -5,9 +5,12 @@ import {Script} from "forge-std/Script.sol"; import {LockAndReleaseTokenManagerUpgradeable} from "contracts/periphery/LockAndReleaseTokenManagerUpgradeable.sol"; import {ITokenManagerStructs} from "contracts/periphery/TokenManagerUpgradeable.sol"; import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; +import { TestnetConfig } from "script/testnetConfig.s.sol"; import "forge-std/console.sol"; -contract Deployment is Script { +/*** @dev uses hardwired addresses; I've left these alone .. + */ +contract Deployment is Script, TestnetConfig { function run() external { uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY_TESTNET"); address owner = vm.addr(deployerPrivateKey); diff --git a/smart-contracts/script/zq-testnet/setChainGatewayOnTokenManager.s.sol b/smart-contracts/script/zq-testnet/setChainGatewayOnTokenManager.s.sol index 2901228..67b284a 100644 --- a/smart-contracts/script/zq-testnet/setChainGatewayOnTokenManager.s.sol +++ b/smart-contracts/script/zq-testnet/setChainGatewayOnTokenManager.s.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.20; import {Script} from "forge-std/Script.sol"; import {LockAndReleaseTokenManagerUpgradeableV3} from "contracts/periphery/TokenManagerV3/LockAndReleaseTokenManagerUpgradeableV3.sol"; import {LockAndReleaseOrNativeTokenManagerUpgradeableV3} from "contracts/periphery/TokenManagerV3/LockAndReleaseOrNativeTokenManagerUpgradeableV3.sol"; -import "script/testnet_config.s.sol"; +import { TestnetConfig } from "script/testnetConfig.s.sol"; import "forge-std/console.sol"; contract Update is TestnetConfig,Script { @@ -13,9 +13,9 @@ contract Update is TestnetConfig,Script { address owner = vm.addr(deployerPrivateKey); console.log("Deployer is %s", owner); - address newChainGateway = zq_chainGateway; - address tokenManagerAddress = zq_lockAndReleaseTokenManager; - address nativeTokenManagerAddress = zq_lockAndReleaseOrNativeTokenManager; + address newChainGateway = zqChainGatewayAddress; + address tokenManagerAddress = zqLockAndReleaseTokenManagerAddress; + address nativeTokenManagerAddress = zqLockAndReleaseOrNativeTokenManagerAddress; vm.startBroadcast(deployerPrivateKey); LockAndReleaseTokenManagerUpgradeableV3 tokenManager = LockAndReleaseTokenManagerUpgradeableV3( diff --git a/smart-contracts/script/zq-testnet/setZilBridgeRouting.s.sol b/smart-contracts/script/zq-testnet/setZilBridgeRouting.s.sol index 31aa2a8..433faf3 100644 --- a/smart-contracts/script/zq-testnet/setZilBridgeRouting.s.sol +++ b/smart-contracts/script/zq-testnet/setZilBridgeRouting.s.sol @@ -10,7 +10,7 @@ import { SwitcheoToken } from "contracts/zilbridge/token/tokens/SwitcheoTokenETH import "forge-std/console.sol"; import {LockProxyTokenManagerUpgradeable} from "contracts/zilbridge/2/LockProxyTokenManagerUpgradeable.sol"; import {LockAndReleaseTokenManagerUpgradeable} from "contracts/periphery/LockAndReleaseTokenManagerUpgradeable.sol"; -import { TestnetConfig } from "script/testnet_config.s.sol"; +import { TestnetConfig } from "script/testnetConfig.s.sol"; /*** @title Route tokens from the BSC side. */ @@ -20,44 +20,38 @@ contract Deployment is Script, TestnetConfig { address validator = vm.addr(validatorPrivateKey); console.log("Owner is %s", validator); - // The BSC testnet chain id (this is an XBridge ID, not a zilBridge one). - uint bscChainId = 97; - // Zilliqa chain id - uint zilliqaChainId = 33101; - vm.startBroadcast(validatorPrivateKey); - LockAndReleaseTokenManagerUpgradeable zilliqaTokenManager = LockAndReleaseTokenManagerUpgradeable(address(zq_lockAndReleaseOrNativeTokenManager)); - LockProxyTokenManagerUpgradeable bscTokenManager = LockProxyTokenManagerUpgradeable(bsc_zilBridgeTokenManager); + LockAndReleaseTokenManagerUpgradeable zilliqaTokenManager = LockAndReleaseTokenManagerUpgradeable(address(zqLockAndReleaseOrNativeTokenManagerAddress)); // OK. Now set up the routing .. - // When zilliqaBridgedERC20 arrives at zilliqaTokenManager, send it to bscERC20 on bscTokenManager + // When zilliqaBridgedERC20 arrives at zilliqaTokenManager, send it to bscERC20 on bscTokenManager ITokenManagerStructs.RemoteToken memory sourceBscERC20GasStruct = ITokenManagerStructs.RemoteToken({ - token: address(bsc_erc20), - tokenManager: address(bscTokenManager), + token: address(bscERC20Address), + tokenManager: address(bscLockProxyTokenManagerAddress), chainId: bscChainId}); - zilliqaTokenManager.registerToken(address(zq_bridged_erc20_evm), sourceBscERC20GasStruct); + zilliqaTokenManager.registerToken(address(zqBridgedERC20EVMAddress), sourceBscERC20GasStruct); // When zilliqaZRC2 arrives at zilliqaTokenManager, send it to bscBridgedZRC2FromZilliqa on bscTokenManager ITokenManagerStructs.RemoteToken memory bridgedZRC2 = ITokenManagerStructs.RemoteToken({ - token: address(bsc_bridgedzrc2), - tokenManager: address(bscTokenManager), + token: address(bscBridgedZRC2Address), + tokenManager: address(bscLockProxyTokenManagerAddress), chainId: bscChainId}); - zilliqaTokenManager.registerToken(address(zq_zrc2_evm), bridgedZRC2); + zilliqaTokenManager.registerToken(address(zqZRC2EVMAddress), bridgedZRC2); // When ZIL arrives at zilliqaTokenManager, send it to bscBridgedZIL on bscTokenManager ITokenManagerStructs.RemoteToken memory bridgedZIL = ITokenManagerStructs.RemoteToken({ - token: address(bsc_bridgedzil), - tokenManager: address(bscTokenManager), + token: address(bscBridgedZILAddress), + tokenManager: address(bscLockProxyTokenManagerAddress), chainId: bscChainId}); zilliqaTokenManager.registerToken(address(0), bridgedZIL); // When zilliqaBridgedBNB arrives at zilliqaTokenManager, send it to 0 on bscTokenManager ITokenManagerStructs.RemoteToken memory bridgedBNB = ITokenManagerStructs.RemoteToken({ token: address(0), - tokenManager: address(bscTokenManager), + tokenManager: address(bscLockProxyTokenManagerAddress), chainId: bscChainId}); - zilliqaTokenManager.registerToken(address(zq_bridged_bnb_evm), bridgedBNB); + zilliqaTokenManager.registerToken(address(zqBridgedBNBEVMAddress), bridgedBNB); } } diff --git a/smart-contracts/script/zq-testnet/unpauseBridge.s.sol b/smart-contracts/script/zq-testnet/unpauseBridge.s.sol index 7f4c3e0..9ee21f2 100644 --- a/smart-contracts/script/zq-testnet/unpauseBridge.s.sol +++ b/smart-contracts/script/zq-testnet/unpauseBridge.s.sol @@ -3,26 +3,40 @@ pragma solidity ^0.8.20; import {Script} from "forge-std/Script.sol"; import {LockAndReleaseTokenManagerUpgradeableV3} from "contracts/periphery/TokenManagerV3/LockAndReleaseTokenManagerUpgradeableV3.sol"; +import { TestnetConfig } from "script/testnetConfig.s.sol"; import "forge-std/console.sol"; -contract Unpause is Script { +contract Unpause is Script, TestnetConfig { function run() external { uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY_TESTNET"); address owner = vm.addr(deployerPrivateKey); console.log("Deployer is %s", owner); - address tokenManagerAddress = 0x1509988c41f02014aA59d455c6a0D67b5b50f129; + address tokenManagerAddress = zqLockAndReleaseTokenManagerAddress; vm.startBroadcast(deployerPrivateKey); - LockAndReleaseTokenManagerUpgradeableV3 tokenManager = LockAndReleaseTokenManagerUpgradeableV3( + { + LockAndReleaseTokenManagerUpgradeableV3 tokenManager = LockAndReleaseTokenManagerUpgradeableV3( tokenManagerAddress - ); - tokenManager.unpause(); - console.log( - "TokenManager %s, paused: %s", - tokenManagerAddress, - tokenManager.paused() - ); + ); + tokenManager.unpause(); + console.log( + "TokenManager %s, paused: %s", + tokenManagerAddress, + tokenManager.paused() + ); + } + { + LockAndReleaseTokenManagerUpgradeableV3 tokenManager = LockAndReleaseTokenManagerUpgradeableV3( + zqLockAndReleaseOrNativeTokenManagerAddress + ); + tokenManager.unpause(); + console.log( + "TokenManager %s, paused: %s", + address(tokenManager), + tokenManager.paused() + ); + } vm.stopBroadcast(); } } diff --git a/smart-contracts/script/zq-testnet/upgradeTokenManagerV2.s.sol b/smart-contracts/script/zq-testnet/upgradeTokenManagerV2.s.sol index 11756de..e80ac05 100644 --- a/smart-contracts/script/zq-testnet/upgradeTokenManagerV2.s.sol +++ b/smart-contracts/script/zq-testnet/upgradeTokenManagerV2.s.sol @@ -4,16 +4,17 @@ pragma solidity ^0.8.20; import {Script} from "forge-std/Script.sol"; import {TokenManagerUpgradeable} from "contracts/periphery/TokenManagerUpgradeable.sol"; import {LockAndReleaseTokenManagerUpgradeableV2} from "contracts/periphery/TokenManagerV2/LockAndReleaseTokenManagerUpgradeableV2.sol"; +import { TestnetConfig } from "script/testnetConfig.s.sol"; import "forge-std/console.sol"; -contract Upgrade is Script { +contract Upgrade is Script, TestnetConfig { function run() external { uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY_TESTNET"); address owner = vm.addr(deployerPrivateKey); console.log("Signer is %s", owner); // Constants - address tokenManagerAddress = 0x1509988c41f02014aA59d455c6a0D67b5b50f129; + address tokenManagerAddress = zqLockAndReleaseTokenManagerAddress; uint fees = 60 ether; // 60 ZIL TokenManagerUpgradeable tokenManager = TokenManagerUpgradeable( diff --git a/smart-contracts/script/zq-testnet/upgradeTokenManagerV3.s.sol b/smart-contracts/script/zq-testnet/upgradeTokenManagerV3.s.sol index 1a1bc76..6a96f8e 100644 --- a/smart-contracts/script/zq-testnet/upgradeTokenManagerV3.s.sol +++ b/smart-contracts/script/zq-testnet/upgradeTokenManagerV3.s.sol @@ -4,16 +4,17 @@ pragma solidity ^0.8.20; import {Script} from "forge-std/Script.sol"; import {TokenManagerUpgradeable} from "contracts/periphery/TokenManagerUpgradeable.sol"; import {LockAndReleaseTokenManagerUpgradeableV3} from "contracts/periphery/TokenManagerV3/LockAndReleaseTokenManagerUpgradeableV3.sol"; +import { TestnetConfig } from "script/testnetConfig.s.sol"; import "forge-std/console.sol"; -contract Upgrade is Script { +contract Upgrade is Script,TestnetConfig { function run() external { uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY_TESTNET"); address owner = vm.addr(deployerPrivateKey); console.log("Signer is %s", owner); // Constants - address tokenManagerAddress = 0x1509988c41f02014aA59d455c6a0D67b5b50f129; + address tokenManagerAddress = zqLockAndReleaseTokenManagerAddress; TokenManagerUpgradeable tokenManager = TokenManagerUpgradeable( tokenManagerAddress diff --git a/smart-contracts/script/zq-testnet/zilBridgeDebug.s.sol b/smart-contracts/script/zq-testnet/zilBridgeDebug.s.sol index 11bd4ea..c40ad32 100644 --- a/smart-contracts/script/zq-testnet/zilBridgeDebug.s.sol +++ b/smart-contracts/script/zq-testnet/zilBridgeDebug.s.sol @@ -7,7 +7,7 @@ import {ITokenManagerStructs, ITokenManager} from "contracts/periphery/TokenMana import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import {ZRC2ProxyForZRC2} from "test/zilbridge/zrc2erc20/ZRC2ProxyForZRC2.sol"; import "forge-std/console.sol"; -import "script/testnet_config.s.sol"; +import { TestnetConfig } from "script/testnetConfig.s.sol"; import {IERC20} from "contracts/periphery/LockAndReleaseTokenManagerUpgradeable.sol"; import {IRelayer, Relayer, CallMetadata} from "contracts/core/Relayer.sol"; import {Registry} from "contracts/core/Registry.sol"; @@ -21,22 +21,21 @@ contract Deployment is Script, TestnetConfig { address validator = vm.addr(validatorPrivateKey); vm.startBroadcast(validatorPrivateKey); console.log("I am %s", validator); - console.log("Token manager at %s", zq_lockAndReleaseOrNativeTokenManager); - console.log("ChainGateway %s", zq_chainGateway); - ChainGateway chainGateway = ChainGateway(zq_chainGateway); - chainGateway.register(address(zq_lockAndReleaseOrNativeTokenManager)); + console.log("Token manager at %s", zqLockAndReleaseOrNativeTokenManagerAddress); + console.log("ChainGateway %s", zqChainGatewayAddress); + ChainGateway chainGateway = ChainGateway(zqChainGatewayAddress); + chainGateway.register(address(zqLockAndReleaseOrNativeTokenManagerAddress)); console.log( "TokenManager %s registered to %s ChainGateway: %s", - address(zq_lockAndReleaseOrNativeTokenManager), + address(zqLockAndReleaseOrNativeTokenManagerAddress), address(chainGateway), - chainGateway.registered(address(zq_lockAndReleaseOrNativeTokenManager)) + chainGateway.registered(address(zqLockAndReleaseOrNativeTokenManagerAddress)) ); - Relayer relayer = Relayer(zq_chainGateway); - bool amRegistered = relayer.registered(zq_lockAndReleaseOrNativeTokenManager); + Relayer relayer = Relayer(zqChainGatewayAddress); + bool amRegistered = relayer.registered(zqLockAndReleaseOrNativeTokenManagerAddress); console.log("isRegistered %d", amRegistered); - - + /* ITokenManager tok = ITokenManager(zq_lockAndReleaseOrNativeTokenManager); */ /* ITokenManagerStructs.RemoteToken memory rt = tok.getRemoteTokens(0x2A82a13A118c0f9E203a9C006742024354D0f4Ca, 97); */ /* console.log("remoteToken = %s / mgr %s / chainId %d", rt.token, rt.tokenManager, rt.chainId); */ diff --git a/smart-contracts/script/zq-testnet/zilBridgeTransferERC20.s.sol b/smart-contracts/script/zq-testnet/zilBridgeTransferERC20.s.sol index 10878a8..af1c391 100644 --- a/smart-contracts/script/zq-testnet/zilBridgeTransferERC20.s.sol +++ b/smart-contracts/script/zq-testnet/zilBridgeTransferERC20.s.sol @@ -4,8 +4,8 @@ import {Script} from "forge-std/Script.sol"; import {LockAndReleaseTokenManagerUpgradeable} from "contracts/periphery/LockAndReleaseTokenManagerUpgradeable.sol"; import {ITokenManagerStructs} from "contracts/periphery/TokenManagerUpgradeable.sol"; import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; +import { TestnetConfig } from "script/testnetConfig.s.sol"; import "forge-std/console.sol"; -import "script/testnet_config.s.sol"; contract Deployment is Script, TestnetConfig { function run() external { @@ -15,7 +15,7 @@ contract Deployment is Script, TestnetConfig { uint256 amount = vm.envUint("ZILBRIDGE_TEST_AMOUNT"); console.log("Owner is %s", validator); vm.startBroadcast(validatorPrivateKey); - ERC20 theContract = ERC20(zq_zrc2_evm); + ERC20 theContract = ERC20(zqZRC2EVMAddress); theContract.transfer( recipient, amount ); } diff --git a/smart-contracts/test/zilbridge/DeployZilBridge.t.sol b/smart-contracts/test/zilbridge/DeployZilBridge.t.sol index 707697c..0a923ca 100644 --- a/smart-contracts/test/zilbridge/DeployZilBridge.t.sol +++ b/smart-contracts/test/zilbridge/DeployZilBridge.t.sol @@ -74,7 +74,7 @@ abstract contract ZilBridgeFixture is Tester, LockProxyTokenManagerDeployer { vm.stopPrank(); } - function getLockProxy() public returns (TestingLockProxy) { + function getLockProxy() public view returns (TestingLockProxy) { return lockProxy; } diff --git a/smart-contracts/test/zilbridge/ccmExtendCrossChainManager.t.sol b/smart-contracts/test/zilbridge/ccmExtendCrossChainManager.t.sol index f674b1b..3a5e9ba 100644 --- a/smart-contracts/test/zilbridge/ccmExtendCrossChainManager.t.sol +++ b/smart-contracts/test/zilbridge/ccmExtendCrossChainManager.t.sol @@ -53,7 +53,7 @@ contract ccmExtendCrossChainManager is ZilBridgeFixture { require(lockProxy.extensions(address(lpTokenManager))==true); } - function test_Pickle() external { + function test_Pickle() view external { console.log("owner = %s", owner); bytes memory payload = ZeroCopySink.WriteVarBytes(Utils.addressToBytes(owner)); console.logBytes(payload);