Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more usefull tasks #63

Merged
merged 8 commits into from
Oct 5, 2024
4 changes: 4 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ import "./tasks/get-statuses-after-execution";
import "./tasks/depositSC";
import "./tasks/set-batch-settle-limit-on-safe"
import "./tasks/deploy";
import "./tasks/token-balance-query"
import "./tasks/get-relayers"
import "./tasks/native-tokens"
import "./tasks/mintburn-tokens"

import { resolve } from "path";

Expand Down
16 changes: 16 additions & 0 deletions tasks/get-relayers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import "@nomicfoundation/hardhat-toolbox";

task("get-relayers", "Get the whitelisted relayers").setAction(async (taskArgs, hre) => {
const [adminWallet] = await hre.ethers.getSigners();
const fs = require("fs");
const config = JSON.parse(fs.readFileSync("setup.config.json", "utf8"));
const bridgeAddress = config["bridge"];
const bridgeContractFactory = await hre.ethers.getContractFactory("Bridge");
const bridge = bridgeContractFactory.attach(bridgeAddress).connect(adminWallet);

const relayers = await bridge.getRelayers();
console.log("whitelisted relayers:")
for (let relayer of relayers) {
console.log(relayer);
}
});
24 changes: 24 additions & 0 deletions tasks/mintburn-tokens.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import "@nomicfoundation/hardhat-toolbox";
import fs from "fs";

task("mintburn-tokens", "Returns if the token is mint-burn or not")
.addParam("address", "Address of the token")
.setAction(async (taskArgs, hre) => {
const address = taskArgs.address;

const filename = "setup.config.json";
const config = JSON.parse(fs.readFileSync(filename, "utf8"));
const safeAddress = config["erc20Safe"];

const safeContractFactory = await hre.ethers.getContractFactory("ERC20Safe");
const contract = safeContractFactory.attach(safeAddress)

await contract
.mintBurnTokens(address)
.then((isMintBurn: any) => {
console.log(`Token ${address} is mint-burn: ${isMintBurn.toString()}`);
})
.catch((err: any) => {
console.log(err);
});
});
24 changes: 24 additions & 0 deletions tasks/native-tokens.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import "@nomicfoundation/hardhat-toolbox";
import fs from "fs";

task("native-tokens", "Returns if the token is native or not")
.addParam("address", "Address of the token")
.setAction(async (taskArgs, hre) => {
const address = taskArgs.address;

const filename = "setup.config.json";
const config = JSON.parse(fs.readFileSync(filename, "utf8"));
const safeAddress = config["erc20Safe"];

const safeContractFactory = await hre.ethers.getContractFactory("ERC20Safe");
const contract = safeContractFactory.attach(safeAddress)

await contract
.nativeTokens(address)
.then((isNative: any) => {
console.log(`Token ${address} is native: ${isNative.toString()}`);
})
.catch((err: any) => {
console.log(err);
});
});
20 changes: 20 additions & 0 deletions tasks/token-balance-query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import "@nomicfoundation/hardhat-toolbox";

task("token-balance-query", "Query the balance of the provided address for the defined tokens")
.addParam("address", "Address for the balance query")
.setAction(async (taskArgs, hre) => {
const fs = require("fs");
const filename = "setup.config.json";
let config = JSON.parse(fs.readFileSync(filename, "utf8"));
const address = taskArgs.address;

console.log("Querying ERC20 balance of the address", address);
for (let token of config["tokens"]) {
const tokenContract = (await hre.ethers.getContractFactory("GenericERC20")).attach(token);
await tokenContract.balanceOf(address)
.then((balance: any) => {
console.log(`Balance of token ${token.toString()}: ${balance.toString()}`);
})

}
});
Loading