PHP WebShell

Текущая директория: /opt/BitGoJS/node_modules/@celo/contractkit/lib

Просмотр файла: contract-cache.js

"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 __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
var _a, _b, _c;
Object.defineProperty(exports, "__esModule", { value: true });
exports.WrapperCache = void 0;
var base_1 = require("./base");
var celo_tokens_1 = require("./celo-tokens");
var Accounts_1 = require("./wrappers/Accounts");
var Attestations_1 = require("./wrappers/Attestations");
var BlockchainParameters_1 = require("./wrappers/BlockchainParameters");
var DoubleSigningSlasher_1 = require("./wrappers/DoubleSigningSlasher");
var DowntimeSlasher_1 = require("./wrappers/DowntimeSlasher");
var Election_1 = require("./wrappers/Election");
var EpochRewards_1 = require("./wrappers/EpochRewards");
var Erc20Wrapper_1 = require("./wrappers/Erc20Wrapper");
var Escrow_1 = require("./wrappers/Escrow");
var Exchange_1 = require("./wrappers/Exchange");
var FederatedAttestations_1 = require("./wrappers/FederatedAttestations");
var Freezer_1 = require("./wrappers/Freezer");
var GasPriceMinimum_1 = require("./wrappers/GasPriceMinimum");
var GoldTokenWrapper_1 = require("./wrappers/GoldTokenWrapper");
var Governance_1 = require("./wrappers/Governance");
var GrandaMento_1 = require("./wrappers/GrandaMento");
var LockedGold_1 = require("./wrappers/LockedGold");
var MetaTransactionWallet_1 = require("./wrappers/MetaTransactionWallet");
var MetaTransactionWalletDeployer_1 = require("./wrappers/MetaTransactionWalletDeployer");
var MultiSig_1 = require("./wrappers/MultiSig");
var OdisPayments_1 = require("./wrappers/OdisPayments");
var Reserve_1 = require("./wrappers/Reserve");
var SortedOracles_1 = require("./wrappers/SortedOracles");
var StableTokenRegistry_1 = require("./wrappers/StableTokenRegistry");
var StableTokenWrapper_1 = require("./wrappers/StableTokenWrapper");
var Validators_1 = require("./wrappers/Validators");
var WrapperFactories = (_a = {},
    _a[base_1.CeloContract.Accounts] = Accounts_1.AccountsWrapper,
    _a[base_1.CeloContract.BlockchainParameters] = BlockchainParameters_1.BlockchainParametersWrapper,
    _a[base_1.CeloContract.EpochRewards] = EpochRewards_1.EpochRewardsWrapper,
    _a[base_1.CeloContract.ERC20] = Erc20Wrapper_1.Erc20Wrapper,
    _a[base_1.CeloContract.Escrow] = Escrow_1.EscrowWrapper,
    _a[base_1.CeloContract.Exchange] = Exchange_1.ExchangeWrapper,
    _a[base_1.CeloContract.ExchangeEUR] = Exchange_1.ExchangeWrapper,
    _a[base_1.CeloContract.ExchangeBRL] = Exchange_1.ExchangeWrapper,
    _a[base_1.CeloContract.FederatedAttestations] = FederatedAttestations_1.FederatedAttestationsWrapper,
    // [CeloContract.FeeCurrencyWhitelist]: FeeCurrencyWhitelistWrapper,
    _a[base_1.CeloContract.Freezer] = Freezer_1.FreezerWrapper,
    _a[base_1.CeloContract.GasPriceMinimum] = GasPriceMinimum_1.GasPriceMinimumWrapper,
    _a[base_1.CeloContract.GoldToken] = GoldTokenWrapper_1.GoldTokenWrapper,
    _a[base_1.CeloContract.GrandaMento] = GrandaMento_1.GrandaMentoWrapper,
    // [CeloContract.Random]: RandomWrapper,
    // [CeloContract.Registry]: RegistryWrapper,
    _a[base_1.CeloContract.MetaTransactionWallet] = MetaTransactionWallet_1.MetaTransactionWalletWrapper,
    _a[base_1.CeloContract.MetaTransactionWalletDeployer] = MetaTransactionWalletDeployer_1.MetaTransactionWalletDeployerWrapper,
    _a[base_1.CeloContract.MultiSig] = MultiSig_1.MultiSigWrapper,
    _a[base_1.CeloContract.OdisPayments] = OdisPayments_1.OdisPaymentsWrapper,
    _a[base_1.CeloContract.Reserve] = Reserve_1.ReserveWrapper,
    _a[base_1.CeloContract.StableToken] = StableTokenWrapper_1.StableTokenWrapper,
    _a[base_1.CeloContract.StableTokenEUR] = StableTokenWrapper_1.StableTokenWrapper,
    _a[base_1.CeloContract.StableTokenBRL] = StableTokenWrapper_1.StableTokenWrapper,
    _a[base_1.CeloContract.StableTokenRegistry] = StableTokenRegistry_1.StableTokenRegistryWrapper,
    _a);
