Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: adjust deployment scripts #7

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading