UNPKG

@ledgerhq/coin-canton

Version:
25 lines 1.12 kB
import coinConfig from "../../config"; import { isGatewayEnabled } from "../../network/gateway"; import { getBalance as gatewayGetBalance } from "../../network/gateway"; const getNativeId = (currency) => coinConfig.getCoinConfig(currency.id).nativeInstrumentId; function adaptInstrument(currency, instrument) { return { value: BigInt(instrument.amount), locked: instrument.locked === true ? BigInt(instrument.amount) : BigInt(0), asset: getNativeId(currency) === instrument.instrument_id ? { type: getNativeId(currency) } : { type: "token", assetReference: instrument.instrument_id }, utxoCount: instrument.utxo_count, instrumentId: instrument.instrument_id, adminId: instrument.admin_id, }; } export async function getBalance(currency, partyId) { if (isGatewayEnabled(currency)) { const balances = await gatewayGetBalance(currency, partyId); return balances.map(instrument => adaptInstrument(currency, instrument)); } else throw new Error("Not implemented"); } //# sourceMappingURL=getBalance.js.map