UNPKG

@ton-community/tlb-runtime

Version:

TL‑B Runtime is a library for parsing and (de)serializing data according to TL‑B schemas

31 lines (30 loc) 932 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parseCell = parseCell; exports.encodeCell = encodeCell; exports.replacer = replacer; const core_1 = require("@ton/core"); const TLBRuntime_1 = require("./TLBRuntime"); function parseCell(schema, data) { return (0, TLBRuntime_1.parseTLB)(schema).parseCell(data); } function encodeCell(schema, data) { return (0, TLBRuntime_1.parseTLB)(schema).encodeCell(data); } // FIXME // eslint-disable-next-line @typescript-eslint/no-explicit-any function replacer(_key, value) { if (typeof value === 'bigint') { return value.toString(); } else if (value instanceof core_1.Address) { return value.toString(); } else if (value instanceof core_1.BitString) { return value.toString(); } else if (value instanceof core_1.Cell) { return value.toBoc().toString('base64'); } return value; }