@ledgerhq/coin-aptos
Version:
Ledger Aptos Coin integration
21 lines • 889 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getBalances = void 0;
const constants_1 = require("../constants");
async function getBalances(aptosClient, address, contract_address) {
const balances = await aptosClient.getBalances(address, contract_address);
return balances.map(balance => {
const isNative = balance.contractAddress === constants_1.APTOS_ASSET_ID;
const type = balance.contractAddress.split("::").length === 3
? constants_1.TOKEN_TYPE.COIN
: constants_1.TOKEN_TYPE.FUNGIBLE_ASSET;
return {
value: BigInt(balance.amount.toString()),
asset: isNative
? { type: "native" }
: { type: type, assetReference: balance.contractAddress },
};
});
}
exports.getBalances = getBalances;
//# sourceMappingURL=getBalances.js.map