Skip to content

Commit

Permalink
Use updated accounthistorycount rpc
Browse files Browse the repository at this point in the history
  • Loading branch information
helloscoopa committed Jan 19, 2023
1 parent 277ccef commit 2388960
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
14 changes: 7 additions & 7 deletions apps/whale-api/src/module.api/consortium.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,31 +306,31 @@ describe('getTransactionHistory', () => {
mintLimit: '40.00000000'
}])

txIds.push(await alice.rpc.token.mintTokens(`0.5@${symbolBTC}`))
txIds.push(await bob.rpc.token.mintTokens(`0.5@${symbolBTC}`))
txIds.push(await alice.rpc.token.mintTokens({ amounts: [`0.5@${symbolBTC}`] }))
txIds.push(await bob.rpc.token.mintTokens({ amounts: [`0.5@${symbolBTC}`] }))
await alice.generate(1)
await bob.generate(1)
await tGroup.waitForSync()

txIds.push(await alice.rpc.token.mintTokens(`0.1@${symbolBTC}`))
txIds.push(await alice.rpc.token.mintTokens({ amounts: [`0.1@${symbolBTC}`] }))
txIds.push(await alice.rpc.token.burnTokens(`0.1@${symbolBTC}`, accountAlice))
txIds.push(await bob.rpc.token.mintTokens(`0.1@${symbolBTC}`))
txIds.push(await bob.rpc.token.mintTokens({ amounts: [`0.1@${symbolBTC}`] }))
txIds.push(await bob.rpc.token.burnTokens(`0.1@${symbolBTC}`, accountBob))
await alice.generate(1)
await bob.generate(1)
await tGroup.waitForSync()

await alice.rpc.token.mintTokens(`1@${symbolBTC}`)
await alice.rpc.token.mintTokens({ amounts: [`1@${symbolBTC}`] })
await alice.generate(1)

await alice.rpc.token.mintTokens(`2@${symbolETH}`)
await alice.rpc.token.mintTokens({ amounts: [`2@${symbolETH}`] })
await alice.generate(1)

await alice.rpc.token.burnTokens(`1@${symbolETH}`, accountAlice)
await alice.generate(1)
await tGroup.waitForSync()

await bob.rpc.token.mintTokens(`4@${symbolBTC}`)
await bob.rpc.token.mintTokens({ amounts: [`4@${symbolBTC}`] })
await bob.generate(1)

await bob.rpc.token.burnTokens(`2@${symbolBTC}`, accountBob)
Expand Down
14 changes: 4 additions & 10 deletions apps/whale-api/src/module.api/consortium.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,22 +100,16 @@ export class ConsortiumService {
}

private async getPaginatedHistoryTransactionsResponse (pageIndex: number, limit: number, members: MemberDetail[]): Promise<ConsortiumTransactionResponse> {
const transactions: AccountHistory[] = await this.rpcClient.account.listAccountHistory(members.map(m => m.ownerAddress), {
const memberAddresses = members.map(m => m.ownerAddress)

const transactions: AccountHistory[] = await this.rpcClient.account.listAccountHistory(memberAddresses, {
txtypes: [DfTxType.MINT_TOKEN, DfTxType.BURN_TOKEN],
including_start: true,
start: pageIndex * limit,
limit
})

const promises = []
for (let i = 0; i < members.length; i++) {
promises.push(this.rpcClient.account.historyCount(members[i].ownerAddress, { txtype: DfTxType.BURN_TOKEN }))
promises.push(this.rpcClient.account.historyCount(members[i].ownerAddress, { txtype: DfTxType.MINT_TOKEN }))
}
const counts = await Promise.all(promises)
const totalTxCount = counts.reduce((prev, curr) => {
return prev + curr
}, 0)
const totalTxCount = await this.rpcClient.account.historyCount(memberAddresses, { txtypes: [DfTxType.BURN_TOKEN, DfTxType.MINT_TOKEN] })

return {
transactions: transactions.map(tx => {
Expand Down

0 comments on commit 2388960

Please sign in to comment.