var WithRegistry = (_b = {},
    _b[base_1.CeloContract.SortedOracles] = SortedOracles_1.SortedOraclesWrapper,
    _b);
var WrapperFactoriesWhichNeedCache = (_c = {},
    _c[base_1.CeloContract.Attestations] = Attestations_1.AttestationsWrapper,
    _c[base_1.CeloContract.DoubleSigningSlasher] = DoubleSigningSlasher_1.DoubleSigningSlasherWrapper,
    _c[base_1.CeloContract.DowntimeSlasher] = DowntimeSlasher_1.DowntimeSlasherWrapper,
    _c[base_1.CeloContract.Election] = Election_1.ElectionWrapper,
    _c[base_1.CeloContract.Governance] = Governance_1.GovernanceWrapper,
    _c[base_1.CeloContract.LockedGold] = LockedGold_1.LockedGoldWrapper,
    _c[base_1.CeloContract.Validators] = Validators_1.ValidatorsWrapper,
    _c);
var contractsWhichRequireCache = new Set(Object.keys(WrapperFactoriesWhichNeedCache));
/**
 * Kit ContractWrappers factory & cache.
 *
 * Provides access to all contract wrappers for celo core contracts
 *
 * @remarks
 *
 * Because it provides access to all contract wrappers it must load all wrappers and the contract ABIs for them
 * Consider Using {@link MiniWrapperCache}, building your own, or if you only need one Wrapper using it directly
 */
