From 30affa0da85985f6dc90b62f6293de46a9e26130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Uhl=C3=AD=C5=99?= Date: Wed, 26 Apr 2023 09:44:55 +0200 Subject: [PATCH] build: make sure marketplace is on predefined address (#54) --- deploy/marketplace.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/deploy/marketplace.js b/deploy/marketplace.js index 2640654..e28b508 100644 --- a/deploy/marketplace.js +++ b/deploy/marketplace.js @@ -1,3 +1,5 @@ +const MARKETPLACE_HARDCODED_ADDRESS = "0x59b670e9fA9D0A427751Af201D676719a970857b" + async function deployMarketplace({ deployments, getNamedAccounts }) { const token = await deployments.get("TestToken") const configuration = { @@ -24,9 +26,23 @@ async function mine256blocks({ network, ethers }) { } } +async function aliasContract({deployments, network}) { + if (network.tags.local) { + const marketplaceDeployment = await deployments.get("Marketplace") + + if (marketplaceDeployment.address === MARKETPLACE_HARDCODED_ADDRESS) { + return + } + + console.log(`Aliasing marketplace from address ${marketplaceDeployment.address} to ${MARKETPLACE_HARDCODED_ADDRESS}`) + await ethers.provider.send("hardhat_setCode", [MARKETPLACE_HARDCODED_ADDRESS, marketplaceDeployment.address]) + } +} + module.exports = async (environment) => { await mine256blocks(environment) await deployMarketplace(environment) + await aliasContract(environment) } module.exports.tags = ["Marketplace"]