@exodus/balances
Advanced tools
Comparing version 1.2.1 to 2.0.0
36
index.js
@@ -6,2 +6,3 @@ import { isNumberUnit } from '@exodus/currency' | ||
import makeConcurrent from 'make-concurrent' | ||
import getConfirmedBalance from './confirmed-balance' | ||
@@ -49,8 +50,9 @@ const cloneBalances = (balances) => | ||
blockchainMetadata.on('loaded', () => { | ||
walletAccountsAtom.observe((payload) => | ||
blockchainMetadata.once('load-wallet-accounts', () => { | ||
walletAccountsAtom.observe((payload) => { | ||
this.#setWalletAccounts( | ||
Object.keys(payload).filter((walletAccount) => payload[walletAccount].enabled) | ||
) | ||
) | ||
}) | ||
blockchainMetadata.on('account-state', this.#handleAccountStateUpdate) | ||
@@ -109,3 +111,29 @@ blockchainMetadata.on('tx-log', this.#handleTxLogUpdate) | ||
const txLog = txLogsByAssetName[assetName] | ||
return asset.api.getBalances({ asset, accountState, txLog }) | ||
const balances = asset.api.getBalances({ asset, accountState, txLog }) | ||
if (!balances || isEmpty(balances)) return null | ||
if (balances.balance && this.#balanceFields.includes('confirmedBalance')) { | ||
balances.confirmedBalance = getConfirmedBalance({ | ||
assets: this.#getAssets(), | ||
asset, | ||
txLog, | ||
balance: balances.balance, | ||
}) | ||
} | ||
const negativeBalanceFields = Object.keys(balances).filter( | ||
(field) => balances[field]?.isNegative | ||
) | ||
if (negativeBalanceFields.length > 0) { | ||
this._logger.warn('unexpected negative balance', { | ||
assetName, | ||
accountState, | ||
txLogsByAssetName, | ||
balances, | ||
negativeBalanceFields, | ||
}) | ||
} | ||
return balances | ||
} | ||
@@ -112,0 +140,0 @@ |
{ | ||
"name": "@exodus/balances", | ||
"version": "1.2.1", | ||
"version": "2.0.0", | ||
"description": "balances", | ||
@@ -29,8 +29,13 @@ "author": "Exodus Movement Inc", | ||
}, | ||
"peerDependencies": { | ||
"@exodus/blockchain-metadata": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"@exodus/atoms": "^1.0.0", | ||
"@exodus/atoms": "^2.3.0", | ||
"@exodus/basic-utils": "^1.0.0", | ||
"@exodus/models": "^8.9.0" | ||
"@exodus/blockchain-metadata": "*", | ||
"@exodus/models": "^8.9.0", | ||
"@exodus/storage-memory": "*" | ||
}, | ||
"gitHead": "03c583ee3f8e75c54871f0da68dd15dd336da09b" | ||
"gitHead": "d03a2b5e5e85e7ffdd3720b22eee00e49f591824" | ||
} |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
12027
249
5
5
1