Skip to content

Commit

Permalink
Deploy send contract to Athens3
Browse files Browse the repository at this point in the history
  • Loading branch information
andresaiello committed Jul 4, 2023
1 parent 47d5bcf commit 1cf78df
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 26 deletions.
5 changes: 3 additions & 2 deletions packages/addresses-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"prepublishOnly": "npx tsc"
},
"devDependencies": {
"@zetachain/addresses": "workspace:^"
"@zetachain/addresses": "workspace:^",
"@zetachain/protocol-contracts": "^1.0.1-athens3"
}
}
}
9 changes: 8 additions & 1 deletion packages/addresses-tools/src/addresses.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import {
ZetaNetworkName,
ZetaTestnetNetworkName
} from "@zetachain/addresses";
import { ZetaProtocolNetwork } from "@zetachain/protocol-contracts/dist/lib";
import { ProtocolNetworkNetworkNameMap } from "@zetachain/protocol-contracts/dist/lib/address.helpers";
import dotenv from "dotenv";
import { readdirSync, readFileSync, writeFileSync } from "fs";
import { network } from "hardhat";
Expand All @@ -31,7 +33,7 @@ import { deepCloneSerializable } from "./misc.helpers";
const LOCAL_PKG = "addresses-tools";
const PUBLIC_PKG = "addresses";

const dirname = __dirname.replace(LOCAL_PKG, PUBLIC_PKG);
const dirname = __dirname.replace(LOCAL_PKG, PUBLIC_PKG).replace("dist", "src");

export const getScanVariable = ({ customNetworkName }: { customNetworkName?: string } = {}): string => {
const networkName = customNetworkName || network.name;
Expand Down Expand Up @@ -290,3 +292,8 @@ export const loadAddressFromFile = async (

throw new Error(`Invalid ZETA_NETWORK + network combination ${ZETA_NETWORK} ${networkName}.`);
};

export const getProtocolNetwork = (value: NetworkName): ZetaProtocolNetwork | undefined => {
//@ts-expect-error
return Object.keys(ProtocolNetworkNetworkNameMap).find(key => ProtocolNetworkNetworkNameMap[key] === value);
};
4 changes: 2 additions & 2 deletions packages/addresses/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"files": [
"dist"
],
"main": "",
"main": "./dist/",
"exports": {
".": "./dist/index.js"
},
Expand All @@ -22,4 +22,4 @@
"vite": "^3.1.0",
"vite-plugin-dts": "^1.4.1"
}
}
}
2 changes: 1 addition & 1 deletion packages/addresses/src/addresses.athens.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
"immutableCreate2Factory": "",
"multiChainSwap": "",
"multiChainSwapZetaConnector": "",
"multiChainValue": "",
"multiChainValue": "0x14BeC0E4A8e7bF7A02Af54Ad81a57a9fcA4D37Fd",
"tridentPoolFactory": "",
"tss": "",
"tssUpdater": "",
Expand Down
2 changes: 1 addition & 1 deletion packages/zeta-app-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@openzeppelin/contracts": "^4.8.3",
"@zetachain/addresses": "workspace:^",
"@zetachain/addresses-tools": "workspace:^",
"@zetachain/protocol-contracts": "^0.0.6",
"@zetachain/protocol-contracts": "^1.0.1-athens3",
"ethers": "5.6.8"
}
}
44 changes: 26 additions & 18 deletions packages/zeta-app-contracts/scripts/multi-chain-value/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,49 @@
import { getChainId, isNetworkName, isZetaTestnet } from "@zetachain/addresses";
import { saveAddress } from "@zetachain/addresses-tools";
import { network } from "hardhat";
import { getChainId, isNetworkName, isZetaTestnet, NetworkName } from "@zetachain/addresses";
import { getProtocolNetwork, saveAddress } from "@zetachain/addresses-tools";
import { getAddress } from "@zetachain/protocol-contracts/dist/lib";
import { ethers, network } from "hardhat";

