@rango-dev/widget-embedded 0.5.1-next.2 → 0.5.1-next.21
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 +14 -0
- package/dist/Wallets.d.ts.map +1 -0
- package/dist/Widget.d.ts +3 -3
- package/dist/Widget.d.ts.map +1 -1
- package/dist/components/AppRouter.d.ts.map +1 -1
- package/dist/components/BottomLogo.d.ts.map +1 -1
- package/dist/components/ChangeSlippageButton.d.ts.map +1 -1
- package/dist/components/ConfirmSwapWarnings.d.ts +2 -2
- package/dist/components/ConfirmSwapWarnings.d.ts.map +1 -1
- package/dist/components/HeaderButtons.d.ts.map +1 -1
- package/dist/components/Layout.d.ts.map +1 -1
- package/dist/components/SwapDetailsPlaceholder.d.ts.map +1 -1
- package/dist/components/TokenInfo.d.ts.map +1 -1
- package/dist/components/TokenPreview.d.ts.map +1 -1
- package/dist/components/WidgetEvents.d.ts +2 -0
- package/dist/components/WidgetEvents.d.ts.map +1 -0
- package/dist/components/warnings/HighSlippageWarning.d.ts.map +1 -1
- package/dist/components/warnings/MinRequiredSlippage.d.ts.map +1 -1
- package/dist/hooks/useConfirmSwap.d.ts +1 -1
- package/dist/hooks/useConfirmSwap.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 +5 -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/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 +2 -2
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/config.d.ts +8 -2
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/swap.d.ts +1 -1
- package/dist/types/swap.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/routing.d.ts +1 -1
- package/dist/utils/routing.d.ts.map +1 -1
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts.map +1 -1
- package/package.json +10 -13
- package/src/QueueManager.tsx +0 -25
- package/src/Wallets.tsx +105 -0
- package/src/Widget.tsx +41 -84
- package/src/components/AppRouter.tsx +0 -2
- package/src/components/BottomLogo.tsx +2 -4
- package/src/components/ChangeSlippageButton.tsx +3 -3
- package/src/components/ConfirmSwapWarnings.tsx +10 -13
- package/src/components/HeaderButtons.tsx +7 -9
- package/src/components/Layout.tsx +10 -11
- package/src/components/SwapDetailsPlaceholder.tsx +10 -2
- package/src/components/TokenInfo.tsx +26 -23
- package/src/components/TokenPreview.tsx +11 -12
- package/src/components/WidgetEvents.tsx +45 -0
- package/src/components/warnings/BalanceErrors.tsx +3 -3
- package/src/components/warnings/HighSlippageWarning.tsx +9 -2
- package/src/components/warnings/MinRequiredSlippage.tsx +11 -4
- package/src/hooks/useConfirmSwap.ts +6 -3
- package/src/hooks/useWalletProviders.ts +20 -0
- package/src/index.ts +57 -1
- package/src/pages/ConfirmSwapPage.tsx +5 -5
- package/src/pages/Home.tsx +4 -5
- package/src/pages/WalletsPage.tsx +10 -7
- package/src/store/wallets.ts +42 -17
- package/src/types/config.ts +8 -2
- package/src/types/swap.ts +1 -1
- package/src/utils/providers.ts +53 -0
- package/src/utils/routing.ts +1 -1
- package/src/utils/swap.ts +26 -13
- package/src/utils/wallets.ts +31 -11
- package/dist/hooks/useSelectLanguage.d.ts +0 -5
- package/dist/hooks/useSelectLanguage.d.ts.map +0 -1
- package/dist/i18n.d.ts +0 -3
- package/dist/i18n.d.ts.map +0 -1
- package/dist/mockData/pendingSwap.d.ts +0 -2
- package/dist/mockData/pendingSwap.d.ts.map +0 -1
- package/src/hooks/useSelectLanguage.ts +0 -15
- package/src/i18n.js +0 -30
- package/src/mockData/pendingSwap.ts +0 -607
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":";
|
|
1
|
+
{"version":3,"file":"Home.d.ts","sourceRoot":"","sources":["../../src/pages/Home.tsx"],"names":[],"mappings":";AAoEA,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;AAGxC,UAAU,SAAS;IACjB,gBAAgB,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IAC1C,YAAY,EAAE,OAAO,CAAC;CACvB;AAyBD,wBAAgB,WAAW,CAAC,EAAE,gBAAgB,EAAE,YAAY,EAAE,EAAE,SAAS,eAyFxE"}
|
package/dist/store/wallets.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ interface WalletsStore {
|
|
|
27
27
|
initSelectedWallets: () => void;
|
|
28
28
|
setSelectedWallet: (wallet: SelectableWallet) => void;
|
|
29
29
|
clearConnectedWallet: () => void;
|
|
30
|
-
|
|
30
|
+
getWalletsDetails: (accounts: Wallet[], shouldRetry?: boolean) => void;
|
|
31
31
|
setCustomDestination: (customDestination: string) => void;
|
|
32
32
|
}
|
|
33
33
|
export declare const useWalletsStore: {
|
|
@@ -51,7 +51,7 @@ export declare const useWalletsStore: {
|
|
|
51
51
|
initSelectedWallets: () => () => void;
|
|
52
52
|
setSelectedWallet: () => (wallet: SelectableWallet) => void;
|
|
53
53
|
clearConnectedWallet: () => () => void;
|
|
54
|
-
|
|
54
|
+
getWalletsDetails: () => (accounts: Wallet[], shouldRetry?: boolean) => void;
|
|
55
55
|
setCustomDestination: () => (customDestination: string) => void;
|
|
56
56
|
};
|
|
57
57
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallets.d.ts","sourceRoot":"","sources":["../../src/store/wallets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAgBvD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,CAAC;AAEF,MAAM,WAAW,eAAgB,SAAQ,MAAM;IAC7C,QAAQ,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,UAAU,YAAY;IACpB,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,eAAe,EA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AAE,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,iBAAiB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,WAAW,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACvE,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;4CACF,MAAM,EAAE,gBAAgB,OAAO,KAAK,IAAI;wDAC5B,MAAM,KAAK,IAAI;;CAoJ1D,CAAC;AAyBF,eAAO,MAAM,uBAAuB,UAAW,YAAY,YACA,CAAC"}
|
package/dist/types/config.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Asset } from 'rango-sdk';
|
|
2
2
|
import { WalletType } from '@rango-dev/wallets-shared';
|
|
3
|
+
import { ProviderInterface } from '@rango-dev/wallets-core';
|
|
4
|
+
import { Language } from '@rango-dev/ui';
|
|
3
5
|
/**
|
|
4
6
|
* The above type defines a set of optional color properties for a widget.
|
|
5
7
|
* @property {string} background
|
|
@@ -99,6 +101,9 @@ export type BlockchainAndTokenConfig = {
|
|
|
99
101
|
* @property {WidgetTheme} theme - The `theme` property is a part of the `WidgetConfig` type and is
|
|
100
102
|
* used to specify the visual theme of the widget. It is of type `WidgetTheme`, which is an interface
|
|
101
103
|
* that defines the various properties of the theme, such as colors, fonts, and others.
|
|
104
|
+
* @property {boolean} externalWallets
|
|
105
|
+
* If `externalWallets` is `true`, you should add `WidgetWallets` to your app.
|
|
106
|
+
|
|
102
107
|
*/
|
|
103
108
|
export type WidgetConfig = {
|
|
104
109
|
apiKey: string;
|
|
@@ -107,10 +112,11 @@ export type WidgetConfig = {
|
|
|
107
112
|
from?: BlockchainAndTokenConfig;
|
|
108
113
|
to?: BlockchainAndTokenConfig;
|
|
109
114
|
liquiditySources?: string[];
|
|
110
|
-
wallets?: WalletType[];
|
|
115
|
+
wallets?: (WalletType | ProviderInterface)[];
|
|
111
116
|
multiWallets?: boolean;
|
|
112
117
|
customDestination?: boolean;
|
|
113
|
-
language?:
|
|
118
|
+
language?: Language;
|
|
114
119
|
theme?: WidgetTheme;
|
|
120
|
+
externalWallets?: boolean;
|
|
115
121
|
};
|
|
116
122
|
//# 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;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;;;;;;;;;;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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AAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC"}
|
package/dist/types/swap.d.ts
CHANGED
package/dist/types/swap.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swap.d.ts","sourceRoot":"","sources":["../../src/types/swap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"swap.d.ts","sourceRoot":"","sources":["../../src/types/swap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,MAAM,MAAM,mBAAmB,GAAG,IAAI,CACpC,iBAAiB,EACjB,qBAAqB,CACtB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,CAC1B;IAAE,QAAQ,EAAE,IAAI,CAAA;CAAE,GAClB;IAAE,QAAQ,EAAE,KAAK,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,CAC5C,GAAG;IACF,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B,GAAG,IAAI,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"}
|
package/dist/utils/routing.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SimulationAssetAndAmount, SimulationValidationStatus } from '@rango-dev/ui/dist/types/swaps';
|
|
1
|
+
import { SimulationAssetAndAmount, SimulationValidationStatus } from '@rango-dev/ui/dist/widget/ui/src/types/swaps';
|
|
2
2
|
import BigNumber from 'bignumber.js';
|
|
3
3
|
import { BestRouteResponse, BlockchainMeta, Token } from 'rango-sdk';
|
|
4
4
|
import { BestRouteEqualityParams, Wallet } from '../types';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/utils/routing.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC3B,MAAM,
|
|
1
|
+
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/utils/routing.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC3B,MAAM,8CAA8C,CAAC;AACtD,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,cAAc,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,OAAO,SAAS,OAAO,qCAIlE,CAAC"}
|
package/dist/utils/swap.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swap.d.ts","sourceRoot":"","sources":["../../src/utils/swap.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,UAAU,EACV,KAAK,EACN,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"swap.d.ts","sourceRoot":"","sources":["../../src/utils/swap.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,UAAU,EACV,KAAK,EACN,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGnD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAGvD,OAAO,EAAE,aAAa,EAAgB,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACnE,OAAO,EAEL,eAAe,EAChB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAGpE,wBAAgB,cAAc,CAC5B,aAAa,EAAE,SAAS,EACxB,cAAc,EAAE,SAAS,iBAI1B;AAED,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,SAAS,EACxB,WAAW,EAAE,SAAS,GAAG,CAAC,WAQ3B;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,iBAAiB,GAAG,IAAI,GAAG,OAAO,CAiB1E;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,iBAAiB,GAAG,IAAI,GAAG;IACtE,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC;IACxB,oBAAoB,EAAE,MAAM,C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C;AACF,eAAO,MAAM,mBAAmB,gBACjB,cAAc,EAAE,UACrB,MAAM,KACb,OAOF,CAAC;AAEF,eAAO,MAAM,kCAAkC,sBAC1B,gBAAgB,EAAE,KACpC,UAAU,EAUZ,CAAC;AAEF,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,gBAAgB,EAAE,EAC1B,gBAAgB,EAAE,eAAe,EAAE,GAClC,gBAAgB,EAAE,CAiCpB;AAED,wBAAgB,eAAe,CAC7B,KAAK,EAAE,cAAc,GAAG,IAAI,EAC5B,MAAM,EAAE,KAAK,EAAE,EACf,gBAAgB,EAAE,eAAe,EAAE,EACnC,gBAAgB,EAAE,gBAAgB,EAAE,GACnC,gBAAgB,EAAE,CAOpB;AAED,wBAAgB,cAAc,CAC5B,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,YAAY,GAAG,QAAQ,GAAG,SAAS,CAAC,GAAG,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.21",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,23 +17,20 @@
|
|
|
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.1-next.
|
|
20
|
+
"@rango-dev/provider-all": "^0.5.1-next.11",
|
|
21
|
+
"@rango-dev/queue-manager-core": "^0.5.1-next.1",
|
|
22
|
+
"@rango-dev/queue-manager-rango-preset": "^0.5.1-next.15",
|
|
23
|
+
"@rango-dev/queue-manager-react": "^0.5.1-next.1",
|
|
24
|
+
"@rango-dev/ui": "^0.5.1-next.14",
|
|
25
|
+
"@rango-dev/wallets-core": "^0.5.1-next.9",
|
|
26
|
+
"@rango-dev/wallets-shared": "^0.5.1-next.14",
|
|
27
27
|
"bignumber.js": "^9.1.1",
|
|
28
28
|
"copy-to-clipboard": "^3.3.3",
|
|
29
29
|
"dayjs": "^1.11.7",
|
|
30
|
-
"i18next": "^22.4.11",
|
|
31
|
-
"i18next-browser-languagedetector": "^7.0.1",
|
|
32
|
-
"i18next-http-backend": "^2.1.1",
|
|
33
30
|
"immer": "^9.0.19",
|
|
34
31
|
"mitt": "^3.0.0",
|
|
35
|
-
"rango-sdk": "^0.1.
|
|
36
|
-
"rango-types": "^0.1.
|
|
32
|
+
"rango-sdk": "^0.1.34",
|
|
33
|
+
"rango-types": "^0.1.44",
|
|
37
34
|
"react-i18next": "^12.2.0",
|
|
38
35
|
"react-router-dom": "^6.8.0",
|
|
39
36
|
"values.js": "2.1.1",
|
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,105 @@
|
|
|
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 { useWalletProviders } from './hooks/useWalletProviders';
|
|
13
|
+
import { WidgetConfig } from './types';
|
|
14
|
+
import { createContext, useRef } from 'react';
|
|
15
|
+
|
|
16
|
+
type OnConnectHandler = (key: string) => void;
|
|
17
|
+
interface WidgetContextInterface {
|
|
18
|
+
onConnectWallet(handler: OnConnectHandler): void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const WidgetContext = createContext<WidgetContextInterface>({
|
|
22
|
+
onConnectWallet: () => {
|
|
23
|
+
return;
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export function WidgetWallets(
|
|
28
|
+
props: PropsWithChildren<{
|
|
29
|
+
providers: WidgetConfig['wallets'];
|
|
30
|
+
onUpdateState?: EventHandler;
|
|
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
|
+
// propagate updates for Dapps using external wallets
|
|
86
|
+
if (props.onUpdateState) {
|
|
87
|
+
props.onUpdateState(type, event, value, state, supportedChains);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
return (
|
|
91
|
+
<WidgetContext.Provider
|
|
92
|
+
value={{
|
|
93
|
+
onConnectWallet: (handler) => {
|
|
94
|
+
onConnectWalletHandler.current = handler;
|
|
95
|
+
},
|
|
96
|
+
}}>
|
|
97
|
+
<Provider
|
|
98
|
+
allBlockChains={blockchains}
|
|
99
|
+
providers={providers}
|
|
100
|
+
onUpdateState={onUpdateState}>
|
|
101
|
+
{props.children}
|
|
102
|
+
</Provider>
|
|
103
|
+
</WidgetContext.Provider>
|
|
104
|
+
);
|
|
105
|
+
}
|
package/src/Widget.tsx
CHANGED
|
@@ -1,49 +1,45 @@
|
|
|
1
|
-
import { SwapContainer } from '@rango-dev/ui';
|
|
2
|
-
import React, {
|
|
1
|
+
import { SwapContainer, styled, I18nManager } 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
|
-
import useSelectLanguage from './hooks/useSelectLanguage';
|
|
20
|
-
import './i18n';
|
|
21
15
|
import QueueManager from './QueueManager';
|
|
22
16
|
import { useUiStore } from './store/ui';
|
|
23
17
|
import { navigationRoutes } from './constants/navigationRoutes';
|
|
24
18
|
import { initConfig } from './utils/configs';
|
|
19
|
+
import { WidgetContext, WidgetWallets } from './Wallets';
|
|
20
|
+
import { WidgetEvents } from './components/WidgetEvents';
|
|
21
|
+
|
|
22
|
+
const MainContainer = styled('div', {
|
|
23
|
+
width: '100%',
|
|
24
|
+
display: 'flex',
|
|
25
|
+
justifyContent: 'center',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
});
|
|
25
28
|
|
|
26
29
|
export type WidgetProps = {
|
|
27
30
|
config?: WidgetConfig;
|
|
28
31
|
};
|
|
29
32
|
|
|
30
|
-
export
|
|
33
|
+
export function Main(props: PropsWithChildren<WidgetProps>) {
|
|
34
|
+
const { config } = props;
|
|
31
35
|
globalFont(config?.theme?.fontFamily || 'Roboto');
|
|
32
36
|
|
|
33
|
-
const { activeTheme } = useTheme(
|
|
34
|
-
const { blockchains } = useMetaStore.use.meta();
|
|
35
|
-
const disconnectWallet = useWalletsStore.use.disconnectWallet();
|
|
36
|
-
const connectWallet = useWalletsStore.use.connectWallet();
|
|
37
|
-
const { changeLanguage } = useSelectLanguage();
|
|
38
|
-
const clearConnectedWallet = useWalletsStore.use.clearConnectedWallet();
|
|
37
|
+
const { activeTheme } = useTheme(config?.theme || {});
|
|
39
38
|
const [lastConnectedWalletWithNetwork, setLastConnectedWalletWithNetwork] =
|
|
40
39
|
useState<string>('');
|
|
41
40
|
const [disconnectedWallet, setDisconnectedWallet] = useState<WalletType>();
|
|
42
41
|
const currentPage = useUiStore.use.currentPage();
|
|
43
|
-
|
|
44
|
-
const evmBasedChainNames = blockchains
|
|
45
|
-
.filter(isEvmBlockchain)
|
|
46
|
-
.map((chain) => chain.name);
|
|
42
|
+
const widgetContext = useContext(WidgetContext);
|
|
47
43
|
|
|
48
44
|
useMemo(() => {
|
|
49
45
|
if (config?.apiKey) {
|
|
@@ -53,65 +49,15 @@ export const Widget: React.FC<WidgetProps> = ({ config }) => {
|
|
|
53
49
|
}
|
|
54
50
|
}, [config]);
|
|
55
51
|
|
|
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
52
|
useEffect(() => {
|
|
105
|
-
|
|
106
|
-
}, [
|
|
53
|
+
widgetContext.onConnectWallet(setLastConnectedWalletWithNetwork);
|
|
54
|
+
}, []);
|
|
107
55
|
|
|
108
56
|
return (
|
|
109
|
-
<
|
|
110
|
-
|
|
111
|
-
providers={providers}
|
|
112
|
-
onUpdateState={onUpdateState}>
|
|
113
|
-
<div id="swap-container" className={activeTheme}>
|
|
57
|
+
<I18nManager language={config?.language}>
|
|
58
|
+
<MainContainer id="swap-container" className={activeTheme}>
|
|
114
59
|
<QueueManager>
|
|
60
|
+
<WidgetEvents />
|
|
115
61
|
<SwapContainer fixedHeight={currentPage !== navigationRoutes.home}>
|
|
116
62
|
<AppRouter
|
|
117
63
|
lastConnectedWallet={lastConnectedWalletWithNetwork}
|
|
@@ -123,7 +69,18 @@ export const Widget: React.FC<WidgetProps> = ({ config }) => {
|
|
|
123
69
|
</AppRouter>
|
|
124
70
|
</SwapContainer>
|
|
125
71
|
</QueueManager>
|
|
126
|
-
</
|
|
127
|
-
</
|
|
72
|
+
</MainContainer>
|
|
73
|
+
</I18nManager>
|
|
128
74
|
);
|
|
129
|
-
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function Widget(props: PropsWithChildren<WidgetProps>) {
|
|
78
|
+
if (!props.config?.externalWallets) {
|
|
79
|
+
return (
|
|
80
|
+
<WidgetWallets providers={props.config?.wallets}>
|
|
81
|
+
<Main {...props} />
|
|
82
|
+
</WidgetWallets>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
return <Main {...props} />;
|
|
86
|
+
}
|
|
@@ -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
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { styled } from '@rango-dev/ui';
|
|
3
3
|
import { Typography } from '@rango-dev/ui';
|
|
4
|
-
import {
|
|
4
|
+
import { i18n } from '@lingui/core';
|
|
5
5
|
|
|
6
6
|
const Container = styled('div', {
|
|
7
7
|
display: 'flex',
|
|
@@ -25,12 +25,10 @@ const StyledAnchor = styled('a', {
|
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
export function BottomLogo() {
|
|
28
|
-
const { t } = useTranslation();
|
|
29
|
-
|
|
30
28
|
return (
|
|
31
29
|
<Container>
|
|
32
30
|
<Typography variant="caption" color="$neutral600">
|
|
33
|
-
{t('Powered By')}
|
|
31
|
+
{i18n.t('Powered By')}
|
|
34
32
|
</Typography>
|
|
35
33
|
<StyledAnchor href="https://rango.exchange" target="_blank">
|
|
36
34
|
<Logo xmlns="http://www.w3.org/2000/svg" viewBox="0 0 33.68 29">
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { Button } from '@rango-dev/ui';
|
|
3
3
|
import { useNavigate } from 'react-router-dom';
|
|
4
4
|
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
5
|
+
import { i18n } from '@lingui/core';
|
|
5
6
|
|
|
6
7
|
export function ChangeSlippageButton() {
|
|
7
8
|
const navigate = useNavigate();
|
|
@@ -11,9 +12,8 @@ export function ChangeSlippageButton() {
|
|
|
11
12
|
type="primary"
|
|
12
13
|
variant="outlined"
|
|
13
14
|
size="small"
|
|
14
|
-
onClick={() => navigate('/' + navigationRoutes.settings)}
|
|
15
|
-
|
|
16
|
-
Change Slippage
|
|
15
|
+
onClick={() => navigate('/' + navigationRoutes.settings)}>
|
|
16
|
+
{i18n.t('Change Slippage')}
|
|
17
17
|
</Button>
|
|
18
18
|
);
|
|
19
19
|
}
|
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ConfirmSwapWarningTypes,
|
|
3
|
+
ConfirmSwapWarnings as ConfirmSwapWarningsType,
|
|
4
|
+
} from '../types';
|
|
2
5
|
|
|
3
|
-
export function ConfirmSwapWarnings(warnings:
|
|
6
|
+
export function ConfirmSwapWarnings(warnings: ConfirmSwapWarningsType[]) {
|
|
4
7
|
return warnings.flatMap((warning) => {
|
|
5
8
|
switch (warning.type) {
|
|
6
9
|
case ConfirmSwapWarningTypes.ROUTE_UPDATED:
|
|
7
|
-
return
|
|
10
|
+
return 'Route has been updated.';
|
|
8
11
|
case ConfirmSwapWarningTypes.ROUTE_AND_OUTPUT_AMOUNT_UPDATED:
|
|
9
|
-
return (
|
|
10
|
-
`Output amount changed to ${warning.newOutputAmount} (${warning.percentageChange}% change).`
|
|
11
|
-
);
|
|
12
|
+
return `Output amount changed to ${warning.newOutputAmount} (${warning.percentageChange}% change).`;
|
|
12
13
|
|
|
13
14
|
case ConfirmSwapWarningTypes.ROUTE_SWAPPERS_UPDATED:
|
|
14
|
-
return
|
|
15
|
-
"Route swappers has been updated."
|
|
16
|
-
);
|
|
15
|
+
return 'Route swappers has been updated.';
|
|
17
16
|
case ConfirmSwapWarningTypes.ROUTE_COINS_UPDATED:
|
|
18
|
-
return
|
|
19
|
-
"Route internal coins has been updated."
|
|
20
|
-
);
|
|
17
|
+
return 'Route internal coins has been updated.';
|
|
21
18
|
default:
|
|
22
19
|
return [];
|
|
23
20
|
}
|
|
24
21
|
});
|
|
25
|
-
}
|
|
22
|
+
}
|