@exodus/balances 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,19 @@
1
+ import { TxSet } from '@exodus/models'
2
+
3
+ const isUnconfirmedTx = (tx) => tx.pending && !tx.error
4
+
5
+ const getTxSetBalance = (txSet) => txSet.getMutations().slice(-1)[0].balance
6
+
7
+ const getUnconfirmedTotal = ({ assets, asset, txLog }) => {
8
+ const unconfirmedTxs = [...txLog].filter(isUnconfirmedTx)
9
+ return unconfirmedTxs.length === 0
10
+ ? asset.currency.ZERO
11
+ : getTxSetBalance(TxSet.fromArray(unconfirmedTxs, { assets }))
12
+ }
13
+
14
+ const getConfirmedBalance = ({ assets, asset, txLog, balance }) => {
15
+ const unconfirmedTotal = getUnconfirmedTotal({ assets, asset, txLog })
16
+ return balance.sub(unconfirmedTotal)
17
+ }
18
+
19
+ export default getConfirmedBalance
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/balances",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "balances",
5
5
  "author": "Exodus Movement Inc",
6
6
  "license": "UNLICENSED",
@@ -10,7 +10,8 @@
10
10
  "lint:fix": "yarn lint --fix"
11
11
  },
12
12
  "files": [
13
- "index.js"
13
+ "index.js",
14
+ "confirmed-balance.js"
14
15
  ],
15
16
  "repository": {
16
17
  "type": "git",
@@ -36,5 +37,5 @@
36
37
  "@exodus/models": "^8.9.0",
37
38
  "@exodus/storage-memory": "*"
38
39
  },
39
- "gitHead": "d03a2b5e5e85e7ffdd3720b22eee00e49f591824"
40
+ "gitHead": "9ef26663a0f2415380d7bebc4c97acfbe8be35f0"
40
41
  }