Return JSON string for setupSwap

This commit is contained in:
Oskar Thoren 2021-02-08 21:59:19 +08:00
parent feb07ef01f
commit 609ed987ae
3 changed files with 24 additions and 12 deletions

View File

@ -25,10 +25,9 @@ task("balance", "Prints an account's balance")
task("setupSwap", "Setup Swap")
.setAction(async taskArgs => {
await swap.setupSwap();
var resp = await swap.setupSwap();
// TODO Should return JSON
console.log("NYI")
console.log(JSON.stringify(resp));
//console.log(web3.utils.fromWei(balance, "ether"), "ETH");
});

View File

@ -2,7 +2,10 @@ const hre = require("hardhat");
let swap = require("../src/setup-swap");
async function main() {
await swap.setupSwap();
var resp = await swap.setupSwap();
console.log("JSON resp");
console.log(JSON.stringify(resp));
}
// We recommend this pattern to be able to use async/await everywhere

View File

@ -48,15 +48,25 @@ async function setupSwap() {
var aliceSwapBalance = (await erc20contract.balanceOf(aliceSwapAddress)).toNumber();
// Print stuff
console.log("ERC20:", erc20.address);
console.log("SimpleSwapFactory:", simpleSwapFactory.address);
console.log("Alice address:", aliceAddress);
console.log("Bob address:", bobAddress);
console.log("AliceSwapAddress:", aliceSwapAddress)
console.log("BobSwapAddress:", bobSwapAddress)
console.log("Alice ERC20 balance:", aliceBalance);
console.log("Bob ERC20 balance:", bobBalance);
// console.log("ERC20:", erc20.address);
// console.log("SimpleSwapFactory:", simpleSwapFactory.address);
// console.log("Alice address:", aliceAddress);
// console.log("Bob address:", bobAddress);
// console.log("AliceSwapAddress:", aliceSwapAddress)
// console.log("BobSwapAddress:", bobSwapAddress)
// console.log("Alice ERC20 balance:", aliceBalance);
// console.log("Bob ERC20 balance:", bobBalance);
// console.log("Alice Swap balance:", aliceSwapBalance);
var resp = {
erc20: erc20.address,
aliceAddress: aliceAddress,
bobAddress: bobAddress,
aliceSwapAddress: aliceSwapAddress,
bobSwapAddress: bobSwapAddress
};
return resp;
}
module.exports.setupSwap = setupSwap;