Skip to content
Open
Show file tree
Hide file tree
Changes from 7 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
3 changes: 2 additions & 1 deletion eth/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ __pycache__
# Flatten script input
json_inputs


# local openzeppelin config
.openzeppelin/unknown-31337.json
2 changes: 1 addition & 1 deletion eth/.openzeppelin/goerli.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,4 @@
}
}
}
}
}
177 changes: 0 additions & 177 deletions eth/.openzeppelin/unknown-31337.json

This file was deleted.

34 changes: 28 additions & 6 deletions eth/hardhat.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { task } = require("hardhat/config");
require("dotenv").config();

require("@nomicfoundation/hardhat-toolbox");

require("@nomicfoundation/hardhat-chai-matchers");
Expand All @@ -9,18 +9,33 @@ require("@nomicfoundation/hardhat-network-helpers");
require("hardhat-contract-sizer");
require("hardhat-abi-exporter");
require("@openzeppelin/hardhat-upgrades");
require('hardhat-storage-layout');
require("hardhat-storage-layout");

const PRIVATE_KEYS = process.env.PRIVATE_KEYS ? process.env.PRIVATE_KEYS.split(",") : [];
const PRIVATE_KEY = process.env.PRIVATE_KEY || '11'.repeat(32);
const PRIVATE_KEY = process.env.PRIVATE_KEY || "11".repeat(32);

const ALCHEMY_API_KEY = process.env.ALCHEMY_API_KEY;
const INFURA_API_KEY = process.env.INFURA_API_KEY;

const FORKING = true;
const FORKING = true; // set undefined to disable forking
const ENABLED_OPTIMIZER = true;
const OPTIMIZER_RUNS = 200;

task("deploy_fastbridge_with_token", "Deploys Eth erc20 Fastbridge with erc20 tokens and whitelists them").setAction(
async (_taskArgs, hre) => {
await hre.run("compile");
const { bridge_deployment_task } = require("./scripts/deployment/deploy_bridge_ETH.js");
await bridge_deployment_task();
}
);

task("get_block_hash", "returns the block hash of input block number")
.addParam("blocknumber", "Block number in integer")
.setAction(async (taskArgs) => {
const { getBlockHash } = require("./scripts/deployment/deploy_bridge_ETH.js");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better rename deploy_bridge_Eth.js to something like deploy_fastbridge_and_token.js

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 1436fac

await getBlockHash(taskArgs.blockNumber);
});

module.exports = {
solidity: {
version: "0.8.11",
Expand All @@ -45,6 +60,14 @@ module.exports = {
enabled: FORKING !== undefined
}
},
ganache: {
url: "HTTP://127.0.0.1:7545",
allowUnlimitedContractSize: true
},
localnet: {
url: "HTTP://127.0.0.1:8545",
allowUnlimitedContractSize: true
},
mainnet: {
url: process.env.MAINNET_URL || "",
accounts: [...PRIVATE_KEYS]
Expand Down Expand Up @@ -89,5 +112,4 @@ module.exports = {
if (process.env.FORKING_BLOCK_NUMBER)
module.exports.networks.hardhat.forking.blockNumber = +process.env.FORKING_BLOCK_NUMBER;

if (process.env.HARDFORK)
module.exports.networks.hardhat.hardfork = process.env.HARDFORK;
if (process.env.HARDFORK) module.exports.networks.hardhat.hardfork = process.env.HARDFORK;
31 changes: 31 additions & 0 deletions eth/scripts/deployment/deploy_bridge_ETH.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const { ethers, upgrades } = require("hardhat");
const provider = new ethers.providers.JsonRpcProvider("HTTP://127.0.0.1:8545");

async function bridge_deployment_task() {
const usdcDecimals = 6;
const [bridge_deployer, token_deployer] = await ethers.getSigners();
const tokenInstance = (await ethers.getContractFactory("TestToken")).connect(token_deployer);
let MockToken = await tokenInstance.deploy(usdcDecimals, "TEST_TOKEN", "MT");
await MockToken.deployed();

const bridge = (await ethers.getContractFactory("EthErc20FastBridge")).connect(bridge_deployer);
let proxy = await upgrades.deployProxy(bridge, [[MockToken.address], [true]], {
unsafeAllow: ["delegatecall"]
});
await proxy.deployed();

const bridge_implementation_address = await upgrades.erc1967.getImplementationAddress(proxy.address);
console.log("Deployment is completed.");
console.log("Proxy FastBridge Deployed at: ", proxy.address);
console.log("FastBridge Implemenation Address: ", bridge_implementation_address);
console.log("Proxy FastBridge Deployed by address: ", bridge_deployer.address);
console.log("Token Address: ", MockToken.address);
console.log("Mock Token deployed by address: ", token_deployer.address);
}

async function getBlockHash(blockNumber) {
const block = await provider.getBlock(blockNumber);
console.log("BLOCK Hash is: ", block.hash);
}

module.exports = { bridge_deployment_task, getBlockHash };
11 changes: 11 additions & 0 deletions eth/scripts/deployment/deploymentAdd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what do we need this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 1436fac

"tokens": {
"USDC": "0xb2d75C5a142A68BDA438e6a318C7FBB2242f9693",
"ETH": "0x0000000000000000000000000000000000000000"
},
"whitelisted_tokens": {
"USDC": true,
"ETH": true
}

}