@rango-dev/widget-embedded 0.5.1-next.9 → 0.7.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.
Files changed (75) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/Wallets.d.ts +2 -1
  3. package/dist/Wallets.d.ts.map +1 -1
  4. package/dist/Widget.d.ts +0 -1
  5. package/dist/Widget.d.ts.map +1 -1
  6. package/dist/components/BottomLogo.d.ts.map +1 -1
  7. package/dist/components/ChangeSlippageButton.d.ts.map +1 -1
  8. package/dist/components/ConfirmSwapWarnings.d.ts +2 -2
  9. package/dist/components/ConfirmSwapWarnings.d.ts.map +1 -1
  10. package/dist/components/HeaderButtons.d.ts.map +1 -1
  11. package/dist/components/Layout.d.ts.map +1 -1
  12. package/dist/components/SwapDetailsPlaceholder.d.ts.map +1 -1
  13. package/dist/components/TokenInfo.d.ts.map +1 -1
  14. package/dist/components/TokenPreview.d.ts +1 -1
  15. package/dist/components/TokenPreview.d.ts.map +1 -1
  16. package/dist/components/WidgetEvents.d.ts.map +1 -1
  17. package/dist/components/warnings/HighSlippageWarning.d.ts.map +1 -1
  18. package/dist/components/warnings/MinRequiredSlippage.d.ts.map +1 -1
  19. package/dist/hooks/useConfirmSwap.d.ts +1 -1
  20. package/dist/hooks/useConfirmSwap.d.ts.map +1 -1
  21. package/dist/index.d.ts +4 -5
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +1 -1
  24. package/dist/index.js.map +4 -4
  25. package/dist/pages/Home.d.ts.map +1 -1
  26. package/dist/pages/WalletsPage.d.ts.map +1 -1
  27. package/dist/store/bestRoute.d.ts +4 -4
  28. package/dist/store/bestRoute.d.ts.map +1 -1
  29. package/dist/store/settings.d.ts +16 -0
  30. package/dist/store/settings.d.ts.map +1 -1
  31. package/dist/store/wallets.d.ts +2 -2
  32. package/dist/store/wallets.d.ts.map +1 -1
  33. package/dist/types/config.d.ts +23 -4
  34. package/dist/types/config.d.ts.map +1 -1
  35. package/dist/types/swap.d.ts +1 -1
  36. package/dist/types/swap.d.ts.map +1 -1
  37. package/dist/utils/routing.d.ts +1 -1
  38. package/dist/utils/routing.d.ts.map +1 -1
  39. package/dist/utils/swap.d.ts +6 -4
  40. package/dist/utils/swap.d.ts.map +1 -1
  41. package/dist/utils/wallets.d.ts.map +1 -1
  42. package/package.json +10 -13
  43. package/src/Wallets.tsx +8 -2
  44. package/src/Widget.tsx +18 -23
  45. package/src/components/BottomLogo.tsx +2 -4
  46. package/src/components/ChangeSlippageButton.tsx +3 -3
  47. package/src/components/ConfirmSwapWarnings.tsx +10 -13
  48. package/src/components/HeaderButtons.tsx +7 -9
  49. package/src/components/Layout.tsx +21 -13
  50. package/src/components/SwapDetailsPlaceholder.tsx +10 -2
  51. package/src/components/TokenInfo.tsx +26 -23
  52. package/src/components/TokenPreview.tsx +12 -13
  53. package/src/components/WidgetEvents.tsx +4 -5
  54. package/src/components/warnings/BalanceErrors.tsx +3 -3
  55. package/src/components/warnings/HighSlippageWarning.tsx +9 -2
  56. package/src/components/warnings/MinRequiredSlippage.tsx +11 -4
  57. package/src/hooks/useConfirmSwap.ts +10 -3
  58. package/src/index.ts +44 -3
  59. package/src/pages/ConfirmSwapPage.tsx +5 -5
  60. package/src/pages/Home.tsx +2 -1
  61. package/src/pages/WalletsPage.tsx +2 -3
  62. package/src/store/bestRoute.ts +18 -8
  63. package/src/store/settings.ts +17 -0
  64. package/src/store/wallets.ts +39 -13
  65. package/src/types/config.ts +22 -4
  66. package/src/types/swap.ts +1 -1
  67. package/src/utils/routing.ts +1 -1
  68. package/src/utils/swap.ts +53 -26
  69. package/src/utils/wallets.ts +18 -4
  70. package/dist/hooks/useSelectLanguage.d.ts +0 -5
  71. package/dist/hooks/useSelectLanguage.d.ts.map +0 -1
  72. package/dist/i18n.d.ts +0 -3
  73. package/dist/i18n.d.ts.map +0 -1
  74. package/src/hooks/useSelectLanguage.ts +0 -17
  75. package/src/i18n.js +0 -30
