@exodus/balances 1.0.0 → 1.1.0

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.
Files changed (2) hide show
  1. package/index.js +8 -6
  2. package/package.json +4 -3
package/index.js CHANGED
@@ -21,8 +21,8 @@ class Balances extends ExodusModule {
21
21
  #walletAccounts = null // string[]
22
22
  #ready = false
23
23
 
24
- #oldBalances = {}
25
- #balances = {}
24
+ #oldBalances = Object.create(null)
25
+ #balances = Object.create(null)
26
26
 
27
27
  constructor({ assetsModule, blockchainMetadata, walletAccountsAtom, balanceFields, logger }) {
28
28
  super({ name: 'Balances', logger })
@@ -66,7 +66,7 @@ class Balances extends ExodusModule {
66
66
 
67
67
  #reset = ({ walletAccounts = this.#walletAccounts } = {}) => {
68
68
  walletAccounts.forEach((walletAccount) => {
69
- this.#balances[walletAccount] = {}
69
+ this.#balances[walletAccount] = Object.create(null)
70
70
  })
71
71
  }
72
72
 
@@ -101,12 +101,12 @@ class Balances extends ExodusModule {
101
101
  }
102
102
 
103
103
  #getBalancesForWalletAccount = async ({ walletAccount }) => {
104
- const assetNames = this.#assetsModule.getBaseAssetNames()
104
+ const assetNames = this.#getSupportedAssetNames()
105
105
  const balances = await Promise.all(
106
106
  assetNames.map((assetName) => this.#getBalancesForAssetSource({ assetName, walletAccount }))
107
107
  )
108
108
 
109
- return merge({}, ...balances)
109
+ return merge(Object.create(null), ...balances)
110
110
  }
111
111
 
112
112
  #load = async ({ walletAccount }) => {
@@ -143,6 +143,8 @@ class Balances extends ExodusModule {
143
143
  }
144
144
 
145
145
  #isSupportedAsset = (assetName) => !this.#getAsset(assetName).isCombined
146
+ #getSupportedAssetNames = () =>
147
+ Object.keys(this.#assetsModule.getAssets()).filter(this.#isSupportedAsset)
146
148
 
147
149
  #isHistoryBasedBalanceAsset = (assetName) => {
148
150
  const asset = this.#getAsset(assetName)
@@ -183,7 +185,7 @@ class Balances extends ExodusModule {
183
185
 
184
186
  const accountBalances = this.#balances[walletAccount]
185
187
  const newBalances = this.#getBalancesFromBlockchainMetadata({ assetName, accountState, txLog })
186
- const changes = {}
188
+ const changes = Object.create(null)
187
189
  for (let subAssetName in newBalances) {
188
190
  const { currency } = this.#getAsset(subAssetName)
189
191
  const newAssetBalances = newBalances?.[subAssetName]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/balances",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "balances",
5
5
  "author": "Exodus Movement Inc",
6
6
  "license": "UNLICENSED",
@@ -28,7 +28,8 @@
28
28
  },
29
29
  "devDependencies": {
30
30
  "@exodus/atoms": "^1.0.0",
31
- "@exodus/basic-utils": "^0.7.0",
31
+ "@exodus/basic-utils": "^1.0.0",
32
32
  "@exodus/models": "^8.9.0"
33
- }
33
+ },
34
+ "gitHead": "8dc3595d4bd5750bdf649fafef7fd5d9dd345824"
34
35
  }