@rango-dev/widget-embedded 0.1.10-next.89 → 0.1.10-next.92
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/App.d.ts +4 -16
- package/dist/App.d.ts.map +1 -1
- package/dist/components/AppRouter.d.ts +7 -1
- package/dist/components/AppRouter.d.ts.map +1 -1
- package/dist/components/AppRoutes.d.ts +2 -1
- package/dist/components/AppRoutes.d.ts.map +1 -1
- package/dist/components/BottomLogo.d.ts.map +1 -1
- package/dist/components/Header.d.ts +3 -0
- package/dist/components/Header.d.ts.map +1 -1
- package/dist/components/Layout.d.ts +5 -1
- package/dist/components/Layout.d.ts.map +1 -1
- package/dist/components/TokenInfo.d.ts.map +1 -1
- package/dist/globalStyles.d.ts +1 -0
- package/dist/globalStyles.d.ts.map +1 -1
- package/dist/hooks/usePrevious.d.ts +2 -0
- package/dist/hooks/usePrevious.d.ts.map +1 -0
- package/dist/hooks/useSelectLanguage.d.ts +5 -0
- package/dist/hooks/useSelectLanguage.d.ts.map +1 -0
- package/dist/hooks/useTheme.d.ts +5 -1
- package/dist/hooks/useTheme.d.ts.map +1 -1
- package/dist/i18n.d.ts +3 -0
- package/dist/i18n.d.ts.map +1 -0
- package/dist/lib.d.ts +6 -1
- package/dist/lib.d.ts.map +1 -1
- package/dist/pages/Home.d.ts +7 -1
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/pages/LiquiditySourcesPage.d.ts +6 -1
- package/dist/pages/LiquiditySourcesPage.d.ts.map +1 -1
- package/dist/pages/SelectChainPage.d.ts +2 -0
- package/dist/pages/SelectChainPage.d.ts.map +1 -1
- package/dist/pages/SelectTokenPage.d.ts +1 -0
- package/dist/pages/SelectTokenPage.d.ts.map +1 -1
- package/dist/pages/SettingsPage.d.ts +6 -1
- package/dist/pages/SettingsPage.d.ts.map +1 -1
- package/dist/pages/WalletsPage.d.ts +7 -1
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/config.d.ts +40 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/common.d.ts +1 -0
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/utils/numbers.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +1 -1
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/widget-embedded.cjs.development.js +500 -100
- package/dist/widget-embedded.cjs.development.js.map +1 -1
- package/dist/widget-embedded.cjs.production.min.js +500 -100
- package/dist/widget-embedded.cjs.production.min.js.map +1 -1
- package/dist/widget-embedded.esm.js +506 -106
- package/dist/widget-embedded.esm.js.map +1 -1
- package/package.json +5 -1
- package/src/App.tsx +20 -30
- package/src/app.css +0 -1
- package/src/components/AppRouter.tsx +16 -6
- package/src/components/AppRoutes.tsx +40 -9
- package/src/components/BottomLogo.tsx +4 -1
- package/src/components/Header.tsx +15 -3
- package/src/components/Layout.tsx +30 -4
- package/src/components/TokenInfo.tsx +68 -23
- package/src/globalStyles.ts +10 -0
- package/src/hooks/usePrevious.ts +13 -0
- package/src/hooks/useSelectLanguage.ts +15 -0
- package/src/hooks/useTheme.ts +101 -11
- package/src/i18n.js +30 -0
- package/src/languages/en.json +13 -0
- package/src/languages/tr.json +11 -0
- package/src/lib.tsx +66 -12
- package/src/pages/Home.tsx +15 -3
- package/src/pages/LiquiditySourcesPage.tsx +16 -4
- package/src/pages/SelectChainPage.tsx +7 -3
- package/src/pages/SelectTokenPage.tsx +6 -2
- package/src/pages/SettingsPage.tsx +29 -5
- package/src/pages/WalletsPage.tsx +17 -3
- package/src/store/wallets.ts +8 -0
- package/src/types/config.ts +44 -0
- package/src/types/index.ts +1 -0
- package/src/utils/common.ts +30 -2
- package/src/utils/numbers.ts +1 -0
- package/src/utils/swap.ts +1 -1
- package/src/utils/wallets.ts +1 -1
- package/dist/swapBox.d.ts +0 -3
- package/dist/swapBox.d.ts.map +0 -1
- package/src/swapBox.tsx +0 -65
package/src/utils/common.ts
CHANGED
|
@@ -2,6 +2,34 @@ export function removeDuplicateFrom<T>(array: T[]): T[] {
|
|
|
2
2
|
return Array.from(new Set(array));
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
-
export function areEqual(
|
|
6
|
-
|
|
5
|
+
export function areEqual(
|
|
6
|
+
array1: (number | string)[],
|
|
7
|
+
array2: (number | string)[]
|
|
8
|
+
) {
|
|
9
|
+
return (
|
|
10
|
+
array1.length === array2.length && array1.every((v, i) => v === array2[i])
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
export function shadeColor(color: string, percent: number) {
|
|
14
|
+
var R = parseInt(color.substring(1, 3), 16);
|
|
15
|
+
var G = parseInt(color.substring(3, 5), 16);
|
|
16
|
+
var B = parseInt(color.substring(5, 7), 16);
|
|
17
|
+
|
|
18
|
+
R = (R * (100 + percent)) / 100;
|
|
19
|
+
G = (G * (100 + percent)) / 100;
|
|
20
|
+
B = (B * (100 + percent)) / 100;
|
|
21
|
+
|
|
22
|
+
R = R < 255 ? R : 255;
|
|
23
|
+
G = G < 255 ? G : 255;
|
|
24
|
+
B = B < 255 ? B : 255;
|
|
25
|
+
|
|
26
|
+
R = Math.round(R);
|
|
27
|
+
G = Math.round(G);
|
|
28
|
+
B = Math.round(B);
|
|
29
|
+
|
|
30
|
+
var RR = R.toString(16).length == 1 ? '0' + R.toString(16) : R.toString(16);
|
|
31
|
+
var GG = G.toString(16).length == 1 ? '0' + G.toString(16) : G.toString(16);
|
|
32
|
+
var BB = B.toString(16).length == 1 ? '0' + B.toString(16) : B.toString(16);
|
|
33
|
+
|
|
34
|
+
return '#' + RR + GG + BB;
|
|
7
35
|
}
|
package/src/utils/numbers.ts
CHANGED
|
@@ -68,6 +68,7 @@ export const convertBigNumberToHex = (value: BigNumber, decimals: number): strin
|
|
|
68
68
|
|
|
69
69
|
export const uint8ArrayToHex = (buffer: Uint8Array): string => {
|
|
70
70
|
// buffer is an ArrayBuffer
|
|
71
|
+
// @ts-ignore
|
|
71
72
|
return [...buffer].map((x) => x.toString(16).padStart(2, '0')).join('');
|
|
72
73
|
};
|
|
73
74
|
|
package/src/utils/swap.ts
CHANGED
|
@@ -18,8 +18,8 @@ import { numberToString } from './numbers';
|
|
|
18
18
|
import { WalletType } from '@rango-dev/wallets-shared';
|
|
19
19
|
import { getRequiredBalanceOfWallet } from './routing';
|
|
20
20
|
import { getRequiredChains, SelectedWallet } from './wallets';
|
|
21
|
-
import { SwapButtonState } from '../types';
|
|
22
21
|
import { LoadingStatus } from '../store/meta';
|
|
22
|
+
import { SwapButtonState } from '../types';
|
|
23
23
|
|
|
24
24
|
export function getOutputRatio(
|
|
25
25
|
inputUsdValue: BigNumber,
|
package/src/utils/wallets.ts
CHANGED
package/dist/swapBox.d.ts
DELETED
package/dist/swapBox.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"swapBox.d.ts","sourceRoot":"","sources":["src/swapBox.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAmB1B,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EA4C3B,CAAC"}
|
package/src/swapBox.tsx
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { SwapContainer } from '@rango-dev/ui';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { AppRouter } from './components/AppRouter';
|
|
4
|
-
import { useMetaStore } from './store/meta';
|
|
5
|
-
import { Events, Provider } from '@rango-dev/wallets-core';
|
|
6
|
-
import { allProviders } from '@rango-dev/provider-all';
|
|
7
|
-
import { EventHandler } from '@rango-dev/wallets-core/dist/wallet';
|
|
8
|
-
import { Network } from '@rango-dev/wallets-shared';
|
|
9
|
-
import {
|
|
10
|
-
prepareAccountsForWalletStore,
|
|
11
|
-
walletAndSupportedChainsNames,
|
|
12
|
-
} from './utils/wallets';
|
|
13
|
-
import { useWalletsStore } from './store/wallets';
|
|
14
|
-
import { Layout } from './components/Layout';
|
|
15
|
-
import { globalStyles } from './globalStyles';
|
|
16
|
-
import { useTheme } from './hooks/useTheme';
|
|
17
|
-
import { isEvmBlockchain } from 'rango-sdk';
|
|
18
|
-
|
|
19
|
-
const providers = allProviders();
|
|
20
|
-
|
|
21
|
-
export const SwapBox: React.FC = () => {
|
|
22
|
-
globalStyles();
|
|
23
|
-
const { activeTheme } = useTheme();
|
|
24
|
-
const { blockchains } = useMetaStore.use.meta();
|
|
25
|
-
const disconnectWallet = useWalletsStore.use.disconnectWallet();
|
|
26
|
-
const connectWallet = useWalletsStore.use.connectWallet();
|
|
27
|
-
const evmBasedChainNames = blockchains
|
|
28
|
-
.filter(isEvmBlockchain)
|
|
29
|
-
.map((chain) => chain.name);
|
|
30
|
-
|
|
31
|
-
const onUpdateState: EventHandler = (type, event, value, supportedChains) => {
|
|
32
|
-
if (event === Events.ACCOUNTS) {
|
|
33
|
-
if (value) {
|
|
34
|
-
const supportedChainNames: Network[] | null =
|
|
35
|
-
//@ts-ignore
|
|
36
|
-
walletAndSupportedChainsNames(supportedChains);
|
|
37
|
-
const data = prepareAccountsForWalletStore(
|
|
38
|
-
type,
|
|
39
|
-
value,
|
|
40
|
-
evmBasedChainNames,
|
|
41
|
-
supportedChainNames
|
|
42
|
-
);
|
|
43
|
-
connectWallet(data);
|
|
44
|
-
} else {
|
|
45
|
-
disconnectWallet(type);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<Provider
|
|
52
|
-
allBlockChains={blockchains}
|
|
53
|
-
providers={providers}
|
|
54
|
-
onUpdateState={onUpdateState}
|
|
55
|
-
>
|
|
56
|
-
<div id="pageContainer" className={activeTheme}>
|
|
57
|
-
<SwapContainer>
|
|
58
|
-
<AppRouter>
|
|
59
|
-
<Layout />
|
|
60
|
-
</AppRouter>
|
|
61
|
-
</SwapContainer>
|
|
62
|
-
</div>
|
|
63
|
-
</Provider>
|
|
64
|
-
);
|
|
65
|
-
};
|