var WrapperCache = /** @class */ (function () {
    function WrapperCache(connection, _web3Contracts, registry) {
        this.connection = connection;
        this._web3Contracts = _web3Contracts;
        this.registry = registry;
        this.wrapperCache = {};
    }
    WrapperCache.prototype.getAccounts = function () {
        return this.getContract(base_1.CeloContract.Accounts);
    };
    WrapperCache.prototype.getAttestations = function () {
        return this.getContract(base_1.CeloContract.Attestations);
    };
    WrapperCache.prototype.getBlockchainParameters = function () {
        return this.getContract(base_1.CeloContract.BlockchainParameters);
    };
    WrapperCache.prototype.getDoubleSigningSlasher = function () {
        return this.getContract(base_1.CeloContract.DoubleSigningSlasher);
    };
    WrapperCache.prototype.getDowntimeSlasher = function () {
        return this.getContract(base_1.CeloContract.DowntimeSlasher);
    };
    WrapperCache.prototype.getElection = function () {
        return this.getContract(base_1.CeloContract.Election);
    };
    WrapperCache.prototype.getEpochRewards = function () {
        return this.getContract(base_1.CeloContract.EpochRewards);
    };
    WrapperCache.prototype.getErc20 = function (address) {
        return this.getContract(base_1.CeloContract.ERC20, address);
    };
    WrapperCache.prototype.getEscrow = function () {
        return this.getContract(base_1.CeloContract.Escrow);
    };
    WrapperCache.prototype.getExchange = function (stableToken) {
        if (stableToken === void 0) { stableToken = celo_tokens_1.StableToken.cUSD; }
        return this.getContract(celo_tokens_1.stableTokenInfos[stableToken].exchangeContract);
    };
    WrapperCache.prototype.getFreezer = function () {
        return this.getContract(base_1.CeloContract.Freezer);
    };
    WrapperCache.prototype.getFederatedAttestations = function () {
        return this.getContract(base_1.CeloContract.FederatedAttestations);
    };
    WrapperCache.prototype.getGasPriceMinimum = function () {
        return this.getContract(base_1.CeloContract.GasPriceMinimum);
    };
    WrapperCache.prototype.getGoldToken = function () {
        return this.getContract(base_1.CeloContract.GoldToken);
    };
    WrapperCache.prototype.getGovernance = function () {
        return this.getContract(base_1.CeloContract.Governance);
    };
    WrapperCache.prototype.getGrandaMento = function () {
        return this.getContract(base_1.CeloContract.GrandaMento);
    };
    WrapperCache.prototype.getLockedGold = function () {
        return this.getContract(base_1.CeloContract.LockedGold);
    };
    WrapperCache.prototype.getMetaTransactionWallet = function (address) {
        return this.getContract(base_1.CeloContract.MetaTransactionWallet, address);
    };
    WrapperCache.prototype.getMetaTransactionWalletDeployer = function (address) {
        return this.getContract(base_1.CeloContract.MetaTransactionWalletDeployer, address);
    };
    WrapperCache.prototype.getMultiSig = function (address) {
        return this.getContract(base_1.CeloContract.MultiSig, address);
    };
    WrapperCache.prototype.getOdisPayments = function () {
        return this.getContract(base_1.CeloContract.OdisPayments);
    };
    WrapperCache.prototype.getReserve = function () {
        return this.getContract(base_1.CeloContract.Reserve);
    };
    WrapperCache.prototype.getSortedOracles = function () {
        return this.getContract(base_1.CeloContract.SortedOracles);
    };
    WrapperCache.prototype.getStableToken = function (stableToken) {
        if (stableToken === void 0) { stableToken = celo_tokens_1.StableToken.cUSD; }
        return this.getContract(celo_tokens_1.stableTokenInfos[stableToken].contract);
    };
    WrapperCache.prototype.getValidators = function () {
        return this.getContract(base_1.CeloContract.Validators);
    };
    WrapperCache.prototype.getStableTokenRegistry = function () {
        return this.getContract(base_1.CeloContract.StableTokenRegistry);
    };
    /**
     * Get Contract wrapper
     */
    WrapperCache.prototype.getContract = function (contract, address) {
        return __awaiter(this, void 0, void 0, function () {
            var instance, Klass, contractName, Klass, wrapper, simpleContractName, Klass;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        if (!(this.wrapperCache[contract] == null || address !== undefined)) return [3 /*break*/, 2];
                        return [4 /*yield*/, this._web3Contracts.getContract(contract, address)];
                    case 1:
                        instance = _a.sent();
                        if (contract === base_1.CeloContract.SortedOracles) {
                            Klass = WithRegistry[base_1.CeloContract.SortedOracles];
                            this.wrapperCache[base_1.CeloContract.SortedOracles] = new Klass(this.connection, instance, this.registry);
                        }
                        else if (contractsWhichRequireCache.has(contract)) {
                            contractName = contract;
                            Klass = WrapperFactoriesWhichNeedCache[contractName];
                            wrapper = new Klass(this.connection, instance, this);
                            this.wrapperCache[contractName] = wrapper;
                        }
                        else {
                            simpleContractName = contract;
                            Klass = WrapperFactories[simpleContractName];
                            this.wrapperCache[simpleContractName] = new Klass(this.connection, instance);
                        }
                        _a.label = 2;
                    case 2: return [2 /*return*/, this.wrapperCache[contract]];
                }
            });
        });
    };
    WrapperCache.prototype.invalidateContract = function (contract) {
        this._web3Contracts.invalidateContract(contract);
        this.wrapperCache[contract] = undefined;
    };
    return WrapperCache;
}());
exports.WrapperCache = WrapperCache;
//# sourceMappingURL=contract-cache.js.map

Выполнить команду


Для локальной разработки. Не используйте в интернете!