Skip to content

Commit

Permalink
Merge pull request #160 from Juneo-io/dev
Browse files Browse the repository at this point in the history
v0.0.125
  • Loading branch information
alekswaslet authored Jul 16, 2024
2 parents 983350a + 3e57073 commit 68396c5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "juneojs",
"version": "0.0.124",
"version": "0.0.125",
"description": "Juneo JS Library",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
16 changes: 11 additions & 5 deletions src/wallet/account/mcn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,20 +219,26 @@ export class MCNAccount {
}

async verifySpendings (summary: OperationSummary): Promise<Spending[]> {
const spendings: Map<string, Spending> = sortSpendings(summary.spendings)
const spendings = sortSpendings(summary.spendings)
const promises: Array<Promise<void>> = []
for (const spending of spendings.values()) {
const assetId: string = spending.assetId
const account: ChainAccount = this.getAccount(spending.chain.id)
const assetId = spending.assetId
const account = this.getAccount(spending.chain.id)
if (account.getAmount(assetId) < spending.amount || account.balances.get(assetId)!.shouldUpdate()) {
promises.push(account.fetchBalance(assetId))
}
}
await Promise.all(promises)
const faulty: Spending[] = []
const isStakingOperation =
summary.operation.type === NetworkOperationType.ValidatePrimary ||
summary.operation.type === NetworkOperationType.DelegatePrimary
for (const spending of spendings.values()) {
const account: ChainAccount = this.getAccount(spending.chain.id)
if (spending.amount > account.getAmount(spending.assetId)) {
const account = this.getAccount(spending.chain.id)
const amount = isStakingOperation
? (account as UtxoAccount).getStakeableAmount(spending.assetId)
: account.getAmount(spending.assetId)
if (spending.amount > amount) {
faulty.push(spending)
}
}
Expand Down

0 comments on commit 68396c5

Please sign in to comment.