@broxus/locklift-network
Version:
In-memory TVM-blockchain emulator for locklift
89 lines (88 loc) • 3.29 kB
JavaScript
;
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 () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__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);
}
enableTraces() {
this._executor.enableTraces();
}
disableTraces() {
this._executor.disableTraces();
}
}
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);
}
}