@broxus/locklift-network
Version:
In-memory TVM-blockchain emulator for locklift
68 lines (67 loc) • 2.84 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 (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.bocFromShardAccount = exports.shardAccountFromBoc = exports.parseBlocks = void 0;
const nt = __importStar(require("nekoton-wasm"));
const core_1 = require("@ton/core");
const parseBlocks = (input) => {
const blocks = input.trim().split(/(?=stack: \[)/); // разбиваем на блоки
return blocks.map((block, idx) => {
const stackMatch = block.match(/stack:\s*\[(.*?)\]/s);
const stack = stackMatch ? stackMatch[1].trim().split(/\s+/) : [];
const codeMatch = block.match(/code cell hash:\s*([a-f0-9]+):(\d+):\d+/i);
const cmdCodeCellHash = codeMatch?.[1] || "";
const cmdCodeOffset = codeMatch?.[2] || "";
const execMatch = block.match(/execute\s+(.*)/i);
const cmdStr = execMatch?.[1]?.trim() || "";
return {
infoType: "Normal",
step: idx + 1,
cmdStr,
stack,
cmdCodeCellHash,
cmdCodeOffset,
gasCmd: "0",
gasUsed: "0",
cmdCodeHex: "",
cmdCodeRemBits: "",
};
});
};
exports.parseBlocks = parseBlocks;
const shardAccountFromBoc = (boc, lastTxLt) => {
const a = nt.parseFullAccountBoc(boc);
const acc = a?.boc ? (0, core_1.loadAccount)(core_1.Cell.fromBase64(a.boc).beginParse()) : null;
return {
account: acc,
lastTransactionHash: 0n,
lastTransactionLt: lastTxLt || acc?.storage.lastTransLt || 0n,
};
};
exports.shardAccountFromBoc = shardAccountFromBoc;
const bocFromShardAccount = (shardAccount) => {
return (0, core_1.beginCell)().store((0, core_1.storeShardAccount)(shardAccount)).endCell().toBoc().toString("base64");
};
exports.bocFromShardAccount = bocFromShardAccount;