From 618e4451fd9fd47042b837eb602c4e11450ea83a Mon Sep 17 00:00:00 2001 From: bitbeckers Date: Mon, 19 Aug 2024 12:18:55 +0200 Subject: [PATCH] chore(deploy): base-sepolia and update contracts pacakge --- contracts/hardhat.config.cts | 8 +-- contracts/package.json | 2 +- contracts/src/deployments/index.ts | 8 +++ contracts/src/index.ts | 11 ++-- contracts/tasks/config.ts | 78 +++++++++++++++++++++++++++ contracts/tasks/deploy-marketplace.ts | 71 +----------------------- 6 files changed, 96 insertions(+), 82 deletions(-) create mode 100644 contracts/tasks/config.ts diff --git a/contracts/hardhat.config.cts b/contracts/hardhat.config.cts index 04845066..97eb6fd8 100644 --- a/contracts/hardhat.config.cts +++ b/contracts/hardhat.config.cts @@ -59,16 +59,11 @@ const ARBISCAN_API_KEY = requireEnv(process.env.ARBISCAN_API_KEY, "ARBISCAN_API_ */ const chainIds = { hardhat: 31337, - // Ethereum: https://docs.infura.io/infura/networks/ethereum/how-to/choose-a-network sepolia: 11155111, - // Optimism: https://docs.infura.io/infura/networks/optimism/how-to/choose-a-network "optimism-mainnet": 10, - // Celo "celo-mainnet": 42220, - // Base "base-sepolia": 84532, "base-mainnet": 8453, - // Arbitrum "arb-sepolia": 421614, "arb-mainnet": 42161, }; @@ -88,7 +83,8 @@ function getChainConfig(chain: keyof typeof chainIds) { if (chain === "optimism-mainnet") { config = { ...config, - url: `https://opt-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}`, + url: "https://virtual.optimism.rpc.tenderly.co/41aca07e-03d1-4a5c-807a-e43c1777100a" + // url: `https://opt-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}`, }; } diff --git a/contracts/package.json b/contracts/package.json index 156f4c5b..4997625c 100644 --- a/contracts/package.json +++ b/contracts/package.json @@ -1,7 +1,7 @@ { "name": "@hypercerts-org/contracts", "description": "EVM compatible protocol for managing impact claims", - "version": "2.0.0-alpha.2", + "version": "2.0.0-alpha.4", "author": { "name": "Hypercerts Foundation", "url": "https://github.com/hypercerts-org/hypercerts" diff --git a/contracts/src/deployments/index.ts b/contracts/src/deployments/index.ts index c573c6eb..440cbc63 100644 --- a/contracts/src/deployments/index.ts +++ b/contracts/src/deployments/index.ts @@ -1,7 +1,15 @@ +import deployments_marketplace_base_sepolia from "./deployment-marketplace-base-sepolia.json" import deployments_marketplace_sepolia from "./deployment-marketplace-sepolia.json"; import deployments_protocol from "./deployments-protocol.json"; const deployments_marketplace = { + "84532": { + TransferManager: deployments_marketplace_base_sepolia.TransferManager.address, + HypercertExchange: deployments_marketplace_base_sepolia.HypercertExchange.address, + OrderValidatorV2A: deployments_marketplace_base_sepolia.OrderValidator.address, + RoyaltyFeeRegistry: deployments_marketplace_base_sepolia.RoyaltyFeeRegistry.address, + StrategyHypercertFractionOffer: deployments_marketplace_base_sepolia.StrategyHypercertFractionOffer.address, + }, "11155111": { TransferManager: deployments_marketplace_sepolia.TransferManager.address, HypercertExchange: deployments_marketplace_sepolia.HypercertExchange.address, diff --git a/contracts/src/index.ts b/contracts/src/index.ts index 5c2a6c0b..cb583a5c 100644 --- a/contracts/src/index.ts +++ b/contracts/src/index.ts @@ -46,11 +46,11 @@ export type DeploymentMarketplace = { HypercertExchange: `0x${string}`; OrderValidatorV2A: `0x${string}`; RoyaltyFeeRegistry: `0x${string}`; - StrategyCollectionOffer: `0x${string}`; - StrategyDutchAuction: `0x${string}`; - StrategyItemIdsRange: `0x${string}`; - StrategyHypercertCollectionOffer: `0x${string}`; - StrategyHypercertDutchAuction: `0x${string}`; + // StrategyCollectionOffer: `0x${string}`; + // StrategyDutchAuction: `0x${string}`; + // StrategyItemIdsRange: `0x${string}`; + // StrategyHypercertCollectionOffer: `0x${string}`; + // StrategyHypercertDutchAuction: `0x${string}`; StrategyHypercertFractionOffer: `0x${string}`; }; @@ -71,6 +71,7 @@ const deployments = { }, 84532: { ...DEPLOYMENTS.protocol["84532"], + ...DEPLOYMENTS.marketplace["84532"], }, 8453: { ...DEPLOYMENTS.protocol["8453"], diff --git a/contracts/tasks/config.ts b/contracts/tasks/config.ts new file mode 100644 index 00000000..4c3f7d7a --- /dev/null +++ b/contracts/tasks/config.ts @@ -0,0 +1,78 @@ +export type TokenAddressType = { sepolia: string; [key: string]: string }; + +const WETH: TokenAddressType = { + localhost: "0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9", //dummy + hardhat: "0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9", //dummy + sepolia: "0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9", + "optimism-mainnet": "0x4200000000000000000000000000000000000006", + "base-sepolia": "0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9", +}; + +// LINK faucet for Sepolia: https://faucets.chain.link/ +const DAI: TokenAddressType = { + localhost: "0x779877A7B0D9E8603169DdbD7836e478b4624789", + hardhat: "0x779877A7B0D9E8603169DdbD7836e478b4624789", + sepolia: "0x779877A7B0D9E8603169DdbD7836e478b4624789", + "optimism-mainnet": "0xda10009cbd5d07dd0cecc66161fc93d7c9000da1", + "base-sepolia": "0xE4aB69C077896252FAFBD49EFD26B5D171A32410", +}; + +// USDC https://faucet.circle.com/ +// https://developers.circle.com/stablecoins/docs/usdc-on-main-networks +const USDC: TokenAddressType = { + localhost: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238", + hardhat: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238", + sepolia: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238", + "optimism-mainnet": "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85", + "base-sepolia": "0x036CbD53842c5426634e7929541eC2318f3dCF7e", +}; + +export const getTokenAddresses = (network: string) => { + return { + wethAddress: WETH[network], + usdceAddress: USDC[network], + daiAddress: DAI[network], + }; +}; + +const ADMIN_ACCOUNT: { [key: string]: string } = { + localhost: "0x4f37308832c6eFE5A74737955cBa96257d76De17", + hardhat: "0x4f37308832c6eFE5A74737955cBa96257d76De17", + sepolia: "0x4f37308832c6eFE5A74737955cBa96257d76De17", + "base-sepolia": "0xA2Cb9D926b090577AD45fC0F40C753BF369B82Ff", + "optimism-mainnet": "0x560adA72a80b4707e493cA8c3B7B7528930E7Be5", + celo: "0x14ae502FEF3843fF3a1735B3209D39B320130af9", + base: "0x14ae502FEF3843fF3a1735B3209D39B320130af9", + arbitrum: "0x14ae502FEF3843fF3a1735B3209D39B320130af9", +}; + +export const getAdminAccount = (network: string): string => { + const account = ADMIN_ACCOUNT[network]; + + if (!account || account === null || account.trim() === "") { + throw new Error(`Admin account for network "${network}" is not defined, null, or empty.`); + } + + return account; +}; + +const FEE_RECIPIENT: { [key: string]: string } = { + localhost: "0x4f37308832c6eFE5A74737955cBa96257d76De17", + hardhat: "0x4f37308832c6eFE5A74737955cBa96257d76De17", + sepolia: "0x4f37308832c6eFE5A74737955cBa96257d76De17", + "base-sepolia": "0xe518aED97D9d45174a06bB8EF663B4fB51330725", + "optimism-mainnet": "0xE7C4531ad8828794904D332a12702beC8ff1A498", + celo: "0xE7C4531ad8828794904D332a12702beC8ff1A498", + base: "0xE7C4531ad8828794904D332a12702beC8ff1A498", + arbitrum: "0xE7C4531ad8828794904D332a12702beC8ff1A498", +}; + +export const getFeeRecipient = (network: string): string => { + const recipient = FEE_RECIPIENT[network]; + + if (!recipient || recipient === null || recipient.trim() === "") { + throw new Error(`Fee recipient for network "${network}" is not defined, null, or empty.`); + } + + return recipient; +}; diff --git a/contracts/tasks/deploy-marketplace.ts b/contracts/tasks/deploy-marketplace.ts index f36ff7ca..52cce1a7 100644 --- a/contracts/tasks/deploy-marketplace.ts +++ b/contracts/tasks/deploy-marketplace.ts @@ -10,81 +10,12 @@ import { PublicClient, } from "viem"; import { writeFile } from "node:fs/promises"; +import { getAdminAccount, getFeeRecipient, getTokenAddresses } from "./config"; function sleep(ms) { return new Promise((resolve) => setTimeout(resolve, ms)); } -type TokenAddressType = { sepolia: string; [key: string]: string }; - -const WETH: TokenAddressType = { - localhost: "0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9", //dummy - hardhat: "0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9", //dummy - sepolia: "0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9", - optimism: "0x4200000000000000000000000000000000000006", - "base-sepolia": "0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9", -}; - -// LINK faucet for Sepolia: https://faucets.chain.link/ -const DAI: TokenAddressType = { - localhost: "0x779877A7B0D9E8603169DdbD7836e478b4624789", - hardhat: "0x779877A7B0D9E8603169DdbD7836e478b4624789", - sepolia: "0x779877A7B0D9E8603169DdbD7836e478b4624789", - optimism: "0xda10009cbd5d07dd0cecc66161fc93d7c9000da1", - "base-sepolia": "0xE4aB69C077896252FAFBD49EFD26B5D171A32410", -}; - -// USDC https://faucet.circle.com/ -const USDC: TokenAddressType = { - localhost: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238", - hardhat: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238", - sepolia: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238", - optimism: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85", - "base-sepolia": "0x036CbD53842c5426634e7929541eC2318f3dCF7e", -}; - -const getTokenAddresses = (network: string) => { - return { - wethAddress: WETH[network], - usdceAddress: USDC[network], - daiAddress: DAI[network], - }; -}; - -const ADMIN_ACCOUNT: { [key: string]: string } = { - localhost: "0x4f37308832c6eFE5A74737955cBa96257d76De17", - hardhat: "0x4f37308832c6eFE5A74737955cBa96257d76De17", - sepolia: "0x4f37308832c6eFE5A74737955cBa96257d76De17", - "base-sepolia": "0xA2Cb9D926b090577AD45fC0F40C753BF369B82Ff", -}; - -const getAdminAccount = (network: string): string => { - const account = ADMIN_ACCOUNT[network]; - - if (!account || account === null || account.trim() === "") { - throw new Error(`Admin account for network "${network}" is not defined, null, or empty.`); - } - - return account; -}; - -const FEE_RECIPIENT: { [key: string]: string } = { - localhost: "0x4f37308832c6eFE5A74737955cBa96257d76De17", - hardhat: "0x4f37308832c6eFE5A74737955cBa96257d76De17", - sepolia: "0x4f37308832c6eFE5A74737955cBa96257d76De17", - "base-sepolia": "0xe518aED97D9d45174a06bB8EF663B4fB51330725", -}; - -const getFeeRecipient = (network: string): string => { - const recipient = FEE_RECIPIENT[network]; - - if (!recipient || recipient === null || recipient.trim() === "") { - throw new Error(`Fee recipient for network "${network}" is not defined, null, or empty.`); - } - - return recipient; -}; - const getCreate2Address = async ( deployer: WalletClient, factory: `0x${string}`,