UNPKG

@mutants/cardano-tx-builder

Version:

A package that provides utility functions to build and destructure a cardano transaction

28 lines (27 loc) 846 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.prepareBoundedBytes = void 0; const prepareBoundedBytes = (str) => { const strChunks = str.match(/.{1,64}/g); const strArray = strChunks?.map((addrPart) => Buffer.from(addrPart)); if (!strArray) { throw new Error("Invalid bounded bytes string - " + str); } if (strArray.length === 1) { return Buffer.from(str); } /** * We have to split the addr into an indefinite length byte * that contains N chunks of 64 bytes */ strArray.encodeCBOR = (gen) => { gen.push("5f", "hex"); for (const buffer of strArray) { gen.pushAny(buffer); } gen.push("ff", "hex"); return true; }; return strArray; }; exports.prepareBoundedBytes = prepareBoundedBytes;