import { getMultiChainValue } from "../../lib/multi-chain-value/MultiChainValue.helpers";
import { getAddress } from "../../lib/shared/address.helpers";
import { MultiChainValue, MultiChainValue__factory } from "../../typechain-types";

const networkName = network.name;
const { ZETA_NETWORK } = process.env;

async function main() {
if (!isNetworkName(networkName)) throw new Error("Invalid network name");

const multiChainValueContract = await getMultiChainValue(getAddress("multiChainValue"));
const protocolNetwork = getProtocolNetwork(networkName);
if (!protocolNetwork) throw new Error("Invalid network name");

const connectorAddress = getAddress("connector", protocolNetwork);
const zetaTokenAddress = getAddress("zetaToken", protocolNetwork);

const Factory = (await ethers.getContractFactory("MultiChainValue")) as MultiChainValue__factory;
const contract = (await Factory.deploy(connectorAddress, zetaTokenAddress)) as MultiChainValue;
await contract.deployed();

//@ts-expect-error
console.log("MultiChainValue deployed to:", contract.address);

if (isZetaTestnet(ZETA_NETWORK)) {
networkName !== "goerli" &&
(await (await multiChainValueContract.addAvailableChainId(getChainId("goerli")))
.wait()
.catch(e => console.error(e)));
(await (await contract.addAvailableChainId(getChainId("goerli"))).wait().catch((e: any) => console.error(e)));

networkName !== "polygon-mumbai" &&
(await (await multiChainValueContract.addAvailableChainId(getChainId("polygon-mumbai")))
(await (await contract.addAvailableChainId(getChainId("polygon-mumbai")))
.wait()
.catch(e => console.error(e)));
.catch((e: any) => console.error(e)));

networkName !== "bsc-testnet" &&
(await (await multiChainValueContract.addAvailableChainId(getChainId("bsc-testnet")))
(await (await contract.addAvailableChainId(getChainId("bsc-testnet")))
.wait()
.catch(e => console.error(e)));
.catch((e: any) => console.error(e)));

networkName !== "ropsten" &&
(await (await multiChainValueContract.addAvailableChainId(getChainId("ropsten")))
.wait()
.catch(e => console.error(e)));
networkName !== "athens" &&
(await (await contract.addAvailableChainId(getChainId("athens"))).wait().catch((e: any) => console.error(e)));
}

saveAddress("multiChainValue", multiChainValueContract.address);
//@ts-expect-error
saveAddress("multiChainValue", contract.address);
}

main().catch(error => {
Expand Down
10 changes: 9 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2703,6 +2703,7 @@ __metadata:
resolution: "@zetachain/addresses-tools@workspace:packages/addresses-tools"
dependencies:
"@zetachain/addresses": "workspace:^"
"@zetachain/protocol-contracts": ^1.0.1-athens3
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -2747,6 +2748,13 @@ __metadata:
languageName: node
linkType: hard

"@zetachain/protocol-contracts@npm:^1.0.1-athens3":
version: 1.0.1-athens3
resolution: "@zetachain/protocol-contracts@npm:1.0.1-athens3"
checksum: b0877c78160ae233ef3786e2e62fa8352592c97711903c10bad9a9fe74683a4a28eaa242d4a5091f0aa594ea8879eb8e0cee108c3a1f61262756a04bb6e5a1a2
languageName: node
linkType: hard

"@zetachain/zeta-app-contracts@workspace:packages/zeta-app-contracts":
version: 0.0.0-use.local
resolution: "@zetachain/zeta-app-contracts@workspace:packages/zeta-app-contracts"
Expand All @@ -2755,7 +2763,7 @@ __metadata:
"@openzeppelin/contracts": ^4.8.3
"@zetachain/addresses": "workspace:^"
"@zetachain/addresses-tools": "workspace:^"
"@zetachain/protocol-contracts": ^0.0.6
"@zetachain/protocol-contracts": ^1.0.1-athens3
ethers: 5.6.8
hardhat-gas-reporter: ^1.0.8
solidity-coverage: ^0.7.20
Expand Down

0 comments on commit 1cf78df

Please sign in to comment.