{"version":3,"file":"parse.mjs","names":[],"sources":["../../../src/predict/reads/parse.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n// BCS decoders for the return values of on-chain reads, built on the\n// `@mysten/sui/bcs` codec so the read layer decodes exactly the on-chain Move ABI\n// (u64 LE, vector<ID>, Option) with no hand-rolled byte walking. Round-tripped\n// against `@mysten/sui/bcs` in tests/reads.test.ts.\n\nimport { bcs } from '@mysten/sui/bcs';\n\n// BCS u64 → bigint. `bcs.u64()` parses to a decimal string.\nexport function parseU64LE(bytes: Uint8Array): bigint {\n\treturn BigInt(bcs.u64().parse(bytes));\n}\n\n// BCS vector<ID> / vector<address> → full-length 0x lowercase ids\n// (`bcs.Address` already yields normalized ids).\nexport function parseVectorOfIds(bytes: Uint8Array): string[] {\n\treturn bcs.vector(bcs.Address).parse(bytes);\n}\n\n// BCS Option<u64>: None → null, Some(x) → x.\nexport function parseOptionalU64(bytes: Uint8Array): bigint | null {\n\tconst v = bcs.option(bcs.u64()).parse(bytes);\n\treturn v == null ? null : BigInt(v);\n}\n\n// BCS Option<ID>: None → null, Some(id) → normalized 0x id.\nexport function parseOptionalId(bytes: Uint8Array): string | null {\n\treturn bcs.option(bcs.Address).parse(bytes);\n}\n"],"mappings":";;;AAUA,SAAgB,WAAW,OAA2B;AACrD,QAAO,OAAO,IAAI,KAAK,CAAC,MAAM,MAAM,CAAC;;AAKtC,SAAgB,iBAAiB,OAA6B;AAC7D,QAAO,IAAI,OAAO,IAAI,QAAQ,CAAC,MAAM,MAAM;;AAI5C,SAAgB,iBAAiB,OAAkC;CAClE,MAAM,IAAI,IAAI,OAAO,IAAI,KAAK,CAAC,CAAC,MAAM,MAAM;AAC5C,QAAO,KAAK,OAAO,OAAO,OAAO,EAAE;;AAIpC,SAAgB,gBAAgB,OAAkC;AACjE,QAAO,IAAI,OAAO,IAAI,QAAQ,CAAC,MAAM,MAAM"}