@rango-dev/widget-embedded 0.12.1-next.30 → 0.12.1-next.31
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/Widget.d.ts.map +1 -1
- package/dist/components/AppRouter.d.ts +2 -0
- package/dist/components/AppRouter.d.ts.map +1 -1
- package/dist/components/AppRoutes.d.ts.map +1 -1
- package/dist/components/BlockchainsSection/BlockchainsSection.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.helpers.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.types.d.ts +0 -1
- package/dist/components/TokenList/TokenList.types.d.ts.map +1 -1
- package/dist/components/UpdateUrl.d.ts +6 -1
- package/dist/components/UpdateUrl.d.ts.map +1 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/hooks/usePrepareBlockchainList.d.ts +18 -0
- package/dist/hooks/usePrepareBlockchainList.d.ts.map +1 -0
- package/dist/hooks/useSyncStoresWithConfig.d.ts +3 -0
- package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -0
- package/dist/hooks/useWalletProviders.d.ts +3 -3
- package/dist/hooks/useWalletProviders.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/pages/SelectBlockchainPage.d.ts +1 -2
- package/dist/pages/SelectBlockchainPage.d.ts.map +1 -1
- package/dist/pages/SelectSwapItemsPage.d.ts +1 -5
- package/dist/pages/SelectSwapItemsPage.d.ts.map +1 -1
- package/dist/services/httpService.d.ts +0 -1
- package/dist/services/httpService.d.ts.map +1 -1
- package/dist/store/app.d.ts +26 -0
- package/dist/store/app.d.ts.map +1 -0
- package/dist/store/bestRoute.d.ts +4 -8
- package/dist/store/bestRoute.d.ts.map +1 -1
- package/dist/store/meta.d.ts +0 -2
- package/dist/store/meta.d.ts.map +1 -1
- package/dist/store/slices/config.d.ts +8 -0
- package/dist/store/slices/config.d.ts.map +1 -0
- package/dist/store/slices/data.d.ts +26 -0
- package/dist/store/slices/data.d.ts.map +1 -0
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/utils/configs.d.ts +3 -0
- package/dist/utils/configs.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +1 -1
- package/dist/utils/wallets.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/Widget.tsx +11 -62
- package/src/components/AppRouter.tsx +3 -1
- package/src/components/AppRoutes.tsx +4 -28
- package/src/components/BlockchainsSection/BlockchainsSection.tsx +19 -41
- package/src/components/TokenList/TokenList.helpers.ts +6 -8
- package/src/components/TokenList/TokenList.tsx +24 -20
- package/src/components/TokenList/TokenList.types.ts +0 -1
- package/src/components/UpdateUrl.tsx +7 -1
- package/src/constants.ts +1 -0
- package/src/hooks/usePrepareBlockchainList.ts +122 -0
- package/src/hooks/useSyncStoresWithConfig.ts +102 -0
- package/src/hooks/useWalletProviders.ts +7 -7
- package/src/pages/SelectBlockchainPage.tsx +18 -23
- package/src/pages/SelectSwapItemsPage.tsx +52 -90
- package/src/services/httpService.ts +4 -5
- package/src/store/app.ts +15 -0
- package/src/store/bestRoute.ts +45 -71
- package/src/store/meta.ts +11 -29
- package/src/store/slices/config.ts +26 -0
- package/src/store/slices/data.ts +203 -0
- package/src/store/wallets.ts +0 -27
- package/src/utils/configs.ts +5 -2
- package/src/utils/wallets.ts +38 -18
- package/dist/components/BlockchainsSection/BlockchainSection.helpers.d.ts +0 -3
- package/dist/components/BlockchainsSection/BlockchainSection.helpers.d.ts.map +0 -1
- package/src/components/BlockchainsSection/BlockchainSection.helpers.ts +0 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectBlockchainPage.d.ts","sourceRoot":"","sources":["../../src/pages/SelectBlockchainPage.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"SelectBlockchainPage.d.ts","sourceRoot":"","sources":["../../src/pages/SelectBlockchainPage.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAWxC,UAAU,SAAS;IACjB,IAAI,EAAE,QAAQ,GAAG,aAAa,CAAC;CAChC;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,SAAS,qBA0DpD"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import type { Asset } from 'rango-sdk';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
interface PropTypes {
|
|
4
|
-
type: '
|
|
5
|
-
supportedBlockchains?: string[];
|
|
6
|
-
supportedTokens?: Asset[];
|
|
7
|
-
pinnedTokens?: Asset[];
|
|
3
|
+
type: 'source' | 'destination';
|
|
8
4
|
}
|
|
9
5
|
export declare function SelectSwapItemsPage(props: PropTypes): React.JSX.Element;
|
|
10
6
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectSwapItemsPage.d.ts","sourceRoot":"","sources":["../../src/pages/SelectSwapItemsPage.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SelectSwapItemsPage.d.ts","sourceRoot":"","sources":["../../src/pages/SelectSwapItemsPage.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAcxC,UAAU,SAAS;IACjB,IAAI,EAAE,QAAQ,GAAG,aAAa,CAAC;CAChC;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,SAAS,qBA4GnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpService.d.ts","sourceRoot":"","sources":["../../src/services/httpService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"httpService.d.ts","sourceRoot":"","sources":["../../src/services/httpService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAMxC,eAAO,MAAM,WAAW,mBAMvB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ConfigSlice } from './slices/config';
|
|
2
|
+
import type { DataSlice } from './slices/data';
|
|
3
|
+
export declare const useAppStore: {
|
|
4
|
+
(): DataSlice & ConfigSlice;
|
|
5
|
+
<U>(selector: (state: DataSlice & ConfigSlice) => U, equals?: ((a: U, b: U) => boolean) | undefined): U;
|
|
6
|
+
} & import("zustand").StoreApi<DataSlice & ConfigSlice> & {
|
|
7
|
+
use: {
|
|
8
|
+
_blockchains: () => import("rango-sdk").BlockchainMeta[];
|
|
9
|
+
_tokens: () => import("rango-sdk").Token[];
|
|
10
|
+
_popularTokens: () => import("rango-sdk").Token[];
|
|
11
|
+
_swappers: () => import("rango-sdk").SwapperMeta[];
|
|
12
|
+
blockchains: () => (options?: {
|
|
13
|
+
type?: "destination" | "source" | undefined;
|
|
14
|
+
} | undefined) => import("rango-sdk").BlockchainMeta[];
|
|
15
|
+
tokens: () => (options?: {
|
|
16
|
+
type?: "destination" | "source" | undefined;
|
|
17
|
+
blockchain?: string | undefined;
|
|
18
|
+
searchFor?: string | undefined;
|
|
19
|
+
} | undefined) => import("rango-sdk").Token[];
|
|
20
|
+
isTokenPinned: () => (token: import("rango-sdk").Token) => boolean;
|
|
21
|
+
fetch: () => () => Promise<void>;
|
|
22
|
+
config: () => import("..").WidgetConfig;
|
|
23
|
+
updateConfig: () => (config: import("..").WidgetConfig) => void;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=app.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/store/app.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAa/C,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;CAAyB,CAAC"}
|
|
@@ -13,14 +13,12 @@ export interface RouteState {
|
|
|
13
13
|
fromToken: TokenWithBalance | null;
|
|
14
14
|
toToken: TokenWithBalance | null;
|
|
15
15
|
routeWalletsConfirmed: boolean;
|
|
16
|
-
sourceTokens: Token[];
|
|
17
|
-
destinationTokens: Token[];
|
|
18
16
|
selectedWallets: Wallet[];
|
|
19
17
|
resetRoute: () => void;
|
|
20
18
|
resetToBlockchain: () => void;
|
|
21
19
|
resetFromBlockchain: () => void;
|
|
22
|
-
setFromBlockchain: (chain: BlockchainMeta | null
|
|
23
|
-
setToBlockchain: (chian: BlockchainMeta | null
|
|
20
|
+
setFromBlockchain: (chain: BlockchainMeta | null) => void;
|
|
21
|
+
setToBlockchain: (chian: BlockchainMeta | null) => void;
|
|
24
22
|
setFromToken: (token: Token | null) => void;
|
|
25
23
|
setToToken: (token: Token | null) => void;
|
|
26
24
|
setInputAmount: (amount: string) => void;
|
|
@@ -56,14 +54,12 @@ export declare const useBestRouteStore: {
|
|
|
56
54
|
fromToken: () => TokenWithBalance | null;
|
|
57
55
|
toToken: () => TokenWithBalance | null;
|
|
58
56
|
routeWalletsConfirmed: () => boolean;
|
|
59
|
-
sourceTokens: () => Token[];
|
|
60
|
-
destinationTokens: () => Token[];
|
|
61
57
|
selectedWallets: () => Wallet[];
|
|
62
58
|
resetRoute: () => () => void;
|
|
63
59
|
resetToBlockchain: () => () => void;
|
|
64
60
|
resetFromBlockchain: () => () => void;
|
|
65
|
-
setFromBlockchain: () => (chain: BlockchainMeta | null
|
|
66
|
-
setToBlockchain: () => (chian: BlockchainMeta | null
|
|
61
|
+
setFromBlockchain: () => (chain: BlockchainMeta | null) => void;
|
|
62
|
+
setToBlockchain: () => (chian: BlockchainMeta | null) => void;
|
|
67
63
|
setFromToken: () => (token: Token | null) => void;
|
|
68
64
|
setToToken: () => (token: Token | null) => void;
|
|
69
65
|
setInputAmount: () => (amount: string) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bestRoute.d.ts","sourceRoot":"","sources":["../../src/store/bestRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mDAAmD,CAAC;AACrF,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAE1E,OAAO,SAAS,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"bestRoute.d.ts","sourceRoot":"","sources":["../../src/store/bestRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mDAAmD,CAAC;AACrF,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAE1E,OAAO,SAAS,MAAM,cAAc,CAAC;AAkBrC,MAAM,WAAW,UAAU;IACzB,cAAc,EAAE,cAAc,GAAG,IAAI,CAAC;IACtC,YAAY,EAAE,cAAc,GAAG,IAAI,CAAC;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,SAAS,GAAG,IAAI,CAAC;IAChC,YAAY,EAAE,SAAS,GAAG,IAAI,CAAC;IAC/B,cAAc,EAAE,SAAS,GAAG,IAAI,CAAC;IACjC,SAAS,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACnC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACjC,qBAAqB,EAAE,OAAO,CAAC;IAC/B,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAC9B,mBAAmB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K,IAAI;4CAClB,MAAM,EAAE,KAAK,IAAI;;8CAEf,MAAM,KAAK,IAAI;uCACtB,IAAI;;CAsN9B,CAAC"}
|
package/dist/store/meta.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ export interface MetaState {
|
|
|
7
7
|
};
|
|
8
8
|
loadingStatus: LoadingStatus;
|
|
9
9
|
fetchMeta: () => Promise<void>;
|
|
10
|
-
setTokensWithBalance: () => void;
|
|
11
10
|
}
|
|
12
11
|
export declare const useMetaStore: {
|
|
13
12
|
(): MetaState;
|
|
@@ -19,7 +18,6 @@ export declare const useMetaStore: {
|
|
|
19
18
|
};
|
|
20
19
|
loadingStatus: () => LoadingStatus;
|
|
21
20
|
fetchMeta: () => () => Promise<void>;
|
|
22
|
-
setTokensWithBalance: () => () => void;
|
|
23
21
|
};
|
|
24
22
|
};
|
|
25
23
|
//# sourceMappingURL=meta.d.ts.map
|
package/dist/store/meta.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../src/store/meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../src/store/meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAO9C,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE7D,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,YAAY,GAAG;QAAE,MAAM,EAAE,gBAAgB,EAAE,CAAA;KAAE,CAAC;IACpD,aAAa,EAAE,aAAa,CAAC;IAC7B,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAChC;AAED,eAAO,MAAM,YAAY;;;;;;oBALQ,gBAAgB,EAAE;;;+BAEhC,QAAQ,IAAI,CAAC;;CAyB/B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { WidgetConfig } from '../../types';
|
|
2
|
+
import type { StateCreator } from 'zustand';
|
|
3
|
+
export type ConfigSlice = {
|
|
4
|
+
config: WidgetConfig;
|
|
5
|
+
updateConfig: (config: WidgetConfig) => void;
|
|
6
|
+
};
|
|
7
|
+
export declare const createConfigSlice: StateCreator<ConfigSlice>;
|
|
8
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/store/slices/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAI5C,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,YAAY,CAAC;IAErB,YAAY,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;CAC9C,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,WAAW,CActD,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ConfigSlice } from './config';
|
|
2
|
+
import type { BlockchainMeta, SwapperMeta, Token } from 'rango-sdk';
|
|
3
|
+
import type { StateCreator } from 'zustand';
|
|
4
|
+
type BlockchainOptions = {
|
|
5
|
+
type?: 'source' | 'destination';
|
|
6
|
+
};
|
|
7
|
+
type TokenOptions = {
|
|
8
|
+
type?: 'source' | 'destination';
|
|
9
|
+
blockchain?: string;
|
|
10
|
+
searchFor?: string;
|
|
11
|
+
};
|
|
12
|
+
export interface DataSlice {
|
|
13
|
+
_blockchains: BlockchainMeta[];
|
|
14
|
+
_tokens: Token[];
|
|
15
|
+
_popularTokens: Token[];
|
|
16
|
+
_swappers: SwapperMeta[];
|
|
17
|
+
blockchains: (options?: BlockchainOptions) => BlockchainMeta[];
|
|
18
|
+
tokens: (options?: TokenOptions) => Token[];
|
|
19
|
+
isTokenPinned: (token: Token) => boolean;
|
|
20
|
+
fetch: () => Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
export declare const createDataSlice: StateCreator<DataSlice & ConfigSlice, [
|
|
23
|
+
], [
|
|
24
|
+
], DataSlice>;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../src/store/slices/data.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAM5C,KAAK,iBAAiB,GAAG;IACvB,IAAI,CAAC,EAAE,QAAQ,GAAG,aAAa,CAAC;CACjC,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,IAAI,CAAC,EAAE,QAAQ,GAAG,aAAa,CAAC;IAEhC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,WAAW,SAAS;IACxB,YAAY,EAAE,cAAc,EAAE,CAAC;IAC/B,OAAO,EAAE,KAAK,EAAE,CAAC;IACjB,cAAc,EAAE,KAAK,EAAE,CAAC;IACxB,SAAS,EAAE,WAAW,EAAE,CAAC;IAEzB,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE,iBAAiB,KAAK,cAAc,EAAE,CAAC;IAC/D,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,YAAY,KAAK,KAAK,EAAE,CAAC;IAC5C,aAAa,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC;IAEzC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAED,eAAO,MAAM,eAAe,EAAE,YAAY,CACxC,SAAS,GAAG,WAAW,EACvB;CAAE,EACF;CAAE,EACF,SAAS,CAoKT,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallets.d.ts","sourceRoot":"","sources":["../../src/store/wallets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"wallets.d.ts","sourceRoot":"","sources":["../../src/store/wallets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAe5D,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,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,UAAU,YAAY;IACpB,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAC5C,gBAAgB,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IACnD,aAAa,EAAE,CAAC,OAAO,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,KAAK,IAAI,CAAC;IAC1E,oBAAoB,EAAE,MAAM,IAAI,CAAC;IACjC,iBAAiB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,WAAW,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CACxE;AAED,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;wCAPA,MAAM,EAAE,KAAK,IAAI;6CACZ,UAAU,KAAK,IAAI;uCACzB;YAAE,UAAU,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,EAAE,KAAK,IAAI;0CAC7C,IAAI;4CACF,MAAM,EAAE,gBAAgB,OAAO,KAAK,IAAI;;CAoKvE,CAAC;AAEF,eAAO,MAAM,uBAAuB,UAAW,YAAY,YACA,CAAC"}
|
package/dist/utils/configs.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ export interface Configs {
|
|
|
3
3
|
}
|
|
4
4
|
export declare function getConfig(name: keyof Configs): string;
|
|
5
5
|
export declare function setConfig(name: keyof Configs, value: any): any;
|
|
6
|
+
/**
|
|
7
|
+
* Getting new configs from params and reset the value of global `configs` with provided param.
|
|
8
|
+
*/
|
|
6
9
|
export declare function initConfig(nextConfigs: Configs): Configs;
|
|
7
10
|
export declare const DEFAULT_PRIMARY_RADIUS = 20;
|
|
8
11
|
export declare const DEFAULT_SECONDARY_RADIUS = 25;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configs.d.ts","sourceRoot":"","sources":["../../src/utils/configs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"configs.d.ts","sourceRoot":"","sources":["../../src/utils/configs.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB;AAMD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,OAAO,UAE5C;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,OAAO,EAAE,KAAK,EAAE,GAAG,OAIxD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,WAAW,EAAE,OAAO,WAS9C;AAED,eAAO,MAAM,sBAAsB,KAAK,CAAC;AACzC,eAAO,MAAM,wBAAwB,KAAK,CAAC"}
|
package/dist/utils/wallets.d.ts
CHANGED
|
@@ -21,9 +21,9 @@ export declare const getUsdPrice: (blockchain: string, symbol: string, address:
|
|
|
21
21
|
export declare const isExperimentalChain: (blockchains: BlockchainMeta[], wallet: string) => boolean;
|
|
22
22
|
export declare const getKeplrCompatibleConnectedWallets: (selectableWallets: Wallet[]) => WalletType[];
|
|
23
23
|
export declare function getTokensWithBalance(tokens: TokenWithBalance[], connectedWallets: ConnectedWallet[]): TokenWithBalance[];
|
|
24
|
+
export declare function getTokensBalanceFromWalletAndSort(tokens: TokenWithBalance[], connectedWallets: ConnectedWallet[]): TokenWithBalance[];
|
|
24
25
|
export declare function getSortedTokens(chain: BlockchainMeta | null, tokens: Token[], connectedWallets: ConnectedWallet[], otherChainTokens: TokenWithBalance[]): TokenWithBalance[];
|
|
25
26
|
export declare function tokensAreEqual(tokenA: Pick<Token, 'blockchain' | 'symbol' | 'address'> | null, tokenB: Pick<Token, 'blockchain' | 'symbol' | 'address'> | null): boolean;
|
|
26
|
-
export declare function getDefaultToken(sortedTokens: TokenWithBalance[], otherToken: TokenWithBalance | null): TokenWithBalance;
|
|
27
27
|
export declare function sortWalletsBasedOnConnectionState(wallets: ModalWalletInfo[]): ModalWalletInfo[];
|
|
28
28
|
export declare function getConciseAddress(address: string, maxChars?: number, ellipsisLength?: number): string;
|
|
29
29
|
export declare function getAddress({ chain, connectedWallets, walletType, }: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallets.d.ts","sourceRoot":"","sources":["../../src/utils/wallets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,UAAU,IAAI,eAAe,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,KAAK,EACV,OAAO,EACP,UAAU,EACV,WAAW,EACX,UAAU,EAEX,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EACd,KAAK,EACL,YAAY,EACb,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,WAAW,IAAI,YAAY,EAAE,MAAM,eAAe,CAAC;AAiB5D,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,WAAW,GAAG,YAAY,CAWvE;AAED,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,WAAW,EAC3C,aAAa,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,UAAU,EAC/C,IAAI,EAAE,UAAU,EAAE,EAClB,KAAK,CAAC,EAAE,MAAM,GACb,eAAe,EAAE,CAuBnB;AAED,wBAAgB,6BAA6B,CAC3C,oBAAoB,EAAE,cAAc,EAAE,GACrC,OAAO,EAAE,GAAG,IAAI,CAUlB;AAED,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,MAAM,EAAE,EAClB,cAAc,EAAE,MAAM,EAAE,EACxB,mBAAmB,EAAE,OAAO,EAAE,GAAG,IAAI,GACpC,MAAM,E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BAAgB,EAAE,GACnC,gBAAgB,EAAE,CAWpB;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,iCAAiC,CAC/C,OAAO,EAAE,eAAe,EAAE,GACzB,eAAe,EAAE,CAcnB;AAED,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EAEf,QAAQ,SAAI,EAEZ,cAAc,SAAI,GACjB,MAAM,CAOR;AAED,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,gBAAgB,EAChB,UAAU,GACX,EAAE;IACD,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf,GAAG,MAAM,GAAG,SAAS,CAMrB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/widget-embedded",
|
|
3
|
-
"version": "0.12.1-next.
|
|
3
|
+
"version": "0.12.1-next.31",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"@rango-dev/queue-manager-core": "^0.15.1-next.2",
|
|
24
24
|
"@rango-dev/queue-manager-rango-preset": "^0.15.1-next.6",
|
|
25
25
|
"@rango-dev/queue-manager-react": "^0.15.1-next.4",
|
|
26
|
-
"@rango-dev/ui": "^0.15.1-next.
|
|
26
|
+
"@rango-dev/ui": "^0.15.1-next.22",
|
|
27
27
|
"@rango-dev/wallets-react": "^0.1.1-next.6",
|
|
28
28
|
"@rango-dev/wallets-shared": "^0.15.1-next.4",
|
|
29
29
|
"bignumber.js": "^9.1.1",
|
package/src/Widget.tsx
CHANGED
|
@@ -11,12 +11,10 @@ import { WidgetEvents } from './components/WidgetEvents';
|
|
|
11
11
|
import { globalFont } from './globalStyles';
|
|
12
12
|
import { useTheme } from './hooks/useTheme';
|
|
13
13
|
import QueueManager from './QueueManager';
|
|
14
|
-
import {
|
|
15
|
-
import { useMetaStore } from './store/meta';
|
|
14
|
+
import { useAppStore } from './store/app';
|
|
16
15
|
import { useNotificationStore } from './store/notification';
|
|
17
16
|
import { useSettingsStore } from './store/settings';
|
|
18
17
|
import { initConfig } from './utils/configs';
|
|
19
|
-
import { tokensAreEqual } from './utils/wallets';
|
|
20
18
|
import { WidgetContext, WidgetWallets } from './Wallets';
|
|
21
19
|
|
|
22
20
|
const MainContainer = styled('div', {
|
|
@@ -64,69 +62,13 @@ export function Main(props: PropsWithChildren<WidgetProps>) {
|
|
|
64
62
|
widgetContext.onConnectWallet(setLastConnectedWalletWithNetwork);
|
|
65
63
|
}, []);
|
|
66
64
|
|
|
67
|
-
const {
|
|
68
|
-
setInputAmount,
|
|
69
|
-
setToToken,
|
|
70
|
-
setToBlockchain,
|
|
71
|
-
setFromBlockchain,
|
|
72
|
-
setFromToken,
|
|
73
|
-
} = useBestRouteStore();
|
|
74
|
-
|
|
75
|
-
const {
|
|
76
|
-
meta: { tokens, blockchains },
|
|
77
|
-
loadingStatus: loadingMetaStatus,
|
|
78
|
-
} = useMetaStore();
|
|
79
|
-
|
|
80
|
-
const { setAffiliateRef, setAffiliatePercent, setAffiliateWallets } =
|
|
81
|
-
useSettingsStore();
|
|
82
|
-
|
|
83
|
-
useEffect(() => {
|
|
84
|
-
setInputAmount(config?.amount?.toString() || '');
|
|
85
|
-
}, [config?.amount]);
|
|
86
|
-
|
|
87
|
-
useEffect(() => {
|
|
88
|
-
if (loadingMetaStatus === 'success') {
|
|
89
|
-
const chain = blockchains.find(
|
|
90
|
-
(chain) => chain.name === config?.from?.blockchain
|
|
91
|
-
);
|
|
92
|
-
const token = tokens.find((t) =>
|
|
93
|
-
tokensAreEqual(t, config?.from?.token || null)
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
setFromBlockchain(chain || null);
|
|
97
|
-
setFromToken(token || null);
|
|
98
|
-
}
|
|
99
|
-
}, [config?.from?.token, config?.from?.blockchain, loadingMetaStatus]);
|
|
100
|
-
|
|
101
|
-
useEffect(() => {
|
|
102
|
-
if (loadingMetaStatus === 'success') {
|
|
103
|
-
const chain = blockchains.find(
|
|
104
|
-
(chain) => chain.name === config?.to?.blockchain
|
|
105
|
-
);
|
|
106
|
-
const token = tokens.find((t) =>
|
|
107
|
-
tokensAreEqual(t, config?.to?.token || null)
|
|
108
|
-
);
|
|
109
|
-
setToBlockchain(chain || null);
|
|
110
|
-
setToToken(token || null);
|
|
111
|
-
}
|
|
112
|
-
}, [config?.to?.token, config?.to?.blockchain, loadingMetaStatus]);
|
|
113
|
-
|
|
114
|
-
useEffect(() => {
|
|
115
|
-
setAffiliateRef(config?.affiliate?.ref ?? null);
|
|
116
|
-
setAffiliatePercent(config?.affiliate?.percent ?? null);
|
|
117
|
-
setAffiliateWallets(config?.affiliate?.wallets ?? null);
|
|
118
|
-
}, [
|
|
119
|
-
config?.affiliate?.ref,
|
|
120
|
-
config?.affiliate?.percent,
|
|
121
|
-
config?.affiliate?.wallets,
|
|
122
|
-
]);
|
|
123
|
-
|
|
124
65
|
return (
|
|
125
66
|
<I18nManager language={config?.language}>
|
|
126
67
|
<MainContainer id="swap-container" className={activeTheme}>
|
|
127
68
|
<QueueManager>
|
|
128
69
|
<WidgetEvents />
|
|
129
70
|
<AppRouter
|
|
71
|
+
config={config}
|
|
130
72
|
lastConnectedWallet={lastConnectedWalletWithNetwork}
|
|
131
73
|
disconnectedWallet={disconnectedWallet}
|
|
132
74
|
clearDisconnectedWallet={() => {
|
|
@@ -141,12 +83,19 @@ export function Main(props: PropsWithChildren<WidgetProps>) {
|
|
|
141
83
|
}
|
|
142
84
|
|
|
143
85
|
export function Widget(props: PropsWithChildren<WidgetProps>) {
|
|
86
|
+
const { updateConfig, config } = useAppStore();
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
if (props.config) {
|
|
89
|
+
updateConfig(props.config);
|
|
90
|
+
}
|
|
91
|
+
}, [props.config]);
|
|
92
|
+
|
|
144
93
|
if (!props.config?.externalWallets) {
|
|
145
94
|
return (
|
|
146
95
|
<WidgetWallets
|
|
147
|
-
providers={
|
|
96
|
+
providers={config?.wallets}
|
|
148
97
|
options={{
|
|
149
|
-
walletConnectProjectId:
|
|
98
|
+
walletConnectProjectId: config?.walletConnectProjectId,
|
|
150
99
|
}}>
|
|
151
100
|
<Main {...props} />
|
|
152
101
|
</WidgetWallets>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { WidgetConfig } from '../types';
|
|
1
2
|
import type { WalletType } from '@rango-dev/wallets-shared';
|
|
2
3
|
import type { PropsWithChildren } from 'react';
|
|
3
4
|
|
|
@@ -43,6 +44,7 @@ export function AppRouter({
|
|
|
43
44
|
lastConnectedWallet: string;
|
|
44
45
|
disconnectedWallet: WalletType | undefined;
|
|
45
46
|
clearDisconnectedWallet: () => void;
|
|
47
|
+
config: WidgetConfig | undefined;
|
|
46
48
|
}) {
|
|
47
49
|
const isRouterInContext = useInRouterContext();
|
|
48
50
|
const Router = isRouterInContext ? Route : MemoryRouter;
|
|
@@ -62,7 +64,7 @@ export function AppRouter({
|
|
|
62
64
|
return (
|
|
63
65
|
<>
|
|
64
66
|
<Router>{children}</Router>
|
|
65
|
-
{isRouterInContext && <UpdateUrl />}
|
|
67
|
+
{isRouterInContext && <UpdateUrl config={props.config} />}
|
|
66
68
|
</>
|
|
67
69
|
);
|
|
68
70
|
}
|
|
@@ -32,43 +32,19 @@ export function AppRoutes(props: PropTypes) {
|
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
34
|
path: navigationRoutes.fromSwap,
|
|
35
|
-
element:
|
|
36
|
-
<SelectSwapItemsPage
|
|
37
|
-
type="from"
|
|
38
|
-
supportedBlockchains={config?.from?.blockchains}
|
|
39
|
-
supportedTokens={config?.from?.tokens}
|
|
40
|
-
pinnedTokens={config?.pinnedTokens}
|
|
41
|
-
/>
|
|
42
|
-
),
|
|
35
|
+
element: <SelectSwapItemsPage type="source" />,
|
|
43
36
|
},
|
|
44
37
|
{
|
|
45
38
|
path: navigationRoutes.toSwap,
|
|
46
|
-
element:
|
|
47
|
-
<SelectSwapItemsPage
|
|
48
|
-
type="to"
|
|
49
|
-
supportedBlockchains={config?.to?.blockchains}
|
|
50
|
-
supportedTokens={config?.to?.tokens}
|
|
51
|
-
pinnedTokens={config?.pinnedTokens}
|
|
52
|
-
/>
|
|
53
|
-
),
|
|
39
|
+
element: <SelectSwapItemsPage type="destination" />,
|
|
54
40
|
},
|
|
55
41
|
{
|
|
56
42
|
path: navigationRoutes.fromBlockchain,
|
|
57
|
-
element:
|
|
58
|
-
<SelectBlockchainPage
|
|
59
|
-
type="from"
|
|
60
|
-
supportedBlockchains={config?.to?.blockchains}
|
|
61
|
-
/>
|
|
62
|
-
),
|
|
43
|
+
element: <SelectBlockchainPage type="source" />,
|
|
63
44
|
},
|
|
64
45
|
{
|
|
65
46
|
path: navigationRoutes.toBlockchain,
|
|
66
|
-
element:
|
|
67
|
-
<SelectBlockchainPage
|
|
68
|
-
type="to"
|
|
69
|
-
supportedBlockchains={config?.to?.blockchains}
|
|
70
|
-
/>
|
|
71
|
-
),
|
|
47
|
+
element: <SelectBlockchainPage type="destination" />,
|
|
72
48
|
},
|
|
73
49
|
{
|
|
74
50
|
path: navigationRoutes.settings,
|
|
@@ -9,40 +9,27 @@ import {
|
|
|
9
9
|
Skeleton,
|
|
10
10
|
Typography,
|
|
11
11
|
} from '@rango-dev/ui';
|
|
12
|
-
import
|
|
13
|
-
import React, { useEffect, useState } from 'react';
|
|
12
|
+
import React from 'react';
|
|
14
13
|
|
|
14
|
+
import { usePrepareBlockchainList } from '../../hooks/usePrepareBlockchainList';
|
|
15
15
|
import { useBestRouteStore } from '../../store/bestRoute';
|
|
16
16
|
import { useMetaStore } from '../../store/meta';
|
|
17
17
|
|
|
18
|
-
import { sortBlockchains } from './BlockchainSection.helpers';
|
|
19
18
|
import { Container } from './BlockchainsSection.styles';
|
|
20
19
|
|
|
21
|
-
const
|
|
22
|
-
const MAX = 10;
|
|
20
|
+
const LIST_SIZE = 10;
|
|
23
21
|
const NUMBER_OF_LOADING = 12;
|
|
22
|
+
|
|
24
23
|
export function BlockchainsSection(props: PropTypes) {
|
|
25
24
|
const { blockchains, type, blockchain, onChange, onMoreClick } = props;
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
const blockchainsList = usePrepareBlockchainList(blockchains, {
|
|
26
|
+
limit: LIST_SIZE,
|
|
27
|
+
selected: blockchain?.name,
|
|
28
|
+
});
|
|
29
|
+
|
|
29
30
|
const loadingStatus = useMetaStore.use.loadingStatus();
|
|
30
31
|
const resetToBlockchain = useBestRouteStore.use.resetToBlockchain();
|
|
31
32
|
const resetFromBlockchain = useBestRouteStore.use.resetFromBlockchain();
|
|
32
|
-
const COUNT_BLOCKCHAINS = !!selectFromMoreBlockchain ? MIN : MAX;
|
|
33
|
-
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
const selectBlockchainFromMore = sortedBlockchains
|
|
36
|
-
.slice(MAX, sortedBlockchains.length)
|
|
37
|
-
.find(
|
|
38
|
-
(item) =>
|
|
39
|
-
item.chainId === blockchain?.chainId && item.name === blockchain?.name
|
|
40
|
-
);
|
|
41
|
-
if (!!selectBlockchainFromMore) {
|
|
42
|
-
setSelectFromMoreBlockchain(selectBlockchainFromMore);
|
|
43
|
-
}
|
|
44
|
-
}, [blockchain]);
|
|
45
|
-
|
|
46
33
|
return (
|
|
47
34
|
<div>
|
|
48
35
|
<Divider size={12} />
|
|
@@ -70,18 +57,7 @@ export function BlockchainsSection(props: PropTypes) {
|
|
|
70
57
|
{i18n.t('All')}
|
|
71
58
|
</Typography>
|
|
72
59
|
</BlockchainsChip>
|
|
73
|
-
{
|
|
74
|
-
<BlockchainsChip
|
|
75
|
-
selected={
|
|
76
|
-
!!selectFromMoreBlockchain &&
|
|
77
|
-
selectFromMoreBlockchain.chainId === blockchain?.chainId
|
|
78
|
-
}
|
|
79
|
-
key={selectFromMoreBlockchain.chainId}
|
|
80
|
-
onClick={() => onChange(selectFromMoreBlockchain)}>
|
|
81
|
-
<Image src={selectFromMoreBlockchain.logo} size={30} />
|
|
82
|
-
</BlockchainsChip>
|
|
83
|
-
)}
|
|
84
|
-
{sortedBlockchains.slice(0, COUNT_BLOCKCHAINS).map((item) => (
|
|
60
|
+
{blockchainsList.list.map((item) => (
|
|
85
61
|
<BlockchainsChip
|
|
86
62
|
key={item.chainId}
|
|
87
63
|
selected={!!blockchain && blockchain.chainId === item.chainId}
|
|
@@ -90,13 +66,15 @@ export function BlockchainsSection(props: PropTypes) {
|
|
|
90
66
|
</BlockchainsChip>
|
|
91
67
|
))}
|
|
92
68
|
|
|
93
|
-
|
|
94
|
-
<
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
69
|
+
{blockchainsList.more.length ? (
|
|
70
|
+
<BlockchainsChip onClick={onMoreClick}>
|
|
71
|
+
<Typography variant="body" size="xsmall" color="secondary500">
|
|
72
|
+
{i18n._('More +{count}', {
|
|
73
|
+
count: blockchainsList.more.length,
|
|
74
|
+
})}
|
|
75
|
+
</Typography>
|
|
76
|
+
</BlockchainsChip>
|
|
77
|
+
) : null}
|
|
100
78
|
</>
|
|
101
79
|
)}
|
|
102
80
|
</Container>
|
|
@@ -3,11 +3,9 @@ import type { TokenWithBalance } from './TokenList.types';
|
|
|
3
3
|
import { containsText } from '../../utils/common';
|
|
4
4
|
|
|
5
5
|
export const filterTokens = (list: TokenWithBalance[], searchedFor: string) =>
|
|
6
|
-
list
|
|
7
|
-
|
|
8
|
-
(token)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
)
|
|
13
|
-
.sort((a, b) => (b.pin as any) - (a.pin as any));
|
|
6
|
+
list.filter(
|
|
7
|
+
(token) =>
|
|
8
|
+
containsText(token.symbol, searchedFor) ||
|
|
9
|
+
containsText(token.address || '', searchedFor) ||
|
|
10
|
+
containsText(token.name || '', searchedFor)
|
|
11
|
+
);
|