UNPKG

@celo/explorer

Version:
39 lines 2.03 kB
"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()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.mapFromPairs = exports.obtainKitContractDetails = exports.getContractDetailsFromContract = void 0; const async_1 = require("@celo/base/lib/async"); const getContractDetailsFromContract = (kit, celoContract, address) => __awaiter(void 0, void 0, void 0, function* () { const contract = yield kit._web3Contracts.getContract(celoContract, address); return { name: celoContract, address: address !== null && address !== void 0 ? address : contract.options.address, jsonInterface: contract.options.jsonInterface, isCore: true, }; }); exports.getContractDetailsFromContract = getContractDetailsFromContract; function obtainKitContractDetails(kit) { return __awaiter(this, void 0, void 0, function* () { const registry = yield kit.registry.addressMapping(); return (0, async_1.concurrentMap)(5, Array.from(registry.entries()), ([celoContract, address]) => (0, exports.getContractDetailsFromContract)(kit, celoContract, address)); }); } exports.obtainKitContractDetails = obtainKitContractDetails; function mapFromPairs(pairs) { const map = new Map(); pairs.forEach(([k, v]) => { map.set(k, v); }); return map; } exports.mapFromPairs = mapFromPairs; //# sourceMappingURL=base.js.map