"use strict";
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());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getArgTypesFromSignature = exports.releaseImpersonation = exports.impersonateSigner = exports.fundAccount = exports.convertToBigInt = exports.convertToUnit = void 0;
const bignumber_js_1 = __importDefault(require("bignumber.js"));
const hardhat_1 = require("hardhat");
bignumber_js_1.default.config({
    FORMAT: {
        decimalSeparator: ".",
        groupSize: 0,
        groupSeparator: "",
        secondaryGroupSize: 0,
        fractionGroupSeparator: "",
        fractionGroupSize: 0,
    },
    ROUNDING_MODE: bignumber_js_1.default.ROUND_DOWN,
    EXPONENTIAL_AT: 1e9,
});
const convertToUnit = (amount, decimals) => {
    return new bignumber_js_1.default(amount).times(new bignumber_js_1.default(10).pow(decimals)).toString();
};
exports.convertToUnit = convertToUnit;
const convertToBigInt = (amount, decimals) => {
    return BigInt((0, exports.convertToUnit)(amount, decimals));
};
exports.convertToBigInt = convertToBigInt;
const fundAccount = (address) => __awaiter(void 0, void 0, void 0, function* () {
    const [deployer] = yield hardhat_1.ethers.getSigners();
    yield deployer.sendTransaction({
        to: address,
        value: hardhat_1.ethers.utils.parseEther("1.0"),
    });
});
exports.fundAccount = fundAccount;
const impersonateSigner = (address) => __awaiter(void 0, void 0, void 0, function* () {
    yield hardhat_1.network.provider.request({
        method: "hardhat_impersonateAccount",
        params: [address],
    });
    const signer = yield hardhat_1.ethers.getSigner(address);
    return signer;
});
exports.impersonateSigner = impersonateSigner;
const releaseImpersonation = (address) => __awaiter(void 0, void 0, void 0, function* () {
    yield hardhat_1.network.provider.request({
        method: "hardhat_stopImpersonatingAccount",
        params: [address],
    });
});
exports.releaseImpersonation = releaseImpersonation;
const getArgTypesFromSignature = (methodSignature) => {
    const [, argumentString] = methodSignature.split("(")[1].split(")");
    return argumentString.split(",").map(arg => arg.trim());
};
exports.getArgTypesFromSignature = getArgTypesFromSignature;
//# sourceMappingURL=utils.js.map