@exodus/balances 12.3.0 → 12.4.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 +6 -0
- package/index.js +7 -9
- package/package.json +2 -2
- package/plugins/analytics.js +19 -0
- package/plugins/index.js +11 -44
- package/plugins/lifecycle.js +40 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
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
|
+
## [12.4.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/balances@12.3.0...@exodus/balances@12.4.0) (2024-01-08)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **balances:** analytics plugin ([#5287](https://github.com/ExodusMovement/exodus-hydra/issues/5287)) ([91de7ba](https://github.com/ExodusMovement/exodus-hydra/commit/91de7ba2fc0563f49b1a5e39dd5546cea4415a6b))
|
|
11
|
+
|
|
6
12
|
## [12.3.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/balances@12.2.0...@exodus/balances@12.3.0) (2024-01-05)
|
|
7
13
|
|
|
8
14
|
### Features
|
package/index.js
CHANGED
|
@@ -5,17 +5,11 @@ import {
|
|
|
5
5
|
fundedWalletAccountsAtomDefinition,
|
|
6
6
|
} from './atoms'
|
|
7
7
|
import balancesReportDefinition from './report'
|
|
8
|
-
import
|
|
8
|
+
import { balancesLifecyclePluginDefinition, balancesAnalyticsPluginDefinition } from './plugins'
|
|
9
9
|
import typeforce from '@exodus/typeforce'
|
|
10
10
|
|
|
11
11
|
const balances = (config) => {
|
|
12
|
-
typeforce(
|
|
13
|
-
{
|
|
14
|
-
balanceFields: typeforce.arrayOf('String'),
|
|
15
|
-
},
|
|
16
|
-
config,
|
|
17
|
-
true
|
|
18
|
-
)
|
|
12
|
+
typeforce({ balanceFields: typeforce.arrayOf('String') }, config, true)
|
|
19
13
|
|
|
20
14
|
return {
|
|
21
15
|
id: 'balances',
|
|
@@ -32,7 +26,11 @@ const balances = (config) => {
|
|
|
32
26
|
},
|
|
33
27
|
{ definition: fundedWalletAccountsAtomDefinition },
|
|
34
28
|
{ definition: balancesReportDefinition },
|
|
35
|
-
{ definition:
|
|
29
|
+
{ definition: balancesLifecyclePluginDefinition },
|
|
30
|
+
{
|
|
31
|
+
if: { registered: ['analytics'] },
|
|
32
|
+
definition: balancesAnalyticsPluginDefinition,
|
|
33
|
+
},
|
|
36
34
|
],
|
|
37
35
|
}
|
|
38
36
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/balances",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.4.0",
|
|
4
4
|
"description": "Tracks crypto balances across enabled wallet accounts.",
|
|
5
5
|
"author": "Exodus Movement Inc.",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"jest": "^29.1.2",
|
|
59
59
|
"redux": "^4.2.1"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "15dba244250d5c1ceec8432a96c781a19a70aaf0"
|
|
62
62
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const createBalancesAnalyticsPlugin = ({ analytics, hasBalanceAtom }) => {
|
|
2
|
+
let unsubscribe
|
|
3
|
+
|
|
4
|
+
const onStart = () => {
|
|
5
|
+
analytics.setDefaultProperties({ hasBalance: false })
|
|
6
|
+
|
|
7
|
+
unsubscribe = hasBalanceAtom.observe((hasBalance) => {
|
|
8
|
+
analytics.setDefaultProperties({ hasBalance })
|
|
9
|
+
})
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const onStop = () => {
|
|
13
|
+
unsubscribe?.()
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return { onStart, onStop }
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default createBalancesAnalyticsPlugin
|
package/plugins/index.js
CHANGED
|
@@ -1,49 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import createBalancesAnalyticsPlugin from './analytics'
|
|
2
|
+
import createBalancesLifecyclePlugin from './lifecycle'
|
|
2
3
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
port,
|
|
6
|
-
atom: balancesAtom,
|
|
7
|
-
event: 'balances',
|
|
8
|
-
})
|
|
9
|
-
balancesAtomObserver.register()
|
|
10
|
-
|
|
11
|
-
const hasBalanceAtomObserver = createAtomObserver({
|
|
12
|
-
port,
|
|
13
|
-
atom: hasBalanceAtom,
|
|
14
|
-
event: 'hasBalance',
|
|
15
|
-
})
|
|
16
|
-
hasBalanceAtomObserver.register()
|
|
17
|
-
|
|
18
|
-
const onLoad = () => {
|
|
19
|
-
hasBalanceAtomObserver.start()
|
|
20
|
-
balancesAtomObserver.start()
|
|
21
|
-
|
|
22
|
-
balances.load()
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const onStop = () => {
|
|
26
|
-
balancesAtomObserver.unregister()
|
|
27
|
-
hasBalanceAtomObserver.unregister()
|
|
28
|
-
balances.stop()
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const onClear = async () => {
|
|
32
|
-
await hasBalanceAtom.set(undefined)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return {
|
|
36
|
-
onLoad,
|
|
37
|
-
onStop,
|
|
38
|
-
onClear,
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const balancesPluginDefinition = {
|
|
43
|
-
id: 'balancesPlugin',
|
|
4
|
+
export const balancesLifecyclePluginDefinition = {
|
|
5
|
+
id: 'balancesLifecyclePlugin',
|
|
44
6
|
type: 'plugin',
|
|
45
|
-
factory:
|
|
7
|
+
factory: createBalancesLifecyclePlugin,
|
|
46
8
|
dependencies: ['balancesAtom', 'port', 'balances', 'hasBalanceAtom'],
|
|
47
9
|
}
|
|
48
10
|
|
|
49
|
-
export
|
|
11
|
+
export const balancesAnalyticsPluginDefinition = {
|
|
12
|
+
id: 'balancesAnalyticsPlugin',
|
|
13
|
+
type: 'plugin',
|
|
14
|
+
factory: createBalancesAnalyticsPlugin,
|
|
15
|
+
dependencies: ['analytics', 'hasBalanceAtom'],
|
|
16
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createAtomObserver } from '@exodus/atoms'
|
|
2
|
+
|
|
3
|
+
const createBalancesLifecyclePlugin = ({ balancesAtom, port, balances, hasBalanceAtom }) => {
|
|
4
|
+
const balancesAtomObserver = createAtomObserver({
|
|
5
|
+
port,
|
|
6
|
+
atom: balancesAtom,
|
|
7
|
+
event: 'balances',
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
const hasBalanceAtomObserver = createAtomObserver({
|
|
11
|
+
port,
|
|
12
|
+
atom: hasBalanceAtom,
|
|
13
|
+
event: 'hasBalance',
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
const onLoad = () => {
|
|
17
|
+
hasBalanceAtomObserver.start()
|
|
18
|
+
balancesAtomObserver.start()
|
|
19
|
+
|
|
20
|
+
balances.load()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const onStop = () => {
|
|
24
|
+
balancesAtomObserver.unregister()
|
|
25
|
+
hasBalanceAtomObserver.unregister()
|
|
26
|
+
balances.stop()
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const onClear = async () => {
|
|
30
|
+
await hasBalanceAtom.set(undefined)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
onLoad,
|
|
35
|
+
onStop,
|
|
36
|
+
onClear,
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default createBalancesLifecyclePlugin
|