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());
    });
};
import { TronAddresses } from "../../config/address/tron";
import { ShastaAddresses } from "../../config/address/shasta";
import { getAddressesByLandId } from "../ethers/addressHelper";
var ChainIDs;
(function (ChainIDs) {
    ChainIDs[ChainIDs["Tron"] = 11112] = "Tron";
    ChainIDs[ChainIDs["Shasta"] = 11111] = "Shasta";
})(ChainIDs || (ChainIDs = {}));
var GenesisBlockID;
(function (GenesisBlockID) {
    GenesisBlockID["Tron"] = "00000000000000001ebf88508a03865c71d452e25f4d51194196a1d22b6653dc";
    GenesisBlockID["Shasta"] = "0000000000000000de1aa88295e1fcf982742f773e0419c5a9c134c994a9059e";
})(GenesisBlockID || (GenesisBlockID = {}));
/**
 * Get Addresses
 * @param genesisBlockId Genesis block id
 * @returns Addresses or undefined
 */
export const getAddressesByChainId = (chainId) => {
    switch (chainId) {
        case ChainIDs.Tron:
            return TronAddresses;
        case ChainIDs.Shasta:
            return ShastaAddresses;
        default:
            return;
    }
};
export const getAddressesByGenesisBlockID = (genesisBlockId) => {
    switch (genesisBlockId) {
        case GenesisBlockID.Tron:
            return TronAddresses;
        case GenesisBlockID.Shasta:
            return ShastaAddresses;
        default:
            return;
    }
};
/**
 * Get Addresses By TronWeb
 * @param tronWeb Tronweb
 * @returns Addresses or undefined
 */
export const getAddressesByTronWeb = (tronWeb) => __awaiter(void 0, void 0, void 0, function* () {
    const genesisBlock = yield tronWeb.trx.getBlock(0);
    return getAddressesByGenesisBlockID(genesisBlock.blockID);
});
/**
 * Get Address By Name
 * @param chainId Chain id
 * @param name Name
 * @returns Address
 */
export const getAddressByName = (landId, name) => {
    const addresses = getAddressesByLandId(landId);
    if (addresses) {
        return addresses[name];
    }
    return "";
};
