Skip to content

Commit

Permalink
fix: GET_ACCOUNT_INFO output based on details
Browse files Browse the repository at this point in the history
  • Loading branch information
iccicci committed Dec 11, 2024
1 parent f2e7457 commit 71b2afa
Show file tree
Hide file tree
Showing 3 changed files with 532 additions and 34 deletions.
20 changes: 11 additions & 9 deletions src/methods/get-account-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const getAccountInfo = async (
},
};

if (details === 'txs' || details === 'txids') {
if (['tokenBalances', 'txids', 'txs'].includes(details)) {
const [externalAddresses, internalAddresses] = await Promise.all([
discoverAddresses(publicKey, 0, accountEmpty),
discoverAddresses(publicKey, 1, accountEmpty),
Expand All @@ -111,14 +111,16 @@ export const getAccountInfo = async (
if (details === 'txids') {
// set only txids
accountInfo.history.txids = requestedPageTxIds.map(t => t.tx_hash);
} else if (details === 'txs') {
// fetch full transaction objects and set account.history.transactions
const txs = await txIdsToTransactions(
requestedPageTxIds.map(item => ({ address: item.address, txIds: [item.tx_hash] })),
cbor,
);

accountInfo.history.transactions = txs;
} else {
if (details === 'txs') {
// fetch full transaction objects and set account.history.transactions
const txs = await txIdsToTransactions(
requestedPageTxIds.map(item => ({ address: item.address, txIds: [item.tx_hash] })),
cbor,
);

accountInfo.history.transactions = txs;
}

// fetch data for each address and set account.addresses
const accountAddresses = await getAccountAddressesData(
Expand Down
Loading

0 comments on commit 71b2afa

Please sign in to comment.