Skip to content

Commit

Permalink
refactor deploy scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
artyukh committed Jul 17, 2023
1 parent 575853c commit f9c6cc9
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 98 deletions.
28 changes: 28 additions & 0 deletions contracts/periphery/BatchBalance.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
pragma solidity ^0.8.7;

interface IERC20Metadata {
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);

/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}

contract BatchBalance {
function balanceFor(
address[] memory _tokens,
address _account
) external view returns (uint256[] memory balances, uint256[] memory decimals) {
balances = new uint256[](_tokens.length);
decimals = new uint256[](_tokens.length);
for (uint256 i = 0; i < _tokens.length; i++) {
balances[i] = IERC20Metadata(_tokens[i]).balanceOf(_account);
decimals[i] = IERC20Metadata(_tokens[i]).decimals();
}
return (balances, decimals);
}
}
6 changes: 1 addition & 5 deletions scripts/deploy/02_SignatureVerifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ module.exports = async function ({ getNamedAccounts, deployments, network }) {
const deployInitParams = debridgeInitParams[networkName];
if (!deployInitParams) return;

const wethAddress = deployInitParams.external.WETH || (await deployments.get("MockWeth")).address;
const deBridgeGateInstance = await getLastDeployedProxy("DeBridgeGate", deployer, [
deployInitParams.excessConfirmations,
wethAddress,
]);
const deBridgeGateInstance = await getLastDeployedProxy("DeBridgeGate", deployer);

const { contract: signatureVerifierInstance, isDeployed } = await deployProxy("SignatureVerifier", deployer, [
deployInitParams.minConfirmations,
Expand Down
21 changes: 1 addition & 20 deletions scripts/deploy/04_FeeProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,8 @@ module.exports = async function ({ getNamedAccounts, deployments, network }) {
const deployInitParams = debridgeInitParams[network.name];
if (!deployInitParams) return;

// const weth = deployInitParams.external.WETH || (await deployments.get("MockWeth")).address;
// const uniswapFactory = deployInitParams.external.UniswapFactory || (await deployments.get("UniswapV2Factory")).address;

// await deployProxy("FeeProxy", deployer, [uniswapFactory, weth], true);

const wethAddress = deployInitParams.external.WETH || (await deployments.get("MockWeth")).address;
const deBridgeGateInstance = await getLastDeployedProxy("DeBridgeGate", deployer, [
deployInitParams.excessConfirmations,
wethAddress,
]);

const deBridgeGateInstance = await getLastDeployedProxy("DeBridgeGate", deployer);
await deployProxy("SimpleFeeProxy", deployer, [deBridgeGateInstance.address, deployInitParams.treasuryAddress], true);


//next TODO needs only for FeeProxy. we will deploy SimpleFeeProxy
//We deployed simple proxy with function only to withdraw fee
//TODO: FeeProxy setTreasury for each chains
//TODO: FeeProxy setDeEthToken
//TODO: FeeProxy setFeeProxyAddress for each chains
//TODO: FeeProxy setFeeProxyAddress for each chains
//TODO: FeeProxy add workers
};

module.exports.tags = ["04_FeeProxy"]
25 changes: 10 additions & 15 deletions scripts/deploy/06_DeBridgeGateSetup.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
const debridgeInitParams = require("../../assets/debridgeInitParams");
const { getLastDeployedProxy, waitTx } = require("../deploy-utils");

module.exports = async function({getNamedAccounts, deployments, network}) {
module.exports = async function ({ getNamedAccounts, deployments, network }) {
const { deployer } = await getNamedAccounts();
const deployInitParams = debridgeInitParams[network.name];
if (!deployInitParams) return;

console.log("Start 06_DeBridgeGateSetup");

const wethAddress = deployInitParams.external.WETH || (await deployments.get("MockWeth")).address;

const deBridgeGateInstance = await getLastDeployedProxy("DeBridgeGate", deployer, [
deployInitParams.excessConfirmations,
wethAddress,
]);
const deBridgeGateInstance = await getLastDeployedProxy("DeBridgeGate", deployer);

let tx;


// --------------------------------
// setup SignatureVerifier
// --------------------------------
Expand All @@ -38,7 +32,7 @@ module.exports = async function({getNamedAccounts, deployments, network}) {
tx = await deBridgeGateInstance.setCallProxy(callProxy.address);
await waitTx(tx);

console.log(`callProxy ${callProxy.address} get DEBRIDGE_GATE_ROLE`);

const DEBRIDGE_GATE_ROLE = await callProxy.DEBRIDGE_GATE_ROLE();
console.log(`callProxy grantRole DEBRIDGE_GATE_ROLE "${DEBRIDGE_GATE_ROLE}" for deBridgeGate "${deBridgeGateInstance.address}"`);
tx = await callProxy.grantRole(DEBRIDGE_GATE_ROLE, deBridgeGateInstance.address);
Expand Down Expand Up @@ -80,9 +74,9 @@ module.exports = async function({getNamedAccounts, deployments, network}) {
// calling updateChainSupport
// --------------------------------

console.log("updateChainSupport");
console.log(deployInitParams.supportedChains);
console.log(deployInitParams.chainSupportInfo);
console.log("deployInitParams.supportedChains: ", deployInitParams.supportedChains);
console.log("deployInitParams.chainSupportInfo: ", deployInitParams.chainSupportInfo);
console.log("updateChainSupport isChainFrom false");
tx = await deBridgeGateInstance.updateChainSupport(
deployInitParams.supportedChains,
deployInitParams.chainSupportInfo,
Expand All @@ -103,16 +97,14 @@ module.exports = async function({getNamedAccounts, deployments, network}) {
);
await waitTx(tx);

console.log("updateChainSupport isChainFrom true");
tx = await deBridgeGateInstance.updateChainSupport(
deployInitParams.supportedChains,
deployInitParams.chainSupportInfo,
true //_isChainFrom is true for editing getChainFromConfig.
);
await waitTx(tx);

console.log("deployInitParams.supportedChains: ", deployInitParams.supportedChains);
console.log("deployInitParams.fixedNativeFee: ", deployInitParams.fixedNativeFee);


// --------------------------------
// calling updateGlobalFee
Expand All @@ -123,6 +115,9 @@ module.exports = async function({getNamedAccounts, deployments, network}) {
// uint16 _globalTransferFeeBps
// )
console.log("deBridgeGate updateGlobalFee");
console.log(`globalFixedNativeFee: ${deployInitParams.globalFixedNativeFee}`);
console.log(`globalTransferFeeBps: ${deployInitParams.globalTransferFeeBps}`);

tx = await deBridgeGateInstance.updateGlobalFee(
deployInitParams.globalFixedNativeFee,
deployInitParams.globalTransferFeeBps
Expand Down
25 changes: 0 additions & 25 deletions scripts/deploy/13_InvitationContract.js

This file was deleted.

16 changes: 0 additions & 16 deletions scripts/deploy/FeesCalculator.js

This file was deleted.

34 changes: 17 additions & 17 deletions scripts/deploy/bulk_upgrade.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
const { ethers, upgrades } = require("hardhat");
const { upgradeProxy } = require("../deploy-utils");
// const { ethers, upgrades } = require("hardhat");
// const { upgradeProxy } = require("../deploy-utils");

module.exports = async function({getNamedAccounts, deployments, network}) {
const { deployer } = await getNamedAccounts();
// module.exports = async function({getNamedAccounts, deployments, network}) {
// const { deployer } = await getNamedAccounts();

console.log('*'.repeat(100));
console.log(`\tStart bulk contracts upgrading`);
console.log(`\tfrom DEPLOYER ${deployer}`);
console.log('*'.repeat(100));
// console.log('*'.repeat(100));
// console.log(`\tStart bulk contracts upgrading`);
// console.log(`\tfrom DEPLOYER ${deployer}`);
// console.log('*'.repeat(100));

const contracts = {
// "0x0000000000000000000000000000000000000000": "ContractName",
}
// const contracts = {
// // "0x0000000000000000000000000000000000000000": "ContractName",
// }

for (const [address, contract] of Object.entries(contracts)) {
await upgradeProxy(contract, address, deployer);
}
};
// for (const [address, contract] of Object.entries(contracts)) {
// await upgradeProxy(contract, address, deployer);
// }
// };

module.exports.tags = ["bulk_upgrade"];
// module.exports.dependencies = [];
// module.exports.tags = ["bulk_upgrade"];
// // module.exports.dependencies = [];

0 comments on commit f9c6cc9

Please sign in to comment.