@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.
@@ -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
- tokenSymbol: Step['fromSymbol'];
6
- tokenAddress: Step['fromSymbolAddress'];
5
+ symbol: Step['fromSymbol'];
6
+ address: Step['fromSymbolAddress'];
7
7
  };
8
8
  to: {
9
9
  blockchain: Step['toBlockchain'];
10
- tokenSymbol: Step['toSymbol'];
11
- tokenAddress: Step['toSymbolAddress'];
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,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAChC,YAAY,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;KACzC,CAAC;IACF,EAAE,EAAE;QACF,UAAU,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QACjC,WAAW,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC9B,YAAY,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;KACvC,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"}
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"}
@@ -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 tokensAreEqual(tokenA: Pick<Token, 'blockchain' | 'symbol' | 'address'> | null, tokenB: Pick<Token, 'blockchain' | 'symbol' | 'address'> | null): boolean;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.21.1-next.2",
3
+ "version": "0.21.1-next.3",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -47,4 +47,4 @@
47
47
  "publishConfig": {
48
48
  "access": "public"
49
49
  }
50
- }
50
+ }
package/readme.md CHANGED
@@ -1,3 +1,4 @@
1
1
  # @rango-dev/widget-embedded
2
2
 
3
3
  Rango Embedded Widget
4
+
@@ -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 fromToken = tokens.find(
45
- (tokenItem) =>
46
- tokenItem.address ===
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={notificationItem.requestId}
73
- onClick={() => handleOnClick(notificationItem.requestId)}
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
- notificationItem.event.messageSeverity ===
80
- EventSeverity.WARNING
71
+ event.messageSeverity === EventSeverity.WARNING
81
72
  ? '$foreground'
82
73
  : '$neutral700'
83
74
  }>
84
- {i18n.t(notificationItem.event.message)}
75
+ {i18n.t(event.message)}
85
76
  </Typography>
86
77
  }
87
- id={notificationItem.requestId}
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('You have no notification')}
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 { tokensAreEqual } from '../utils/wallets';
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
- tokensAreEqual(fromToken, toToken) ||
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 { tokensAreEqual } from '../utils/wallets';
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
- tokensAreEqual(t, config?.from?.token || null)
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
- tokensAreEqual(t, config?.to?.token || null)
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
- tokenAddress: fromStep.fromSymbolAddress,
38
- tokenSymbol: fromStep.fromSymbol,
37
+ address: fromStep.fromSymbolAddress,
38
+ symbol: fromStep.fromSymbol,
39
39
  },
40
40
  to: {
41
41
  blockchain: toStep.toBlockchain,
42
- tokenSymbol: toStep.toSymbol,
43
- tokenAddress: toStep.toSymbolAddress,
42
+ address: toStep.toSymbolAddress,
43
+ symbol: toStep.toSymbol,
44
44
  },
45
45
  },
46
46
  };
@@ -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 { tokensAreEqual } from '../../utils/wallets';
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
- tokensAreEqual(pinnedToken, token)
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
- tokenSymbol: Step['fromSymbol'];
12
- tokenAddress: Step['fromSymbolAddress'];
11
+ symbol: Step['fromSymbol'];
12
+ address: Step['fromSymbolAddress'];
13
13
  };
14
14
  to: {
15
15
  blockchain: Step['toBlockchain'];
16
- tokenSymbol: Step['toSymbol'];
17
- tokenAddress: Step['toSymbolAddress'];
16
+ symbol: Step['toSymbol'];
17
+ address: Step['toSymbolAddress'];
18
18
  };
19
19
  };
20
20
 
@@ -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 { tokensAreEqual } from './wallets';
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) => tokensAreEqual(asset, token));
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
- tokensAreEqual(asset, token)
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 { tokensAreEqual } from './wallets';
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) => tokensAreEqual(token, t)) ?? null;
28
+ return tokens.find((token) => areTokensEqual(token, t)) ?? null;
29
29
  }
30
30
 
31
31
  export function findBlockchain(name: string, blockchains: BlockchainMeta[]) {
@@ -443,7 +443,7 @@ export function sortTokens(
443
443
  return tokens;
444
444
  }
445
445
 
446
- export function tokensAreEqual(
446
+ export function areTokensEqual(
447
447
  tokenA: Pick<Token, 'blockchain' | 'symbol' | 'address'> | null,
448
448
  tokenB: Pick<Token, 'blockchain' | 'symbol' | 'address'> | null
449
449
  ) {