@rango-dev/widget-embedded 0.5.1-next.0 → 0.5.1-next.10
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/QueueManager.d.ts.map +1 -1
- package/dist/Wallets.d.ts +13 -0
- package/dist/Wallets.d.ts.map +1 -0
- package/dist/Widget.d.ts +3 -2
- package/dist/Widget.d.ts.map +1 -1
- package/dist/components/AppRouter.d.ts.map +1 -1
- package/dist/components/WidgetEvents.d.ts +2 -0
- package/dist/components/WidgetEvents.d.ts.map +1 -0
- package/dist/hooks/useSelectLanguage.d.ts.map +1 -1
- package/dist/hooks/useWalletProviders.d.ts +6 -0
- package/dist/hooks/useWalletProviders.d.ts.map +1 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/pages/WalletsPage.d.ts +2 -2
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/config.d.ts +6 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/providers.d.ts +11 -0
- package/dist/utils/providers.d.ts.map +1 -0
- package/dist/utils/wallets.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/QueueManager.tsx +0 -25
- package/src/Wallets.tsx +100 -0
- package/src/Widget.tsx +53 -91
- package/src/components/AppRouter.tsx +0 -2
- package/src/components/WidgetEvents.tsx +46 -0
- package/src/hooks/useSelectLanguage.ts +2 -0
- package/src/hooks/useWalletProviders.ts +20 -0
- package/src/index.ts +16 -1
- package/src/pages/ConfirmSwapPage.tsx +3 -4
- package/src/pages/Home.tsx +2 -4
- package/src/pages/WalletsPage.tsx +8 -4
- package/src/store/wallets.ts +4 -5
- package/src/types/config.ts +6 -1
- package/src/utils/providers.ts +53 -0
- package/src/utils/wallets.ts +17 -10
- package/dist/mockData/pendingSwap.d.ts +0 -2
- package/dist/mockData/pendingSwap.d.ts.map +0 -1
- package/src/mockData/pendingSwap.ts +0 -607
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmSwapPage.d.ts","sourceRoot":"","sources":["../../src/pages/ConfirmSwapPage.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"ConfirmSwapPage.d.ts","sourceRoot":"","sources":["../../src/pages/ConfirmSwapPage.tsx"],"names":[],"mappings":";AAoCA,wBAAgB,eAAe,CAAC,EAC9B,wBAAwB,GACzB,EAAE;IACD,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACpC,eA8MA"}
|
package/dist/pages/Home.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Home.d.ts","sourceRoot":"","sources":["../../src/pages/Home.tsx"],"names":[],"mappings":";AAmEA,wBAAgB,IAAI,
|
|
1
|
+
{"version":3,"file":"Home.d.ts","sourceRoot":"","sources":["../../src/pages/Home.tsx"],"names":[],"mappings":";AAmEA,wBAAgB,IAAI,gBA6JnB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { WidgetConfig } from '../types';
|
|
3
3
|
interface PropTypes {
|
|
4
|
-
supportedWallets
|
|
4
|
+
supportedWallets: WidgetConfig['wallets'];
|
|
5
5
|
multiWallets: boolean;
|
|
6
6
|
}
|
|
7
7
|
export declare function WalletsPage({ supportedWallets, multiWallets }: PropTypes): JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WalletsPage.d.ts","sourceRoot":"","sources":["../../src/pages/WalletsPage.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"WalletsPage.d.ts","sourceRoot":"","sources":["../../src/pages/WalletsPage.tsx"],"names":[],"mappings":";AAwBA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;A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CAAC;IACf,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,UAAU,YAAY;IACpB,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAC5C,gBAAgB,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IACnD,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,iBAAiB,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACtD,oBAAoB,EAAE,MAAM,IAAI,CAAC;IACjC,sBAAsB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,oBAAoB,EAAE,CAAC,iBAAiB,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3D;AAED,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;wCATA,MAAM,EAAE,KAAK,IAAI;6CACZ,UAAU,KAAK,IAAI;yCACvB,IAAI;0CACH,gBAAgB,KAAK,IAAI;0CACzB,IAAI;gDACE,MAAM,KAAK,IAAI;wDACP,MAAM,KAAK,IAAI;;CA0H1D,CAAC;AAyBF,eAAO,MAAM,uBAAuB,UAAW,YAAY,YACA,CAAC"}
|
package/dist/types/config.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Asset } from 'rango-sdk';
|
|
2
2
|
import { WalletType } from '@rango-dev/wallets-shared';
|
|
3
|
+
import { ProviderInterface } from '@rango-dev/wallets-core';
|
|
3
4
|
/**
|
|
4
5
|
* The above type defines a set of optional color properties for a widget.
|
|
5
6
|
* @property {string} background
|
|
@@ -99,6 +100,9 @@ export type BlockchainAndTokenConfig = {
|
|
|
99
100
|
* @property {WidgetTheme} theme - The `theme` property is a part of the `WidgetConfig` type and is
|
|
100
101
|
* used to specify the visual theme of the widget. It is of type `WidgetTheme`, which is an interface
|
|
101
102
|
* that defines the various properties of the theme, such as colors, fonts, and others.
|
|
103
|
+
* @property {boolean} externalWallets
|
|
104
|
+
* If `externalWallets` is `true`, you should add `WidgetWallets` to your app.
|
|
105
|
+
|
|
102
106
|
*/
|
|
103
107
|
export type WidgetConfig = {
|
|
104
108
|
apiKey: string;
|
|
@@ -107,10 +111,11 @@ export type WidgetConfig = {
|
|
|
107
111
|
from?: BlockchainAndTokenConfig;
|
|
108
112
|
to?: BlockchainAndTokenConfig;
|
|
109
113
|
liquiditySources?: string[];
|
|
110
|
-
wallets?: WalletType[];
|
|
114
|
+
wallets?: (WalletType | ProviderInterface)[];
|
|
111
115
|
multiWallets?: boolean;
|
|
112
116
|
customDestination?: boolean;
|
|
113
117
|
language?: string;
|
|
114
118
|
theme?: WidgetTheme;
|
|
119
|
+
externalWallets?: boolean;
|
|
115
120
|
};
|
|
116
121
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,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AQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ProviderInterface } from '@rango-dev/wallets-core';
|
|
2
|
+
import { WidgetConfig } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* Generate a list of providers by passing a provider name (e.g. metamask) or a custom provider which implemented ProviderInterface.
|
|
6
|
+
* @returns ProviderInterface[] a list of ProviderInterface
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
export declare function matchAndGenerateProviders(providers: WidgetConfig['wallets']): ProviderInterface[];
|
|
10
|
+
export declare function configWalletsToWalletName(config: WidgetConfig['wallets']): string[];
|
|
11
|
+
//# sourceMappingURL=providers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/utils/providers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,YAAY,CAAC,SAAS,CAAC,GACjC,iBAAiB,EAAE,CA8BrB;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,YAAY,CAAC,SAAS,CAAC,GAC9B,MAAM,EAAE,CAMV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallets.d.ts","sourceRoot":"","sources":["../../src/utils/wallets.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,OAAO,EACP,WAAW,EACX,UAAU,EAEV,UAAU,EACV,WAAW,
|
|
1
|
+
{"version":3,"file":"wallets.d.ts","sourceRoot":"","sources":["../../src/utils/wallets.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,OAAO,EACP,WAAW,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AG,IAAI,EAC/D,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,YAAY,GAAG,QAAQ,GAAG,SAAS,CAAC,GAAG,IAAI,WAOhE;AAED,wBAAgB,eAAe,CAC7B,YAAY,EAAE,gBAAgB,EAAE,EAChC,UAAU,EAAE,gBAAgB,GAAG,IAAI,GAClC,gBAAgB,CAQlB;AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,eAAe,EAAE,GACzB,eAAe,EAAE,CAcnB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/widget-embedded",
|
|
3
|
-
"version": "0.5.1-next.
|
|
3
|
+
"version": "0.5.1-next.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
"lint": "eslint \"**/*.{ts,tsx}\" --ignore-path ../../.eslintignore"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@rango-dev/provider-all": "^0.5.1-next.
|
|
21
|
-
"@rango-dev/queue-manager-core": "^0.5.1-next.
|
|
22
|
-
"@rango-dev/queue-manager-rango-preset": "^0.5.1-next.
|
|
23
|
-
"@rango-dev/queue-manager-react": "^0.5.1-next.
|
|
24
|
-
"@rango-dev/ui": "^0.5.1-next.
|
|
25
|
-
"@rango-dev/wallets-core": "^0.5.1-next.
|
|
26
|
-
"@rango-dev/wallets-shared": "^0.5.
|
|
20
|
+
"@rango-dev/provider-all": "^0.5.1-next.5",
|
|
21
|
+
"@rango-dev/queue-manager-core": "^0.5.1-next.1",
|
|
22
|
+
"@rango-dev/queue-manager-rango-preset": "^0.5.1-next.10",
|
|
23
|
+
"@rango-dev/queue-manager-react": "^0.5.1-next.1",
|
|
24
|
+
"@rango-dev/ui": "^0.5.1-next.9",
|
|
25
|
+
"@rango-dev/wallets-core": "^0.5.1-next.5",
|
|
26
|
+
"@rango-dev/wallets-shared": "^0.5.1-next.10",
|
|
27
27
|
"bignumber.js": "^9.1.1",
|
|
28
28
|
"copy-to-clipboard": "^3.3.3",
|
|
29
29
|
"dayjs": "^1.11.7",
|
package/src/QueueManager.tsx
CHANGED
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
makeQueueDefinition,
|
|
5
5
|
SwapQueueContext,
|
|
6
6
|
checkWaitingForNetworkChange,
|
|
7
|
-
SwapProgressNotification,
|
|
8
7
|
} from '@rango-dev/queue-manager-rango-preset';
|
|
9
8
|
import { useWallets } from '@rango-dev/wallets-core';
|
|
10
9
|
import {
|
|
@@ -33,7 +32,6 @@ function QueueManager(props: PropsWithChildren) {
|
|
|
33
32
|
API_KEY: getConfig('API_KEY'),
|
|
34
33
|
});
|
|
35
34
|
}, []);
|
|
36
|
-
const getOneOfWalletsDetails = useWalletsStore.use.getOneOfWalletsDetails();
|
|
37
35
|
|
|
38
36
|
const { blockchains } = useMetaStore.use.meta();
|
|
39
37
|
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
@@ -70,28 +68,6 @@ function QueueManager(props: PropsWithChildren) {
|
|
|
70
68
|
return walletAndSupportedChainsNames(supportedChains);
|
|
71
69
|
};
|
|
72
70
|
const allProviders = providers();
|
|
73
|
-
const notifier = (data: SwapProgressNotification) => {
|
|
74
|
-
const lastStep = data.swap?.steps[data.swap.steps.length - 1];
|
|
75
|
-
const outputAmount = data.step?.outputAmount || '';
|
|
76
|
-
const step = data.step || lastStep;
|
|
77
|
-
|
|
78
|
-
if (
|
|
79
|
-
data.eventType === 'task_completed' ||
|
|
80
|
-
(data.eventType === 'step_completed_with_output' &&
|
|
81
|
-
lastStep?.id !== data.step?.id) ||
|
|
82
|
-
!!outputAmount
|
|
83
|
-
) {
|
|
84
|
-
const fromAccount = connectedWallets.find(
|
|
85
|
-
(account) => account.chain === step?.fromBlockchain
|
|
86
|
-
);
|
|
87
|
-
const toAccount =
|
|
88
|
-
step?.fromBlockchain !== step?.toBlockchain &&
|
|
89
|
-
connectedWallets.find((wallet) => wallet.chain === step?.toBlockchain);
|
|
90
|
-
|
|
91
|
-
fromAccount && getOneOfWalletsDetails(fromAccount);
|
|
92
|
-
toAccount && getOneOfWalletsDetails(toAccount);
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
71
|
|
|
96
72
|
const context: SwapQueueContext = {
|
|
97
73
|
meta: {
|
|
@@ -112,7 +88,6 @@ function QueueManager(props: PropsWithChildren) {
|
|
|
112
88
|
connect,
|
|
113
89
|
state,
|
|
114
90
|
isMobileWallet,
|
|
115
|
-
notifier,
|
|
116
91
|
};
|
|
117
92
|
|
|
118
93
|
return (
|
package/src/Wallets.tsx
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from 'react';
|
|
2
|
+
import { useMetaStore } from './store/meta';
|
|
3
|
+
import { Events, Provider } from '@rango-dev/wallets-core';
|
|
4
|
+
import { EventHandler } from '@rango-dev/wallets-core';
|
|
5
|
+
import { Network } from '@rango-dev/wallets-shared';
|
|
6
|
+
import {
|
|
7
|
+
prepareAccountsForWalletStore,
|
|
8
|
+
walletAndSupportedChainsNames,
|
|
9
|
+
} from './utils/wallets';
|
|
10
|
+
import { useWalletsStore } from './store/wallets';
|
|
11
|
+
import { isEvmBlockchain } from 'rango-sdk';
|
|
12
|
+
import './i18n';
|
|
13
|
+
import { useWalletProviders } from './hooks/useWalletProviders';
|
|
14
|
+
import { WidgetConfig } from './types';
|
|
15
|
+
import { createContext, useRef } from 'react';
|
|
16
|
+
|
|
17
|
+
type OnConnectHandler = (key: string) => void;
|
|
18
|
+
interface WidgetContextInterface {
|
|
19
|
+
onConnectWallet(handler: OnConnectHandler): void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const WidgetContext = createContext<WidgetContextInterface>({
|
|
23
|
+
onConnectWallet: () => {
|
|
24
|
+
return;
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export function WidgetWallets(
|
|
29
|
+
props: PropsWithChildren<{
|
|
30
|
+
providers: WidgetConfig['wallets'];
|
|
31
|
+
}>
|
|
32
|
+
) {
|
|
33
|
+
const { blockchains } = useMetaStore.use.meta();
|
|
34
|
+
const { providers } = useWalletProviders(props.providers);
|
|
35
|
+
const disconnectWallet = useWalletsStore.use.disconnectWallet();
|
|
36
|
+
const connectWallet = useWalletsStore.use.connectWallet();
|
|
37
|
+
const onConnectWalletHandler = useRef<OnConnectHandler>();
|
|
38
|
+
|
|
39
|
+
const evmBasedChainNames = blockchains
|
|
40
|
+
.filter(isEvmBlockchain)
|
|
41
|
+
.map((chain) => chain.name);
|
|
42
|
+
|
|
43
|
+
const onUpdateState: EventHandler = (
|
|
44
|
+
type,
|
|
45
|
+
event,
|
|
46
|
+
value,
|
|
47
|
+
state,
|
|
48
|
+
supportedChains
|
|
49
|
+
) => {
|
|
50
|
+
if (event === Events.ACCOUNTS) {
|
|
51
|
+
if (value) {
|
|
52
|
+
const supportedChainNames: Network[] | null =
|
|
53
|
+
walletAndSupportedChainsNames(supportedChains);
|
|
54
|
+
const data = prepareAccountsForWalletStore(
|
|
55
|
+
type,
|
|
56
|
+
value,
|
|
57
|
+
evmBasedChainNames,
|
|
58
|
+
supportedChainNames
|
|
59
|
+
);
|
|
60
|
+
connectWallet(data);
|
|
61
|
+
} else {
|
|
62
|
+
disconnectWallet(type);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (event === Events.ACCOUNTS && state.connected) {
|
|
66
|
+
const key = `${type}-${state.network}-${value}`;
|
|
67
|
+
|
|
68
|
+
if (state.connected) {
|
|
69
|
+
if (!!onConnectWalletHandler.current)
|
|
70
|
+
onConnectWalletHandler.current(key);
|
|
71
|
+
else
|
|
72
|
+
console.warn(
|
|
73
|
+
`onConnectWallet handler hasn't been set. Are you sure?`
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (event === Events.NETWORK && state.network) {
|
|
79
|
+
const key = `${type}-${state.network}`;
|
|
80
|
+
if (!!onConnectWalletHandler.current) onConnectWalletHandler.current(key);
|
|
81
|
+
else
|
|
82
|
+
console.warn(`onConnectWallet handler hasn't been set. Are you sure?`);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
return (
|
|
86
|
+
<WidgetContext.Provider
|
|
87
|
+
value={{
|
|
88
|
+
onConnectWallet: (handler) => {
|
|
89
|
+
onConnectWalletHandler.current = handler;
|
|
90
|
+
},
|
|
91
|
+
}}>
|
|
92
|
+
<Provider
|
|
93
|
+
allBlockChains={blockchains}
|
|
94
|
+
providers={providers}
|
|
95
|
+
onUpdateState={onUpdateState}>
|
|
96
|
+
{props.children}
|
|
97
|
+
</Provider>
|
|
98
|
+
</WidgetContext.Provider>
|
|
99
|
+
);
|
|
100
|
+
}
|
package/src/Widget.tsx
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
import { SwapContainer } from '@rango-dev/ui';
|
|
2
|
-
import React, {
|
|
1
|
+
import { SwapContainer, styled } from '@rango-dev/ui';
|
|
2
|
+
import React, {
|
|
3
|
+
PropsWithChildren,
|
|
4
|
+
useContext,
|
|
5
|
+
useEffect,
|
|
6
|
+
useMemo,
|
|
7
|
+
useState,
|
|
8
|
+
} from 'react';
|
|
3
9
|
import { AppRouter } from './components/AppRouter';
|
|
4
|
-
import {
|
|
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, WalletType } from '@rango-dev/wallets-shared';
|
|
9
|
-
import {
|
|
10
|
-
prepareAccountsForWalletStore,
|
|
11
|
-
walletAndSupportedChainsNames,
|
|
12
|
-
} from './utils/wallets';
|
|
13
|
-
import { useWalletsStore } from './store/wallets';
|
|
10
|
+
import { WalletType } from '@rango-dev/wallets-shared';
|
|
14
11
|
import { Layout } from './components/Layout';
|
|
15
12
|
import { globalFont } from './globalStyles';
|
|
16
13
|
import { useTheme } from './hooks/useTheme';
|
|
17
|
-
import { isEvmBlockchain } from 'rango-sdk';
|
|
18
14
|
import { WidgetConfig } from './types';
|
|
19
15
|
import useSelectLanguage from './hooks/useSelectLanguage';
|
|
20
16
|
import './i18n';
|
|
@@ -22,28 +18,31 @@ import QueueManager from './QueueManager';
|
|
|
22
18
|
import { useUiStore } from './store/ui';
|
|
23
19
|
import { navigationRoutes } from './constants/navigationRoutes';
|
|
24
20
|
import { initConfig } from './utils/configs';
|
|
21
|
+
import { WidgetContext, WidgetWallets } from './Wallets';
|
|
22
|
+
import { WidgetEvents } from './components/WidgetEvents';
|
|
23
|
+
|
|
24
|
+
const MainContainer = styled('div', {
|
|
25
|
+
width: '100%',
|
|
26
|
+
display: 'flex',
|
|
27
|
+
justifyContent: 'center',
|
|
28
|
+
alignItems: 'center',
|
|
29
|
+
});
|
|
25
30
|
|
|
26
31
|
export type WidgetProps = {
|
|
27
32
|
config?: WidgetConfig;
|
|
28
33
|
};
|
|
29
34
|
|
|
30
|
-
export
|
|
35
|
+
export function Main(props: PropsWithChildren<WidgetProps>) {
|
|
36
|
+
const { config } = props;
|
|
31
37
|
globalFont(config?.theme?.fontFamily || 'Roboto');
|
|
32
38
|
|
|
33
|
-
const { activeTheme } = useTheme(
|
|
34
|
-
const { blockchains } = useMetaStore.use.meta();
|
|
35
|
-
const disconnectWallet = useWalletsStore.use.disconnectWallet();
|
|
36
|
-
const connectWallet = useWalletsStore.use.connectWallet();
|
|
39
|
+
const { activeTheme } = useTheme(config?.theme || {});
|
|
37
40
|
const { changeLanguage } = useSelectLanguage();
|
|
38
|
-
const clearConnectedWallet = useWalletsStore.use.clearConnectedWallet();
|
|
39
41
|
const [lastConnectedWalletWithNetwork, setLastConnectedWalletWithNetwork] =
|
|
40
42
|
useState<string>('');
|
|
41
43
|
const [disconnectedWallet, setDisconnectedWallet] = useState<WalletType>();
|
|
42
44
|
const currentPage = useUiStore.use.currentPage();
|
|
43
|
-
|
|
44
|
-
const evmBasedChainNames = blockchains
|
|
45
|
-
.filter(isEvmBlockchain)
|
|
46
|
-
.map((chain) => chain.name);
|
|
45
|
+
const widgetContext = useContext(WidgetContext);
|
|
47
46
|
|
|
48
47
|
useMemo(() => {
|
|
49
48
|
if (config?.apiKey) {
|
|
@@ -53,77 +52,40 @@ export const Widget: React.FC<WidgetProps> = ({ config }) => {
|
|
|
53
52
|
}
|
|
54
53
|
}, [config]);
|
|
55
54
|
|
|
56
|
-
const onUpdateState: EventHandler = (
|
|
57
|
-
type,
|
|
58
|
-
event,
|
|
59
|
-
value,
|
|
60
|
-
state,
|
|
61
|
-
supportedChains
|
|
62
|
-
) => {
|
|
63
|
-
if (event === Events.ACCOUNTS) {
|
|
64
|
-
if (value) {
|
|
65
|
-
const supportedChainNames: Network[] | null =
|
|
66
|
-
walletAndSupportedChainsNames(supportedChains);
|
|
67
|
-
const data = prepareAccountsForWalletStore(
|
|
68
|
-
type,
|
|
69
|
-
value,
|
|
70
|
-
evmBasedChainNames,
|
|
71
|
-
supportedChainNames
|
|
72
|
-
);
|
|
73
|
-
connectWallet(data);
|
|
74
|
-
} else {
|
|
75
|
-
disconnectWallet(type);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
if (event === Events.ACCOUNTS && state.connected) {
|
|
79
|
-
const key = `${type}-${state.network}-${value}`;
|
|
80
|
-
|
|
81
|
-
if (state.connected) {
|
|
82
|
-
setLastConnectedWalletWithNetwork(key);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (event === Events.NETWORK && state.network) {
|
|
87
|
-
const key = `${type}-${state.network}`;
|
|
88
|
-
setLastConnectedWalletWithNetwork(key);
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
let providers = allProviders();
|
|
92
|
-
|
|
93
|
-
useEffect(() => {
|
|
94
|
-
const wallets = config?.wallets;
|
|
95
|
-
clearConnectedWallet();
|
|
96
|
-
providers = !wallets
|
|
97
|
-
? allProviders()
|
|
98
|
-
: allProviders().filter((provider) => {
|
|
99
|
-
const type = provider.config.type;
|
|
100
|
-
return wallets.find((w) => w === type);
|
|
101
|
-
});
|
|
102
|
-
}, [config?.wallets]);
|
|
103
|
-
|
|
104
55
|
useEffect(() => {
|
|
105
56
|
changeLanguage(config?.language || 'en');
|
|
106
57
|
}, [config?.language]);
|
|
107
58
|
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
widgetContext.onConnectWallet(setLastConnectedWalletWithNetwork);
|
|
61
|
+
}, []);
|
|
62
|
+
|
|
108
63
|
return (
|
|
109
|
-
<
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
</SwapContainer>
|
|
125
|
-
</QueueManager>
|
|
126
|
-
</div>
|
|
127
|
-
</Provider>
|
|
64
|
+
<MainContainer id="swap-container" className={activeTheme}>
|
|
65
|
+
<QueueManager>
|
|
66
|
+
<WidgetEvents />
|
|
67
|
+
<SwapContainer fixedHeight={currentPage !== navigationRoutes.home}>
|
|
68
|
+
<AppRouter
|
|
69
|
+
lastConnectedWallet={lastConnectedWalletWithNetwork}
|
|
70
|
+
disconnectedWallet={disconnectedWallet}
|
|
71
|
+
clearDisconnectedWallet={() => {
|
|
72
|
+
setDisconnectedWallet(undefined);
|
|
73
|
+
}}>
|
|
74
|
+
<Layout config={config} />
|
|
75
|
+
</AppRouter>
|
|
76
|
+
</SwapContainer>
|
|
77
|
+
</QueueManager>
|
|
78
|
+
</MainContainer>
|
|
128
79
|
);
|
|
129
|
-
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function Widget(props: PropsWithChildren<WidgetProps>) {
|
|
83
|
+
if (!props.config?.externalWallets) {
|
|
84
|
+
return (
|
|
85
|
+
<WidgetWallets providers={props.config?.wallets}>
|
|
86
|
+
<Main {...props} />
|
|
87
|
+
</WidgetWallets>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
return <Main {...props} />;
|
|
91
|
+
}
|
|
@@ -27,8 +27,6 @@ export function AppRouter({
|
|
|
27
27
|
clearDisconnectedWallet: props.clearDisconnectedWallet,
|
|
28
28
|
disconnectedWallet: props.disconnectedWallet,
|
|
29
29
|
evmChains,
|
|
30
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
31
|
-
notifier: () => {},
|
|
32
30
|
canSwitchNetworkTo,
|
|
33
31
|
});
|
|
34
32
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
useEvents,
|
|
4
|
+
MainEvents,
|
|
5
|
+
StepEventType,
|
|
6
|
+
StepExecutionEventStatus,
|
|
7
|
+
isApprovalTX,
|
|
8
|
+
} from '@rango-dev/queue-manager-rango-preset';
|
|
9
|
+
import { useWalletsStore } from '../store/wallets';
|
|
10
|
+
|
|
11
|
+
export function WidgetEvents() {
|
|
12
|
+
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
13
|
+
const getOneOfWalletsDetails = useWalletsStore.use.getOneOfWalletsDetails();
|
|
14
|
+
|
|
15
|
+
const widgetEvents = useEvents();
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
widgetEvents.on(MainEvents.StepEvent, (widgetEvent) => {
|
|
19
|
+
const { event, step } = widgetEvent;
|
|
20
|
+
console.log({ event: widgetEvent });
|
|
21
|
+
const shouldRefetchBalance =
|
|
22
|
+
(event.type === StepEventType.TX_EXECUTION &&
|
|
23
|
+
event.status === StepExecutionEventStatus.TX_SENT &&
|
|
24
|
+
isApprovalTX(step)) ||
|
|
25
|
+
event.type === StepEventType.SUCCEEDED;
|
|
26
|
+
|
|
27
|
+
if (shouldRefetchBalance) {
|
|
28
|
+
const fromAccount = connectedWallets.find(
|
|
29
|
+
(account) => account.chain === step?.fromBlockchain
|
|
30
|
+
);
|
|
31
|
+
const toAccount =
|
|
32
|
+
step?.fromBlockchain !== step?.toBlockchain &&
|
|
33
|
+
connectedWallets.find(
|
|
34
|
+
(wallet) => wallet.chain === step?.toBlockchain
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
fromAccount && getOneOfWalletsDetails(fromAccount);
|
|
38
|
+
toAccount && getOneOfWalletsDetails(toAccount);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
return () => widgetEvents.all.clear();
|
|
43
|
+
}, [widgetEvents, connectedWallets.length]);
|
|
44
|
+
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
@@ -2,10 +2,12 @@ import { useTranslation } from 'react-i18next';
|
|
|
2
2
|
|
|
3
3
|
export default function useSelectLanguage() {
|
|
4
4
|
const { i18n } = useTranslation();
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
5
6
|
// @ts-ignore
|
|
6
7
|
const currentLanguage = i18n?.language || 'en';
|
|
7
8
|
const changeLanguage = (value: string) => {
|
|
8
9
|
if (currentLanguage !== value) {
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
9
11
|
// @ts-ignore
|
|
10
12
|
i18n.changeLanguage(value);
|
|
11
13
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ProviderInterface } from '@rango-dev/wallets-core';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { useWalletsStore } from '../store/wallets';
|
|
4
|
+
import { WidgetConfig } from '../types';
|
|
5
|
+
import { matchAndGenerateProviders } from '../utils/providers';
|
|
6
|
+
|
|
7
|
+
export function useWalletProviders(providers: WidgetConfig['wallets']) {
|
|
8
|
+
const clearConnectedWallet = useWalletsStore.use.clearConnectedWallet();
|
|
9
|
+
let generateProviders: ProviderInterface[] =
|
|
10
|
+
matchAndGenerateProviders(undefined);
|
|
11
|
+
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
clearConnectedWallet();
|
|
14
|
+
generateProviders = matchAndGenerateProviders(providers);
|
|
15
|
+
}, [providers]);
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
providers: generateProviders,
|
|
19
|
+
};
|
|
20
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -6,6 +6,16 @@ import {
|
|
|
6
6
|
} from './types';
|
|
7
7
|
import { WidgetProps, Widget } from './Widget';
|
|
8
8
|
import { WalletType } from '@rango-dev/wallets-shared';
|
|
9
|
+
import { WidgetWallets } from './Wallets';
|
|
10
|
+
import { useWallets } from '@rango-dev/wallets-core';
|
|
11
|
+
import {
|
|
12
|
+
useEvents as useWidgetEvents,
|
|
13
|
+
MainEvents,
|
|
14
|
+
RouteEvent,
|
|
15
|
+
StepEvent,
|
|
16
|
+
Route,
|
|
17
|
+
Step,
|
|
18
|
+
} from '@rango-dev/queue-manager-rango-preset';
|
|
9
19
|
|
|
10
20
|
export type {
|
|
11
21
|
WidgetConfig,
|
|
@@ -14,5 +24,10 @@ export type {
|
|
|
14
24
|
WidgetColors,
|
|
15
25
|
BlockchainAndTokenConfig,
|
|
16
26
|
WidgetProps,
|
|
27
|
+
RouteEvent,
|
|
28
|
+
StepEvent,
|
|
29
|
+
Route,
|
|
30
|
+
Step,
|
|
17
31
|
};
|
|
18
|
-
export { Widget };
|
|
32
|
+
export { Widget, WidgetWallets };
|
|
33
|
+
export { useWallets, useWidgetEvents, MainEvents };
|
|
@@ -17,10 +17,9 @@ import {
|
|
|
17
17
|
} from '../utils/swap';
|
|
18
18
|
import { numberToString } from '../utils/numbers';
|
|
19
19
|
import { useMetaStore } from '../store/meta';
|
|
20
|
-
import {
|
|
20
|
+
import { WalletType } from '@rango-dev/wallets-shared';
|
|
21
21
|
import { useNavigateBack } from '../hooks/useNavigateBack';
|
|
22
22
|
import { TokenPreview } from '../components/TokenPreview';
|
|
23
|
-
// @ts-ignore // TODO: fix error in tsc build
|
|
24
23
|
import { t } from 'i18next';
|
|
25
24
|
import { Divider, ConfirmSwap, LoadingFailedAlert } from '@rango-dev/ui';
|
|
26
25
|
import RoutesOverview from '../components/RoutesOverview';
|
|
@@ -90,7 +89,7 @@ export function ConfirmSwapPage({
|
|
|
90
89
|
const toAmount = numberToString(lastStep?.toAmount, 4, 6);
|
|
91
90
|
useEffect(() => {
|
|
92
91
|
initSelectedWallets();
|
|
93
|
-
if (
|
|
92
|
+
if (customDestination) {
|
|
94
93
|
setCustomDestination('');
|
|
95
94
|
}
|
|
96
95
|
}, []);
|
|
@@ -108,7 +107,7 @@ export function ConfirmSwapPage({
|
|
|
108
107
|
);
|
|
109
108
|
|
|
110
109
|
const handleConnectChain = (wallet: string) => {
|
|
111
|
-
const network = wallet
|
|
110
|
+
const network = wallet;
|
|
112
111
|
getKeplrCompatibleConnectedWallets(selectableWallets).forEach(
|
|
113
112
|
(compatibleWallet: WalletType) => connect?.(compatibleWallet, network)
|
|
114
113
|
);
|
package/src/pages/Home.tsx
CHANGED
|
@@ -159,8 +159,7 @@ export function Home() {
|
|
|
159
159
|
onClick={() => {
|
|
160
160
|
switchFromAndTo();
|
|
161
161
|
setCount((prev) => prev + 1);
|
|
162
|
-
}}
|
|
163
|
-
>
|
|
162
|
+
}}>
|
|
164
163
|
<VerticalSwapIcon size={32} />
|
|
165
164
|
{isRouterInContext && <SwithFromAndTo count={count} />}
|
|
166
165
|
</Button>
|
|
@@ -216,8 +215,7 @@ export function Home() {
|
|
|
216
215
|
else {
|
|
217
216
|
navigate(navigationRoutes.confirmSwap, { replace: true });
|
|
218
217
|
}
|
|
219
|
-
}}
|
|
220
|
-
>
|
|
218
|
+
}}>
|
|
221
219
|
{swapButtonState.title}
|
|
222
220
|
</Button>
|
|
223
221
|
<BottomLogo />
|