@exodus/balances 13.16.1 → 13.17.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/atoms/asset-names-with-balance.d.ts +1 -0
- package/atoms/asset-names-with-balance.js +1 -40
- package/atoms/asset-total-wallet-amounts.d.ts +1 -0
- package/atoms/asset-total-wallet-amounts.js +1 -47
- package/atoms/assets-with-balance-count.d.ts +1 -0
- package/atoms/assets-with-balance-count.js +1 -8
- package/atoms/balances.d.ts +1 -0
- package/atoms/balances.js +1 -6
- package/atoms/funded-wallet-accounts.d.ts +1 -0
- package/atoms/funded-wallet-accounts.js +1 -25
- package/atoms/has-balance.d.ts +1 -0
- package/atoms/has-balance.js +1 -31
- package/atoms/index.d.ts +8 -0
- package/atoms/index.js +8 -54
- package/default-config.d.ts +1 -0
- package/default-config.js +1 -26
- package/index.d.ts +2 -35
- package/index.js +1 -65
- package/lib/atoms/asset-names-with-balance.d.ts +5 -0
- package/lib/atoms/asset-names-with-balance.js +31 -0
- package/lib/atoms/asset-total-wallet-amounts.d.ts +5 -0
- package/lib/atoms/asset-total-wallet-amounts.js +39 -0
- package/lib/atoms/assets-with-balance-count.d.ts +5 -0
- package/lib/atoms/assets-with-balance-count.js +6 -0
- package/lib/atoms/balances.d.ts +3 -0
- package/lib/atoms/balances.js +3 -0
- package/lib/atoms/funded-wallet-accounts.d.ts +8 -0
- package/lib/atoms/funded-wallet-accounts.js +19 -0
- package/lib/atoms/has-balance.d.ts +7 -0
- package/lib/atoms/has-balance.js +21 -0
- package/lib/atoms/index.d.ts +54 -0
- package/lib/atoms/index.js +48 -0
- package/lib/default-config.d.ts +3 -0
- package/lib/default-config.js +24 -0
- package/lib/index.d.ts +187 -0
- package/lib/index.js +49 -0
- package/lib/module/balances-utils.d.ts +13 -0
- package/lib/module/balances-utils.js +70 -0
- package/lib/module/index.d.ts +11 -0
- package/lib/module/index.js +367 -0
- package/lib/module/mockable-balances.d.ts +16 -0
- package/lib/module/mockable-balances.js +21 -0
- package/lib/module/types.d.ts +80 -0
- package/lib/module/types.js +1 -0
- package/lib/plugins/analytics.d.ts +18 -0
- package/lib/plugins/analytics.js +30 -0
- package/lib/plugins/index.d.ts +35 -0
- package/lib/plugins/index.js +22 -0
- package/lib/plugins/lifecycle.d.ts +14 -0
- package/lib/plugins/lifecycle.js +32 -0
- package/lib/redux/id.d.ts +2 -0
- package/lib/redux/id.js +1 -0
- package/lib/redux/index.d.ts +588 -0
- package/lib/redux/index.js +53 -0
- package/lib/redux/initial-state.d.ts +3 -0
- package/lib/redux/initial-state.js +6 -0
- package/lib/redux/multi-account-helper.d.ts +463 -0
- package/lib/redux/multi-account-helper.js +23 -0
- package/lib/redux/selectors/by-asset.d.ts +12 -0
- package/lib/redux/selectors/by-asset.js +19 -0
- package/lib/redux/selectors/create-balance-selectors.d.ts +70 -0
- package/lib/redux/selectors/create-balance-selectors.js +32 -0
- package/lib/redux/selectors/create-balances.d.ts +11 -0
- package/lib/redux/selectors/create-balances.js +13 -0
- package/lib/redux/selectors/create-fuel-threshold.d.ts +19 -0
- package/lib/redux/selectors/create-fuel-threshold.js +22 -0
- package/lib/redux/selectors/create-requires-fuel-threshold.d.ts +19 -0
- package/lib/redux/selectors/create-requires-fuel-threshold.js +29 -0
- package/lib/redux/selectors/create-unconfirmed-balance.d.ts +15 -0
- package/lib/redux/selectors/create-unconfirmed-balance.js +14 -0
- package/lib/redux/selectors/get-balance-for-field.d.ts +14 -0
- package/lib/redux/selectors/get-balance-for-field.js +19 -0
- package/lib/redux/selectors/get-balance-selectors.d.ts +68 -0
- package/lib/redux/selectors/get-balance-selectors.js +32 -0
- package/lib/redux/selectors/get-balances.d.ts +10 -0
- package/lib/redux/selectors/get-balances.js +13 -0
- package/lib/redux/selectors/get-unconfirmed-balance.d.ts +19 -0
- package/lib/redux/selectors/get-unconfirmed-balance.js +27 -0
- package/lib/redux/selectors/index.d.ts +339 -0
- package/lib/redux/selectors/index.js +22 -0
- package/lib/redux/types.d.ts +45 -0
- package/lib/redux/types.js +1 -0
- package/lib/report/index.d.ts +34 -0
- package/lib/report/index.js +51 -0
- package/lib/types.d.ts +24 -0
- package/lib/types.js +1 -0
- package/module/balances-utils.d.ts +1 -0
- package/module/balances-utils.js +1 -86
- package/module/index.d.ts +2 -0
- package/module/index.js +2 -497
- package/module/mockable-balances.d.ts +1 -0
- package/module/mockable-balances.js +1 -27
- package/package.json +23 -17
- package/plugins/analytics.d.ts +1 -0
- package/plugins/analytics.js +1 -48
- package/plugins/index.d.ts +4 -0
- package/plugins/index.js +4 -24
- package/plugins/lifecycle.d.ts +1 -0
- package/plugins/lifecycle.js +1 -40
- package/redux/id.d.ts +1 -0
- package/redux/id.js +1 -1
- package/redux/index.d.ts +2 -0
- package/redux/index.js +1 -61
- package/redux/initial-state.d.ts +1 -0
- package/redux/initial-state.js +1 -8
- package/redux/multi-account-helper.d.ts +1 -0
- package/redux/multi-account-helper.js +1 -14
- package/redux/selectors/by-asset.d.ts +1 -0
- package/redux/selectors/by-asset.js +1 -25
- package/redux/selectors/create-balance-selectors.d.ts +1 -0
- package/redux/selectors/create-balance-selectors.js +1 -48
- package/redux/selectors/create-balances.d.ts +1 -0
- package/redux/selectors/create-balances.js +1 -26
- package/redux/selectors/create-fuel-threshold.d.ts +1 -0
- package/redux/selectors/create-fuel-threshold.js +1 -32
- package/redux/selectors/create-requires-fuel-threshold.d.ts +1 -0
- package/redux/selectors/create-requires-fuel-threshold.js +1 -59
- package/redux/selectors/create-unconfirmed-balance.d.ts +1 -0
- package/redux/selectors/create-unconfirmed-balance.js +1 -28
- package/redux/selectors/get-balance-for-field.d.ts +1 -0
- package/redux/selectors/get-balance-for-field.js +1 -34
- package/redux/selectors/get-balance-selectors.d.ts +1 -0
- package/redux/selectors/get-balance-selectors.js +1 -42
- package/redux/selectors/get-balances.d.ts +1 -0
- package/redux/selectors/get-balances.js +1 -24
- package/redux/selectors/get-unconfirmed-balance.d.ts +2 -0
- package/redux/selectors/get-unconfirmed-balance.js +2 -43
- package/redux/selectors/index.d.ts +1 -0
- package/redux/selectors/index.js +1 -23
- package/report/index.d.ts +1 -0
- package/report/index.js +1 -61
- package/tsconfig.json +0 -8
|
@@ -0,0 +1,463 @@
|
|
|
1
|
+
import type { BalanceAsset, FieldBalances } from '../module/types.js';
|
|
2
|
+
declare const helper: {
|
|
3
|
+
createInitialState: () => import("@exodus/multi-account-redux").SliceState<FieldBalances>;
|
|
4
|
+
getAccount: (state: import("@exodus/multi-account-redux").SliceState<FieldBalances>, walletAccount: string) => import("@exodus/multi-account-redux").AccountState<FieldBalances> | undefined;
|
|
5
|
+
updateAccount: <TAssetData_1 = unknown>(state: import("@exodus/multi-account-redux").SliceState<TAssetData_1>, walletAccount: string, update: Partial<import("@exodus/multi-account-redux").AccountState<TAssetData_1>>) => import("@exodus/multi-account-redux").SliceState<TAssetData_1>;
|
|
6
|
+
mergeAccountsData: <TAssetData_1 = unknown>(state: import("@exodus/multi-account-redux").SliceState<TAssetData_1>, payload: Record<string, import("@exodus/multi-account-redux").PerAssetData<TAssetData_1>>) => import("@exodus/multi-account-redux").SliceState<TAssetData_1>;
|
|
7
|
+
setAccounts: <TAssetData_1 = unknown>(state: import("@exodus/multi-account-redux").SliceState<TAssetData_1>, valuesByAccount: Record<string, import("@exodus/multi-account-redux").PerAssetData<TAssetData_1>>) => import("@exodus/multi-account-redux").SliceState<TAssetData_1>;
|
|
8
|
+
resetAccount: (state: import("@exodus/multi-account-redux").SliceState<FieldBalances>, walletAccount: string) => import("@exodus/multi-account-redux").SliceState<FieldBalances>;
|
|
9
|
+
setLoaded: <TAssetData_1 = unknown>(state: import("@exodus/multi-account-redux").SliceState<TAssetData_1>, walletAccount: string, data?: import("@exodus/multi-account-redux").PerAssetData<TAssetData_1>) => import("@exodus/multi-account-redux").SliceState<TAssetData_1>;
|
|
10
|
+
setLoading: <TAssetData_1 = unknown>(state: import("@exodus/multi-account-redux").SliceState<TAssetData_1>, walletAccount: string) => import("@exodus/multi-account-redux").SliceState<TAssetData_1>;
|
|
11
|
+
setLoadingError: (state: import("@exodus/multi-account-redux").SliceState<FieldBalances>, walletAccount: string, error: unknown) => import("@exodus/multi-account-redux").SliceState<FieldBalances>;
|
|
12
|
+
getAssets: (state: import("@exodus/multi-account-redux").SliceState<FieldBalances>, walletAccount: string) => import("@exodus/multi-account-redux").PerAssetData<FieldBalances> | undefined;
|
|
13
|
+
getAsset: (state: import("@exodus/multi-account-redux").SliceState<FieldBalances>, walletAccount: string, asset: import("@exodus/multi-account-redux").AssetInstance | undefined) => FieldBalances | null | undefined;
|
|
14
|
+
setAsset: <TAssetData_1 = unknown>(state: import("@exodus/multi-account-redux").SliceState<TAssetData_1>, walletAccount: string, assetName: string, value: TAssetData_1) => import("@exodus/multi-account-redux").SliceState<TAssetData_1>;
|
|
15
|
+
resetAsset: (state: import("@exodus/multi-account-redux").SliceState<FieldBalances>, walletAccount: string, asset: BalanceAsset) => import("@exodus/multi-account-redux").SliceState<FieldBalances>;
|
|
16
|
+
selectorDefinitions: readonly [{
|
|
17
|
+
readonly id: "createAssetSourceSelector";
|
|
18
|
+
readonly selectorFactory: <TState>(myStateSelector: (state: TState) => import("@exodus/multi-account-redux").SliceState<FieldBalances>, getAssetInstanceSelector: (state: TState) => (assetName: string) => BalanceAsset) => (source: {
|
|
19
|
+
walletAccount: string;
|
|
20
|
+
assetName: string;
|
|
21
|
+
network?: string;
|
|
22
|
+
}) => (state: TState) => FieldBalances | null | undefined;
|
|
23
|
+
readonly dependencies: readonly [{
|
|
24
|
+
readonly selector: "$state";
|
|
25
|
+
}, {
|
|
26
|
+
readonly module: "assets";
|
|
27
|
+
readonly selector: "getAsset";
|
|
28
|
+
}];
|
|
29
|
+
}, {
|
|
30
|
+
readonly id: "createAssetSourceSelectorOld";
|
|
31
|
+
readonly resultFunction: (myState: import("@exodus/multi-account-redux").SliceState<FieldBalances>, activeWalletAccount: string, getAssetInstance: (assetName: string) => BalanceAsset) => import("@exodus/basic-utils/lib/memoize.js").MemoizedFunction<({ walletAccount, assetName }: Omit<{
|
|
32
|
+
walletAccount: string;
|
|
33
|
+
assetName: string;
|
|
34
|
+
network?: string;
|
|
35
|
+
}, "walletAccount"> & {
|
|
36
|
+
walletAccount?: string;
|
|
37
|
+
}) => FieldBalances | null | undefined>;
|
|
38
|
+
readonly dependencies: readonly [{
|
|
39
|
+
readonly selector: "$state";
|
|
40
|
+
}, {
|
|
41
|
+
readonly module: "walletAccounts";
|
|
42
|
+
readonly selector: "active";
|
|
43
|
+
}, {
|
|
44
|
+
readonly module: "assets";
|
|
45
|
+
readonly selector: "getAsset";
|
|
46
|
+
}];
|
|
47
|
+
}, {
|
|
48
|
+
readonly id: "createBaseAssetSourceSelector";
|
|
49
|
+
readonly selectorFactory: <TState>(myStateSelector: (state: TState) => import("@exodus/multi-account-redux").SliceState<FieldBalances>, getAssetInstanceSelector: (state: TState) => (assetName: string) => BalanceAsset) => (source: {
|
|
50
|
+
walletAccount: string;
|
|
51
|
+
assetName: string;
|
|
52
|
+
network?: string;
|
|
53
|
+
}) => (state: TState) => FieldBalances | null | undefined;
|
|
54
|
+
readonly dependencies: readonly [{
|
|
55
|
+
readonly selector: "$state";
|
|
56
|
+
}, {
|
|
57
|
+
readonly module: "assets";
|
|
58
|
+
readonly selector: "getAsset";
|
|
59
|
+
}];
|
|
60
|
+
}, {
|
|
61
|
+
readonly id: "createBaseAssetSourceSelectorOld";
|
|
62
|
+
readonly resultFunction: (myState: import("@exodus/multi-account-redux").SliceState<FieldBalances>, activeWalletAccount: string, getAssetInstance: (assetName: string) => BalanceAsset) => import("@exodus/basic-utils/lib/memoize.js").MemoizedFunction<({ walletAccount, assetName }: {
|
|
63
|
+
walletAccount: string;
|
|
64
|
+
assetName: string;
|
|
65
|
+
network?: string;
|
|
66
|
+
}) => FieldBalances | null | undefined>;
|
|
67
|
+
readonly dependencies: readonly [{
|
|
68
|
+
readonly selector: "$state";
|
|
69
|
+
}, {
|
|
70
|
+
readonly module: "walletAccounts";
|
|
71
|
+
readonly selector: "active";
|
|
72
|
+
}, {
|
|
73
|
+
readonly module: "assets";
|
|
74
|
+
readonly selector: "getAsset";
|
|
75
|
+
}];
|
|
76
|
+
}, {
|
|
77
|
+
readonly id: "createActiveAssetSourceSelectorOld";
|
|
78
|
+
readonly resultFunction: (activeWalletAccount: string, getAssetInstance: (assetName: string) => BalanceAsset, myState: import("@exodus/multi-account-redux").SliceState<FieldBalances>) => import("@exodus/basic-utils/lib/memoize.js").MemoizedFunction<(assetName: string) => FieldBalances | null | undefined>;
|
|
79
|
+
readonly dependencies: readonly [{
|
|
80
|
+
readonly module: "walletAccounts";
|
|
81
|
+
readonly selector: "active";
|
|
82
|
+
}, {
|
|
83
|
+
readonly module: "assets";
|
|
84
|
+
readonly selector: "getAsset";
|
|
85
|
+
}, {
|
|
86
|
+
readonly selector: "$state";
|
|
87
|
+
}];
|
|
88
|
+
}, {
|
|
89
|
+
readonly id: "createActiveAssetSourceSelector";
|
|
90
|
+
readonly selectorFactory: <TState>(activeWalletAccountSelector: (state: TState) => string, getAssetInstanceSelector: (state: TState) => (assetName: string) => BalanceAsset, myStateSelector: (state: TState) => import("@exodus/multi-account-redux").SliceState<FieldBalances>) => (assetName: string) => (state: TState) => FieldBalances | null | undefined;
|
|
91
|
+
readonly dependencies: readonly [{
|
|
92
|
+
readonly module: "walletAccounts";
|
|
93
|
+
readonly selector: "active";
|
|
94
|
+
}, {
|
|
95
|
+
readonly module: "assets";
|
|
96
|
+
readonly selector: "getAsset";
|
|
97
|
+
}, {
|
|
98
|
+
readonly selector: "$state";
|
|
99
|
+
}];
|
|
100
|
+
}, {
|
|
101
|
+
readonly id: "createActiveBaseAssetSourceSelector";
|
|
102
|
+
readonly selectorFactory: <TState>(activeWalletAccountSelector: (state: TState) => string, getAssetInstanceSelector: (state: TState) => (assetName: string) => BalanceAsset, myStateSelector: (state: TState) => import("@exodus/multi-account-redux").SliceState<FieldBalances>) => (assetName: string) => (state: TState) => FieldBalances | null | undefined;
|
|
103
|
+
readonly dependencies: readonly [{
|
|
104
|
+
readonly module: "walletAccounts";
|
|
105
|
+
readonly selector: "active";
|
|
106
|
+
}, {
|
|
107
|
+
readonly module: "assets";
|
|
108
|
+
readonly selector: "getAsset";
|
|
109
|
+
}, {
|
|
110
|
+
readonly selector: "$state";
|
|
111
|
+
}];
|
|
112
|
+
}, {
|
|
113
|
+
readonly id: "createIsWalletAccountLoadingSelectorOld";
|
|
114
|
+
readonly selectorFactory: <TState>(activeWalletAccountSelector: (state: TState) => string, myStateSelector: (state: TState) => import("@exodus/multi-account-redux").SliceState<FieldBalances>) => (state: TState) => (walletAccount?: string) => boolean;
|
|
115
|
+
readonly dependencies: readonly [{
|
|
116
|
+
readonly module: "walletAccounts";
|
|
117
|
+
readonly selector: "active";
|
|
118
|
+
}, {
|
|
119
|
+
readonly selector: "$state";
|
|
120
|
+
}];
|
|
121
|
+
}, {
|
|
122
|
+
readonly id: "createIsWalletAccountLoadingSelector";
|
|
123
|
+
readonly selectorFactory: <TState>(myStateSelector: (state: TState) => import("@exodus/multi-account-redux").SliceState<FieldBalances>) => (walletAccount: string) => (state: TState) => boolean;
|
|
124
|
+
readonly dependencies: readonly [{
|
|
125
|
+
readonly selector: "$state";
|
|
126
|
+
}];
|
|
127
|
+
}, {
|
|
128
|
+
readonly id: "createIsWalletAccountLoadedSelectorOld";
|
|
129
|
+
readonly resultFunction: (activeWalletAccount: string, subState: import("@exodus/multi-account-redux").SliceState<FieldBalances>) => (walletAccount?: string) => boolean;
|
|
130
|
+
readonly dependencies: readonly [{
|
|
131
|
+
readonly module: "walletAccounts";
|
|
132
|
+
readonly selector: "active";
|
|
133
|
+
}, {
|
|
134
|
+
readonly selector: "$state";
|
|
135
|
+
}];
|
|
136
|
+
}, {
|
|
137
|
+
readonly id: "createIsWalletAccountLoadedSelector";
|
|
138
|
+
readonly selectorFactory: <TState>(myStateSelector: (state: TState) => import("@exodus/multi-account-redux").SliceState<FieldBalances>) => (walletAccount: string) => (state: TState) => boolean;
|
|
139
|
+
readonly dependencies: readonly [{
|
|
140
|
+
readonly selector: "$state";
|
|
141
|
+
}];
|
|
142
|
+
}, {
|
|
143
|
+
readonly id: "isActiveWalletAccountLoading";
|
|
144
|
+
readonly resultFunction: (activeWalletAccount: string, subState: import("@exodus/multi-account-redux").SliceState<FieldBalances>) => boolean;
|
|
145
|
+
readonly dependencies: readonly [{
|
|
146
|
+
readonly module: "walletAccounts";
|
|
147
|
+
readonly selector: "active";
|
|
148
|
+
}, {
|
|
149
|
+
readonly selector: "$state";
|
|
150
|
+
}];
|
|
151
|
+
}, {
|
|
152
|
+
readonly id: "isActiveWalletAccountLoaded";
|
|
153
|
+
readonly resultFunction: (activeWalletAccount: string, subState: import("@exodus/multi-account-redux").SliceState<FieldBalances>) => boolean;
|
|
154
|
+
readonly dependencies: readonly [{
|
|
155
|
+
readonly module: "walletAccounts";
|
|
156
|
+
readonly selector: "active";
|
|
157
|
+
}, {
|
|
158
|
+
readonly selector: "$state";
|
|
159
|
+
}];
|
|
160
|
+
}, {
|
|
161
|
+
readonly id: "createAccountAssetsSelector";
|
|
162
|
+
readonly selectorFactory: <TState>(myStateSelector: (state: TState) => import("@exodus/multi-account-redux").SliceState<FieldBalances>) => (walletAccount: string) => (state: TState) => import("@exodus/multi-account-redux").PerAssetData<FieldBalances> | undefined;
|
|
163
|
+
readonly dependencies: readonly [{
|
|
164
|
+
readonly selector: "$state";
|
|
165
|
+
}];
|
|
166
|
+
}, {
|
|
167
|
+
readonly id: "activeAccountAssetsSelector";
|
|
168
|
+
readonly resultFunction: (myState: import("@exodus/multi-account-redux").SliceState<FieldBalances>, activeAccount: string) => import("@exodus/multi-account-redux").PerAssetData<FieldBalances> | undefined;
|
|
169
|
+
readonly dependencies: readonly [{
|
|
170
|
+
readonly selector: "$state";
|
|
171
|
+
}, {
|
|
172
|
+
readonly module: "walletAccounts";
|
|
173
|
+
readonly selector: "active";
|
|
174
|
+
}];
|
|
175
|
+
}, {
|
|
176
|
+
readonly id: "getAccountAssetsSelector";
|
|
177
|
+
readonly resultFunction: (myState: import("@exodus/multi-account-redux").SliceState<FieldBalances>) => (walletAccount: string) => import("@exodus/multi-account-redux").PerAssetData<FieldBalances> | undefined;
|
|
178
|
+
readonly dependencies: readonly [{
|
|
179
|
+
readonly selector: "$state";
|
|
180
|
+
}];
|
|
181
|
+
}, ...({
|
|
182
|
+
readonly id: "createAccountAssetsBalanceSelector";
|
|
183
|
+
readonly selectorFactory: <TState>(createAccountAssetsSelector: (walletAccount: string) => (state: TState) => import("@exodus/multi-account-redux").PerAssetData<FieldBalances> | undefined) => (walletAccount: string) => (state: TState) => Record<string, import("@exodus/currency").default | undefined>;
|
|
184
|
+
readonly dependencies: readonly [{
|
|
185
|
+
readonly selector: "createAccountAssetsSelector";
|
|
186
|
+
}];
|
|
187
|
+
} | {
|
|
188
|
+
readonly id: "activeAccountAssetsBalanceSelector";
|
|
189
|
+
readonly resultFunction: (accountAssets: import("@exodus/multi-account-redux").PerAssetData<FieldBalances> | undefined) => Record<string, import("@exodus/currency").default | undefined>;
|
|
190
|
+
readonly dependencies: readonly [{
|
|
191
|
+
readonly selector: "activeAccountAssetsSelector";
|
|
192
|
+
}];
|
|
193
|
+
} | {
|
|
194
|
+
readonly id: "getAccountAssetsBalanceSelector";
|
|
195
|
+
readonly resultFunction: (getAccountAssets: (walletAccount: string) => import("@exodus/multi-account-redux").PerAssetData<FieldBalances> | undefined) => import("@exodus/basic-utils/lib/memoize.js").MemoizedFunction<(walletAccount: string) => Record<string, import("@exodus/currency").default | undefined>>;
|
|
196
|
+
readonly dependencies: readonly [{
|
|
197
|
+
readonly selector: "getAccountAssetsSelector";
|
|
198
|
+
}];
|
|
199
|
+
} | {
|
|
200
|
+
readonly id: "createAssetSourceBalanceSelector";
|
|
201
|
+
readonly selectorFactory: <TState>(createAssetSourceSelector: (key: {
|
|
202
|
+
walletAccount: string;
|
|
203
|
+
assetName: string;
|
|
204
|
+
network?: string;
|
|
205
|
+
}) => (state: TState) => FieldBalances | null | undefined) => (source: {
|
|
206
|
+
walletAccount: string;
|
|
207
|
+
assetName: string;
|
|
208
|
+
network?: string;
|
|
209
|
+
}) => (state: TState) => import("@exodus/currency").default | undefined;
|
|
210
|
+
readonly dependencies: readonly [{
|
|
211
|
+
readonly selector: "createAssetSourceSelector";
|
|
212
|
+
}];
|
|
213
|
+
} | {
|
|
214
|
+
readonly id: "createActiveAssetSourceBalanceSelector";
|
|
215
|
+
readonly selectorFactory: <TState>(createActiveAssetSourceSelector: (assetName: string) => (state: TState) => FieldBalances | null | undefined) => (assetName: string) => (state: TState) => import("@exodus/currency").default | undefined;
|
|
216
|
+
readonly dependencies: readonly [{
|
|
217
|
+
readonly selector: "createActiveAssetSourceSelector";
|
|
218
|
+
}];
|
|
219
|
+
} | {
|
|
220
|
+
readonly id: "getAssetSourceBalanceSelector";
|
|
221
|
+
readonly resultFunction: (getAssetSource: (key: {
|
|
222
|
+
walletAccount: string;
|
|
223
|
+
assetName: string;
|
|
224
|
+
network?: string;
|
|
225
|
+
}) => FieldBalances | null | undefined, activeWalletAccount: string) => import("@exodus/basic-utils/lib/memoize.js").MemoizedFunction<({ assetName, walletAccount }: Omit<{
|
|
226
|
+
walletAccount: string;
|
|
227
|
+
assetName: string;
|
|
228
|
+
network?: string;
|
|
229
|
+
}, "walletAccount"> & {
|
|
230
|
+
walletAccount?: string;
|
|
231
|
+
}) => import("@exodus/currency").default | undefined>;
|
|
232
|
+
readonly dependencies: readonly [{
|
|
233
|
+
readonly selector: "createAssetSourceSelectorOld";
|
|
234
|
+
}, {
|
|
235
|
+
readonly module: "walletAccounts";
|
|
236
|
+
readonly selector: "active";
|
|
237
|
+
}];
|
|
238
|
+
})[]];
|
|
239
|
+
};
|
|
240
|
+
export declare const helperSelectorDefinitions: readonly [{
|
|
241
|
+
readonly id: "createAssetSourceSelector";
|
|
242
|
+
readonly selectorFactory: <TState>(myStateSelector: (state: TState) => import("@exodus/multi-account-redux").SliceState<FieldBalances>, getAssetInstanceSelector: (state: TState) => (assetName: string) => BalanceAsset) => (source: {
|
|
243
|
+
walletAccount: string;
|
|
244
|
+
assetName: string;
|
|
245
|
+
network?: string;
|
|
246
|
+
}) => (state: TState) => FieldBalances | null | undefined;
|
|
247
|
+
readonly dependencies: readonly [{
|
|
248
|
+
readonly selector: "$state";
|
|
249
|
+
}, {
|
|
250
|
+
readonly module: "assets";
|
|
251
|
+
readonly selector: "getAsset";
|
|
252
|
+
}];
|
|
253
|
+
}, {
|
|
254
|
+
readonly id: "createAssetSourceSelectorOld";
|
|
255
|
+
readonly resultFunction: (myState: import("@exodus/multi-account-redux").SliceState<FieldBalances>, activeWalletAccount: string, getAssetInstance: (assetName: string) => BalanceAsset) => import("@exodus/basic-utils/lib/memoize.js").MemoizedFunction<({ walletAccount, assetName }: Omit<{
|
|
256
|
+
walletAccount: string;
|
|
257
|
+
assetName: string;
|
|
258
|
+
network?: string;
|
|
259
|
+
}, "walletAccount"> & {
|
|
260
|
+
walletAccount?: string;
|
|
261
|
+
}) => FieldBalances | null | undefined>;
|
|
262
|
+
readonly dependencies: readonly [{
|
|
263
|
+
readonly selector: "$state";
|
|
264
|
+
}, {
|
|
265
|
+
readonly module: "walletAccounts";
|
|
266
|
+
readonly selector: "active";
|
|
267
|
+
}, {
|
|
268
|
+
readonly module: "assets";
|
|
269
|
+
readonly selector: "getAsset";
|
|
270
|
+
}];
|
|
271
|
+
}, {
|
|
272
|
+
readonly id: "createBaseAssetSourceSelector";
|
|
273
|
+
readonly selectorFactory: <TState>(myStateSelector: (state: TState) => import("@exodus/multi-account-redux").SliceState<FieldBalances>, getAssetInstanceSelector: (state: TState) => (assetName: string) => BalanceAsset) => (source: {
|
|
274
|
+
walletAccount: string;
|
|
275
|
+
assetName: string;
|
|
276
|
+
network?: string;
|
|
277
|
+
}) => (state: TState) => FieldBalances | null | undefined;
|
|
278
|
+
readonly dependencies: readonly [{
|
|
279
|
+
readonly selector: "$state";
|
|
280
|
+
}, {
|
|
281
|
+
readonly module: "assets";
|
|
282
|
+
readonly selector: "getAsset";
|
|
283
|
+
}];
|
|
284
|
+
}, {
|
|
285
|
+
readonly id: "createBaseAssetSourceSelectorOld";
|
|
286
|
+
readonly resultFunction: (myState: import("@exodus/multi-account-redux").SliceState<FieldBalances>, activeWalletAccount: string, getAssetInstance: (assetName: string) => BalanceAsset) => import("@exodus/basic-utils/lib/memoize.js").MemoizedFunction<({ walletAccount, assetName }: {
|
|
287
|
+
walletAccount: string;
|
|
288
|
+
assetName: string;
|
|
289
|
+
network?: string;
|
|
290
|
+
}) => FieldBalances | null | undefined>;
|
|
291
|
+
readonly dependencies: readonly [{
|
|
292
|
+
readonly selector: "$state";
|
|
293
|
+
}, {
|
|
294
|
+
readonly module: "walletAccounts";
|
|
295
|
+
readonly selector: "active";
|
|
296
|
+
}, {
|
|
297
|
+
readonly module: "assets";
|
|
298
|
+
readonly selector: "getAsset";
|
|
299
|
+
}];
|
|
300
|
+
}, {
|
|
301
|
+
readonly id: "createActiveAssetSourceSelectorOld";
|
|
302
|
+
readonly resultFunction: (activeWalletAccount: string, getAssetInstance: (assetName: string) => BalanceAsset, myState: import("@exodus/multi-account-redux").SliceState<FieldBalances>) => import("@exodus/basic-utils/lib/memoize.js").MemoizedFunction<(assetName: string) => FieldBalances | null | undefined>;
|
|
303
|
+
readonly dependencies: readonly [{
|
|
304
|
+
readonly module: "walletAccounts";
|
|
305
|
+
readonly selector: "active";
|
|
306
|
+
}, {
|
|
307
|
+
readonly module: "assets";
|
|
308
|
+
readonly selector: "getAsset";
|
|
309
|
+
}, {
|
|
310
|
+
readonly selector: "$state";
|
|
311
|
+
}];
|
|
312
|
+
}, {
|
|
313
|
+
readonly id: "createActiveAssetSourceSelector";
|
|
314
|
+
readonly selectorFactory: <TState>(activeWalletAccountSelector: (state: TState) => string, getAssetInstanceSelector: (state: TState) => (assetName: string) => BalanceAsset, myStateSelector: (state: TState) => import("@exodus/multi-account-redux").SliceState<FieldBalances>) => (assetName: string) => (state: TState) => FieldBalances | null | undefined;
|
|
315
|
+
readonly dependencies: readonly [{
|
|
316
|
+
readonly module: "walletAccounts";
|
|
317
|
+
readonly selector: "active";
|
|
318
|
+
}, {
|
|
319
|
+
readonly module: "assets";
|
|
320
|
+
readonly selector: "getAsset";
|
|
321
|
+
}, {
|
|
322
|
+
readonly selector: "$state";
|
|
323
|
+
}];
|
|
324
|
+
}, {
|
|
325
|
+
readonly id: "createActiveBaseAssetSourceSelector";
|
|
326
|
+
readonly selectorFactory: <TState>(activeWalletAccountSelector: (state: TState) => string, getAssetInstanceSelector: (state: TState) => (assetName: string) => BalanceAsset, myStateSelector: (state: TState) => import("@exodus/multi-account-redux").SliceState<FieldBalances>) => (assetName: string) => (state: TState) => FieldBalances | null | undefined;
|
|
327
|
+
readonly dependencies: readonly [{
|
|
328
|
+
readonly module: "walletAccounts";
|
|
329
|
+
readonly selector: "active";
|
|
330
|
+
}, {
|
|
331
|
+
readonly module: "assets";
|
|
332
|
+
readonly selector: "getAsset";
|
|
333
|
+
}, {
|
|
334
|
+
readonly selector: "$state";
|
|
335
|
+
}];
|
|
336
|
+
}, {
|
|
337
|
+
readonly id: "createIsWalletAccountLoadingSelectorOld";
|
|
338
|
+
readonly selectorFactory: <TState>(activeWalletAccountSelector: (state: TState) => string, myStateSelector: (state: TState) => import("@exodus/multi-account-redux").SliceState<FieldBalances>) => (state: TState) => (walletAccount?: string) => boolean;
|
|
339
|
+
readonly dependencies: readonly [{
|
|
340
|
+
readonly module: "walletAccounts";
|
|
341
|
+
readonly selector: "active";
|
|
342
|
+
}, {
|
|
343
|
+
readonly selector: "$state";
|
|
344
|
+
}];
|
|
345
|
+
}, {
|
|
346
|
+
readonly id: "createIsWalletAccountLoadingSelector";
|
|
347
|
+
readonly selectorFactory: <TState>(myStateSelector: (state: TState) => import("@exodus/multi-account-redux").SliceState<FieldBalances>) => (walletAccount: string) => (state: TState) => boolean;
|
|
348
|
+
readonly dependencies: readonly [{
|
|
349
|
+
readonly selector: "$state";
|
|
350
|
+
}];
|
|
351
|
+
}, {
|
|
352
|
+
readonly id: "createIsWalletAccountLoadedSelectorOld";
|
|
353
|
+
readonly resultFunction: (activeWalletAccount: string, subState: import("@exodus/multi-account-redux").SliceState<FieldBalances>) => (walletAccount?: string) => boolean;
|
|
354
|
+
readonly dependencies: readonly [{
|
|
355
|
+
readonly module: "walletAccounts";
|
|
356
|
+
readonly selector: "active";
|
|
357
|
+
}, {
|
|
358
|
+
readonly selector: "$state";
|
|
359
|
+
}];
|
|
360
|
+
}, {
|
|
361
|
+
readonly id: "createIsWalletAccountLoadedSelector";
|
|
362
|
+
readonly selectorFactory: <TState>(myStateSelector: (state: TState) => import("@exodus/multi-account-redux").SliceState<FieldBalances>) => (walletAccount: string) => (state: TState) => boolean;
|
|
363
|
+
readonly dependencies: readonly [{
|
|
364
|
+
readonly selector: "$state";
|
|
365
|
+
}];
|
|
366
|
+
}, {
|
|
367
|
+
readonly id: "isActiveWalletAccountLoading";
|
|
368
|
+
readonly resultFunction: (activeWalletAccount: string, subState: import("@exodus/multi-account-redux").SliceState<FieldBalances>) => boolean;
|
|
369
|
+
readonly dependencies: readonly [{
|
|
370
|
+
readonly module: "walletAccounts";
|
|
371
|
+
readonly selector: "active";
|
|
372
|
+
}, {
|
|
373
|
+
readonly selector: "$state";
|
|
374
|
+
}];
|
|
375
|
+
}, {
|
|
376
|
+
readonly id: "isActiveWalletAccountLoaded";
|
|
377
|
+
readonly resultFunction: (activeWalletAccount: string, subState: import("@exodus/multi-account-redux").SliceState<FieldBalances>) => boolean;
|
|
378
|
+
readonly dependencies: readonly [{
|
|
379
|
+
readonly module: "walletAccounts";
|
|
380
|
+
readonly selector: "active";
|
|
381
|
+
}, {
|
|
382
|
+
readonly selector: "$state";
|
|
383
|
+
}];
|
|
384
|
+
}, {
|
|
385
|
+
readonly id: "createAccountAssetsSelector";
|
|
386
|
+
readonly selectorFactory: <TState>(myStateSelector: (state: TState) => import("@exodus/multi-account-redux").SliceState<FieldBalances>) => (walletAccount: string) => (state: TState) => import("@exodus/multi-account-redux").PerAssetData<FieldBalances> | undefined;
|
|
387
|
+
readonly dependencies: readonly [{
|
|
388
|
+
readonly selector: "$state";
|
|
389
|
+
}];
|
|
390
|
+
}, {
|
|
391
|
+
readonly id: "activeAccountAssetsSelector";
|
|
392
|
+
readonly resultFunction: (myState: import("@exodus/multi-account-redux").SliceState<FieldBalances>, activeAccount: string) => import("@exodus/multi-account-redux").PerAssetData<FieldBalances> | undefined;
|
|
393
|
+
readonly dependencies: readonly [{
|
|
394
|
+
readonly selector: "$state";
|
|
395
|
+
}, {
|
|
396
|
+
readonly module: "walletAccounts";
|
|
397
|
+
readonly selector: "active";
|
|
398
|
+
}];
|
|
399
|
+
}, {
|
|
400
|
+
readonly id: "getAccountAssetsSelector";
|
|
401
|
+
readonly resultFunction: (myState: import("@exodus/multi-account-redux").SliceState<FieldBalances>) => (walletAccount: string) => import("@exodus/multi-account-redux").PerAssetData<FieldBalances> | undefined;
|
|
402
|
+
readonly dependencies: readonly [{
|
|
403
|
+
readonly selector: "$state";
|
|
404
|
+
}];
|
|
405
|
+
}, ...({
|
|
406
|
+
readonly id: "createAccountAssetsBalanceSelector";
|
|
407
|
+
readonly selectorFactory: <TState>(createAccountAssetsSelector: (walletAccount: string) => (state: TState) => import("@exodus/multi-account-redux").PerAssetData<FieldBalances> | undefined) => (walletAccount: string) => (state: TState) => Record<string, import("@exodus/currency").default | undefined>;
|
|
408
|
+
readonly dependencies: readonly [{
|
|
409
|
+
readonly selector: "createAccountAssetsSelector";
|
|
410
|
+
}];
|
|
411
|
+
} | {
|
|
412
|
+
readonly id: "activeAccountAssetsBalanceSelector";
|
|
413
|
+
readonly resultFunction: (accountAssets: import("@exodus/multi-account-redux").PerAssetData<FieldBalances> | undefined) => Record<string, import("@exodus/currency").default | undefined>;
|
|
414
|
+
readonly dependencies: readonly [{
|
|
415
|
+
readonly selector: "activeAccountAssetsSelector";
|
|
416
|
+
}];
|
|
417
|
+
} | {
|
|
418
|
+
readonly id: "getAccountAssetsBalanceSelector";
|
|
419
|
+
readonly resultFunction: (getAccountAssets: (walletAccount: string) => import("@exodus/multi-account-redux").PerAssetData<FieldBalances> | undefined) => import("@exodus/basic-utils/lib/memoize.js").MemoizedFunction<(walletAccount: string) => Record<string, import("@exodus/currency").default | undefined>>;
|
|
420
|
+
readonly dependencies: readonly [{
|
|
421
|
+
readonly selector: "getAccountAssetsSelector";
|
|
422
|
+
}];
|
|
423
|
+
} | {
|
|
424
|
+
readonly id: "createAssetSourceBalanceSelector";
|
|
425
|
+
readonly selectorFactory: <TState>(createAssetSourceSelector: (key: {
|
|
426
|
+
walletAccount: string;
|
|
427
|
+
assetName: string;
|
|
428
|
+
network?: string;
|
|
429
|
+
}) => (state: TState) => FieldBalances | null | undefined) => (source: {
|
|
430
|
+
walletAccount: string;
|
|
431
|
+
assetName: string;
|
|
432
|
+
network?: string;
|
|
433
|
+
}) => (state: TState) => import("@exodus/currency").default | undefined;
|
|
434
|
+
readonly dependencies: readonly [{
|
|
435
|
+
readonly selector: "createAssetSourceSelector";
|
|
436
|
+
}];
|
|
437
|
+
} | {
|
|
438
|
+
readonly id: "createActiveAssetSourceBalanceSelector";
|
|
439
|
+
readonly selectorFactory: <TState>(createActiveAssetSourceSelector: (assetName: string) => (state: TState) => FieldBalances | null | undefined) => (assetName: string) => (state: TState) => import("@exodus/currency").default | undefined;
|
|
440
|
+
readonly dependencies: readonly [{
|
|
441
|
+
readonly selector: "createActiveAssetSourceSelector";
|
|
442
|
+
}];
|
|
443
|
+
} | {
|
|
444
|
+
readonly id: "getAssetSourceBalanceSelector";
|
|
445
|
+
readonly resultFunction: (getAssetSource: (key: {
|
|
446
|
+
walletAccount: string;
|
|
447
|
+
assetName: string;
|
|
448
|
+
network?: string;
|
|
449
|
+
}) => FieldBalances | null | undefined, activeWalletAccount: string) => import("@exodus/basic-utils/lib/memoize.js").MemoizedFunction<({ assetName, walletAccount }: Omit<{
|
|
450
|
+
walletAccount: string;
|
|
451
|
+
assetName: string;
|
|
452
|
+
network?: string;
|
|
453
|
+
}, "walletAccount"> & {
|
|
454
|
+
walletAccount?: string;
|
|
455
|
+
}) => import("@exodus/currency").default | undefined>;
|
|
456
|
+
readonly dependencies: readonly [{
|
|
457
|
+
readonly selector: "createAssetSourceSelectorOld";
|
|
458
|
+
}, {
|
|
459
|
+
readonly module: "walletAccounts";
|
|
460
|
+
readonly selector: "active";
|
|
461
|
+
}];
|
|
462
|
+
})[]];
|
|
463
|
+
export default helper;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { memoize } from '@exodus/basic-utils';
|
|
2
|
+
import { createReduxModuleHelper } from '@exodus/multi-account-redux';
|
|
3
|
+
import id from './id.js';
|
|
4
|
+
const createInitialPerAssetData = memoize(({ asset }) => ({
|
|
5
|
+
balance: asset.currency.ZERO,
|
|
6
|
+
total: asset.currency.ZERO,
|
|
7
|
+
}), ({ asset }) => asset.name);
|
|
8
|
+
const helper = createReduxModuleHelper({
|
|
9
|
+
slice: id,
|
|
10
|
+
createInitialPerAssetData,
|
|
11
|
+
assetSourceDataSelectors: [
|
|
12
|
+
{
|
|
13
|
+
name: 'balance',
|
|
14
|
+
selector: (assetData) => {
|
|
15
|
+
if (!assetData)
|
|
16
|
+
throw new Error('balances: no data for asset');
|
|
17
|
+
return assetData.total;
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
});
|
|
22
|
+
export const helperSelectorDefinitions = helper.selectorDefinitions;
|
|
23
|
+
export default helper;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type NumberUnit from '@exodus/currency';
|
|
2
|
+
declare const byAssetSelector: {
|
|
3
|
+
readonly id: "byAsset";
|
|
4
|
+
readonly resultFunction: (walletAccounts: string[], getAssetBalances: (account: string) => Record<string, NumberUnit>) => Record<string, NumberUnit>;
|
|
5
|
+
readonly dependencies: readonly [{
|
|
6
|
+
readonly module: "walletAccounts";
|
|
7
|
+
readonly selector: "enabled";
|
|
8
|
+
}, {
|
|
9
|
+
readonly selector: "getAccountAssetsBalanceSelector";
|
|
10
|
+
}];
|
|
11
|
+
};
|
|
12
|
+
export default byAssetSelector;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const resultFunction = (walletAccounts, getAssetBalances) => walletAccounts.reduce((all, walletAccount) => {
|
|
2
|
+
for (const [assetName, balance] of Object.entries(getAssetBalances(walletAccount))) {
|
|
3
|
+
if (!all[assetName]) {
|
|
4
|
+
all[assetName] = balance;
|
|
5
|
+
continue;
|
|
6
|
+
}
|
|
7
|
+
all[assetName] = all[assetName].add(balance);
|
|
8
|
+
}
|
|
9
|
+
return all;
|
|
10
|
+
}, {});
|
|
11
|
+
const byAssetSelector = {
|
|
12
|
+
id: 'byAsset',
|
|
13
|
+
resultFunction,
|
|
14
|
+
dependencies: [
|
|
15
|
+
{ module: 'walletAccounts', selector: 'enabled' },
|
|
16
|
+
{ selector: 'getAccountAssetsBalanceSelector' },
|
|
17
|
+
],
|
|
18
|
+
};
|
|
19
|
+
export default byAssetSelector;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Source, Selector, CreateAssetSelector, State } from '../types.js';
|
|
2
|
+
import lodash from 'lodash';
|
|
3
|
+
declare const createBalanceSelectorFactory: <const Id extends string>({ field, id, }: {
|
|
4
|
+
field: string;
|
|
5
|
+
id: Id;
|
|
6
|
+
}) => {
|
|
7
|
+
readonly id: Id;
|
|
8
|
+
readonly selectorFactory: (createAssetSelector: CreateAssetSelector, selfSelector: Selector<State>) => (({ assetName, walletAccount }: Source) => import("reselect").OutputSelector<unknown, import("@exodus/currency").default | undefined, (res1: import("../types.js").Asset | undefined, res2: State) => import("@exodus/currency").default | undefined>) & lodash.MemoizedFunction;
|
|
9
|
+
readonly dependencies: readonly [{
|
|
10
|
+
readonly module: "assets";
|
|
11
|
+
readonly selector: "createAssetSelector";
|
|
12
|
+
}, {
|
|
13
|
+
readonly selector: "$state";
|
|
14
|
+
}];
|
|
15
|
+
};
|
|
16
|
+
declare const fieldDefinitions: readonly [{
|
|
17
|
+
readonly id: "createTotal";
|
|
18
|
+
readonly field: "total";
|
|
19
|
+
}, {
|
|
20
|
+
readonly id: "createBalance";
|
|
21
|
+
readonly field: "balance";
|
|
22
|
+
}, {
|
|
23
|
+
readonly id: "createSpendable";
|
|
24
|
+
readonly field: "spendable";
|
|
25
|
+
}, {
|
|
26
|
+
readonly id: "createSpendableBalance";
|
|
27
|
+
readonly field: "spendableBalance";
|
|
28
|
+
}, {
|
|
29
|
+
readonly id: "createUnconfirmedSent";
|
|
30
|
+
readonly field: "unconfirmedSent";
|
|
31
|
+
}, {
|
|
32
|
+
readonly id: "createUnconfirmedReceived";
|
|
33
|
+
readonly field: "unconfirmedReceived";
|
|
34
|
+
}, {
|
|
35
|
+
readonly id: "createUnspendable";
|
|
36
|
+
readonly field: "unspendable";
|
|
37
|
+
}, {
|
|
38
|
+
readonly id: "createWalletReserve";
|
|
39
|
+
readonly field: "walletReserve";
|
|
40
|
+
}, {
|
|
41
|
+
readonly id: "createNetworkReserve";
|
|
42
|
+
readonly field: "networkReserve";
|
|
43
|
+
}, {
|
|
44
|
+
readonly id: "createStaking";
|
|
45
|
+
readonly field: "staking";
|
|
46
|
+
}, {
|
|
47
|
+
readonly id: "createStaked";
|
|
48
|
+
readonly field: "staked";
|
|
49
|
+
}, {
|
|
50
|
+
readonly id: "createStakeable";
|
|
51
|
+
readonly field: "stakeable";
|
|
52
|
+
}, {
|
|
53
|
+
readonly id: "createUnstaking";
|
|
54
|
+
readonly field: "unstaking";
|
|
55
|
+
}, {
|
|
56
|
+
readonly id: "createUnstaked";
|
|
57
|
+
readonly field: "unstaked";
|
|
58
|
+
}, {
|
|
59
|
+
readonly id: "createRewards";
|
|
60
|
+
readonly field: "rewards";
|
|
61
|
+
}, {
|
|
62
|
+
readonly id: "createFrozen";
|
|
63
|
+
readonly field: "frozen";
|
|
64
|
+
}];
|
|
65
|
+
type FieldId = (typeof fieldDefinitions)[number]['id'];
|
|
66
|
+
type FieldDefinition = {
|
|
67
|
+
[Id in FieldId]: ReturnType<typeof createBalanceSelectorFactory<Id>>;
|
|
68
|
+
}[FieldId];
|
|
69
|
+
declare const createBalanceSelectors: FieldDefinition[];
|
|
70
|
+
export default createBalanceSelectors;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import lodash from 'lodash';
|
|
2
|
+
import { MY_STATE } from '@exodus/redux-dependency-injection';
|
|
3
|
+
import { createSelector } from 'reselect';
|
|
4
|
+
const { memoize } = lodash;
|
|
5
|
+
const createBalanceSelectorFactory = ({ field, id, }) => {
|
|
6
|
+
const selectorFactory = (createAssetSelector, selfSelector) => memoize(({ assetName, walletAccount }) => createSelector(createAssetSelector(assetName), selfSelector, (asset, balances) => balances[walletAccount]?.data[assetName]?.[field] ?? asset?.currency.ZERO), ({ assetName, walletAccount, field }) => [assetName, walletAccount, field].join('-'));
|
|
7
|
+
return {
|
|
8
|
+
id,
|
|
9
|
+
selectorFactory,
|
|
10
|
+
dependencies: [{ module: 'assets', selector: 'createAssetSelector' }, { selector: MY_STATE }],
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
const fieldDefinitions = [
|
|
14
|
+
{ id: 'createTotal', field: 'total' },
|
|
15
|
+
{ id: 'createBalance', field: 'balance' },
|
|
16
|
+
{ id: 'createSpendable', field: 'spendable' },
|
|
17
|
+
{ id: 'createSpendableBalance', field: 'spendableBalance' },
|
|
18
|
+
{ id: 'createUnconfirmedSent', field: 'unconfirmedSent' },
|
|
19
|
+
{ id: 'createUnconfirmedReceived', field: 'unconfirmedReceived' },
|
|
20
|
+
{ id: 'createUnspendable', field: 'unspendable' },
|
|
21
|
+
{ id: 'createWalletReserve', field: 'walletReserve' },
|
|
22
|
+
{ id: 'createNetworkReserve', field: 'networkReserve' },
|
|
23
|
+
{ id: 'createStaking', field: 'staking' },
|
|
24
|
+
{ id: 'createStaked', field: 'staked' },
|
|
25
|
+
{ id: 'createStakeable', field: 'stakeable' },
|
|
26
|
+
{ id: 'createUnstaking', field: 'unstaking' },
|
|
27
|
+
{ id: 'createUnstaked', field: 'unstaked' },
|
|
28
|
+
{ id: 'createRewards', field: 'rewards' },
|
|
29
|
+
{ id: 'createFrozen', field: 'frozen' },
|
|
30
|
+
];
|
|
31
|
+
const createBalanceSelectors = fieldDefinitions.map(createBalanceSelectorFactory);
|
|
32
|
+
export default createBalanceSelectors;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FieldBalances } from '../../module/types.js';
|
|
2
|
+
import type { Source, Selector, State } from '../types.js';
|
|
3
|
+
import lodash from 'lodash';
|
|
4
|
+
declare const createBalancesSelectorDefinition: {
|
|
5
|
+
readonly id: "createBalances";
|
|
6
|
+
readonly selectorFactory: (selfSelector: Selector<State>) => (({ assetName, walletAccount }: Source) => import("reselect").OutputSelector<unknown, FieldBalances, (res: State) => FieldBalances>) & lodash.MemoizedFunction;
|
|
7
|
+
readonly dependencies: readonly [{
|
|
8
|
+
readonly selector: "$state";
|
|
9
|
+
}];
|
|
10
|
+
};
|
|
11
|
+
export default createBalancesSelectorDefinition;
|