UNPKG

@broxus/locklift-network

Version:

In-memory TVM-blockchain emulator for locklift

73 lines (72 loc) 2.83 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.LockliftNetwork = void 0; const nt = __importStar(require("nekoton-wasm")); const executor_1 = require("./internal/executor"); const transport_1 = require("./internal/transport"); class LockliftNetwork { _transport; _connectionFactory; _executor; constructor(config) { this._transport = new transport_1.LockliftTransport(config?.networkConfig); this._executor = new executor_1.LockliftExecutor(this._transport, config?.accountFetcher); const _onClock = (clock) => { this._executor.setClock(clock); }; this._connectionFactory = new ProxyConnectionFactory(this._transport, _onClock); } async initialize() { await this._executor.initialize(); } setAccount = (...params) => this._executor.setAccount(...params); saveSnapshot = (...params) => this._executor.saveSnapshot(...params); loadSnapshot = (...params) => this._executor.loadSnapshot(...params); clearSnapshots = (...params) => this._executor.clearSnapshots(...params); resetBlockchainState = (...params) => this._executor.resetBlockchainState(...params); get connectionFactory() { return this._connectionFactory; } getBlockchainConfig() { return this._transport.getBlockchainConfig(); } getTxTrace(txHash) { return this._executor.getTxTrace(txHash); } } exports.LockliftNetwork = LockliftNetwork; class ProxyConnectionFactory { transport; clockHandler; constructor(transport, clockHandler) { this.transport = transport; this.clockHandler = clockHandler; } create(clock) { this.clockHandler(clock); return new nt.ProxyConnection(this.transport); } }