UNPKG

@mutants/cardano-tx-builder

Version:

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

25 lines (24 loc) 889 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.decodeAssetMap = void 0; const decodeAssetMap = (encodedAssetMap) => { const assetMap = {}; for (const key of encodedAssetMap.keys()) { const policyId = key.toString("hex"); if (!assetMap[policyId]) { assetMap[policyId] = {}; } const policyAssetsMap = encodedAssetMap.get(key); if (policyAssetsMap) { for (const asset of policyAssetsMap.keys()) { const quantity = policyAssetsMap.get(asset); const assetName = asset.toString("hex"); if (typeof quantity === "bigint" || typeof quantity === "number") { assetMap[policyId][assetName] = BigInt(quantity); } } } } return assetMap; }; exports.decodeAssetMap = decodeAssetMap;