From 98867a5d59821172be092ed76d401214c805bccd Mon Sep 17 00:00:00 2001 From: Uladzislau Hubar Date: Thu, 26 Dec 2024 21:19:18 +0800 Subject: [PATCH] Added NeuroERC20 setter script --- deploy/100_set_neuro_erc20.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 deploy/100_set_neuro_erc20.ts diff --git a/deploy/100_set_neuro_erc20.ts b/deploy/100_set_neuro_erc20.ts new file mode 100644 index 00000000..c92870c2 --- /dev/null +++ b/deploy/100_set_neuro_erc20.ts @@ -0,0 +1,23 @@ +import { HardhatRuntimeEnvironment } from 'hardhat/types'; +import { DeployFunction } from 'hardhat-deploy/types'; + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const neuroERC20Exists = hre.helpers.inConfig('NeurowebERC20'); + if (neuroERC20Exists) { + const hubAddress = + hre.helpers.contractDeployments.contracts['Hub'].evmAddress; + const Hub = await hre.ethers.getContractAt('Hub', hubAddress); + + const tokenInHub = await Hub['isContract(string)']('NeurowebERC20'); + if (!tokenInHub) { + hre.helpers.newContracts.push({ + name: 'NeurowebERC20', + addr: hre.helpers.contractDeployments.contracts['NeurowebERC20'] + .evmAddress, + }); + } + } +}; +export default func; +func.tags = ['Neuro']; +func.dependencies = ['Hub'];