@exodus/fiat-balances 1.0.0 → 1.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.
Files changed (2) hide show
  1. package/index.js +13 -18
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -6,18 +6,15 @@ import { difference, set } from 'lodash'
6
6
  class FiatBalances extends ExodusModule {
7
7
  #assetsModule
8
8
  #balanceFields
9
- #ratesMonitor
10
9
  #fiatCurrency
11
10
  #cachedRates
12
11
  #enabledAssetsData
13
12
  #latestAssetBalances = null
14
- #initialized = false
15
- #balances = {
16
- // totals: Object,
17
- // byWalletAccount: Object,
18
- // byAssetSource: Object,
19
- // byBaseAssetSource: Object,
20
- }
13
+ #balances = Object.create(null)
14
+ // #balances.totals: Object,
15
+ // #balances.byWalletAccount: Object,
16
+ // #balances.byAssetSource: Object,
17
+ // #balances.byBaseAssetSource: Object,
21
18
 
22
19
  constructor({ assetsModule, logger, balances, balanceFields, ratesMonitor, enabledAssets }) {
23
20
  super({ name: 'FiatBalances', logger })
@@ -70,7 +67,7 @@ class FiatBalances extends ExodusModule {
70
67
 
71
68
  const balances = this.#latestAssetBalances
72
69
  const { byAssetSource, byBaseAssetSource, byWalletAccount } = this.#balances
73
- const { enabledAssets = {} } = this.#enabledAssetsData || {}
70
+ const { enabledAssets = Object.create(null) } = this.#enabledAssetsData || Object.create(null)
74
71
  Object.keys(balances).forEach((walletAccount) => {
75
72
  const walletAccountBalances = balances[walletAccount]
76
73
  this.#balanceFields.forEach((field) => {
@@ -155,22 +152,20 @@ class FiatBalances extends ExodusModule {
155
152
  )
156
153
  })
157
154
 
158
- this.#initialized = true
159
155
  this.sync()
160
156
  }
161
157
 
162
158
  #reset = () => {
163
- this.#initialized = false
164
-
165
- const byWalletAccount = {}
166
- const byAssetSource = {}
167
- const byBaseAssetSource = {}
168
- this.#balances = {
169
- totals: {},
159
+ const totals = Object.create(null)
160
+ const byWalletAccount = Object.create(null)
161
+ const byAssetSource = Object.create(null)
162
+ const byBaseAssetSource = Object.create(null)
163
+ this.#balances = Object.assign(Object.create(null), {
164
+ totals,
170
165
  byWalletAccount,
171
166
  byAssetSource,
172
167
  byBaseAssetSource,
173
- }
168
+ })
174
169
  }
175
170
 
176
171
  sync = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/fiat-balances",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "module to track fiat balances based on changes in crypto balances and fiat currency",
5
5
  "author": "Exodus Movement Inc",
6
6
  "license": "UNLICENSED",