@rango-dev/widget-embedded 0.21.1-next.2 → 0.21.1-next.3
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/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +1 -1
- package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +3 -3
- package/dist/types/notification.d.ts +4 -4
- package/dist/types/notification.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +1 -1
- package/package.json +2 -2
- package/readme.md +1 -0
- package/src/components/NotificationContent/NotificationContent.tsx +13 -22
- package/src/components/NotificationContent/NotificationNotFound.tsx +1 -1
- package/src/hooks/useSwapInput.ts +2 -2
- package/src/hooks/useSyncStoresWithConfig.ts +3 -3
- package/src/store/notification.ts +4 -4
- package/src/store/slices/data.ts +2 -2
- package/src/types/notification.ts +4 -4
- package/src/utils/configs.ts +3 -3
- package/src/utils/meta.ts +2 -2
- package/src/utils/wallets.ts +1 -1
|
@@ -2,13 +2,13 @@ import { type Route, type RouteEvent, type Step, type StepEvent } from '@rango-d
|
|
|
2
2
|
type NotificationRoute = {
|
|
3
3
|
from: {
|
|
4
4
|
blockchain: Step['fromBlockchain'];
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
symbol: Step['fromSymbol'];
|
|
6
|
+
address: Step['fromSymbolAddress'];
|
|
7
7
|
};
|
|
8
8
|
to: {
|
|
9
9
|
blockchain: Step['toBlockchain'];
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
symbol: Step['toSymbol'];
|
|
11
|
+
address: Step['toSymbolAddress'];
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
14
|
export type Notification = Pick<Route, 'requestId'> & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.d.ts","sourceRoot":"","sources":["../../src/types/notification.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,KAAK,EACV,KAAK,UAAU,EACf,KAAK,IAAI,EACT,KAAK,SAAS,EACf,MAAM,uCAAuC,CAAC;AAE/C,KAAK,iBAAiB,GAAG;IACvB,IAAI,EAAE;QACJ,UAAU,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACnC,
|
|
1
|
+
{"version":3,"file":"notification.d.ts","sourceRoot":"","sources":["../../src/types/notification.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,KAAK,EACV,KAAK,UAAU,EACf,KAAK,IAAI,EACT,KAAK,SAAS,EACf,MAAM,uCAAuC,CAAC;AAE/C,KAAK,iBAAiB,GAAG;IACvB,IAAI,EAAE;QACJ,UAAU,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACnC,MAAM,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC3B,OAAO,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;KACpC,CAAC;IACF,EAAE,EAAE;QACF,UAAU,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QACjC,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACzB,OAAO,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;KAClC,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,EAAE,WAAW,CAAC,GAAG;IACpD,KAAK,EAAE,UAAU,GAAG,SAAS,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,iBAAiB,CAAC;CAC1B,CAAC"}
|
package/dist/utils/wallets.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare const isExperimentalChain: (blockchains: BlockchainMeta[], wallet
|
|
|
18
18
|
export declare const getKeplrCompatibleConnectedWallets: (selectableWallets: Wallet[]) => WalletType[];
|
|
19
19
|
export declare function formatBalance(balance: Balance | null): Balance | null;
|
|
20
20
|
export declare function sortTokens(tokens: Token[], getBalanceFor: (token: Token) => Balance | null, isTokenPinned: (token: Token) => boolean): Token[];
|
|
21
|
-
export declare function
|
|
21
|
+
export declare function areTokensEqual(tokenA: Pick<Token, 'blockchain' | 'symbol' | 'address'> | null, tokenB: Pick<Token, 'blockchain' | 'symbol' | 'address'> | null): boolean;
|
|
22
22
|
export declare function sortWalletsBasedOnConnectionState(wallets: ModalWalletInfo[]): ModalWalletInfo[];
|
|
23
23
|
export declare function getConciseAddress(address: string, maxChars?: number, ellipsisLength?: number): string;
|
|
24
24
|
export declare function getAddress({ chain, connectedWallets, walletType, }: {
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -14,6 +14,7 @@ import { useNavigate } from 'react-router-dom';
|
|
|
14
14
|
import { navigationRoutes } from '../../constants/navigationRoutes';
|
|
15
15
|
import { useAppStore } from '../../store/AppStore';
|
|
16
16
|
import { useNotificationStore } from '../../store/notification';
|
|
17
|
+
import { areTokensEqual } from '../../utils/wallets';
|
|
17
18
|
|
|
18
19
|
import { Container, Images, List } from './NotificationContent.styles';
|
|
19
20
|
import { NotificationNotFound } from './NotificationNotFound';
|
|
@@ -41,50 +42,40 @@ export function NotificationContent() {
|
|
|
41
42
|
{sortedNotification.length ? (
|
|
42
43
|
<List>
|
|
43
44
|
{sortedNotification.map((notificationItem) => {
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
notificationItem.route.from.tokenAddress &&
|
|
48
|
-
tokenItem.blockchain ===
|
|
49
|
-
notificationItem.route.from.blockchain &&
|
|
50
|
-
tokenItem.symbol === notificationItem.route.from.tokenSymbol
|
|
45
|
+
const { route, requestId, event } = notificationItem;
|
|
46
|
+
const fromToken = tokens.find((tokenItem) =>
|
|
47
|
+
areTokensEqual(tokenItem, route.from)
|
|
51
48
|
);
|
|
52
49
|
|
|
53
50
|
const fromBlockchain = blockchains.find(
|
|
54
|
-
(blockchainItem) =>
|
|
55
|
-
blockchainItem.name === notificationItem.route.from.blockchain
|
|
51
|
+
(blockchainItem) => blockchainItem.name === route.from.blockchain
|
|
56
52
|
);
|
|
57
53
|
|
|
58
|
-
const toToken = tokens.find(
|
|
59
|
-
(tokenItem)
|
|
60
|
-
tokenItem.address === notificationItem.route.to.tokenAddress &&
|
|
61
|
-
tokenItem.blockchain === notificationItem.route.to.blockchain &&
|
|
62
|
-
tokenItem.symbol === notificationItem.route.to.tokenSymbol
|
|
54
|
+
const toToken = tokens.find((tokenItem) =>
|
|
55
|
+
areTokensEqual(tokenItem, route.to)
|
|
63
56
|
);
|
|
64
57
|
|
|
65
58
|
const toBlockchain = blockchains.find(
|
|
66
|
-
(blockchainItem) =>
|
|
67
|
-
blockchainItem.name === notificationItem.route.to.blockchain
|
|
59
|
+
(blockchainItem) => blockchainItem.name === route.to.blockchain
|
|
68
60
|
);
|
|
69
61
|
|
|
70
62
|
return (
|
|
71
63
|
<ListItemButton
|
|
72
|
-
key={
|
|
73
|
-
onClick={() => handleOnClick(
|
|
64
|
+
key={requestId}
|
|
65
|
+
onClick={() => handleOnClick(requestId)}
|
|
74
66
|
title={
|
|
75
67
|
<Typography
|
|
76
68
|
variant="body"
|
|
77
69
|
size="small"
|
|
78
70
|
color={
|
|
79
|
-
|
|
80
|
-
EventSeverity.WARNING
|
|
71
|
+
event.messageSeverity === EventSeverity.WARNING
|
|
81
72
|
? '$foreground'
|
|
82
73
|
: '$neutral700'
|
|
83
74
|
}>
|
|
84
|
-
{i18n.t(
|
|
75
|
+
{i18n.t(event.message)}
|
|
85
76
|
</Typography>
|
|
86
77
|
}
|
|
87
|
-
id={
|
|
78
|
+
id={requestId}
|
|
88
79
|
start={
|
|
89
80
|
<Images>
|
|
90
81
|
<div className="from-chain-token">
|
|
@@ -10,7 +10,7 @@ export function NotificationNotFound() {
|
|
|
10
10
|
<NoNotificationIcon color="secondary" size={26} />
|
|
11
11
|
<Divider size={12} />
|
|
12
12
|
<Typography variant="body" size="medium" color="neutral700">
|
|
13
|
-
{i18n.t('
|
|
13
|
+
{i18n.t('There are no notifications.')}
|
|
14
14
|
</Typography>
|
|
15
15
|
</NotFoundContainer>
|
|
16
16
|
);
|
|
@@ -11,7 +11,7 @@ import { isPositiveNumber } from '../utils/numbers';
|
|
|
11
11
|
import { generateQuoteWarnings } from '../utils/quote';
|
|
12
12
|
import { isFeatureEnabled } from '../utils/settings';
|
|
13
13
|
import { createQuoteRequestBody } from '../utils/swap';
|
|
14
|
-
import {
|
|
14
|
+
import { areTokensEqual } from '../utils/wallets';
|
|
15
15
|
|
|
16
16
|
import {
|
|
17
17
|
handleQuoteErrors,
|
|
@@ -68,7 +68,7 @@ export function useSwapInput(): UseSwapInput {
|
|
|
68
68
|
const tokensValueInvalid = !fromToken || !toToken;
|
|
69
69
|
const shouldSkipRequest =
|
|
70
70
|
tokensValueInvalid ||
|
|
71
|
-
|
|
71
|
+
areTokensEqual(fromToken, toToken) ||
|
|
72
72
|
!isPositiveNumber(inputAmount);
|
|
73
73
|
|
|
74
74
|
const resetState = (loading: boolean) => {
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
isBlockchainExcludedInConfig,
|
|
9
9
|
isTokenExcludedInConfig,
|
|
10
10
|
} from '../utils/configs';
|
|
11
|
-
import {
|
|
11
|
+
import { areTokensEqual } from '../utils/wallets';
|
|
12
12
|
|
|
13
13
|
export function useSyncStoresWithConfig() {
|
|
14
14
|
const {
|
|
@@ -50,7 +50,7 @@ export function useSyncStoresWithConfig() {
|
|
|
50
50
|
(chain) => chain.name === config?.from?.blockchain
|
|
51
51
|
);
|
|
52
52
|
const token = tokens.find((t) =>
|
|
53
|
-
|
|
53
|
+
areTokensEqual(t, config?.from?.token || null)
|
|
54
54
|
);
|
|
55
55
|
|
|
56
56
|
if (chain || (!chain && prevConfigFromBlockchain.current)) {
|
|
@@ -99,7 +99,7 @@ export function useSyncStoresWithConfig() {
|
|
|
99
99
|
(chain) => chain.name === config?.to?.blockchain
|
|
100
100
|
);
|
|
101
101
|
const token = tokens.find((t) =>
|
|
102
|
-
|
|
102
|
+
areTokensEqual(t, config?.to?.token || null)
|
|
103
103
|
);
|
|
104
104
|
|
|
105
105
|
if (chain || (!chain && prevConfigToBlockchain.current)) {
|
|
@@ -34,13 +34,13 @@ export const useNotificationStore = createSelectors(
|
|
|
34
34
|
route: {
|
|
35
35
|
from: {
|
|
36
36
|
blockchain: fromStep.fromBlockchain,
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
address: fromStep.fromSymbolAddress,
|
|
38
|
+
symbol: fromStep.fromSymbol,
|
|
39
39
|
},
|
|
40
40
|
to: {
|
|
41
41
|
blockchain: toStep.toBlockchain,
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
address: toStep.toSymbolAddress,
|
|
43
|
+
symbol: toStep.toSymbol,
|
|
44
44
|
},
|
|
45
45
|
},
|
|
46
46
|
};
|
package/src/store/slices/data.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { httpService as sdk } from '../../services/httpService';
|
|
|
8
8
|
import { containsText } from '../../utils/common';
|
|
9
9
|
import { isTokenExcludedInConfig } from '../../utils/configs';
|
|
10
10
|
import { sortLiquiditySourcesByGroupTitle } from '../../utils/settings';
|
|
11
|
-
import {
|
|
11
|
+
import { areTokensEqual } from '../../utils/wallets';
|
|
12
12
|
|
|
13
13
|
type BlockchainOptions = {
|
|
14
14
|
type?: 'source' | 'destination';
|
|
@@ -163,7 +163,7 @@ export const createDataSlice: StateCreator<
|
|
|
163
163
|
? get().config.from?.pinnedTokens
|
|
164
164
|
: get().config.to?.pinnedTokens;
|
|
165
165
|
const pinned = !!pinnedTokens?.some((pinnedToken) =>
|
|
166
|
-
|
|
166
|
+
areTokensEqual(pinnedToken, token)
|
|
167
167
|
);
|
|
168
168
|
return pinned;
|
|
169
169
|
},
|
|
@@ -8,13 +8,13 @@ import {
|
|
|
8
8
|
type NotificationRoute = {
|
|
9
9
|
from: {
|
|
10
10
|
blockchain: Step['fromBlockchain'];
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
symbol: Step['fromSymbol'];
|
|
12
|
+
address: Step['fromSymbolAddress'];
|
|
13
13
|
};
|
|
14
14
|
to: {
|
|
15
15
|
blockchain: Step['toBlockchain'];
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
symbol: Step['toSymbol'];
|
|
17
|
+
address: Step['toSymbolAddress'];
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
20
|
|
package/src/utils/configs.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Asset, BlockchainMeta, Token } from 'rango-sdk';
|
|
|
3
3
|
|
|
4
4
|
import { RANGO_PUBLIC_API_KEY } from '../constants';
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { areTokensEqual } from './wallets';
|
|
7
7
|
|
|
8
8
|
export interface Configs {
|
|
9
9
|
API_KEY: string;
|
|
@@ -57,10 +57,10 @@ export const isTokenExcludedInConfig = (
|
|
|
57
57
|
let result = false;
|
|
58
58
|
if (tokensConfig && token) {
|
|
59
59
|
if (Array.isArray(tokensConfig)) {
|
|
60
|
-
result = !tokensConfig.some((asset) =>
|
|
60
|
+
result = !tokensConfig.some((asset) => areTokensEqual(asset, token));
|
|
61
61
|
} else if (!Array.isArray(tokensConfig) && tokensConfig[token.blockchain]) {
|
|
62
62
|
result = tokensConfig[token.blockchain].tokens.some((asset) =>
|
|
63
|
-
|
|
63
|
+
areTokensEqual(asset, token)
|
|
64
64
|
);
|
|
65
65
|
const isExcluded = tokensConfig[token.blockchain].isExcluded;
|
|
66
66
|
return (!isExcluded && !result) || (isExcluded && result);
|
package/src/utils/meta.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Asset, BlockchainMeta, SwapperMeta, Token } from 'rango-sdk';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { areTokensEqual } from './wallets';
|
|
4
4
|
|
|
5
5
|
export function getBlockchainDisplayNameFor(
|
|
6
6
|
blockchainName: string,
|
|
@@ -25,7 +25,7 @@ export function getSwapperDisplayName(
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export function findToken(t: Asset, tokens: Token[]) {
|
|
28
|
-
return tokens.find((token) =>
|
|
28
|
+
return tokens.find((token) => areTokensEqual(token, t)) ?? null;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export function findBlockchain(name: string, blockchains: BlockchainMeta[]) {
|
package/src/utils/wallets.ts
CHANGED
|
@@ -443,7 +443,7 @@ export function sortTokens(
|
|
|
443
443
|
return tokens;
|
|
444
444
|
}
|
|
445
445
|
|
|
446
|
-
export function
|
|
446
|
+
export function areTokensEqual(
|
|
447
447
|
tokenA: Pick<Token, 'blockchain' | 'symbol' | 'address'> | null,
|
|
448
448
|
tokenB: Pick<Token, 'blockchain' | 'symbol' | 'address'> | null
|
|
449
449
|
) {
|