-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinteract_with_bridge.js
More file actions
80 lines (76 loc) · 3.64 KB
/
interact_with_bridge.js
File metadata and controls
80 lines (76 loc) · 3.64 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
const { ethers } = require("hardhat");
const {
bulkWhitelistStatusUpdate,
addTokenToWhitelist,
removeTokenFromWhitelist,
isTokenInWhitelist
} = require("./whitelistTokens");
const { pauseTransfer, unpauseTransfer } = require("./pause_unpause");
const { withdrawStuckTokens } = require("./withdraw_Stuck_tokens");
const prompt = require("prompt-sync")();
async function main() {
console.log(
"Please select operation to perform on Bridge :\n" +
"1. Bulk whitelist Tokens\n" +
"2. Add one token to whitelist\n" +
"3. Remove token from whitelist\n" +
"4. Check token's whitelist status\n" +
"5. Pause transfers\n" +
"6. Unpause transfers\n" +
"7. Withdraw stuck tokens\n"
);
const choice = prompt("Please Enter your choice :");
if (choice !== null) {
let userInput = choice.toString().trim().toLowerCase();
if (userInput === "1") {
console.log("to execute bulkWhitelistStatusUpdate(tokensArray, statusArray, signer)");
const inputTokens = prompt("please enter space separated token addresses : ");
let addressArray = inputTokens.trim().split(" ");
const inputStatuses = prompt("please enter space separated token whitelists status in bool : ");
let statusArray = inputStatuses.trim().split(" ");
console.log(addressArray);
const [whitelistingAdminSigner] = await ethers.getSigners();
if (addressArray.length == statusArray) {
await bulkWhitelistStatusUpdate(addressArray, statusArray, whitelistingAdminSigner);
} else {
console.log("number of tokens is not equal to number of statuses provided");
}
} else if (userInput === "2") {
console.log("to execute addTokenToWhitelist(token, signer)");
const inputToken = prompt("please enter token address : ");
let tokenAddress = inputToken.trim();
const [whitelistingAdminSigner] = await ethers.getSigners();
await addTokenToWhitelist(tokenAddress, whitelistingAdminSigner);
} else if (userInput === "3") {
console.log("to execute removeTokenFromWhitelist(token, signer)");
const inputToken = prompt("please enter token address : ");
let tokenAddress = inputToken.trim();
const [whitelistingAdminSigner] = await ethers.getSigners();
await removeTokenFromWhitelist(tokenAddress, whitelistingAdminSigner);
} else if (userInput === "4") {
console.log("to execute isTokenInWhitelist(token)");
const inputToken = prompt("please enter token address : ");
let token = inputToken.trim();
await isTokenInWhitelist(token);
} else if (userInput === "5") {
console.log("to execute pauseTransfer(signer)");
const [pausableAdminSigner] = await ethers.getSigners();
await pauseTransfer(pausableAdminSigner);
} else if (userInput === "6") {
console.log("Executing unpauseTransfer(signer)");
const [unpausableAdminSigner] = await ethers.getSigners();
await unpauseTransfer(unpausableAdminSigner);
} else if (userInput === "7") {
console.log("to execute withdrawStuckTokens(signer)");
const [defaultAdminSigner] = await ethers.getSigners();
await withdrawStuckTokens(defaultAdminSigner);
} else {
// Handle invalid input
console.log("Invalid input.");
}
}
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});