Skip to content

Commit

Permalink
Merge pull request #7 from 1inch/chore/adjust-deploument-scripts
Browse files Browse the repository at this point in the history
chore: adjust deployment scripts
  • Loading branch information
ZumZoom authored Oct 26, 2023
2 parents d50e1c6 + 2c27eb8 commit 16b832f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
35 changes: 35 additions & 0 deletions deploy/deploy-metadata.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const hre = require('hardhat');
// const { ethers } = hre;
const { getChainId } = hre;

module.exports = async ({ deployments, getNamedAccounts }) => {
const networkName = hre.network.name;
console.log(`running ${networkName} deploy script`);
const chainId = await getChainId();
console.log('network id ', chainId);
if (chainId !== hre.config.networks[networkName].chainId.toString()) {
console.log(`network chain id: ${hre.config.networks[networkName].chainId}, your chain id ${chainId}`);
console.log('skipping wrong chain id deployment');
return;
}

const { deploy } = deployments;
const { deployer } = await getNamedAccounts();

const contractName = 'AddressTokenMetadata';
const contract = await deploy('AddressTokenMetadata', {
from: deployer,
contract: contractName,
skipIfAlreadyDeployed: true,
});

console.log(`${contractName} deployed to: ${contract.address}`);

if (chainId !== '31337') {
await hre.run('verify:verify', {
address: contract.address,
});
}
};

module.exports.skip = async () => true;
12 changes: 9 additions & 3 deletions hardhat.networks.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
const networks = {
// Uncomment this to use hardhat forking
// hardhat: {
// forking: {
// url: process.env.MAINNET_RPC_URL,
// httpHeaders: {
// 'auth-key': process.env.RPC_AUTH_HEADER,
// },
// },
// chainId: Number(process.env.FORK_CHAIN_ID) || 31337,
// },
};
const etherscan = { apiKey: {} };
const etherscan = { apiKey: {}, customChains: [] };

function register (name, chainId, url, privateKey, etherscanNetworkName, etherscanKey) {
if (url && privateKey && etherscanKey) {
networks[name] = {
url,
httpHeaders: {
'auth-key': process.env.RPC_AUTH_HEADER,
},
chainId,
accounts: [privateKey],
};
Expand All @@ -36,10 +41,11 @@ register('kovan', 42, process.env.KOVAN_RPC_URL, process.env.KOVAN_PRIVATE_KEY,
register('optimistic', 10, process.env.OPTIMISTIC_RPC_URL, process.env.OPTIMISTIC_PRIVATE_KEY, 'optimisticEthereum', process.env.OPTIMISTIC_ETHERSCAN_KEY);
register('matic', 137, process.env.MATIC_RPC_URL, process.env.MATIC_PRIVATE_KEY, 'polygon', process.env.MATIC_ETHERSCAN_KEY);
register('arbitrum', 42161, process.env.ARBITRUM_RPC_URL, process.env.ARBITRUM_PRIVATE_KEY, 'arbitrumOne', process.env.ARBITRUM_ETHERSCAN_KEY);
register('xdai', 100, process.env.XDAI_RPC_URL, process.env.XDAI_PRIVATE_KEY, 'xdai', process.env.XDAI_ETHERSCAN_KEY);
register('xdai', 100, process.env.XDAI_RPC_URL, process.env.XDAI_PRIVATE_KEY, 'gnosis', process.env.XDAI_ETHERSCAN_KEY);
register('avax', 43114, process.env.AVAX_RPC_URL, process.env.AVAX_PRIVATE_KEY, 'avalanche', process.env.AVAX_ETHERSCAN_KEY);
register('fantom', 250, process.env.FANTOM_RPC_URL, process.env.FANTOM_PRIVATE_KEY, 'opera', process.env.FANTOM_ETHERSCAN_KEY);
register('aurora', 1313161554, process.env.AURORA_RPC_URL, process.env.AURORA_PRIVATE_KEY, 'aurora', process.env.AURORA_ETHERSCAN_KEY);
register('base', 8453, process.env.BASE_RPC_URL, process.env.BASE_PRIVATE_KEY, 'base', process.env.BASE_ETHERSCAN_KEY);
registerCustom('klaytn', 8217, process.env.KLAYTN_RPC_URL, process.env.KLAYTN_PRIVATE_KEY, process.env.KLAYTN_ETHERSCAN_KEY, 'https://scope.klaytn.com/', 'https://scope.klaytn.com/');

module.exports = {
Expand Down

0 comments on commit 16b832f

Please sign in to comment.