Skip to content

Commit

Permalink
Update release addImplementation script
Browse files Browse the repository at this point in the history
  • Loading branch information
nkrishang committed Oct 26, 2022
1 parent 5865d0a commit 9330f3b
Show file tree
Hide file tree
Showing 4 changed files with 1,825 additions and 112 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@openzeppelin/contracts": "4.7.3",
"@openzeppelin/contracts-upgradeable": "4.7.3",
"@primitivefi/hardhat-dodoc": "^0.2.0",
"@thirdweb-dev/sdk": "^3.0.4",
"@thirdweb-dev/sdk": "^3.4.1",
"@typechain/ethers-v5": "^10.0.0",
"@typechain/hardhat": "^4.0.0",
"@types/fs-extra": "^9.0.13",
Expand Down
10 changes: 8 additions & 2 deletions scripts/release/add_implementations_from_release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { chainIdToName } from "./constants";
////// To run this script: `npx ts-node scripts/release/add_implementations_from_release.ts` //////
///// MAKE SURE TO PUT IN THE RIGHT CONTRACT NAME HERE AFTER CREATING A RELEASE FOR IT /////
//// THE RELEASE SHOULD HAVE THE IMPLEMENTATIONS ALREADY DEPLOYED AND RECORDED (via dashboard) ////
const releasedContractName = "SignatureDrop";
const releasedContractName = "Multiwrap";
const privateKey: string = process.env.DEPLOYER_KEY as string; // should be the correct deployer key

const polygonSDK = ThirdwebSDK.fromPrivateKey(privateKey, "polygon");
Expand Down Expand Up @@ -36,10 +36,16 @@ async function main() {
console.log("Adding implementations...");
for (const [chainId, implementation] of Object.entries(implementations)) {
const chainName = chainIdToName[parseInt(chainId) as SUPPORTED_CHAIN_ID];

if(!chainName) {
console.log("No chainName found for chain: ", chainId);
continue;
}

const chainSDK = ThirdwebSDK.fromPrivateKey(privateKey, chainName);
const factoryAddr = prevReleaseMetadata?.factoryDeploymentData?.factoryAddresses?.[chainId];
if (implementation && factoryAddr) {
const factory = chainSDK.getContractFromAbi(
const factory = await chainSDK.getContractFromAbi(
factoryAddr,
JSON.parse(readFileSync("artifacts_forge/TWFactory.sol/TWFactory.json", "utf-8")).abi,
);
Expand Down
9 changes: 2 additions & 7 deletions scripts/release/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { ChainId, CONTRACT_ADDRESSES } from "@thirdweb-dev/sdk";

export const nativeTokenWrapper: Record<number, string> = {
1: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // mainnet
4: "0xc778417E063141139Fce010982780140Aa0cD5Ab", // rinkeby
5: "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6", // goerli
137: "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270", // polygon
80001: "0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889", // mumbai
Expand All @@ -11,24 +10,19 @@ export const nativeTokenWrapper: Record<number, string> = {
250: "0x21be370D5312f44cB42ce377BC9b8a0cEF1A4C83", // fantom
4002: "0xf1277d1Ed8AD466beddF92ef448A132661956621", // fantom testnet
10: "0x4200000000000000000000000000000000000006", // optimism
69: "0xbC6F6b680bc61e30dB47721c6D1c5cde19C1300d", // optimism kovan
420: "0x4200000000000000000000000000000000000006", // optimism goerli
42161: "0x82af49447d8a07e3bd95bd0d56f35241523fbab1", // arbitrum
421611: "0xEBbc3452Cc911591e4F18f3b36727Df45d6bd1f9", // arbitrum rinkeby
421613: "0xe39Ab88f8A4777030A534146A9Ca3B52bd5D43A3", // arbitrum goerli
};

export const chainIdToName: Record<number, string> = {
[ChainId.Mumbai]: "mumbai",
[ChainId.Rinkeby]: "rinkeby",
[ChainId.Goerli]: "goerli",
[ChainId.Polygon]: "polygon",
[ChainId.Mainnet]: "mainnet",
[ChainId.Optimism]: "optimism",
[ChainId.OptimismKovan]: "optimism-kovan",
[ChainId.OptimismGoerli]: "optimism-goerli",
[ChainId.Arbitrum]: "arbitrum",
[ChainId.ArbitrumRinkeby]: "arbitrum-rinkeby",
[ChainId.ArbitrumGoerli]: "arbitrum-goerli",
[ChainId.Fantom]: "fantom",
[ChainId.FantomTestnet]: "fantom-testnet",
Expand All @@ -41,7 +35,6 @@ export const chainIdToName: Record<number, string> = {
export const defaultFactories: Record<number, string> = {
[ChainId.Mainnet]: CONTRACT_ADDRESSES[ChainId.Mainnet].twFactory,
[ChainId.Goerli]: CONTRACT_ADDRESSES[ChainId.Goerli].twFactory,
[ChainId.Rinkeby]: CONTRACT_ADDRESSES[ChainId.Rinkeby].twFactory,
[ChainId.Polygon]: CONTRACT_ADDRESSES[ChainId.Polygon].twFactory,
[ChainId.Mumbai]: CONTRACT_ADDRESSES[ChainId.Mumbai].twFactory,
[ChainId.Fantom]: CONTRACT_ADDRESSES[ChainId.Fantom].twFactory,
Expand All @@ -52,4 +45,6 @@ export const defaultFactories: Record<number, string> = {
[ChainId.ArbitrumGoerli]: CONTRACT_ADDRESSES[ChainId.ArbitrumGoerli].twFactory,
[ChainId.Avalanche]: CONTRACT_ADDRESSES[ChainId.Avalanche].twFactory,
[ChainId.AvalancheFujiTestnet]: CONTRACT_ADDRESSES[ChainId.AvalancheFujiTestnet].twFactory,
[ChainId.BinanceSmartChainMainnet]: CONTRACT_ADDRESSES[ChainId.BinanceSmartChainMainnet].twFactory,
[ChainId.BinanceSmartChainTestnet]: CONTRACT_ADDRESSES[ChainId.BinanceSmartChainTestnet].twFactory,
};
Loading

0 comments on commit 9330f3b

Please sign in to comment.