mirror of
https://github.com/vacp2p/swap-contracts-module.git
synced 2025-02-28 19:00:40 +00:00
Add get balance task
This commit is contained in:
parent
1b615e9604
commit
13ddea07c3
@ -44,6 +44,13 @@ task("redeemCheque", "Redeem cheque")
|
|||||||
console.log(JSON.stringify(resp));
|
console.log(JSON.stringify(resp));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
task("getBalances", "Get ERC20 Balances for Alice and Bob")
|
||||||
|
.addParam("erc20address", "ERC20 Address")
|
||||||
|
.setAction(async taskArgs => {
|
||||||
|
var resp = await swap.getBalances(taskArgs.erc20address);
|
||||||
|
console.log(JSON.stringify(resp));
|
||||||
|
});
|
||||||
|
|
||||||
// You need to export an object to set up your config
|
// You need to export an object to set up your config
|
||||||
// Go to https://hardhat.org/config/ to learn more
|
// Go to https://hardhat.org/config/ to learn more
|
||||||
|
|
||||||
|
@ -151,14 +151,25 @@ async function redeemCheque(aliceSwapAddress, issuerSig) {
|
|||||||
var foo = await swapContract.cashChequeBeneficiary(recipient, cumulativePayout, issuerSig);
|
var foo = await swapContract.cashChequeBeneficiary(recipient, cumulativePayout, issuerSig);
|
||||||
console.log("Resp", foo);
|
console.log("Resp", foo);
|
||||||
|
|
||||||
// Reproduced error here:
|
return {resp: foo};
|
||||||
// ProviderError: VM Exception while processing transaction: revert SimpleSwap: invalid issuer signature
|
|
||||||
// TODO Fix it
|
|
||||||
|
|
||||||
return {resp: foo}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
async function getBalances(erc20address) {
|
||||||
|
var erc20artifact = await artifacts.readArtifact("ERC20PresetMinterPauser");
|
||||||
|
var signers = await ethers.getSigners();
|
||||||
|
var aliceSigner = signers[0];
|
||||||
|
var erc20contract = new ethers.Contract(erc20address, erc20artifact.abi, aliceSigner);
|
||||||
|
|
||||||
|
var aliceBalance = await erc20contract.balanceOf(aliceAddress);
|
||||||
|
var bobBalance = await erc20contract.balanceOf(bobAddress);
|
||||||
|
|
||||||
|
return {aliceBalance: aliceBalance.toNumber(),
|
||||||
|
bobBalance: bobBalance.toNumber()};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports.setupSwap = setupSwap;
|
module.exports.setupSwap = setupSwap;
|
||||||
module.exports.signCheque = signCheque;
|
module.exports.signCheque = signCheque;
|
||||||
module.exports.redeemCheque = redeemCheque;
|
module.exports.redeemCheque = redeemCheque;
|
||||||
|
module.exports.getBalances = getBalances;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user