@@ -20,7 +20,7 @@ import {
20
20
  } from '../utils/wallets';
21
21
  import { removeDuplicateFrom } from '../utils/common';
22
22
  import { WidgetConfig } from '../types';
23
- import { useTranslation } from 'react-i18next';
23
+ import { i18n } from '@lingui/core';
24
24
  import { useBestRouteStore } from '../store/bestRoute';
25
25
  import { useMetaStore } from '../store/meta';
26
26
  import { useSettingsStore } from '../store/settings';
@@ -57,7 +57,7 @@ export function Layout({ config }: LayoutProps) {
57
57
  const { getWalletInfo } = useWallets();
58
58
  const connectedWalletsImages = removeDuplicateFrom(
59
59
  getSelectableWallets(connectedWallets, selectedWallets, getWalletInfo).map(
60
- w => w.image
60
+ (w) => w.image
61
61
  )
62
62
  );
63
63
  const { blockchains, tokens } = useMetaStore.use.meta();
@@ -67,19 +67,21 @@ export function Layout({ config }: LayoutProps) {
67
67
  const setToToken = useBestRouteStore.use.setToToken();
68
68
  const setInputAmount = useBestRouteStore.use.setInputAmount();
69
69
  const setAffiliateRef = useSettingsStore.use.setAffiliateRef();
70
+ const setAffiliatePercent = useSettingsStore.use.setAffiliatePercent();
71
+ const setAffiliateWallets = useSettingsStore.use.setAffiliateWallets();
70
72
 
71
73
  const totalBalance = calculateWalletUsdValue(connectedWallets);
72
- const connectWalletsButtonDisabled = useUiStore.use.connectWalletsButtonDisabled();
74
+ const connectWalletsButtonDisabled =
75
+ useUiStore.use.connectWalletsButtonDisabled();
73
76
  const loadingMetaStatus = useMetaStore.use.loadingStatus();
74
77
  const fetchingBalance = useWalletsStore(fetchingBalanceSelector);
75
78
 
76
- const { t } = useTranslation();
77
79
  useEffect(() => {
78
80
  if (loadingMetaStatus === 'success') {
79
81
  const chain = blockchains.find(
80
- chain => chain.name === config?.to?.blockchain
82
+ (chain) => chain.name === config?.to?.blockchain
81
83
  );
82
- const token = tokens.find(t =>
84
+ const token = tokens.find((t) =>
83
85
  tokensAreEqual(t, config?.to?.token || null)
84
86
  );
85
87
  setToChain(chain || null);
@@ -94,9 +96,9 @@ export function Layout({ config }: LayoutProps) {
94
96
  useEffect(() => {
95
97
  if (loadingMetaStatus === 'success') {
96
98
  const chain = blockchains.find(
97
- chain => chain.name === config?.from?.blockchain
99
+ (chain) => chain.name === config?.from?.blockchain
98
100
  );
99
- const token = tokens.find(t =>
101
+ const token = tokens.find((t) =>
100
102
  tokensAreEqual(t, config?.from?.token || null)
101
103
  );
102
104
 
@@ -106,8 +108,15 @@ export function Layout({ config }: LayoutProps) {
106
108
  }, [config?.from?.token, config?.from?.blockchain, loadingMetaStatus]);
107
109
 
108
110
  useEffect(() => {
109
- setAffiliateRef(config?.affiliateRef || null);
110
- }, [config?.affiliateRef]);
111
+ setAffiliateRef(config?.affiliate?.ref ?? null);
112
+ setAffiliatePercent(config?.affiliate?.percent ?? null);
113
+ setAffiliateWallets(config?.affiliate?.wallets ?? null);
114
+ }, [
115
+ config?.affiliate?.ref,
116
+ config?.affiliate?.percent,
117
+ config?.affiliate?.wallets,
118
+ ]);
119
+
111
120
  return (
112
121
  <>
113
122
  <Header>
@@ -132,12 +141,11 @@ export function Layout({ config }: LayoutProps) {
132
141
  ))}
133
142
  </WalletImages>
134
143
  ) : null
135
- }
136
- >
144
+ }>
137
145
  <div className="balance">
138
146
  <Typography variant="body2">
139
147
  {!connectedWallets?.length
140
- ? t('Connect Wallet')
148
+ ? i18n.t('Connect Wallet')
141
149
  : `$${totalBalance || 0}`}
142
150
  </Typography>
143
151
  {fetchingBalance && <Spinner />}
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { SecondaryPage, Spinner, Alert, styled } from '@rango-dev/ui';
3
+ import { i18n } from '@lingui/core';
3
4
 
4
5
  const PlaceholderContainer = styled('div', { height: '450px' });
5
6
 
@@ -21,7 +22,10 @@ export function SwapDetailsPlaceholder(props: PropTypes) {
21
22
  const { requestId, loading, onBack } = props;
22
23
 
23
24
  return (
24
- <SecondaryPage title="Swap Details" textField={false} onBack={onBack}>
25
+ <SecondaryPage
26
+ title={i18n.t('Swap Details')}
27
+ textField={false}
28
+ onBack={onBack}>
25
29
  <PlaceholderContainer>
26
30
  {loading ? (
27
31
  <LoaderContainer>
@@ -30,7 +34,11 @@ export function SwapDetailsPlaceholder(props: PropTypes) {
30
34
  ) : (
31
35
  <Alert
32
36
  type="secondary"
33
- title={`Swap with request ID = ${requestId} not found.`}
37
+ title={i18n.t(
38
+ 'swapNotFound',
39
+ { requestId },
40
+ { message: 'Swap with request ID = ${requestId} not found.' }
41
+ )}
34
42
  />
35
43
  )}
36
44
  </PlaceholderContainer>
@@ -17,7 +17,8 @@ import { numberToString } from '../utils/numbers';
17
17
  import BigNumber from 'bignumber.js';
18
18
  import { getBalanceFromWallet } from '../utils/wallets';
19
19
  import { useWalletsStore } from '../store/wallets';
20
- import { useTranslation } from 'react-i18next';
20
+ import { Trans } from '@lingui/react';
21
+ import { i18n } from '@lingui/core';
21
22
  import { PercentageChange } from './PercentageChange';
22
23
 
23
24
  type PropTypes = (
@@ -136,7 +137,6 @@ export function TokenInfo(props: PropTypes) {
136
137
  const connectedWallets = useWalletsStore.use.connectedWallets();
137
138
  const fetchingBestRoute = useBestRouteStore.use.loading();
138
139
  const navigate = useNavigate();
139
- const { t } = useTranslation();
140
140
 
141
141
  const tokenBalance =
142
142
  !!fromChain && !!fromToken
@@ -175,8 +175,7 @@ export function TokenInfo(props: PropTypes) {
175
175
  display: 'flex',
176
176
  justifyContent: 'center',
177
177
  alignItems: 'center',
178
- }}
179
- >
178
+ }}>
180
179
  {loadingStatus === 'failed' && <InfoCircleIcon color="error" size={24} />}
181
180
  <AngleDownIcon />
182
181
  </div>
@@ -187,7 +186,11 @@ export function TokenInfo(props: PropTypes) {
187
186
  <Container type={props.type === 'From' ? 'filled' : 'outlined'}>
188
187
  <div className="head">
189
188
  <Typography variant="body2" color="neutral800">
190
- {t(type)}
189
+ {type === 'From' ? (
190
+ <Trans id="swap from" message="From" />
191
+ ) : (
192
+ <Trans id="swap to" message="To" />
193
+ )}
191
194
  </Typography>
192
195
  {props.type === 'From' ? (
193
196
  <Options>
@@ -196,14 +199,13 @@ export function TokenInfo(props: PropTypes) {
196
199
  onClick={() => {
197
200
  if (tokenBalance !== '0')
198
201
  setInputAmount(tokenBalanceReal.split(',').join(''));
199
- }}
200
- >
201
- <Typography variant="body3" color="neutral600">{`${t(
202
- 'Balance'
203
- )}: ${tokenBalance} ${fromToken?.symbol || ''}`}</Typography>
202
+ }}>
203
+ <Typography variant="body3" color="neutral600">
204
+ {i18n.t('Balance')}: {tokenBalance} {fromToken?.symbol || ''}
205
+ </Typography>
204
206
  <Divider size={4} />
205
207
  <Button type="primary" variant="ghost" size="compact">
206
- {t('Max')}
208
+ <Trans id="maximum amount of asset" message="Max" />
207
209
  </Button>
208
210
  </div>
209
211
  </Options>
@@ -216,8 +218,9 @@ export function TokenInfo(props: PropTypes) {
216
218
  <div>
217
219
  <Typography
218
220
  variant="caption"
219
- color="neutral600"
220
- >{`$${numberToString(props.outputUsdValue)}`}</Typography>
221
+ color="neutral600">{`$${numberToString(
222
+ props.outputUsdValue
223
+ )}`}</Typography>
221
224
  </div>
222
225
  </div>
223
226
  )}
@@ -240,11 +243,10 @@ export function TokenInfo(props: PropTypes) {
240
243
  }
241
244
  suffix={ItemSuffix}
242
245
  align="start"
243
- size="large"
244
- >
246
+ size="large">
245
247
  {loadingStatus === 'success' && chain
246
248
  ? chain.displayName
247
- : t('Chain')}
249
+ : i18n.t('Chain')}
248
250
  </Button>
249
251
  <Divider size={12} direction="horizontal" />
250
252
  <Button
@@ -268,9 +270,10 @@ export function TokenInfo(props: PropTypes) {
268
270
  }
269
271
  suffix={ItemSuffix}
270
272
  size="large"
271
- align="start"
272
- >
273
- {loadingStatus === 'success' && token ? token.symbol : t('Token')}
273
+ align="start">
274
+ {loadingStatus === 'success' && token
275
+ ? token.symbol
276
+ : i18n.t('Token')}
274
277
  </Button>
275
278
  <Divider size={12} direction="horizontal" />
276
279
  <div className="amount">
@@ -290,12 +293,12 @@ export function TokenInfo(props: PropTypes) {
290
293
  position: 'absolute',
291
294
  right: '4px',
292
295
  bottom: '2px',
293
- }}
294
- >
296
+ }}>
295
297
  <Typography
296
298
  variant="caption"
297
- color="neutral800"
298
- >{`$${numberToString(inputUsdValue)}`}</Typography>
299
+ color="neutral800">{`$${numberToString(
300
+ inputUsdValue
301
+ )}`}</Typography>
299
302
  </span>
300
303
  }
301
304
  value={props.inputAmount || ''}
@@ -8,7 +8,7 @@ import {
8
8
  Image,
9
9
  } from '@rango-dev/ui';
10
10
  import { LoadingStatus } from '../store/meta';
11
- import { useTranslation } from 'react-i18next';
11
+ import { i18n } from '@lingui/core';
12
12
  import BigNumber from 'bignumber.js';
13
13
  import { numberToString } from '../utils/numbers';
14
14
 
@@ -90,7 +90,7 @@ const OutputContainer = styled('div', {
90
90
  interface PropTypes {
91
91
  label: string;
92
92
  amount: string;
93
- usdValue?: BigNumber;
93
+ usdValue: BigNumber | null;
94
94
  loadingStatus: LoadingStatus;
95
95
  chain: {
96
96
  displayName: string;
@@ -105,7 +105,6 @@ interface PropTypes {
105
105
 
106
106
  export function TokenPreview(props: PropTypes) {
107
107
  const { chain, token, loadingStatus, percentageChange } = props;
108
- const { t } = useTranslation();
109
108
 
110
109
  const ItemSuffix = (
111
110
  <div
@@ -113,8 +112,7 @@ export function TokenPreview(props: PropTypes) {
113
112
  display: 'flex',
114
113
  justifyContent: 'center',
115
114
  alignItems: 'center',
116
- }}
117
- >
115
+ }}>
118
116
  {loadingStatus === 'failed' && <InfoCircleIcon color="error" size={24} />}
119
117
  </div>
120
118
  );
@@ -132,8 +130,9 @@ export function TokenPreview(props: PropTypes) {
132
130
  <Typography
133
131
  variant="caption"
134
132
  color="neutral600"
135
- className="usd-value"
136
- >{`$${numberToString(props.usdValue)}`}</Typography>
133
+ className="usd-value">{`$${numberToString(
134
+ props.usdValue
135
+ )}`}</Typography>
137
136
  )}
138
137
  </div>
139
138
  </div>
@@ -151,11 +150,10 @@ export function TokenPreview(props: PropTypes) {
151
150
  }
152
151
  suffix={ItemSuffix}
153
152
  align="start"
154
- size="large"
155
- >
153
+ size="large">
156
154
  {loadingStatus === 'success' && chain
157
155
  ? chain.displayName
158
- : t('Chain')}
156
+ : i18n.t('Chain')}
159
157
  </Button>
160
158
  <Divider size={12} direction="horizontal" />
161
159
  <Button
@@ -171,9 +169,10 @@ export function TokenPreview(props: PropTypes) {
171
169
  }
172
170
  suffix={ItemSuffix}
173
171
  size="large"
174
- align="start"
175
- >
176
- {loadingStatus === 'success' && token ? token.symbol : t('Token')}
172
+ align="start">
173
+ {loadingStatus === 'success' && token
174
+ ? token.symbol
175
+ : i18n.t('Token')}
177
176
  </Button>
178
177
  <Divider size={12} direction="horizontal" />
179
178
  <div className="amount">
@@ -10,18 +10,17 @@ import { useWalletsStore } from '../store/wallets';
10
10
 
11
11
  export function WidgetEvents() {
12
12
  const connectedWallets = useWalletsStore.use.connectedWallets();
13
- const getOneOfWalletsDetails = useWalletsStore.use.getOneOfWalletsDetails();
13
+ const getWalletsDetails = useWalletsStore.use.getWalletsDetails();
14
14
 
15
15
  const widgetEvents = useEvents();
16
16
 
17
17
  useEffect(() => {
18
18
  widgetEvents.on(MainEvents.StepEvent, (widgetEvent) => {
19
19
  const { event, step } = widgetEvent;
20
- console.log({ event: widgetEvent });
21
20
  const shouldRefetchBalance =
22
21
  (event.type === StepEventType.TX_EXECUTION &&
23
22
  event.status === StepExecutionEventStatus.TX_SENT &&
24
- isApprovalTX(step)) ||
23
+ !isApprovalTX(step)) ||
25
24
  event.type === StepEventType.SUCCEEDED;
26
25
 
27
26
  if (shouldRefetchBalance) {
@@ -34,8 +33,8 @@ export function WidgetEvents() {
34
33
  (wallet) => wallet.chain === step?.toBlockchain
35
34
  );
36
35
 
37
- fromAccount && getOneOfWalletsDetails(fromAccount);
38
- toAccount && getOneOfWalletsDetails(toAccount);
36
+ fromAccount && getWalletsDetails([fromAccount]);
37
+ toAccount && getWalletsDetails([toAccount]);
39
38
  }
40
39
  });
41
40
 
@@ -1,6 +1,6 @@
1
1
  import { Divider, styled, Typography } from '@rango-dev/ui';
2
2
  import React from 'react';
3
-
3
+ import { i18n } from '@lingui/core';
4
4
  interface PropTypes {
5
5
  messages: string[];
6
6
  }
@@ -32,7 +32,7 @@ export function BalanceErrors({ messages }: PropTypes) {
32
32
  return (
33
33
  <>
34
34
  <Typography className="title" variant="title" color={'error'}>
35
- Insufficent Balance:
35
+ {i18n.t('Insufficent Balance:')}
36
36
  </Typography>
37
37
  <Divider size={8} />
38
38
  <List showListStyle={showListStyle}>
@@ -44,4 +44,4 @@ export function BalanceErrors({ messages }: PropTypes) {
44
44
  </List>
45
45
  </>
46
46
  );
47
- }
47
+ }
@@ -1,6 +1,7 @@
1
1
  import { Alert } from '@rango-dev/ui';
2
2
  import React from 'react';
3
3
  import { ChangeSlippageButton } from '../ChangeSlippageButton';
4
+ import { i18n } from '@lingui/core';
4
5
 
5
6
  interface PropTypes {
6
7
  selectedSlippage: number;
@@ -11,8 +12,14 @@ export function HighSlippageWarning(props: PropTypes) {
11
12
 
12
13
  return (
13
14
  <Alert type="warning" footer={<ChangeSlippageButton />}>
14
- Caution, your slippage is high (=
15
- {selectedSlippage}). Your trade may be front run.
15
+ {i18n.t(
16
+ 'highSlippage',
17
+ { selectedSlippage },
18
+ {
19
+ message:
20
+ ' Caution, your slippage is high (={selectedSlippage}). Your trade may be front run.',
21
+ }
22
+ )}
16
23
  </Alert>
17
24
  );
18
25
  }
@@ -1,6 +1,7 @@
1
1
  import { Divider, Typography, styled } from '@rango-dev/ui';
2
2
  import React from 'react';
3
3
  import { ChangeSlippageButton } from '../ChangeSlippageButton';
4
+ import { i18n } from '@lingui/core';
4
5
 
5
6
  interface PropTypes {
6
7
  minRequiredSlippage: string | null;
@@ -13,10 +14,16 @@ const StyledMessage = styled(Typography, {
13
14
  export function MinRequiredSlippage({ minRequiredSlippage }: PropTypes) {
14
15
  return (
15
16
  <StyledMessage variant="body2">
16
- We recommend you to increase slippage to at least &nbsp;
17
- {minRequiredSlippage}
18
- &nbsp; for this route.
19
- <Divider size={8}/>
17
+ {i18n.t(
18
+ 'increaseSlippage',
19
+ { minRequiredSlippage },
20
+ {
21
+ message:
22
+ 'We recommend you to increase slippage to at least {minRequiredSlippage} for this route.',
23
+ }
24
+ )}
25
+
26
+ <Divider size={8} />
20
27
  <ChangeSlippageButton />
21
28
  </StyledMessage>
22
29
  );
@@ -10,7 +10,7 @@ import {
10
10
  ConfirmSwapWarnings,
11
11
  PendingSwapSettings,
12
12
  } from '../types';
13
- import { PendingSwap } from '@rango-dev/ui/dist/containers/History/types';
13
+
14
14
  import {
15
15
  createBestRouteRequestBody,
16
16
  getBalanceWarnings,
@@ -33,7 +33,10 @@ import {
33
33
  } from '../utils/routing';
34
34
  import { numberToString } from '../utils/numbers';
35
35
  import { BestRouteResponse } from 'rango-sdk';
36
- import { calculatePendingSwap } from '@rango-dev/queue-manager-rango-preset';
36
+ import {
37
+ calculatePendingSwap,
38
+ PendingSwap,
39
+ } from '@rango-dev/queue-manager-rango-preset';
37
40
 
38
41
  type ConfirmSwap = {
39
42
  loading: boolean;
@@ -50,6 +53,8 @@ export function useConfirmSwap(): ConfirmSwap {
50
53
  const setBestRoute = useBestRouteStore.use.setBestRoute();
51
54
  const inputUsdValue = useBestRouteStore.use.inputUsdValue();
52
55
  const affiliateRef = useSettingsStore.use.affiliateRef();
56
+ const affiliatePercent = useSettingsStore.use.affiliatePercent();
57
+ const affiliateWallets = useSettingsStore.use.affiliateWallets();
53
58
 
54
59
  const connectedWallets = useWalletsStore.use.connectedWallets();
55
60
  const destination = useWalletsStore.use.customDestination();
@@ -63,7 +68,7 @@ export function useConfirmSwap(): ConfirmSwap {
63
68
  const userSlippage = customSlippage || slippage;
64
69
  const proceedAnywayRef = useRef(false);
65
70
  const confiremedRouteRef = useRef<BestRouteResponse | null>(null);
66
- let abortControllerRef = useRef<AbortController | null>(null);
71
+ const abortControllerRef = useRef<AbortController | null>(null);
67
72
 
68
73
  const [loading, setLoading] = useState(false);
69
74
  const [errors, setErrors] = useState<ConfirmSwapError[]>([]);
@@ -115,6 +120,8 @@ export function useConfirmSwap(): ConfirmSwap {
115
120
  disabledLiquiditySources,
116
121
  userSlippage,
117
122
  affiliateRef,
123
+ affiliatePercent,
124
+ affiliateWallets,
118
125
  initialRoute,
119
126
  destination
120
127
  );
package/src/index.ts CHANGED
@@ -7,7 +7,11 @@ import {
7
7
  import { WidgetProps, Widget } from './Widget';
8
8
  import { WalletType } from '@rango-dev/wallets-shared';
9
9
  import { WidgetWallets } from './Wallets';
10
- import { useWallets } from '@rango-dev/wallets-core';
10
+ import {
11
+ useWallets,
12
+ ProviderInterface,
13
+ EventHandler as HandleWalletsUpdate,
14
+ } from '@rango-dev/wallets-core';
11
15
  import {
12
16
  useEvents as useWidgetEvents,
13
17
  MainEvents,
@@ -15,6 +19,21 @@ import {
15
19
  StepEvent,
16
20
  Route,
17
21
  Step,
22
+ RouteStartedEvent,
23
+ RouteSucceededEvent,
24
+ RouteFailedEvent,
25
+ RouteEventType,
26
+ StepStartedEvent,
27
+ StepSucceededEvent,
28
+ StepFailedEvent,
29
+ StepTxExecutionUpdatedEvent,
30
+ StepTxExecutionBlockedEvent,
31
+ StepCheckStatusEvent,
32
+ StepApprovalTxSucceededEvent,
33
+ StepOutputRevealedEvent,
34
+ StepEventType,
35
+ StepExecutionEventStatus,
36
+ StepExecutionBlockedEventStatus,
18
37
  } from '@rango-dev/queue-manager-rango-preset';
19
38
 
20
39
  export type {
@@ -22,12 +41,34 @@ export type {
22
41
  WalletType,
23
42
  WidgetTheme,
24
43
  WidgetColors,
44
+ ProviderInterface,
25
45
  BlockchainAndTokenConfig,
26
46
  WidgetProps,
27
47
  RouteEvent,
28
48
  StepEvent,
29
49
  Route,
30
50
  Step,
51
+ RouteStartedEvent,
52
+ RouteSucceededEvent,
53
+ RouteFailedEvent,
54
+ StepStartedEvent,
55
+ StepSucceededEvent,
56
+ StepFailedEvent,
57
+ StepTxExecutionUpdatedEvent,
58
+ StepTxExecutionBlockedEvent,
59
+ StepCheckStatusEvent,
60
+ StepApprovalTxSucceededEvent,
61
+ StepOutputRevealedEvent,
62
+ HandleWalletsUpdate,
63
+ };
64
+ export {
65
+ Widget,
66
+ WidgetWallets,
67
+ useWallets,
68
+ useWidgetEvents,
69
+ MainEvents,
70
+ RouteEventType,
71
+ StepEventType,
72
+ StepExecutionEventStatus,
73
+ StepExecutionBlockedEventStatus,
31
74
  };
32
- export { Widget, WidgetWallets };
33
- export { useWallets, useWidgetEvents, MainEvents };
@@ -3,6 +3,7 @@ import { useNavigate } from 'react-router-dom';
3
3
  import { useBestRouteStore } from '../store/bestRoute';
4
4
  import { useWalletsStore } from '../store/wallets';
5
5
  import { useWallets } from '@rango-dev/wallets-core';
6
+ import { i18n } from '@lingui/core';
6
7
  import { navigationRoutes } from '../constants/navigationRoutes';
7
8
  import {
8
9
  getKeplrCompatibleConnectedWallets,
@@ -20,7 +21,6 @@ import { useMetaStore } from '../store/meta';
20
21
  import { WalletType } from '@rango-dev/wallets-shared';
21
22
  import { useNavigateBack } from '../hooks/useNavigateBack';
22
23
  import { TokenPreview } from '../components/TokenPreview';
23
- import { t } from 'i18next';
24
24
  import { Divider, ConfirmSwap, LoadingFailedAlert } from '@rango-dev/ui';
25
25
  import RoutesOverview from '../components/RoutesOverview';
26
26
  import { useManager } from '@rango-dev/queue-manager-react';
@@ -179,7 +179,7 @@ export function ConfirmSwapPage({
179
179
  }}
180
180
  usdValue={inputUsdValue}
181
181
  amount={fromAmount}
182
- label={t('From')}
182
+ label={i18n.t('From')}
183
183
  loadingStatus={
184
184
  loadingMetaStatus !== 'success'
185
185
  ? loadingMetaStatus
@@ -198,7 +198,7 @@ export function ConfirmSwapPage({
198
198
  }}
199
199
  usdValue={outputUsdValue}
200
200
  amount={toAmount}
201
- label={t('To')}
201
+ label={i18n.t('To')}
202
202
  loadingStatus={
203
203
  loadingMetaStatus !== 'success'
204
204
  ? loadingMetaStatus
@@ -239,8 +239,8 @@ export function ConfirmSwapPage({
239
239
  }
240
240
  confirmButtonTitle={
241
241
  warnings.length > 0 || errors.length > 0
242
- ? 'Proceed anyway!'
243
- : 'Confirm swap!'
242
+ ? `${i18n.t('Proceed anyway!')}`
243
+ : `${i18n.t('Confirm swap!')}`
244
244
  }
245
245
  />
246
246
  );
@@ -8,6 +8,7 @@ import {
8
8
  Header,
9
9
  } from '@rango-dev/ui';
10
10
  import React, { useEffect, useState } from 'react';
11
+ import { i18n } from '@lingui/core';
11
12
  import { useInRouterContext, useNavigate } from 'react-router-dom';
12
13
  import { TokenInfo } from '../components/TokenInfo';
13
14
  import { fetchBestRoute, useBestRouteStore } from '../store/bestRoute';
@@ -136,7 +137,7 @@ export function Home() {
136
137
  return (
137
138
  <Container>
138
139
  <Header
139
- title="SWAP"
140
+ title={i18n.t('SWAP')}
140
141
  suffix={
141
142
  <HeaderButtons
142
143
  onClickRefresh={
@@ -18,7 +18,7 @@ import { useWallets } from '@rango-dev/wallets-core';
18
18
  import { useUiStore } from '../store/ui';
19
19
  import { useNavigateBack } from '../hooks/useNavigateBack';
20
20
  import { navigationRoutes } from '../constants/navigationRoutes';
21
- import { useTranslation } from 'react-i18next';
21
+ import { i18n } from '@lingui/core';
22
22
  import { useMetaStore } from '../store/meta';
23
23
  import { Spinner } from '@rango-dev/ui';
24
24
  import { LoadingFailedAlert } from '@rango-dev/ui';
@@ -71,7 +71,6 @@ export function WalletsPage({ supportedWallets, multiWallets }: PropTypes) {
71
71
  const toggleConnectWalletsButton =
72
72
  useUiStore.use.toggleConnectWalletsButton();
73
73
  const loadingMetaStatus = useMetaStore.use.loadingStatus();
74
- const { t } = useTranslation();
75
74
 
76
75
  const onSelectWallet = async (type: WalletType) => {
77
76
  const wallet = state(type);
@@ -115,7 +114,7 @@ export function WalletsPage({ supportedWallets, multiWallets }: PropTypes) {
115
114
 
116
115
  return (
117
116
  <SecondaryPage
118
- title={t('Select Wallet') || ''}
117
+ title={i18n.t('Select Wallet') || ''}
119
118
  textField={false}
120
119
  onBack={navigateBackFrom.bind(null, navigationRoutes.wallets)}>
121
120
  <>