Skip to content

Commit

Permalink
(feat) Remove (as many as possible) manifest constants from the test …
Browse files Browse the repository at this point in the history
…scripts

(feat) change names of symbolic constants to mixedCase

Signed-off-by: Richard Watts <[email protected]>
  • Loading branch information
rrw-zilliqa committed Jul 29, 2024
1 parent 0baa9b1 commit 512a64d
Show file tree
Hide file tree
Showing 35 changed files with 318 additions and 200 deletions.
9 changes: 5 additions & 4 deletions smart-contracts/script/bsc-testnet/bridgeTokens.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
9 changes: 8 additions & 1 deletion smart-contracts/script/bsc-testnet/deployBridge.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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"}(
Expand All @@ -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(
Expand All @@ -51,7 +56,6 @@ contract Deployment is Script {
MintAndBurnTokenManagerUpgradeable.initialize,
address(chainGateway)
);

address proxy = address(
new ERC1967Proxy(implementation, initializeData)
);
Expand All @@ -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);
Expand Down
11 changes: 6 additions & 5 deletions smart-contracts/script/bsc-testnet/deployBridgeToken.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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(
Expand All @@ -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);
Expand Down
22 changes: 12 additions & 10 deletions smart-contracts/script/bsc-testnet/deployMockZilBridge.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,28 @@ 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 {
address[] memory a = new address[](0);
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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 9 additions & 6 deletions smart-contracts/script/bsc-testnet/deployZilBridgeTokens.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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_) {
Expand All @@ -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));
}
}
22 changes: 19 additions & 3 deletions smart-contracts/script/bsc-testnet/pauseBridge.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading

0 comments on commit 512a64d

Please sign in to comment.