diff --git a/backend-ausdce/src/services/blockchain.ts b/backend-ausdce/src/services/blockchain.ts index 753e16a..2431101 100644 --- a/backend-ausdce/src/services/blockchain.ts +++ b/backend-ausdce/src/services/blockchain.ts @@ -10,19 +10,21 @@ import { EIP712DOMAIN_NAME, EIP712DOMAIN_VERSION, eip712Transaction } from '@/ut export const getWalletEVM = () => new Wallet(process.env.PRIVATE_KEY!) -const getWallet = () => { - return process.env.DEBUG - ? new Wallet(process.env.PRIVATE_KEY, getProvider(config.DEFAULT_CHAINID)) - : new Wallet(process.env.PRIVATE_KEY, getProvider(config.DEFAULT_CHAINID)) +const getWallet = (signerIndex: number) => { + if (signerIndex === 0) { + return new Wallet(process.env.PRIVATE_KEY, getProvider(config.DEFAULT_CHAINID)) + } + return new Wallet(process.env.PRIVATE_KEY2!, getProvider(config.DEFAULT_CHAINID)) } async function signHashedTransaction( transaction: FulfillTxContract, chainId: string, - contractAddress: string + contractAddress: string, + signerIndex: number ) { - const wallet = getWallet() + const wallet = getWallet(signerIndex) const domain = { name: EIP712DOMAIN_NAME, version: EIP712DOMAIN_VERSION, @@ -71,12 +73,25 @@ export const signTransaction = async ( throw Error('waiting for confirmations') if (tx.toChain.startsWith('evm.')) { const chainId = tx.toChain.replace('evm.', '') - const { bridgeAssist } = useContracts(undefined, chainId as ChainId) - return await signHashedTransaction( + // const { bridgeAssist } = useContracts(undefined, chainId as ChainId) + let signatures = [] + const signer0 = await signHashedTransaction( extractFulfillTransaction(tx), chainId, - bridgeAssist(toBridgeAddress).address + toBridgeAddress, + 0 ) + signatures.push(signer0) + if (process.env.PROD){ + const signer1 = await signHashedTransaction( + extractFulfillTransaction(tx), + chainId, + toBridgeAddress, + 1 + ) + signatures.push(signer1) + } + return signatures } else { throw Error('bad contract params') } diff --git a/backend-usdc/src/services/blockchain.ts b/backend-usdc/src/services/blockchain.ts index 0d6cb27..0ef5217 100644 --- a/backend-usdc/src/services/blockchain.ts +++ b/backend-usdc/src/services/blockchain.ts @@ -24,10 +24,12 @@ const eip712Transaction = { export const getWalletEVM = () => new Wallet(process.env.PRIVATE_KEY!) -const getWallet: () => TypedDataSigner = () => - process.env.DEBUG - ? new Wallet(process.env.PRIVATE_KEY, getProvider(config.DEFAULT_CHAINID)) - : new Wallet(process.env.PRIVATE_KEY, getProvider(config.DEFAULT_CHAINID)) +const getWallet = (signerIndex: number) => { + if (signerIndex === 0) { + return new Wallet(process.env.PRIVATE_KEY, getProvider(config.DEFAULT_CHAINID)) + } + return new Wallet(process.env.PRIVATE_KEY2!, getProvider(config.DEFAULT_CHAINID)) +} // : new GotbitKmsSigner( // process.env.GKMS_URL!, // process.env.GKMS_ACCESS_KEY!, @@ -78,9 +80,10 @@ export type TransactionAndFulfilled = { export async function signHashedTransaction( transaction: FulfillTxContract, chainId: string, - contractAddress: string + contractAddress: string, + signerIndex: number ): Promise { - const wallet = getWallet() + const wallet = getWallet(signerIndex) const domain = { name: EIP712DOMAIN_NAME, version: EIP712DOMAIN_VERSION, @@ -235,12 +238,24 @@ export const signTransaction = async ( throw Error('waiting for confirmations') if (tx.toChain.startsWith('evm.')) { const chainId = tx.toChain.replace('evm.', '') - const { bridgeAssist } = useContracts(undefined, chainId as ChainId) - return await signHashedTransaction( + let signatures = [] + const signer0 = await signHashedTransaction( extractFulfillTransaction(tx), chainId, - bridgeAssist(toBridgeAddress).address + toBridgeAddress, + 0 ) + signatures.push(signer0) + if (process.env.PROD){ + const signer1 = await signHashedTransaction( + extractFulfillTransaction(tx), + chainId, + toBridgeAddress, + 1 + ) + signatures.push(signer1) + } + return signatures } else { throw Error('bad contract params') } diff --git a/backend-usdt/src/services/blockchain.ts b/backend-usdt/src/services/blockchain.ts index bd62750..0298cb1 100644 --- a/backend-usdt/src/services/blockchain.ts +++ b/backend-usdt/src/services/blockchain.ts @@ -24,10 +24,12 @@ const eip712Transaction = { export const getWalletEVM = () => new Wallet(process.env.PRIVATE_KEY!) -const getWallet: () => TypedDataSigner = () => - process.env.DEBUG - ? new Wallet(process.env.PRIVATE_KEY, getProvider(config.DEFAULT_CHAINID)) - : new Wallet(process.env.PRIVATE_KEY, getProvider(config.DEFAULT_CHAINID)) +const getWallet = (signerIndex: number) => { + if (signerIndex === 0) { + return new Wallet(process.env.PRIVATE_KEY, getProvider(config.DEFAULT_CHAINID)) + } + return new Wallet(process.env.PRIVATE_KEY2!, getProvider(config.DEFAULT_CHAINID)) +} // : new GotbitKmsSigner( // process.env.GKMS_URL!, // process.env.GKMS_ACCESS_KEY!, @@ -78,9 +80,10 @@ export type TransactionAndFulfilled = { export async function signHashedTransaction( transaction: FulfillTxContract, chainId: string, - contractAddress: string + contractAddress: string, + signerIndex: number ): Promise { - const wallet = getWallet() + const wallet = getWallet(signerIndex) const domain = { name: EIP712DOMAIN_NAME, version: EIP712DOMAIN_VERSION, @@ -237,12 +240,24 @@ export const signTransaction = async ( throw Error('waiting for confirmations') if (tx.toChain.startsWith('evm.')) { const chainId = tx.toChain.replace('evm.', '') - const { bridgeAssist } = useContracts(undefined, chainId as ChainId) - return await signHashedTransaction( + let signatures = [] + const signer0 = await signHashedTransaction( extractFulfillTransaction(tx), chainId, - bridgeAssist(toBridgeAddress).address + toBridgeAddress, + 0 ) + signatures.push(signer0) + if (process.env.PROD){ + const signer1 = await signHashedTransaction( + extractFulfillTransaction(tx), + chainId, + toBridgeAddress, + 1 + ) + signatures.push(signer1) + } + return signatures } else { throw Error('bad contract params') } diff --git a/backend-wbtc/src/services/blockchain.ts b/backend-wbtc/src/services/blockchain.ts index 2691829..5e5a49b 100644 --- a/backend-wbtc/src/services/blockchain.ts +++ b/backend-wbtc/src/services/blockchain.ts @@ -71,12 +71,24 @@ export const signTransaction = async ( throw Error('waiting for confirmations') if (tx.toChain.startsWith('evm.')) { const chainId = tx.toChain.replace('evm.', '') - const { bridgeAssist } = useContracts(undefined, chainId as ChainId) - const signature1 = await signHashedTransaction(extractFulfillTransaction(tx), chainId, bridgeAssist(toBridgeAddress).address, 0) - const signature2 = await signHashedTransaction(extractFulfillTransaction(tx), chainId, bridgeAssist(toBridgeAddress).address, 1) - console.log(signature1, signature2) - return [signature1, signature2] - + let signatures = [] + const signer0 = await signHashedTransaction( + extractFulfillTransaction(tx), + chainId, + toBridgeAddress, + 0 + ) + signatures.push(signer0) + + const signer1 = await signHashedTransaction( + extractFulfillTransaction(tx), + chainId, + toBridgeAddress, + 1 + ) + signatures.push(signer1) + + return signatures } else { throw Error('bad contract params') } diff --git a/backend-wnt/src/services/blockchain.ts b/backend-wnt/src/services/blockchain.ts index a1d4421..edd879c 100644 --- a/backend-wnt/src/services/blockchain.ts +++ b/backend-wnt/src/services/blockchain.ts @@ -23,10 +23,12 @@ const eip712Transaction = { export const getWalletEVM = () => new Wallet(process.env.PRIVATE_KEY!) -const getWallet: () => TypedDataSigner = () => - process.env.DEBUG - ? new Wallet(process.env.PRIVATE_KEY, getProvider(config.DEFAULT_CHAINID)) - : new Wallet(process.env.PRIVATE_KEY, getProvider(config.DEFAULT_CHAINID)) +const getWallet = (signerIndex: number) => { + if (signerIndex === 0) { + return new Wallet(process.env.PRIVATE_KEY, getProvider(config.DEFAULT_CHAINID)) + } + return new Wallet(process.env.PRIVATE_KEY2!, getProvider(config.DEFAULT_CHAINID)) +} // : new GotbitKmsSigner( // process.env.GKMS_URL!, // process.env.GKMS_ACCESS_KEY!, @@ -77,9 +79,10 @@ export type TransactionAndFulfilled = { export async function signHashedTransaction( transaction: FulfillTxContract, chainId: string, - contractAddress: string + contractAddress: string, + signerIndex: number ): Promise { - const wallet = getWallet() + const wallet = getWallet(signerIndex) const domain = { name: EIP712DOMAIN_NAME, version: EIP712DOMAIN_VERSION, @@ -235,12 +238,24 @@ export const signTransaction = async ( throw Error('waiting for confirmations') if (tx.toChain.startsWith('evm.')) { const chainId = tx.toChain.replace('evm.', '') - const { bridgeAssist } = useContracts(undefined, chainId as ChainId) - return await signHashedTransaction( + let signatures = [] + const signer0 = await signHashedTransaction( extractFulfillTransaction(tx), chainId, - bridgeAssist(toBridgeAddress).address + toBridgeAddress, + 0 ) + signatures.push(signer0) + if (process.env.PROD){ + const signer1 = await signHashedTransaction( + extractFulfillTransaction(tx), + chainId, + toBridgeAddress, + 1 + ) + signatures.push(signer1) + } + return signatures } else { throw Error('bad contract params') } diff --git a/backend/src/services/blockchain.ts b/backend/src/services/blockchain.ts index 08889e5..d0ba71c 100644 --- a/backend/src/services/blockchain.ts +++ b/backend/src/services/blockchain.ts @@ -23,10 +23,12 @@ const eip712Transaction = { export const getWalletEVM = () => new Wallet(process.env.PRIVATE_KEY!) -const getWallet: () => TypedDataSigner = () => - process.env.DEBUG - ? new Wallet(process.env.PRIVATE_KEY, getProvider(config.DEFAULT_CHAINID)) - : new Wallet(process.env.PRIVATE_KEY, getProvider(config.DEFAULT_CHAINID)) +const getWallet = (signerIndex: number) => { + if (signerIndex === 0) { + return new Wallet(process.env.PRIVATE_KEY, getProvider(config.DEFAULT_CHAINID)) + } + return new Wallet(process.env.PRIVATE_KEY2!, getProvider(config.DEFAULT_CHAINID)) +} // : new GotbitKmsSigner( // process.env.GKMS_URL!, // process.env.GKMS_ACCESS_KEY!, @@ -77,9 +79,10 @@ export type TransactionAndFulfilled = { export async function signHashedTransaction( transaction: FulfillTxContract, chainId: string, - contractAddress: string + contractAddress: string, + signerIndex: number ): Promise { - const wallet = getWallet() + const wallet = getWallet(signerIndex) const domain = { name: EIP712DOMAIN_NAME, version: EIP712DOMAIN_VERSION, @@ -239,12 +242,24 @@ export const signTransaction = async ( throw Error('waiting for confirmations') if (tx.toChain.startsWith('evm.')) { const chainId = tx.toChain.replace('evm.', '') - // const { bridgeAssist } = useContracts(undefined, chainId as ChainId) - return await signHashedTransaction( + let signatures = [] + const signer0 = await signHashedTransaction( extractFulfillTransaction(tx), chainId, - toBridgeAddress //bridgeAssist(toBridgeAddress).address + toBridgeAddress, + 0 ) + signatures.push(signer0) + if (process.env.PROD){ + const signer1 = await signHashedTransaction( + extractFulfillTransaction(tx), + chainId, + toBridgeAddress, + 1 + ) + signatures.push(signer1) + } + return signatures } else { throw Error('bad contract params') } diff --git a/contracts/config.ts b/contracts/config.ts index 35f9a3e..609c12d 100644 --- a/contracts/config.ts +++ b/contracts/config.ts @@ -25,6 +25,19 @@ export const CHAIN_IDS = { bitlayer: 200810 } +export const MAINNET_CHAIN_IDS = { + assetChain: 42420, + arbitrum: 42161, + polygon: 137, + ethereum: 1, + bsc: 56, + base: 8453, + bitlayer: 200901 +} + +export const DEFAULT_NATIVE_TOKEN_CONTRACT = + '0x0000000000000000000000000000000000000001' + export const DEFAULT_TOKEN_PARAMS: { [chainId: number]: { [token: string]: IDefaultTokenParams } } = { @@ -252,4 +265,38 @@ export const BRIDGED_TOKEN_PARAMS: { chainIdOriginal: CHAIN_IDS.bitlayer, }, }, +} + +export const MAINNET_BRIDGED_TOKEN_PARAMS: { + [chainId: number]: { [token: string]: IBridgedTokenParams } +} = { + 42420: { + WNT: { + name: 'Wicrypt Network Token', + symbol: 'WNT', + decimals: 18, + totalSupply: '0', + isLockActive: false, + tokenOriginal: '0xAD4b9c1FbF4923061814dD9d5732EB703FaA53D4', + chainIdOriginal: CHAIN_IDS.arbitrum, + }, + USDT: { + name: 'Tether USD', + symbol: 'USDT', + decimals: 6, + totalSupply: '0', + isLockActive: true, + tokenOriginal: '0xdAC17F958D2ee523a2206206994597C13D831ec7', + chainIdOriginal: CHAIN_IDS.ethereum, + }, + BTC: { + name: 'Bitlayer Bitcoin', + symbol: 'BTC', + decimals: 18, + totalSupply: '0', + isLockActive: true, + tokenOriginal: DEFAULT_NATIVE_TOKEN_CONTRACT, + chainIdOriginal: CHAIN_IDS.bitlayer, + }, + }, } \ No newline at end of file diff --git a/contracts/deploy/mainnet/asset-chain/BTC.deploy.ts b/contracts/deploy/mainnet/asset-chain/BTC.deploy.ts new file mode 100644 index 0000000..f633ac2 --- /dev/null +++ b/contracts/deploy/mainnet/asset-chain/BTC.deploy.ts @@ -0,0 +1,45 @@ +import { ethers, getNamedAccounts } from 'hardhat' +import type { DeployFunction } from 'hardhat-deploy/types' +import {BRIDGED_TOKEN_PARAMS, CHAIN_IDS, MAINNET_BRIDGED_TOKEN_PARAMS} from '@/config' + +import { wrapperHRE } from '@/gotbit-tools/hardhat' +import type { BridgedAssetChainToken__factory, MultiSigWallet } from '@/typechain' +import { BigNumber } from 'ethers' + +const func: DeployFunction = async (hre) => { + const { deploy } = wrapperHRE(hre) + const [deployer] = await ethers.getSigners() + const { chainId } = await ethers.provider.getNetwork() + + if (chainId != CHAIN_IDS.assetChain) { + return + } + + const token = 'BTC' + const params = MAINNET_BRIDGED_TOKEN_PARAMS[chainId][token] + + if (!token) throw new Error('Token not set') + + const mulsigwallet = '' // address + if (!mulsigwallet) throw new Error('Set address') + + await deploy(token, { + contract: 'BridgedAssetChainToken', + from: deployer.address, + args: [ + params.name, + params.symbol, + params.decimals, + BigNumber.from(params.totalSupply), + params.isLockActive, + params.tokenOriginal, + params.chainIdOriginal, + mulsigwallet + ], + log: true, + }) +} +export default func + +func.tags = ['BTC.deploy'] +// func.dependencies = ['MultiSigWallet.deploy'] diff --git a/contracts/deploy/mainnet/asset-chain/BridgeCircle.deploy.ts b/contracts/deploy/mainnet/asset-chain/BridgeCircle.deploy.ts new file mode 100644 index 0000000..3e19d8a --- /dev/null +++ b/contracts/deploy/mainnet/asset-chain/BridgeCircle.deploy.ts @@ -0,0 +1,30 @@ +import { ethers } from 'hardhat' +import type { DeployFunction } from 'hardhat-deploy/types' +import { CHAIN_IDS } from '@/config' + +import { wrapperHRE } from '@/gotbit-tools/hardhat' +import type { BridgeAssistCircleMintUpgradeable__factory } from '@/typechain' + +const func: DeployFunction = async (hre) => { + const { deploy } = wrapperHRE(hre) + const [deployer] = await ethers.getSigners() + const { chainId } = await ethers.provider.getNetwork() + + if (chainId != CHAIN_IDS.assetChain) { + return + } + + await deploy( + 'BridgeAssistCircleMintUpgradeable', + { + contract: 'BridgeAssistCircleMintUpgradeable', + from: deployer.address, + args: [], + log: true, + } + ) +} +export default func + +func.tags = ['BridgeAssistCircleMintUpgradeable.deploy'] +// func.dependencies = ['MultiSigWallet.deploy'] diff --git a/contracts/deploy/mainnet/asset-chain/BridgeFactory.deploy.ts b/contracts/deploy/mainnet/asset-chain/BridgeFactory.deploy.ts new file mode 100644 index 0000000..6d8daa1 --- /dev/null +++ b/contracts/deploy/mainnet/asset-chain/BridgeFactory.deploy.ts @@ -0,0 +1,75 @@ +import { ethers } from 'hardhat' +import type { DeployFunction } from 'hardhat-deploy/types' +import { CHAIN_IDS } from '@/config' + +import { wrapperHRE } from '@/gotbit-tools/hardhat' +import type { + BridgeAssistMintUpgradeable, + BridgeAssistNativeUpgradeable, + BridgeFactoryUpgradeable__factory, + MultiSigWallet, +} from '@/typechain' + +const func: DeployFunction = async (hre) => { + const { deploy } = wrapperHRE(hre) + const [deployer] = await ethers.getSigners() + + + // Fake tx for nonce incrementing + const tx = await deployer.sendTransaction({ + to: deployer.address, + value: 1, + }) + console.log(`Incrementing nonce tx: ${tx.hash}`) + await tx.wait() + + const nonce = await ethers.provider.getTransactionCount(deployer.address) + const bridgeMint = ethers.utils.getContractAddress({ + from: deployer.address, + nonce: nonce + 8, + }) + const bridgeNative = ethers.utils.getContractAddress({ + from: deployer.address, + nonce: nonce + 9, + }) + + const bridgeCircle = ethers.utils.getContractAddress({ + from: deployer.address, + nonce: nonce + 8, + }) + const bridgeTransfer = ethers.utils.getContractAddress({ + from: deployer.address, + nonce: nonce + 9, + }) + + const mulsigwallet = '' // address + console.log(`future mint: ${bridgeMint}`); + console.log(`future native: ${bridgeNative}`); + + if (!mulsigwallet) throw new Error('Multisig not set') + + await deploy('BridgeFactoryUpgradeable', { + contract: 'BridgeFactoryUpgradeable', + from: deployer.address, + proxy: { + owner: deployer.address, + proxyContract: 'OpenZeppelinTransparentProxy', + execute: { + methodName: 'initialize', + args: [ + bridgeTransfer, + bridgeMint, + bridgeNative, + bridgeCircle, + mulsigwallet, + deployer.address, + ], + }, + }, + log: true, + }) +} +export default func + +func.tags = ['BridgeFactoryUpgradeable.deploy'] +// func.dependencies = ['MultiSigWallet.deploy'] diff --git a/contracts/deploy/mainnet/asset-chain/BridgeMint.deploy.ts b/contracts/deploy/mainnet/asset-chain/BridgeMint.deploy.ts new file mode 100644 index 0000000..c5b0a58 --- /dev/null +++ b/contracts/deploy/mainnet/asset-chain/BridgeMint.deploy.ts @@ -0,0 +1,26 @@ +import { ethers } from 'hardhat' +import type { DeployFunction } from 'hardhat-deploy/types' +import { CHAIN_IDS } from '@/config' + +import { wrapperHRE } from '@/gotbit-tools/hardhat' +import type { BridgeAssistMintUpgradeable__factory } from '@/typechain' + +const func: DeployFunction = async (hre) => { + const { deploy } = wrapperHRE(hre) + const [deployer] = await ethers.getSigners() + const { chainId } = await ethers.provider.getNetwork() + + if (chainId != CHAIN_IDS.assetChain) { + return + } + + await deploy('BridgeAssistMintUpgradeable', { + contract: 'BridgeAssistMintUpgradeable', + from: deployer.address, + args: [], + log: true, + }) +} +export default func + +func.tags = ['BridgeAssistMintUpgradeable.deploy'] diff --git a/contracts/deploy/mainnet/asset-chain/BridgeNative.deploy.ts b/contracts/deploy/mainnet/asset-chain/BridgeNative.deploy.ts new file mode 100644 index 0000000..4269b24 --- /dev/null +++ b/contracts/deploy/mainnet/asset-chain/BridgeNative.deploy.ts @@ -0,0 +1,26 @@ +import { ethers } from 'hardhat' +import type { DeployFunction } from 'hardhat-deploy/types' +import { CHAIN_IDS } from '@/config' + +import { wrapperHRE } from '@/gotbit-tools/hardhat' +import type { BridgeAssistNativeUpgradeable__factory } from '@/typechain' + +const func: DeployFunction = async (hre) => { + const { deploy } = wrapperHRE(hre) + const [deployer] = await ethers.getSigners() + const { chainId } = await ethers.provider.getNetwork() + + if (chainId != CHAIN_IDS.assetChain) { + return + } + + await deploy('BridgeAssistNativeUpgradeable', { + contract: 'BridgeAssistNativeUpgradeable', + from: deployer.address, + args: [], + log: true, + }) +} +export default func + +func.tags = ['BridgeAssistNativeUpgradeable.deploy'] diff --git a/contracts/deploy/mainnet/asset-chain/BridgeTransfer.deploy.ts b/contracts/deploy/mainnet/asset-chain/BridgeTransfer.deploy.ts new file mode 100644 index 0000000..d881ea3 --- /dev/null +++ b/contracts/deploy/mainnet/asset-chain/BridgeTransfer.deploy.ts @@ -0,0 +1,26 @@ +import { ethers } from 'hardhat' +import type { DeployFunction } from 'hardhat-deploy/types' +import { CHAIN_IDS } from '@/config' + +import { wrapperHRE } from '@/gotbit-tools/hardhat' +import type { BridgeAssistTransferUpgradeable__factory } from '@/typechain' + +const func: DeployFunction = async (hre) => { + const { deploy } = wrapperHRE(hre) + const [deployer] = await ethers.getSigners() + const { chainId } = await ethers.provider.getNetwork() + + if (chainId == CHAIN_IDS.assetChain) { + return + } + + await deploy('BridgeAssistTransferUpgradeable', { + contract: 'BridgeAssistTransferUpgradeable', + from: deployer.address, + args: [], + log: true, + }) +} +export default func + +func.tags = ['BridgeAssistTransferUpgradeable.deploy'] diff --git a/contracts/deploy/mainnet/asset-chain/USDT.deploy.ts b/contracts/deploy/mainnet/asset-chain/USDT.deploy.ts new file mode 100644 index 0000000..853f4d4 --- /dev/null +++ b/contracts/deploy/mainnet/asset-chain/USDT.deploy.ts @@ -0,0 +1,45 @@ +import { ethers, getNamedAccounts } from 'hardhat' +import type { DeployFunction } from 'hardhat-deploy/types' +import { CHAIN_IDS, MAINNET_BRIDGED_TOKEN_PARAMS} from '@/config' + +import { wrapperHRE } from '@/gotbit-tools/hardhat' +import type { BridgedAssetChainToken__factory, MultiSigWallet } from '@/typechain' +import { BigNumber } from 'ethers' + +const func: DeployFunction = async (hre) => { + const { deploy } = wrapperHRE(hre) + const [deployer] = await ethers.getSigners() + const { chainId } = await ethers.provider.getNetwork() + + if (chainId != CHAIN_IDS.assetChain) { + return + } + + const token = 'USDT' + const params = MAINNET_BRIDGED_TOKEN_PARAMS[chainId][token] + + if (!token) throw new Error('Token not set') + + const mulsigwallet = '' // address + if (!mulsigwallet) throw new Error('Set address') + + await deploy(token, { + contract: 'BridgedAssetChainToken', + from: deployer.address, + args: [ + params.name, + params.symbol, + params.decimals, + BigNumber.from(params.totalSupply), + params.isLockActive, + params.tokenOriginal, + params.chainIdOriginal, + mulsigwallet + ], + log: true, + }) +} +export default func + +func.tags = ['USDT.deploy'] +func.dependencies = ['MultiSigWallet.deploy'] diff --git a/contracts/deploy/mainnet/asset-chain/WNT.deploy.ts b/contracts/deploy/mainnet/asset-chain/WNT.deploy.ts new file mode 100644 index 0000000..6d1e87a --- /dev/null +++ b/contracts/deploy/mainnet/asset-chain/WNT.deploy.ts @@ -0,0 +1,45 @@ +import { ethers, getNamedAccounts } from 'hardhat' +import type { DeployFunction } from 'hardhat-deploy/types' +import {BRIDGED_TOKEN_PARAMS, CHAIN_IDS, MAINNET_BRIDGED_TOKEN_PARAMS} from '@/config' + +import { wrapperHRE } from '@/gotbit-tools/hardhat' +import type { BridgedAssetChainToken__factory, MultiSigWallet } from '@/typechain' +import { BigNumber } from 'ethers' + +const func: DeployFunction = async (hre) => { + const { deploy } = wrapperHRE(hre) + const [deployer] = await ethers.getSigners() + const { chainId } = await ethers.provider.getNetwork() + + if (chainId != CHAIN_IDS.assetChain) { + return + } + + const token = 'WNT' + const params = MAINNET_BRIDGED_TOKEN_PARAMS[chainId][token] + + if (!token) throw new Error('Token not set') + + const mulsigwallet = '' // address + if (!mulsigwallet) throw new Error('Set address') + + await deploy(token, { + contract: 'BridgedAssetChainToken', + from: deployer.address, + args: [ + params.name, + params.symbol, + params.decimals, + BigNumber.from(params.totalSupply), + params.isLockActive, + params.tokenOriginal, + params.chainIdOriginal, + mulsigwallet + ], + log: true, + }) +} +export default func + +func.tags = ['WNT.deploy'] +// func.dependencies = ['MultiSigWallet.deploy'] diff --git a/contracts/deploy/mainnet/non-asset-chain/BridgeCircle.deploy.ts b/contracts/deploy/mainnet/non-asset-chain/BridgeCircle.deploy.ts new file mode 100644 index 0000000..3e19d8a --- /dev/null +++ b/contracts/deploy/mainnet/non-asset-chain/BridgeCircle.deploy.ts @@ -0,0 +1,30 @@ +import { ethers } from 'hardhat' +import type { DeployFunction } from 'hardhat-deploy/types' +import { CHAIN_IDS } from '@/config' + +import { wrapperHRE } from '@/gotbit-tools/hardhat' +import type { BridgeAssistCircleMintUpgradeable__factory } from '@/typechain' + +const func: DeployFunction = async (hre) => { + const { deploy } = wrapperHRE(hre) + const [deployer] = await ethers.getSigners() + const { chainId } = await ethers.provider.getNetwork() + + if (chainId != CHAIN_IDS.assetChain) { + return + } + + await deploy( + 'BridgeAssistCircleMintUpgradeable', + { + contract: 'BridgeAssistCircleMintUpgradeable', + from: deployer.address, + args: [], + log: true, + } + ) +} +export default func + +func.tags = ['BridgeAssistCircleMintUpgradeable.deploy'] +// func.dependencies = ['MultiSigWallet.deploy'] diff --git a/contracts/deploy/mainnet/non-asset-chain/BridgeFactory.deploy.ts b/contracts/deploy/mainnet/non-asset-chain/BridgeFactory.deploy.ts new file mode 100644 index 0000000..6d8daa1 --- /dev/null +++ b/contracts/deploy/mainnet/non-asset-chain/BridgeFactory.deploy.ts @@ -0,0 +1,75 @@ +import { ethers } from 'hardhat' +import type { DeployFunction } from 'hardhat-deploy/types' +import { CHAIN_IDS } from '@/config' + +import { wrapperHRE } from '@/gotbit-tools/hardhat' +import type { + BridgeAssistMintUpgradeable, + BridgeAssistNativeUpgradeable, + BridgeFactoryUpgradeable__factory, + MultiSigWallet, +} from '@/typechain' + +const func: DeployFunction = async (hre) => { + const { deploy } = wrapperHRE(hre) + const [deployer] = await ethers.getSigners() + + + // Fake tx for nonce incrementing + const tx = await deployer.sendTransaction({ + to: deployer.address, + value: 1, + }) + console.log(`Incrementing nonce tx: ${tx.hash}`) + await tx.wait() + + const nonce = await ethers.provider.getTransactionCount(deployer.address) + const bridgeMint = ethers.utils.getContractAddress({ + from: deployer.address, + nonce: nonce + 8, + }) + const bridgeNative = ethers.utils.getContractAddress({ + from: deployer.address, + nonce: nonce + 9, + }) + + const bridgeCircle = ethers.utils.getContractAddress({ + from: deployer.address, + nonce: nonce + 8, + }) + const bridgeTransfer = ethers.utils.getContractAddress({ + from: deployer.address, + nonce: nonce + 9, + }) + + const mulsigwallet = '' // address + console.log(`future mint: ${bridgeMint}`); + console.log(`future native: ${bridgeNative}`); + + if (!mulsigwallet) throw new Error('Multisig not set') + + await deploy('BridgeFactoryUpgradeable', { + contract: 'BridgeFactoryUpgradeable', + from: deployer.address, + proxy: { + owner: deployer.address, + proxyContract: 'OpenZeppelinTransparentProxy', + execute: { + methodName: 'initialize', + args: [ + bridgeTransfer, + bridgeMint, + bridgeNative, + bridgeCircle, + mulsigwallet, + deployer.address, + ], + }, + }, + log: true, + }) +} +export default func + +func.tags = ['BridgeFactoryUpgradeable.deploy'] +// func.dependencies = ['MultiSigWallet.deploy'] diff --git a/contracts/deploy/mainnet/non-asset-chain/BridgeMint.deploy.ts b/contracts/deploy/mainnet/non-asset-chain/BridgeMint.deploy.ts new file mode 100644 index 0000000..c5b0a58 --- /dev/null +++ b/contracts/deploy/mainnet/non-asset-chain/BridgeMint.deploy.ts @@ -0,0 +1,26 @@ +import { ethers } from 'hardhat' +import type { DeployFunction } from 'hardhat-deploy/types' +import { CHAIN_IDS } from '@/config' + +import { wrapperHRE } from '@/gotbit-tools/hardhat' +import type { BridgeAssistMintUpgradeable__factory } from '@/typechain' + +const func: DeployFunction = async (hre) => { + const { deploy } = wrapperHRE(hre) + const [deployer] = await ethers.getSigners() + const { chainId } = await ethers.provider.getNetwork() + + if (chainId != CHAIN_IDS.assetChain) { + return + } + + await deploy('BridgeAssistMintUpgradeable', { + contract: 'BridgeAssistMintUpgradeable', + from: deployer.address, + args: [], + log: true, + }) +} +export default func + +func.tags = ['BridgeAssistMintUpgradeable.deploy'] diff --git a/contracts/deploy/mainnet/non-asset-chain/BridgeNative.deploy.ts b/contracts/deploy/mainnet/non-asset-chain/BridgeNative.deploy.ts new file mode 100644 index 0000000..4269b24 --- /dev/null +++ b/contracts/deploy/mainnet/non-asset-chain/BridgeNative.deploy.ts @@ -0,0 +1,26 @@ +import { ethers } from 'hardhat' +import type { DeployFunction } from 'hardhat-deploy/types' +import { CHAIN_IDS } from '@/config' + +import { wrapperHRE } from '@/gotbit-tools/hardhat' +import type { BridgeAssistNativeUpgradeable__factory } from '@/typechain' + +const func: DeployFunction = async (hre) => { + const { deploy } = wrapperHRE(hre) + const [deployer] = await ethers.getSigners() + const { chainId } = await ethers.provider.getNetwork() + + if (chainId != CHAIN_IDS.assetChain) { + return + } + + await deploy('BridgeAssistNativeUpgradeable', { + contract: 'BridgeAssistNativeUpgradeable', + from: deployer.address, + args: [], + log: true, + }) +} +export default func + +func.tags = ['BridgeAssistNativeUpgradeable.deploy'] diff --git a/contracts/deploy/mainnet/non-asset-chain/BridgeTransfer.deploy.ts b/contracts/deploy/mainnet/non-asset-chain/BridgeTransfer.deploy.ts new file mode 100644 index 0000000..d881ea3 --- /dev/null +++ b/contracts/deploy/mainnet/non-asset-chain/BridgeTransfer.deploy.ts @@ -0,0 +1,26 @@ +import { ethers } from 'hardhat' +import type { DeployFunction } from 'hardhat-deploy/types' +import { CHAIN_IDS } from '@/config' + +import { wrapperHRE } from '@/gotbit-tools/hardhat' +import type { BridgeAssistTransferUpgradeable__factory } from '@/typechain' + +const func: DeployFunction = async (hre) => { + const { deploy } = wrapperHRE(hre) + const [deployer] = await ethers.getSigners() + const { chainId } = await ethers.provider.getNetwork() + + if (chainId == CHAIN_IDS.assetChain) { + return + } + + await deploy('BridgeAssistTransferUpgradeable', { + contract: 'BridgeAssistTransferUpgradeable', + from: deployer.address, + args: [], + log: true, + }) +} +export default func + +func.tags = ['BridgeAssistTransferUpgradeable.deploy'] diff --git a/contracts/hardhat.config.ts b/contracts/hardhat.config.ts index 4da0e5e..fe63f0a 100644 --- a/contracts/hardhat.config.ts +++ b/contracts/hardhat.config.ts @@ -66,26 +66,42 @@ const config: HardhatUserConfig = { deploy: ['deploy/testnet/non-asset-chain'], accounts: [process.env.PRIVATE_TEST!, process.env.PRIVATE_TEST2!], }, - // polygon_amoy: { - // tags: ['testnet'], - // deploy: ['deploy/testnet/'], - // url: 'https://polygon-amoy.blockpi.network/v1/rpc/public', - // accounts: [process.env.PRIVATE_TEST!], - // }, - // eth_sepolia: { - // tags: ['testnet'], - // deploy: ['deploy/testnet/'], - // url: 'https://1rpc.io/sepolia', - // accounts: [process.env.PRIVATE_TEST!], - // }, - // base_sepolia: { - // tags: ['testnet'], - // deploy: ['deploy/testnet/'], - // url: 'https://base-sepolia.blockpi.network/v1/rpc/public', - // accounts: [process.env.PRIVATE_TEST!], - // }, - // ...genNetworks(), - // place here any network you like (for overriding `genNetworks`) + xend: { + tags: ['mainnet'], + deploy: ['deploy/mainnet/asset-chain'], + url: 'https://mainnet-rpc.assetchain.org', + accounts: [process.env.PRIVATE_TEST!, process.env.PRIVATE_TEST2!] + }, + arbitrum: { + tags: ['mainnet'], + deploy: ['deploy/mainnet/non-asset-chain'], + url: 'https://arb1.arbitrum.io/rpc', + accounts: [process.env.PRIVATE_TEST!, process.env.PRIVATE_TEST2!], + }, + bsc: { + tags: ['mainnet'], + deploy: ['deploy/mainnet/non-asset-chain'], + url: 'https://binance.llamarpc.com', + accounts: [process.env.PRIVATE_TEST!, process.env.PRIVATE_TEST2!], + }, + base: { + url: 'https://mainnet.base.org', + tags: ['mainnet'], + deploy: ['deploy/mainnet/non-asset-chain'], + accounts: [process.env.PRIVATE_TEST!, process.env.PRIVATE_TEST2!], + }, + bitlayer: { + url: 'https://rpc.bitlayer.org', + tags: ['mainnet'], + deploy: ['deploy/mainnet/non-asset-chain'], + accounts: [process.env.PRIVATE_TEST!, process.env.PRIVATE_TEST2!], + }, + ethereum: { + url: 'https://ethereum-rpc.publicnode.com', + tags: ['mainnet'], + deploy: ['deploy/mainnet/non-asset-chain'], + accounts: [process.env.PRIVATE_TEST!, process.env.PRIVATE_TEST2!], + } }, gasReporter: { enabled: true, diff --git a/contracts/package.json b/contracts/package.json index 3438a14..2d70b4d 100644 --- a/contracts/package.json +++ b/contracts/package.json @@ -31,7 +31,26 @@ "bridgetoken:xend": "hardhat --network xend_testnet run scripts/assetChainBridgeToken.ts", "factory:bitlayer_testnet": "hardhat --network bitlayer_testnet run scripts/factory.ts", "deploy:bitlayer_testnet": "hardhat deploy --export-all dev/contracts.json --network bitlayer_testnet", - "bridge:bitlayer_testnet": "hardhat --network bitlayer_testnet run scripts/bridge.ts" + "bridge:bitlayer_testnet": "hardhat --network bitlayer_testnet run scripts/bridge.ts", + "deploy:arb": "hardhat deploy --export-all dev/contracts.json --network arbitrum", + "deploy:xend": "hardhat deploy --export-all dev/contracts.json --network xend", + "deploy:bsc": "hardhat deploy --export-all dev/contracts.json --network bsc", + "deploy:ethereum": "hardhat deploy --export-all dev/contracts.json --network ethereum", + "factory:arb_main": "hardhat --network arbitrum run scripts/factory.ts", + "factory:xend_main": "hardhat --network xend run scripts/factory.ts", + "factory:bsc_main": "hardhat --network bsc run scripts/factory.ts", + "factory:ethereum": "hardhat --network ethereum run scripts/factory.ts", + "bridge:arb_main": "hardhat --network arbitrum run scripts/bridge.ts", + "bridge:xend_main": "hardhat --network xend run scripts/bridge.ts", + "bridge:bsc_main": "hardhat --network bsc run scripts/bridge.ts", + "deploy:base": "hardhat deploy --export-all dev/contracts.json --network base", + "factory:base": "hardhat --network base run scripts/factory.ts", + "bridge:base": "hardhat --network base run scripts/bridge.ts", + "bridgetoken:xend_main": "hardhat --network xend run scripts/assetChainBridgeToken.ts", + "factory:bitlayer": "hardhat --network bitlayer run scripts/factory.ts", + "deploy:bitlayer": "hardhat deploy --export-all dev/contracts.json --network bitlayer", + "bridge:bitlayer": "hardhat --network bitlayer run scripts/bridge.ts", + "bridge:ethereum": "hardhat --network ethereum run scripts/bridge.ts" }, "_moduleAliases": { "@": "."