-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathclose_transfer.ts
50 lines (39 loc) · 1.62 KB
/
close_transfer.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// We require the Hardhat Runtime Environment explicitly here. This is optional
// but useful for running the script in a standalone fashion through `node <script>`.
//
// When running the script with `npx hardhat run <script>` you'll find the Hardhat
// Runtime Environment's members available in the global scope.
import { ethers } from "ethers";
import { ERC20__factory } from "../typechain/factories/ERC20__factory";
import { BridgeEscrow__factory } from "../typechain/factories/BridgeEscrow__factory";
import { getConfig, getSigners, getSigner } from "./get_signers";
async function main() {
let argv = process.argv.slice(2);
if (argv.length < 1 || argv[0] == "-h" || argv[0] == "--help") {
console.log("Usage: close_transfer.ts <transfer-id>");
console.log("\t close transfer account ");
console.log("\t nicknames: alice, bob, carol, pete, todd, bridgeEscrow");
return;
}
const transfer_id = argv[0];
// get signers
let signers = getSigners();
let aliceWallet = getSigner(signers, "alice");
// get contracts
let config = getConfig();
let bridgeEscrowAddr = config.escrowContract;
const provider = new ethers.providers.JsonRpcProvider("http://localhost:8545");
const BridgeEscrow = BridgeEscrow__factory.connect(bridgeEscrowAddr, provider);
// close
let signer = aliceWallet.connect(provider);
const tx = await BridgeEscrow.connect(signer).closeTransferAccountSender(
transfer_id
);
console.log("Close: ", tx);
}
// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});