"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.toAddress = exports.getArgTypesFromSignature = exports.AddressOne = exports.scaleDownBy = exports.convertToUnit = void 0;
const bignumber_js_1 = __importDefault(require("bignumber.js"));
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 scaleDownBy = (amount, decimals) => {
    return new bignumber_js_1.default(amount).dividedBy(new bignumber_js_1.default(10).pow(decimals)).toString();
};
exports.scaleDownBy = scaleDownBy;
exports.AddressOne = "0x0000000000000000000000000000000000000001";
// Function to get argument types from method signature
const getArgTypesFromSignature = (methodSignature) => {
    const [, argumentString] = methodSignature.split("(")[1].split(")");
    return argumentString.split(",").map(arg => arg.trim());
};
exports.getArgTypesFromSignature = getArgTypesFromSignature;
const toAddress = async (addressOrAlias, hre) => {
    const { getNamedAccounts } = hre;
    const { deployments } = hre;
    if (addressOrAlias.startsWith("0x")) {
        return addressOrAlias;
    }
    if (addressOrAlias.startsWith("account:")) {
        const namedAccounts = await getNamedAccounts();
        return namedAccounts[addressOrAlias.slice("account:".length)];
    }
    const deployment = await deployments.get(addressOrAlias);
    return deployment.address;
};
exports.toAddress = toAddress;
