Skip to content

Commit

Permalink
feat: Update repo to support mainnet (#155)
Browse files Browse the repository at this point in the history
feat Update repo to support mainnet
  • Loading branch information
andresaiello authored Mar 6, 2024
1 parent 45930f0 commit f0e89ed
Show file tree
Hide file tree
Showing 14 changed files with 86 additions and 25 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "zetachain",
"license": "MIT",
"version": "0.1.0",
"private": false,
"workspaces": {
"packages": [
"packages/*"
Expand Down Expand Up @@ -68,4 +67,4 @@
"dependencies": {
"solc": "0.8.7"
}
}
}
1 change: 1 addition & 0 deletions packages/zeta-app-contracts/arguments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = [];
6 changes: 3 additions & 3 deletions packages/zeta-app-contracts/data/addresses.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"zetaTokenConsumerUniV3": ""
},
"bsc_testnet": {
"multiChainSwap": "0x8BD7144Ddb59c9Fa3Dcf809998521E9cAD946fa1",
"multiChainSwap": "",
"multiChainValue": "",
"zetaTokenConsumerUniV2": "",
"zetaTokenConsumerUniV3": ""
Expand All @@ -31,13 +31,13 @@
"zetaTokenConsumerUniV3": ""
},
"goerli_testnet": {
"multiChainSwap": "0x323745f16C93e56a98012970c28788498d8B3a14",
"multiChainSwap": "",
"multiChainValue": "",
"zetaTokenConsumerUniV2": "",
"zetaTokenConsumerUniV3": ""
},
"mumbai_testnet": {
"multiChainSwap": "0xb1b812b664c28E1bA1d35De925Ae88b7Bc7cdCF5",
"multiChainSwap": "",
"multiChainValue": "",
"zetaTokenConsumerUniV2": "",
"zetaTokenConsumerUniV3": ""
Expand Down
21 changes: 21 additions & 0 deletions packages/zeta-app-contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,28 @@ const config: HardhatUserConfig = {
// ETH
goerli: process.env.ETHERSCAN_API_KEY || "",
mainnet: process.env.ETHERSCAN_API_KEY || "",
zeta_mainnet: "NO_TOKEN",
zeta_testnet: "NO_TOKEN",
},
//@ts-ignore
customChains: [
{
chainId: 7000,
network: "zeta_mainnet",
urls: {
apiURL: "https://zetachain.blockscout.com/api",
browserURL: "https://zetachain.blockscout.com",
},
},
{
chainId: 7001,
network: "zeta_testnet",
urls: {
apiURL: "https://zetachain-athens-3.blockscout.com/api",
browserURL: "https://zetachain-athens-3.blockscout.com",
},
},
],
},
gasReporter: {
currency: "USD",
Expand Down
1 change: 0 additions & 1 deletion packages/zeta-app-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "@zetachain/zeta-app-contracts",
"version": "0.0.2",
"license": "MIT",
"private": false,
"author": "zetachain",
"publishConfig": {
"access": "public",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,52 @@ const doTranfer = async (
) => {
//@ts-ignore
if (getChainId(sourceChain) == chainId) return;
const ccmGasLimit = 100000;

if (sourceChain === "zeta_testnet") {
const tx = await multiChainValueContract.sendZeta(chainId, destinationAddress, { value: amount });
const tx = await multiChainValueContract.sendZeta(chainId, destinationAddress, ccmGasLimit, { value: amount });
await tx.wait();
return;
}

const tx = await multiChainValueContract.send(chainId, destinationAddress, amount);
const tx = await multiChainValueContract.send(chainId, destinationAddress, amount, ccmGasLimit);
await tx.wait();
};

const main = async () => {
if (!isProtocolNetworkName(networkName)) throw new Error("Invalid network name");
//@ts-ignore
const isTestnet = isTestnetNetwork(networkName);
if (!isTestnet)
throw new Error("This script is only for testnet. If you are sure you want to run it, remove this line.");

const multiChainValueContract = await getMultiChainValue(getAppAddress("multiChainValue", networkName));

const [signer] = await ethers.getSigners();

const amount = parseEther("1");

if (networkName !== "zeta_testnet") {
if (networkName !== "zeta_testnet" && networkName !== "zeta_mainnet") {
const zetaToken = await getErc20(getAddress("zetaToken", networkName));
const tx = await zetaToken.approve(multiChainValueContract.address, amount.mul(10));
await tx.wait();
}

const destinationAddress = ethers.utils.solidityPack(["address"], [process.env.PUBLIC_KEY_1 ?? signer.address]);

await doTranfer(networkName, multiChainValueContract, getChainId("goerli_testnet"), amount, destinationAddress);
await doTranfer(networkName, multiChainValueContract, getChainId("mumbai_testnet"), amount, destinationAddress);
await doTranfer(networkName, multiChainValueContract, getChainId("bsc_testnet"), amount, destinationAddress);
await doTranfer(networkName, multiChainValueContract, getChainId("zeta_testnet"), amount, destinationAddress);
//@ts-ignore
const isTestnet = isTestnetNetwork(networkName);

if (isTestnet) {
await doTranfer(networkName, multiChainValueContract, getChainId("goerli_testnet"), amount, destinationAddress);
await doTranfer(networkName, multiChainValueContract, getChainId("mumbai_testnet"), amount, destinationAddress);
await doTranfer(networkName, multiChainValueContract, getChainId("bsc_testnet"), amount, destinationAddress);
await doTranfer(networkName, multiChainValueContract, getChainId("zeta_testnet"), amount, destinationAddress);
} else {
await doTranfer(networkName, multiChainValueContract, getChainId("bsc_mainnet"), amount, destinationAddress);
await doTranfer(networkName, multiChainValueContract, getChainId("zeta_mainnet"), amount, destinationAddress);
await doTranfer(networkName, multiChainValueContract, getChainId("eth_mainnet"), amount, destinationAddress);
}
};

main().catch((error) => {
Expand Down
1 change: 1 addition & 0 deletions packages/zevm-app-contracts/arguments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = [];
21 changes: 21 additions & 0 deletions packages/zevm-app-contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,28 @@ const config: HardhatUserConfig = {
// ETH
goerli: process.env.ETHERSCAN_API_KEY || "",
mainnet: process.env.ETHERSCAN_API_KEY || "",
zeta_mainnet: "NO_TOKEN",
zeta_testnet: "NO_TOKEN",
},
//@ts-ignore
customChains: [
{
chainId: 7000,
network: "zeta_mainnet",
urls: {
apiURL: "https://zetachain.blockscout.com/api",
browserURL: "https://zetachain.blockscout.com",
},
},
{
chainId: 7001,
network: "zeta_testnet",
urls: {
apiURL: "https://zetachain-athens-3.blockscout.com/api",
browserURL: "https://zetachain-athens-3.blockscout.com",
},
},
],
},
gasReporter: {
currency: "USD",
Expand Down
3 changes: 1 addition & 2 deletions packages/zevm-app-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "@zetachain/zevm-app-contracts",
"version": "0.0.2",
"license": "MIT",
"private": false,
"author": "zetachain",
"publishConfig": {
"access": "public",
Expand Down Expand Up @@ -41,4 +40,4 @@
"@zetachain/protocol-contracts": "^4.0.1",
"ethers": "5.6.8"
}
}
}
6 changes: 2 additions & 4 deletions packages/zevm-app-contracts/scripts/address.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,14 @@ export const getSystemContractAddress = () => {
return protocolAddresses["zevm"]["zeta_testnet"].systemContract;
};

export const saveAddress = (name: string, address: string) => {
const networkName = "zeta_testnet";

export const saveAddress = (name: string, address: string, networkName: ZetaProtocolNetwork) => {
console.log(`Updating ${name} address on ${networkName}.`);

const filename = join(__dirname, `../data/addresses.json`);

const newAddresses = JSON.parse(readFileSync(filename, "utf8"));

newAddresses["zevm"]["zeta_testnet"][name] = address;
newAddresses["zevm"][networkName][name] = address;

writeFileSync(filename, JSON.stringify(newAddresses, null, 2));
};
2 changes: 1 addition & 1 deletion packages/zevm-app-contracts/scripts/disperse/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async function main() {
const disperseFactory = await DisperseFactory.deploy();
await disperseFactory.deployed();
console.log("Disperse deployed to:", disperseFactory.address);
saveAddress("disperse", disperseFactory.address);
saveAddress("disperse", disperseFactory.address, networkName);
}

main().catch((error) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async function main() {
const rewardDistributorFactory = await RewardDistributorFactoryFactory.deploy(zetaTokenAddress, SYSTEM_CONTRACT);
await rewardDistributorFactory.deployed();
console.log("RewardDistributorFactory deployed to:", rewardDistributorFactory.address);
saveAddress("rewardDistributorFactory", rewardDistributorFactory.address);
saveAddress("rewardDistributorFactory", rewardDistributorFactory.address, networkName);
}

main().catch((error) => {
Expand Down
4 changes: 3 additions & 1 deletion packages/zevm-app-contracts/scripts/zeta-points/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import { saveAddress } from "../address.helpers";
const networkName = network.name;

const invitationManager = async () => {
if (!isProtocolNetworkName(networkName)) throw new Error("Invalid network name");

const InvitationManagerFactory = (await ethers.getContractFactory("InvitationManager")) as InvitationManager__factory;
const invitationManager = await InvitationManagerFactory.deploy();
await invitationManager.deployed();
console.log("InvitationManager deployed to:", invitationManager.address);
saveAddress("invitationManager", invitationManager.address);
saveAddress("invitationManager", invitationManager.address, networkName);
};

const main = async () => {
Expand Down
11 changes: 8 additions & 3 deletions packages/zevm-app-contracts/scripts/zeta-swap/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { ethers } from "hardhat";
import { isProtocolNetworkName } from "@zetachain/protocol-contracts";
import { ethers, network } from "hardhat";

import { ZetaSwap, ZetaSwap__factory, ZetaSwapBtcInbound, ZetaSwapBtcInbound__factory } from "../../typechain-types";
import { getSystemContractAddress, saveAddress } from "../address.helpers";

const networkName = network.name;

const main = async () => {
if (!isProtocolNetworkName(networkName)) throw new Error("Invalid network name");

console.log(`Deploying ZetaSwap...`);
const SYSTEM_CONTRACT = getSystemContractAddress();

Expand All @@ -12,14 +17,14 @@ const main = async () => {
await contract.deployed();

console.log("Deployed ZetaSwap. Address:", contract.address);
saveAddress("zetaSwap", contract.address);
saveAddress("zetaSwap", contract.address, networkName);

const FactoryBTC = (await ethers.getContractFactory("ZetaSwapBtcInbound")) as ZetaSwapBtcInbound__factory;
const contractBTC = (await FactoryBTC.deploy(SYSTEM_CONTRACT)) as ZetaSwapBtcInbound;
await contractBTC.deployed();

console.log("Deployed zetaSwapBtcInbound. Address:", contractBTC.address);
saveAddress("zetaSwapBtcInbound", contractBTC.address);
saveAddress("zetaSwapBtcInbound", contractBTC.address, networkName);
};

main().catch((error) => {
Expand Down

0 comments on commit f0e89ed

Please sign in to comment.