hardhat-deal
Version:
🎩🪄 Easily deal any amount of any ERC20 tokens to any account on the hardhat network
28 lines (27 loc) • 1.89 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const config_1 = require("hardhat/config");
const constants_1 = require("./constants");
const helpers_1 = require("./helpers");
(0, config_1.task)("deal", `Deals any amount of ERC20 tokens to a given address`)
.addPositionalParam("to", "Target address", undefined, config_1.types.string)
.addOptionalPositionalParam("erc20", `The ERC20 symbol or address [supported symbols: ${Object.keys(constants_1.defaultSymbols).join(", ")}]`, "WETH", config_1.types.string)
.addOptionalPositionalParam("amount", "Token amount, with decimals", "1000000000000000000", config_1.types.string)
.addOptionalParam("maxSlot", "The maximum storage slot index to brute-force", undefined, config_1.types.int)
.setAction(function (_a, hre_1) {
return __awaiter(this, arguments, void 0, function* ({ erc20, to, amount, maxSlot, }, hre) {
const symbol = constants_1.defaultSymbols[erc20];
const erc20Address = symbol || erc20;
yield (0, helpers_1.deal)(erc20Address, to, amount, maxSlot, hre);
console.log(`Dealt ${amount} ${symbol ? erc20 : "ERC20(" + erc20Address + ")"} to ${to}`);
});
});