Skip to content

Commit

Permalink
Group api call at beginning (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
sleyter93 authored Nov 16, 2023
1 parent cd9bfc4 commit 4d725ef
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/rifWalletServices/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rsksmart/rif-wallet-services",
"version": "1.1.0",
"version": "1.1.1",
"description": "RIF Wallet Services library",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
19 changes: 9 additions & 10 deletions packages/rifWalletServices/src/RifWalletServicesSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,15 @@ export class RifWalletServicesSocket
const blockNumber = this.cache.get(cacheBlockNumberText) || '0'
const catchedTxs = this.cache.get(cacheTxsText) || []

const fetchedTransactions = await fetcher.fetchTransactionsByAddress(
address,
null,
null,
blockNumber,
)
const [fetchedTokens, fetchedTransactions] = await Promise.all([
fetcher.fetchTokensByAddress(address),
fetcher.fetchTransactionsByAddress(
address,
null,
null,
blockNumber,
)
])

let lastBlockNumber = blockNumber
const activityTransactions = await Promise.all(
Expand Down Expand Up @@ -97,10 +100,6 @@ export class RifWalletServicesSocket
this.cache.set(cacheTxsText, transactions)
this.cache.set(cacheBlockNumberText, lastBlockNumber.toString())

const fetchedTokens = await fetcher?.fetchTokensByAddress(
address,
)

this.emit('init', {
transactions: transactions,
balances: fetchedTokens,
Expand Down

0 comments on commit 4d725ef

Please sign in to comment.