UNPKG

tokamak-staking-lib

Version:
44 lines (43 loc) 1.57 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const web3_connector_1 = __importDefault(require("../common/web3-connector")); const Layer2RegistryABI = require("./abi/Layer2Registry.json"); class Layer2Registry { constructor() { const web3 = web3_connector_1.default.instance().web3; this._contract = new web3.eth.Contract(Layer2RegistryABI, Layer2Registry._address); } static instance() { if (!Layer2Registry._instance) { Layer2Registry._instance = new Layer2Registry(); } return Layer2Registry._instance; } static setNetwork(net) { switch (net) { case "mainnet": Layer2Registry._address = "0x0b3E174A2170083e770D5d4Cf56774D221b7063e"; break; case "rinkeby": Layer2Registry._address = "0x4d031C0E74cE863F3885342C4FF6B6557449f068"; break; } } static get address() { return Layer2Registry._address; } async numLayer2s() { return Number(await this._contract.methods.numLayer2s().call()); } layer2ByIndex(index) { return this._contract.methods.layer2ByIndex(index).call(); } layer2s(layer2) { return this._contract.methods.layer2s(layer2).call(); } } exports.default = Layer2Registry; Layer2Registry._address = "0x0b3E174A2170083e770D5d4Cf56774D221b7063e";