diff --git a/scripts/setup-swap.js b/scripts/setup-swap.js index 9e6f0f9..727d47e 100644 --- a/scripts/setup-swap.js +++ b/scripts/setup-swap.js @@ -2,7 +2,11 @@ const hre = require("hardhat"); async function main() { // Deploy ERC20 Token - // XXX Who is default signer here? + var signers = await ethers.getSigners(); + var firstAddress = signers[0].address; + + var DEFAULT_HARDDEPOSIT_DECREASE_TIMEOUT = ethers.BigNumber.from(86400) + const ERC20 = await hre.ethers.getContractFactory("ERC20PresetMinterPauser"); var erc20 = await ERC20.deploy("TestToken", "TEST"); await erc20.deployed(); @@ -14,6 +18,16 @@ async function main() { await simpleSwapFactory.deployed(); console.log("SimpleSwapFactory: ", simpleSwapFactory.address); + // Deploy Swap + var resp = await simpleSwapFactory.deploySimpleSwap(firstAddress, DEFAULT_HARDDEPOSIT_DECREASE_TIMEOUT) + console.log("deploySimpleSwap resp:", resp) + + // Get contract interface to parse logs + var logs = await ethers.provider.getLogs({address: simpleSwapFactory.address}); + var swapFactoryArtifact = await artifacts.readArtifact("SimpleSwapFactory"); + var swapFactoryInterface = new ethers.utils.Interface(swapFactoryArtifact.abi); + var ERC20SimpleSwapAddress = swapFactoryInterface.parseLog(logs[0]).args.contractAddress + console.log("ERC20SimpleSwapAddress ", ERC20SimpleSwapAddress) } // We recommend this pattern to be able to use async/await everywhere