@ledgerhq/coin-canton
Version:
31 lines • 1.38 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getBalance = getBalance;
const config_1 = __importDefault(require("../../config"));
const gateway_1 = require("../../network/gateway");
const gateway_2 = require("../../network/gateway");
const getNativeId = (currency) => config_1.default.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,
};
}
async function getBalance(currency, partyId) {
if ((0, gateway_1.isGatewayEnabled)(currency)) {
const balances = await (0, gateway_2.getBalance)(currency, partyId);
return balances.map(instrument => adaptInstrument(currency, instrument));
}
else
throw new Error("Not implemented");
}
//# sourceMappingURL=getBalance.js.map