@rango-dev/widget-embedded 0.39.1-next.9 → 0.40.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/dist/components/SwapDetailsModal/SwapDetailsCompleteModal.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts +160 -0
- package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts.map +1 -1
- package/dist/constants/profileBanner.d.ts +3 -0
- package/dist/constants/profileBanner.d.ts.map +1 -0
- package/dist/constants/wallets.d.ts +1 -0
- package/dist/constants/wallets.d.ts.map +1 -1
- package/dist/containers/Wallets/Wallets.d.ts.map +1 -1
- package/dist/containers/Wallets/Wallets.helpers.d.ts +4 -0
- package/dist/containers/Wallets/Wallets.helpers.d.ts.map +1 -0
- package/dist/containers/Wallets/Wallets.types.d.ts +6 -2
- package/dist/containers/Wallets/Wallets.types.d.ts.map +1 -1
- package/dist/containers/Wallets/useUpdates.d.ts +13 -0
- package/dist/containers/Wallets/useUpdates.d.ts.map +1 -0
- package/dist/hooks/useSubscribeToWidgetEvents/useSubscribeToWidgetEvents.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/dist/store/middlewares/keepLastUpdated.d.ts +8 -0
- package/dist/store/middlewares/keepLastUpdated.d.ts.map +1 -0
- package/dist/store/slices/wallets.d.ts +19 -13
- package/dist/store/slices/wallets.d.ts.map +1 -1
- package/dist/store/utils/wallets.d.ts +3 -3
- package/dist/store/utils/wallets.d.ts.map +1 -1
- package/dist/utils/common.d.ts +5 -0
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/widget-embedded.build.json +1 -1
- package/package.json +12 -12
- package/src/components/ConfirmWalletsModal/WalletList.tsx +1 -1
- package/src/components/SwapDetailsModal/SwapDetailsCompleteModal.tsx +14 -7
- package/src/components/SwapDetailsModal/SwapDetailsModal.styles.ts +4 -0
- package/src/constants/profileBanner.ts +3 -0
- package/src/constants/wallets.ts +2 -0
- package/src/containers/Wallets/Wallets.helpers.ts +26 -0
- package/src/containers/Wallets/Wallets.tsx +23 -127
- package/src/containers/Wallets/Wallets.types.ts +16 -2
- package/src/containers/Wallets/useUpdates.ts +240 -0
- package/src/hooks/useSubscribeToWidgetEvents/useSubscribeToWidgetEvents.ts +19 -9
- package/src/store/middlewares/keepLastUpdated.ts +19 -0
- package/src/store/slices/wallets.ts +546 -414
- package/src/store/utils/wallets.ts +12 -11
- package/src/utils/common.ts +24 -2
|
@@ -1,38 +1,39 @@
|
|
|
1
1
|
import type { Balance } from '../../types';
|
|
2
2
|
import type { AppStoreState } from '../app';
|
|
3
|
-
import type {
|
|
4
|
-
AggregatedBalanceState,
|
|
5
|
-
AssetKey,
|
|
6
|
-
BalanceKey,
|
|
7
|
-
BalanceState,
|
|
8
|
-
} from '../slices/wallets';
|
|
9
3
|
import type { Asset, WalletDetail } from 'rango-types';
|
|
10
4
|
|
|
11
5
|
import BigNumber from 'bignumber.js';
|
|
12
6
|
|
|
13
7
|
import { ZERO } from '../../constants/numbers';
|
|
8
|
+
import { BALANCE_SEPARATOR } from '../../constants/wallets';
|
|
9
|
+
import {
|
|
10
|
+
type AggregatedBalanceState,
|
|
11
|
+
type AssetKey,
|
|
12
|
+
type BalanceKey,
|
|
13
|
+
type BalanceState,
|
|
14
|
+
} from '../slices/wallets';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Note: We need to use `symbol` as well since native coins and cosmos blockchains don't have `address`
|
|
17
|
-
* output format: BlockchainId
|
|
18
|
+
* output format: BlockchainId${BALANCE_SEPARATOR}TokenAddress${BALANCE_SEPARATOR}TokenSymbol
|
|
18
19
|
*/
|
|
19
20
|
export function createAssetKey(asset: Asset): AssetKey {
|
|
20
|
-
return `${asset.blockchain}
|
|
21
|
+
return `${asset.blockchain}${BALANCE_SEPARATOR}${asset.address}${BALANCE_SEPARATOR}${asset.symbol}`;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
|
-
* output format: BlockchainId
|
|
25
|
+
* output format: BlockchainId${BALANCE_SEPARATOR}TokenAddress${BALANCE_SEPARATOR}TokenSymbol${BALANCE_SEPARATOR}WalletAddress
|
|
25
26
|
*/
|
|
26
27
|
export function createBalanceKey(
|
|
27
28
|
accountAddress: string,
|
|
28
29
|
asset: Asset
|
|
29
30
|
): BalanceKey {
|
|
30
31
|
const assetKey = createAssetKey(asset);
|
|
31
|
-
return `${assetKey}
|
|
32
|
+
return `${assetKey}${BALANCE_SEPARATOR}${accountAddress}`;
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
export function extractAssetFromBalanceKey(key: BalanceKey): Asset {
|
|
35
|
-
const [assetChain, assetAddress, assetSymbol] = key.split(
|
|
36
|
+
const [assetChain, assetAddress, assetSymbol] = key.split(BALANCE_SEPARATOR);
|
|
36
37
|
|
|
37
38
|
// null will be serialized to 'null', we need to make it back to a null type
|
|
38
39
|
const address = assetAddress === 'null' ? null : assetAddress;
|
package/src/utils/common.ts
CHANGED
|
@@ -26,10 +26,12 @@ export function areEqual(
|
|
|
26
26
|
array1.length === array2.length && array1.every((v, i) => v === array2[i])
|
|
27
27
|
);
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
30
31
|
export function debounce(fn: Function, time: number) {
|
|
31
32
|
let timeoutId: ReturnType<typeof setTimeout> | null;
|
|
32
33
|
return wrapper;
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
35
|
function wrapper(...args: any) {
|
|
34
36
|
if (timeoutId) {
|
|
35
37
|
clearTimeout(timeoutId);
|
|
@@ -42,7 +44,6 @@ export function debounce(fn: Function, time: number) {
|
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
export function containsText(text: string, searchText: string): boolean {
|
|
45
|
-
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
46
47
|
return text.toLowerCase().indexOf(searchText.toLowerCase()) > -1;
|
|
47
48
|
}
|
|
48
49
|
|
|
@@ -258,3 +259,24 @@ export function isSingleWalletActive(
|
|
|
258
259
|
);
|
|
259
260
|
return multiWallets === false && atLeastOneWalletIsConnected;
|
|
260
261
|
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* A simple memo implementation
|
|
265
|
+
* you can use it when you want to memoize a value in js space
|
|
266
|
+
*/
|
|
267
|
+
export function memoizedResult(): <R>(fn: () => R, key: number | string) => R {
|
|
268
|
+
let currentKey: number | string;
|
|
269
|
+
|
|
270
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
271
|
+
let result: any;
|
|
272
|
+
|
|
273
|
+
return (fn, key) => {
|
|
274
|
+
if (!result || !currentKey || currentKey !== key) {
|
|
275
|
+
currentKey = key;
|
|
276
|
+
result = fn();
|
|
277
|
+
return result;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return result;
|
|
281
|
+
};
|
|
282
|
+
}
|