Deploy swap and parse event logs to get address
This commit is contained in:
parent
6432c647a3
commit
4d9e7e8660
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue