@exodus/fiat-balances 4.0.0 → 5.0.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [5.0.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/fiat-balances@4.0.0...@exodus/fiat-balances@5.0.0) (2023-04-25)
7
+
8
+ ### ⚠ BREAKING CHANGES
9
+
10
+ - use atoms in fiat balances (#1355)
11
+ - replace emit with atom in balances module (#1349)
12
+
13
+ ### Features
14
+
15
+ - replace emit with atom in balances module ([#1349](https://github.com/ExodusMovement/exodus-hydra/issues/1349)) ([f9110f8](https://github.com/ExodusMovement/exodus-hydra/commit/f9110f8e9e76b8b199bc4d40461cb1bed3a5be1e))
16
+ - use atoms in fiat balances ([#1355](https://github.com/ExodusMovement/exodus-hydra/issues/1355)) ([3bbdb4d](https://github.com/ExodusMovement/exodus-hydra/commit/3bbdb4d0a956151d9e4895d2445cf8deee19dd09))
17
+
6
18
  ## [4.0.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/fiat-balances@3.0.0...@exodus/fiat-balances@4.0.0) (2023-02-02)
7
19
 
8
20
  ### ⚠ BREAKING CHANGES
@@ -0,0 +1,5 @@
1
+ import { createInMemoryAtom } from '@exodus/atoms'
2
+
3
+ const createFiatBalancesAtom = () => createInMemoryAtom()
4
+
5
+ export default createFiatBalancesAtom
package/atoms/index.js ADDED
@@ -0,0 +1,8 @@
1
+ import createFiatBalancesAtom from './fiat-balances'
2
+
3
+ export const fiatBalancesAtomDefinition = {
4
+ id: 'fiatBalancesAtom',
5
+ type: 'atom',
6
+ factory: createFiatBalancesAtom,
7
+ dependencies: [],
8
+ }
package/module/index.js CHANGED
@@ -16,6 +16,7 @@ class FiatBalances extends ExodusModule {
16
16
  #latestAssetBalances = null
17
17
  #enabledAssetsData = Object.create(null)
18
18
  #balances = Object.create(null)
19
+ #fiatBalancesAtom
19
20
  // #balances.totals: Object,
20
21
  // #balances.byWalletAccount: Object,
21
22
  // #balances.byAssetSource: Object,
@@ -24,17 +25,20 @@ class FiatBalances extends ExodusModule {
24
25
  constructor({
25
26
  assetsModule,
26
27
  logger,
27
- balances,
28
+ balancesAtom,
28
29
  config: { balanceFields },
29
30
  ratesMonitor,
30
31
  enabledAssetsAtom,
32
+ fiatBalancesAtom,
31
33
  }) {
32
34
  super({ name: MODULE_ID, logger })
33
35
 
34
36
  this.#assetsModule = assetsModule
35
37
  this.#balanceFields = balanceFields
38
+ this.#fiatBalancesAtom = fiatBalancesAtom
36
39
 
37
- balances.on('balances', this.#setBalances)
40
+ // eslint-disable-next-line hydra/module-side-effects
41
+ balancesAtom.observe(this.#setBalances)
38
42
 
39
43
  ratesMonitor.on('rates', ({ rates, currency }) => {
40
44
  this._logger.log('recomputing based on new rates and/or fiat currency')
@@ -144,6 +148,7 @@ class FiatBalances extends ExodusModule {
144
148
 
145
149
  this._logger.log('recomputing based on new balances')
146
150
 
151
+ // TODO set changes to fiatBalancesAtom as well
147
152
  const { byWalletAccount, byAssetSource, byBaseAssetSource } = this.#balances
148
153
  Object.entries(changes).forEach(([walletAccount, walletAccountBalancesChanges]) => {
149
154
  const walletAccountBalances = byWalletAccount[walletAccount]
@@ -202,7 +207,7 @@ class FiatBalances extends ExodusModule {
202
207
  )
203
208
  })
204
209
 
205
- this.sync()
210
+ this.#flush()
206
211
  }
207
212
 
208
213
  #reset = () => {
@@ -218,9 +223,9 @@ class FiatBalances extends ExodusModule {
218
223
  })
219
224
  }
220
225
 
221
- sync = () => {
226
+ #flush = () => {
222
227
  this._logger.log('fiat balances updated')
223
- this.emit('fiat-balances', { balances: this.#balances })
228
+ this.#fiatBalancesAtom.set({ balances: this.#balances })
224
229
  }
225
230
  }
226
231
 
@@ -233,7 +238,8 @@ export default {
233
238
  dependencies: [
234
239
  'assetsModule',
235
240
  'logger',
236
- 'balances',
241
+ 'balancesAtom',
242
+ 'fiatBalancesAtom',
237
243
  'config',
238
244
  'ratesMonitor',
239
245
  'enabledAssetsAtom',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/fiat-balances",
3
- "version": "4.0.0",
3
+ "version": "5.0.0",
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",
@@ -31,11 +31,11 @@
31
31
  "lodash": "^4.17.21"
32
32
  },
33
33
  "devDependencies": {
34
- "@exodus/atoms": "^2.10.0",
35
- "@exodus/balances": "^4.0.0",
36
- "@exodus/basic-utils": "^1.0.0",
34
+ "@exodus/atoms": "^3.5.0",
35
+ "@exodus/balances": "^5.0.0",
36
+ "@exodus/basic-utils": "^2.0.0",
37
37
  "@exodus/blockchain-metadata": "*",
38
- "@exodus/enabled-assets": "^5.0.0",
38
+ "@exodus/enabled-assets": "^5.0.4",
39
39
  "@exodus/models": "^8.9.0",
40
40
  "@exodus/storage-memory": "^1.0.0",
41
41
  "@exodus/wallet-accounts": "*",
@@ -43,5 +43,5 @@
43
43
  "events": "^3.3.0",
44
44
  "jest": "^29.1.2"
45
45
  },
46
- "gitHead": "a72d79cc75c6c02876d745a498bf28b256d7f99e"
46
+ "gitHead": "990b8c6a59d2145d55fd43bd622bd8770c710ab2"
47
47
  }