@rango-dev/widget-embedded 0.17.1-next.24 → 0.17.1-next.26
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/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +3 -3
- package/dist/components/Quote/Quote.styles.d.ts +1 -1
- package/dist/components/TokenList/TokenList.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.helpers.d.ts +2 -2
- package/dist/components/TokenList/TokenList.helpers.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.types.d.ts +3 -9
- package/dist/components/TokenList/TokenList.types.d.ts.map +1 -1
- package/dist/components/TokenList/index.d.ts +0 -1
- package/dist/components/TokenList/index.d.ts.map +1 -1
- package/dist/containers/Wallets/Wallets.d.ts.map +1 -1
- package/dist/containers/WidgetInfo/WidgetInfo.d.ts.map +1 -1
- package/dist/containers/WidgetInfo/WidgetInfo.helpers.d.ts +12 -0
- package/dist/containers/WidgetInfo/WidgetInfo.helpers.d.ts.map +1 -0
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts +2 -2
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts.map +1 -1
- package/dist/index.d.ts +7 -4
- 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/SelectSwapItemsPage.d.ts.map +1 -1
- package/dist/store/quote.d.ts +4 -5
- package/dist/store/quote.d.ts.map +1 -1
- package/dist/store/wallets.d.ts +5 -2
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/wallets.d.ts +15 -1
- package/dist/types/wallets.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +6 -8
- package/dist/utils/wallets.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/components/TokenList/TokenList.helpers.ts +2 -2
- package/src/components/TokenList/TokenList.tsx +10 -12
- package/src/components/TokenList/TokenList.types.ts +3 -10
- package/src/components/TokenList/index.ts +0 -1
- package/src/containers/Wallets/Wallets.tsx +2 -3
- package/src/containers/WidgetInfo/WidgetInfo.helpers.ts +45 -0
- package/src/containers/WidgetInfo/WidgetInfo.tsx +4 -3
- package/src/containers/WidgetInfo/WidgetInfo.types.ts +2 -2
- package/src/index.ts +37 -2
- package/src/pages/Home.tsx +9 -33
- package/src/pages/SelectSwapItemsPage.tsx +3 -6
- package/src/store/quote.ts +2 -3
- package/src/store/wallets.ts +56 -29
- package/src/types/wallets.ts +18 -1
- package/src/utils/wallets.ts +80 -134
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":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Home.d.ts","sourceRoot":"","sources":["../../src/pages/Home.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AA8C3D,wBAAgB,IAAI,sBA4NnB"}
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,qBA2FnD"}
|
package/dist/store/quote.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { TokenWithBalance } from '../components/TokenList';
|
|
2
1
|
import type { Wallet } from '../types';
|
|
3
2
|
import type { PendingSwap } from '@rango-dev/queue-manager-rango-preset/dist/shared';
|
|
4
3
|
import type { BestRouteResponse, BlockchainMeta, MetaResponse, Token } from 'rango-sdk';
|
|
@@ -18,8 +17,8 @@ export interface QuoteState {
|
|
|
18
17
|
inputUsdValue: BigNumber | null;
|
|
19
18
|
outputAmount: BigNumber | null;
|
|
20
19
|
outputUsdValue: BigNumber | null;
|
|
21
|
-
fromToken:
|
|
22
|
-
toToken:
|
|
20
|
+
fromToken: Token | null;
|
|
21
|
+
toToken: Token | null;
|
|
23
22
|
quoteWalletsConfirmed: boolean;
|
|
24
23
|
selectedWallets: Wallet[];
|
|
25
24
|
quoteWarningsConfirmed: boolean;
|
|
@@ -62,8 +61,8 @@ export declare const useQuoteStore: {
|
|
|
62
61
|
inputUsdValue: () => BigNumber | null;
|
|
63
62
|
outputAmount: () => BigNumber | null;
|
|
64
63
|
outputUsdValue: () => BigNumber | null;
|
|
65
|
-
fromToken: () =>
|
|
66
|
-
toToken: () =>
|
|
64
|
+
fromToken: () => Token | null;
|
|
65
|
+
toToken: () => Token | null;
|
|
67
66
|
quoteWalletsConfirmed: () => boolean;
|
|
68
67
|
selectedWallets: () => Wallet[];
|
|
69
68
|
quoteWarningsConfirmed: () => boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quote.d.ts","sourceRoot":"","sources":["../../src/store/quote.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"quote.d.ts","sourceRoot":"","sources":["../../src/store/quote.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mDAAmD,CAAC;AACrF,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc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, Wallet } from '../types';
|
|
2
2
|
import type { WalletType } from '@rango-dev/wallets-shared';
|
|
3
3
|
import type { Token } from 'rango-sdk';
|
|
4
4
|
export type TokenBalance = {
|
|
@@ -21,6 +21,7 @@ export interface ConnectedWallet extends Wallet {
|
|
|
21
21
|
}
|
|
22
22
|
interface WalletsStore {
|
|
23
23
|
connectedWallets: ConnectedWallet[];
|
|
24
|
+
balances: TokensBalance;
|
|
24
25
|
customDestination: string;
|
|
25
26
|
loading: boolean;
|
|
26
27
|
connectWallet: (accounts: Wallet[], tokens: Token[]) => void;
|
|
@@ -31,6 +32,7 @@ interface WalletsStore {
|
|
|
31
32
|
}[]) => void;
|
|
32
33
|
clearConnectedWallet: () => void;
|
|
33
34
|
getWalletsDetails: (accounts: Wallet[], tokens: Token[], shouldRetry?: boolean) => void;
|
|
35
|
+
getBalanceFor: (token: Token) => Balance | null;
|
|
34
36
|
}
|
|
35
37
|
export declare const useWalletsStore: {
|
|
36
38
|
(): WalletsStore;
|
|
@@ -47,6 +49,7 @@ export declare const useWalletsStore: {
|
|
|
47
49
|
} & {
|
|
48
50
|
use: {
|
|
49
51
|
connectedWallets: () => ConnectedWallet[];
|
|
52
|
+
balances: () => TokensBalance;
|
|
50
53
|
customDestination: () => string;
|
|
51
54
|
loading: () => boolean;
|
|
52
55
|
connectWallet: () => (accounts: Wallet[], tokens: Token[]) => void;
|
|
@@ -57,8 +60,8 @@ export declare const useWalletsStore: {
|
|
|
57
60
|
}[]) => void;
|
|
58
61
|
clearConnectedWallet: () => () => void;
|
|
59
62
|
getWalletsDetails: () => (accounts: Wallet[], tokens: Token[], shouldRetry?: boolean) => void;
|
|
63
|
+
getBalanceFor: () => (token: Token) => Balance | null;
|
|
60
64
|
};
|
|
61
65
|
};
|
|
62
|
-
export declare const fetchingBalanceSelector: (state: WalletsStore) => boolean;
|
|
63
66
|
export {};
|
|
64
67
|
//# sourceMappingURL=wallets.d.ts.map
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"wallets.d.ts","sourceRoot":"","sources":["../../src/store/wallets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAgBvC,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;AACD,UAAU,YAAY;IACpB,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,QAAQ,EAAE,aAAa,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,IAAI,CAAC;IAC7D,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,CACjB,QAAQ,EAAE,MAAM,EAAE,EAClB,MAAM,EAAE,KAAK,EAAE,EACf,WAAW,CAAC,EAAE,OAAO,KAClB,IAAI,CAAC;IACV,aAAa,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,GAAG,IAAI,CAAC;CACjD;AAED,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;wCAZA,MAAM,EAAE,UAAU,KAAK,EAAE,KAAK,IAAI;6CAC7B,UAAU,KAAK,IAAI;uCACzB;YAAE,UAAU,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,EAAE,KAAK,IAAI;0CAC7C,IAAI;4CAEpB,MAAM,EAAE,UACV,KAAK,EAAE,gBACD,OAAO,KAClB,IAAI;qCACc,KAAK,KAAK,OAAO,GAAG,IAAI;;CA+LhD,CAAC"}
|
package/dist/types/wallets.d.ts
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
|
-
import { WalletType } from '@rango-dev/wallets-shared';
|
|
1
|
+
import type { WalletType } from '@rango-dev/wallets-shared';
|
|
2
2
|
export interface Wallet {
|
|
3
3
|
chain: string;
|
|
4
4
|
address: string;
|
|
5
5
|
walletType: WalletType;
|
|
6
6
|
}
|
|
7
|
+
export type Balance = {
|
|
8
|
+
amount: string;
|
|
9
|
+
decimals: number;
|
|
10
|
+
usdValue: string;
|
|
11
|
+
};
|
|
12
|
+
type Blockchain = string;
|
|
13
|
+
type TokenSymbol = string;
|
|
14
|
+
type Address = string;
|
|
15
|
+
/** `blockchain-symbol-Address` */
|
|
16
|
+
export type TokenHash = `${Blockchain}-${TokenSymbol}-${Address}`;
|
|
17
|
+
export type TokensBalance = {
|
|
18
|
+
[key: TokenHash]: Balance;
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
7
21
|
//# sourceMappingURL=wallets.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallets.d.ts","sourceRoot":"","sources":["../../src/types/wallets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"wallets.d.ts","sourceRoot":"","sources":["../../src/types/wallets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,UAAU,CAAC;CACxB;AAED,MAAM,MAAM,OAAO,GAAG;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,UAAU,GAAG,MAAM,CAAC;AACzB,KAAK,WAAW,GAAG,MAAM,CAAC;AAC1B,KAAK,OAAO,GAAG,MAAM,CAAC;AAEtB,kCAAkC;AAClC,MAAM,MAAM,SAAS,GAAG,GAAG,UAAU,IAAI,WAAW,IAAI,OAAO,EAAE,CAAC;AAElE,MAAM,MAAM,aAAa,GAAG;IAC1B,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC;CAC3B,CAAC"}
|
package/dist/utils/wallets.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { TokenWithBalance } from '../components/TokenList';
|
|
2
1
|
import type { ConnectedWallet, TokenBalance } from '../store/wallets';
|
|
3
|
-
import type { Wallet } from '../types';
|
|
2
|
+
import type { Balance, TokenHash, TokensBalance, Wallet } from '../types';
|
|
4
3
|
import type { WalletInfo as ModalWalletInfo } from '@rango-dev/ui';
|
|
5
|
-
import type { Network, WalletInfo, WalletState, WalletType } from '@rango-dev/wallets-shared';
|
|
4
|
+
import type { Asset, Network, WalletInfo, WalletState, WalletType } from '@rango-dev/wallets-shared';
|
|
6
5
|
import type { BestRouteResponse, BlockchainMeta, Token, WalletDetail } from 'rango-sdk';
|
|
7
6
|
import { WalletState as WalletStatus } from '@rango-dev/ui';
|
|
8
7
|
export declare function mapStatusToWalletState(state: WalletState): WalletStatus;
|
|
@@ -10,18 +9,15 @@ export declare function mapWalletTypesToWalletInfo(getState: (type: WalletType)
|
|
|
10
9
|
export declare function walletAndSupportedChainsNames(supportedBlockchains: BlockchainMeta[]): Network[] | null;
|
|
11
10
|
export declare function prepareAccountsForWalletStore(wallet: WalletType, accounts: string[], evmBasedChains: string[], supportedChainNames: Network[] | null, isContractWallet: boolean): Wallet[];
|
|
12
11
|
export declare function getRequiredChains(quote: BestRouteResponse | null): string[];
|
|
13
|
-
export declare function getBalanceFromWallet(connectedWallets: ConnectedWallet[], chain: string, symbol: string, address: string | null): TokenBalance | null;
|
|
14
12
|
export declare function isAccountAndWalletMatched(account: Wallet, connectedWallet: ConnectedWallet): boolean;
|
|
15
13
|
export declare function makeBalanceFor(retrievedBalance: WalletDetail, tokens: Token[]): TokenBalance[];
|
|
16
14
|
export declare function resetConnectedWalletState(connectedWallet: ConnectedWallet): ConnectedWallet;
|
|
17
15
|
export declare const calculateWalletUsdValue: (connectedWallet: ConnectedWallet[]) => string;
|
|
18
|
-
export declare const sortTokens: (tokens: TokenWithBalance[]) => TokenWithBalance[];
|
|
19
16
|
export declare const getUsdPrice: (blockchain: string, symbol: string, address: string | null, allTokens: Token[]) => number | null;
|
|
20
17
|
export declare const isExperimentalChain: (blockchains: BlockchainMeta[], wallet: string) => boolean;
|
|
21
18
|
export declare const getKeplrCompatibleConnectedWallets: (selectableWallets: Wallet[]) => WalletType[];
|
|
22
|
-
export declare function
|
|
23
|
-
export declare function
|
|
24
|
-
export declare function getSortedTokens(chain: BlockchainMeta | null, tokens: Token[], connectedWallets: ConnectedWallet[], otherChainTokens: TokenWithBalance[]): TokenWithBalance[];
|
|
19
|
+
export declare function formatBalance(balance: Balance | null): Balance | null;
|
|
20
|
+
export declare function sortTokensByBalance(tokens: Token[], getBalanceFor: (token: Token) => Balance | null): Token[];
|
|
25
21
|
export declare function tokensAreEqual(tokenA: Pick<Token, 'blockchain' | 'symbol' | 'address'> | null, tokenB: Pick<Token, 'blockchain' | 'symbol' | 'address'> | null): boolean;
|
|
26
22
|
export declare function sortWalletsBasedOnConnectionState(wallets: ModalWalletInfo[]): ModalWalletInfo[];
|
|
27
23
|
export declare function getConciseAddress(address: string, maxChars?: number, ellipsisLength?: number): string;
|
|
@@ -30,4 +26,6 @@ export declare function getAddress({ chain, connectedWallets, walletType, }: {
|
|
|
30
26
|
walletType: string;
|
|
31
27
|
chain: string;
|
|
32
28
|
}): string | undefined;
|
|
29
|
+
export declare function createTokenHash(token: Asset): TokenHash;
|
|
30
|
+
export declare function makeTokensBalance(connectedWallets: ConnectedWallet[]): TokensBalance;
|
|
33
31
|
//# sourceMappingURL=wallets.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallets.d.ts","sourceRoot":"","sources":["../../src/utils/wallets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"wallets.d.ts","sourceRoot":"","sources":["../../src/utils/wallets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAC1E,OAAO,KAAK,EAAE,UAAU,IAAI,eAAe,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,KAAK,EACV,KAAK,EACL,OAAO,EACP,UAAU,EACV,WAAW,EACX,U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
|
3
|
+
"version": "0.17.1-next.26",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@lingui/core": "4.2.1",
|
|
23
23
|
"@lingui/react": "4.2.1",
|
|
24
|
-
"@rango-dev/provider-all": "^0.22.1-next.
|
|
25
|
-
"@rango-dev/queue-manager-core": "^0.22.1-next.
|
|
26
|
-
"@rango-dev/queue-manager-rango-preset": "^0.22.1-next.
|
|
27
|
-
"@rango-dev/queue-manager-react": "^0.22.1-next.
|
|
28
|
-
"@rango-dev/ui": "^0.22.1-next.
|
|
29
|
-
"@rango-dev/wallets-react": "^0.8.1-next.
|
|
30
|
-
"@rango-dev/wallets-shared": "^0.21.1-next.
|
|
24
|
+
"@rango-dev/provider-all": "^0.22.1-next.7",
|
|
25
|
+
"@rango-dev/queue-manager-core": "^0.22.1-next.3",
|
|
26
|
+
"@rango-dev/queue-manager-rango-preset": "^0.22.1-next.10",
|
|
27
|
+
"@rango-dev/queue-manager-react": "^0.22.1-next.3",
|
|
28
|
+
"@rango-dev/ui": "^0.22.1-next.15",
|
|
29
|
+
"@rango-dev/wallets-react": "^0.8.1-next.5",
|
|
30
|
+
"@rango-dev/wallets-shared": "^0.21.1-next.5",
|
|
31
31
|
"bignumber.js": "^9.1.1",
|
|
32
32
|
"copy-to-clipboard": "^3.3.3",
|
|
33
33
|
"dayjs": "^1.11.7",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Token } from 'rango-sdk';
|
|
2
2
|
|
|
3
3
|
import { containsText } from '../../utils/common';
|
|
4
4
|
|
|
5
|
-
export const filterTokens = (list:
|
|
5
|
+
export const filterTokens = (list: Token[], searchedFor: string) =>
|
|
6
6
|
list.filter(
|
|
7
7
|
(token) =>
|
|
8
8
|
containsText(token.symbol, searchedFor) ||
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-magic-numbers */
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
RenderDescProps,
|
|
5
|
-
TokenWithBalance,
|
|
6
|
-
} from './TokenList.types';
|
|
2
|
+
import type { PropTypes, RenderDescProps } from './TokenList.types';
|
|
3
|
+
import type { Token } from 'rango-sdk';
|
|
7
4
|
import type { CommonProps } from 'react-window';
|
|
8
5
|
|
|
9
6
|
import { i18n } from '@lingui/core';
|
|
@@ -24,6 +21,7 @@ import React, { forwardRef, useEffect, useState } from 'react';
|
|
|
24
21
|
import { useAppStore } from '../../store/AppStore';
|
|
25
22
|
import { useWalletsStore } from '../../store/wallets';
|
|
26
23
|
import { generateRangeColors } from '../../utils/colors';
|
|
24
|
+
import { formatBalance } from '../../utils/wallets';
|
|
27
25
|
|
|
28
26
|
import { LoadingTokenList } from './LoadingTokenList';
|
|
29
27
|
import {
|
|
@@ -85,11 +83,11 @@ const renderDesc = (props: RenderDescProps) => {
|
|
|
85
83
|
export function TokenList(props: PropTypes) {
|
|
86
84
|
const { list, searchedFor = '', onChange, selectedBlockchain } = props;
|
|
87
85
|
|
|
88
|
-
const [tokens, setTokens] = useState<
|
|
86
|
+
const [tokens, setTokens] = useState<Token[]>(list);
|
|
89
87
|
const fetchStatus = useAppStore().fetchStatus;
|
|
90
88
|
const blockchains = useAppStore().blockchains();
|
|
91
89
|
const [hasNextPage, setHasNextPage] = useState<boolean>(true);
|
|
92
|
-
const loadingWallet = useWalletsStore
|
|
90
|
+
const { getBalanceFor, loading: loadingWallet } = useWalletsStore();
|
|
93
91
|
const { isTokenPinned } = useAppStore();
|
|
94
92
|
|
|
95
93
|
// eslint-disable-next-line react/display-name
|
|
@@ -134,7 +132,7 @@ export function TokenList(props: PropTypes) {
|
|
|
134
132
|
<VirtualizedList
|
|
135
133
|
Item={({ index, style }) => {
|
|
136
134
|
const token = tokens[index];
|
|
137
|
-
|
|
135
|
+
const tokenBalance = formatBalance(getBalanceFor(token));
|
|
138
136
|
const address = token.address || '';
|
|
139
137
|
const blockchain = blockchains.find(
|
|
140
138
|
(blockchain) => blockchain.name === token.blockchain
|
|
@@ -229,18 +227,18 @@ export function TokenList(props: PropTypes) {
|
|
|
229
227
|
<Skeleton variant="text" size="medium" width={50} />
|
|
230
228
|
</End>
|
|
231
229
|
) : (
|
|
232
|
-
|
|
230
|
+
tokenBalance && (
|
|
233
231
|
<BalanceContainer>
|
|
234
232
|
<Typography variant="title" size="small">
|
|
235
|
-
{
|
|
233
|
+
{tokenBalance.amount}
|
|
236
234
|
</Typography>
|
|
237
235
|
<div />
|
|
238
|
-
{
|
|
236
|
+
{tokenBalance.usdValue && (
|
|
239
237
|
<Typography
|
|
240
238
|
variant="body"
|
|
241
239
|
className="usd-value"
|
|
242
240
|
size="xsmall">
|
|
243
|
-
{`$${
|
|
241
|
+
{`$${tokenBalance.usdValue}`}
|
|
244
242
|
</Typography>
|
|
245
243
|
)}
|
|
246
244
|
</BalanceContainer>
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
import type { Token } from 'rango-sdk';
|
|
2
2
|
|
|
3
|
-
export interface TokenWithBalance extends Token {
|
|
4
|
-
balance?: {
|
|
5
|
-
amount: string;
|
|
6
|
-
usdValue: string;
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
|
|
10
3
|
export interface PropTypes {
|
|
11
|
-
list:
|
|
4
|
+
list: Token[];
|
|
12
5
|
searchedFor?: string;
|
|
13
|
-
onChange: (token:
|
|
6
|
+
onChange: (token: Token) => void;
|
|
14
7
|
selectedBlockchain?: string;
|
|
15
8
|
}
|
|
16
9
|
|
|
@@ -22,7 +15,7 @@ export interface RenderDescProps {
|
|
|
22
15
|
name?: string | null;
|
|
23
16
|
address: string;
|
|
24
17
|
url: string;
|
|
25
|
-
token:
|
|
18
|
+
token: Token;
|
|
26
19
|
customCssForTag: TagCSS;
|
|
27
20
|
customCssForTagTitle: TitleCSS;
|
|
28
21
|
}
|
|
@@ -28,15 +28,14 @@ export const WidgetContext = createContext<WidgetContextInterface>({
|
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
function Main(props: PropsWithChildren<PropTypes>) {
|
|
31
|
-
const updateConfig = useAppStore()
|
|
31
|
+
const { updateConfig } = useAppStore();
|
|
32
32
|
const blockchains = useAppStore().blockchains();
|
|
33
33
|
const tokens = useAppStore().tokens();
|
|
34
34
|
const walletOptions: ProvidersOptions = {
|
|
35
35
|
walletConnectProjectId: props.config?.walletConnectProjectId,
|
|
36
36
|
};
|
|
37
37
|
const { providers } = useWalletProviders(props.config.wallets, walletOptions);
|
|
38
|
-
const disconnectWallet = useWalletsStore
|
|
39
|
-
const connectWallet = useWalletsStore.use.connectWallet();
|
|
38
|
+
const { connectWallet, disconnectWallet } = useWalletsStore();
|
|
40
39
|
const onConnectWalletHandler = useRef<OnConnectHandler>();
|
|
41
40
|
useSyncStoresWithConfig();
|
|
42
41
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Manager } from '@rango-dev/queue-manager-core';
|
|
2
|
+
import type { PendingSwap } from '@rango-dev/queue-manager-rango-preset';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
getCurrentBlockchainOfOrNull,
|
|
6
|
+
getCurrentStep,
|
|
7
|
+
getRelatedWalletOrNull,
|
|
8
|
+
} from '@rango-dev/queue-manager-rango-preset';
|
|
9
|
+
|
|
10
|
+
import { getPendingSwaps } from '../../utils/queue';
|
|
11
|
+
|
|
12
|
+
export class WidgetHistory {
|
|
13
|
+
private manager: Manager | undefined;
|
|
14
|
+
|
|
15
|
+
constructor(manager: Manager | undefined) {
|
|
16
|
+
this.manager = manager;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public getAllSwaps() {
|
|
20
|
+
return getPendingSwaps(this.manager);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public getCurrentStep(swap: PendingSwap) {
|
|
24
|
+
return this.getCurrentStepInfo(swap).step;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public getCurrentStepWallet(swap: PendingSwap) {
|
|
28
|
+
return this.getCurrentStepInfo(swap).wallet;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public getCurrentStepNetwork(swap: PendingSwap) {
|
|
32
|
+
return this.getCurrentStepInfo(swap).network;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private getCurrentStepInfo(swap: PendingSwap) {
|
|
36
|
+
const currentStep = getCurrentStep(swap);
|
|
37
|
+
return {
|
|
38
|
+
step: currentStep,
|
|
39
|
+
wallet: currentStep ? getRelatedWalletOrNull(swap, currentStep) : null,
|
|
40
|
+
network: currentStep
|
|
41
|
+
? getCurrentBlockchainOfOrNull(swap, currentStep)
|
|
42
|
+
: null,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -4,23 +4,24 @@ import { useManager } from '@rango-dev/queue-manager-react';
|
|
|
4
4
|
import React, { createContext, useContext } from 'react';
|
|
5
5
|
|
|
6
6
|
import { useWalletsStore } from '../../store/wallets';
|
|
7
|
-
import { getPendingSwaps } from '../../utils/queue';
|
|
8
7
|
import { calculateWalletUsdValue } from '../../utils/wallets';
|
|
9
8
|
|
|
9
|
+
import { WidgetHistory } from './WidgetInfo.helpers';
|
|
10
|
+
|
|
10
11
|
export const WidgetInfoContext = createContext<
|
|
11
12
|
WidgetInfoContextInterface | undefined
|
|
12
13
|
>(undefined);
|
|
13
14
|
|
|
14
15
|
export function WidgetInfo(props: React.PropsWithChildren) {
|
|
15
16
|
const { manager } = useManager();
|
|
16
|
-
const
|
|
17
|
+
const history = new WidgetHistory(manager);
|
|
17
18
|
const details = useWalletsStore.use.connectedWallets();
|
|
18
19
|
const isLoading = useWalletsStore.use.loading();
|
|
19
20
|
const totalBalance = calculateWalletUsdValue(details);
|
|
20
21
|
const refetch = useWalletsStore.use.getWalletsDetails();
|
|
21
22
|
// eslint-disable-next-line react/jsx-no-constructed-context-values
|
|
22
23
|
const value = {
|
|
23
|
-
|
|
24
|
+
history,
|
|
24
25
|
wallets: {
|
|
25
26
|
isLoading,
|
|
26
27
|
details,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import type { WidgetHistory } from './WidgetInfo.helpers';
|
|
1
2
|
import type { ConnectedWallet } from '../../store/wallets';
|
|
2
3
|
import type { Wallet } from '../../types';
|
|
3
|
-
import type { PendingSwapWithQueueID } from '@rango-dev/queue-manager-rango-preset';
|
|
4
4
|
import type { Token } from 'rango-sdk';
|
|
5
5
|
|
|
6
6
|
export interface WidgetInfoContextInterface {
|
|
7
|
-
|
|
7
|
+
history: WidgetHistory;
|
|
8
8
|
wallets: {
|
|
9
9
|
details: ConnectedWallet[];
|
|
10
10
|
totalBalance: string;
|
package/src/index.ts
CHANGED
|
@@ -8,8 +8,13 @@ import type {
|
|
|
8
8
|
WidgetTheme,
|
|
9
9
|
} from './types';
|
|
10
10
|
import type {
|
|
11
|
+
EventSeverity,
|
|
12
|
+
PendingSwap,
|
|
13
|
+
PendingSwapStep,
|
|
14
|
+
PendingSwapWithQueueID,
|
|
11
15
|
Route,
|
|
12
16
|
RouteEvent,
|
|
17
|
+
RouteExecutionEvents,
|
|
13
18
|
RouteFailedEvent,
|
|
14
19
|
RouteStartedEvent,
|
|
15
20
|
RouteSucceededEvent,
|
|
@@ -28,17 +33,27 @@ import type {
|
|
|
28
33
|
EventHandler as HandleWalletsUpdate,
|
|
29
34
|
ProviderInterface,
|
|
30
35
|
} from '@rango-dev/wallets-react';
|
|
31
|
-
import type {
|
|
36
|
+
import type {
|
|
37
|
+
WalletInfo,
|
|
38
|
+
WalletState,
|
|
39
|
+
WalletType,
|
|
40
|
+
} from '@rango-dev/wallets-shared';
|
|
32
41
|
|
|
33
42
|
import {
|
|
34
43
|
MainEvents,
|
|
44
|
+
PendingSwapNetworkStatus,
|
|
35
45
|
RouteEventType,
|
|
36
46
|
StepEventType,
|
|
37
47
|
StepExecutionBlockedEventStatus,
|
|
38
48
|
StepExecutionEventStatus,
|
|
39
49
|
useEvents as useWidgetEvents,
|
|
40
50
|
} from '@rango-dev/queue-manager-rango-preset';
|
|
41
|
-
import {
|
|
51
|
+
import {
|
|
52
|
+
readAccountAddress,
|
|
53
|
+
useWallets,
|
|
54
|
+
Events as WalletEvents,
|
|
55
|
+
} from '@rango-dev/wallets-react';
|
|
56
|
+
import { Networks, WalletTypes } from '@rango-dev/wallets-shared';
|
|
42
57
|
|
|
43
58
|
import { WidgetWallets } from './containers/Wallets';
|
|
44
59
|
import { Widget } from './containers/Widget';
|
|
@@ -90,3 +105,23 @@ export {
|
|
|
90
105
|
StepExecutionEventStatus,
|
|
91
106
|
StepExecutionBlockedEventStatus,
|
|
92
107
|
};
|
|
108
|
+
|
|
109
|
+
// Internal type exports for Rango
|
|
110
|
+
export type {
|
|
111
|
+
WalletState,
|
|
112
|
+
WalletInfo,
|
|
113
|
+
PendingSwap,
|
|
114
|
+
PendingSwapWithQueueID,
|
|
115
|
+
PendingSwapStep,
|
|
116
|
+
RouteExecutionEvents,
|
|
117
|
+
EventSeverity,
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
// Internal function and enum exports for Rango
|
|
121
|
+
export {
|
|
122
|
+
readAccountAddress,
|
|
123
|
+
Networks,
|
|
124
|
+
WalletEvents,
|
|
125
|
+
WalletTypes,
|
|
126
|
+
PendingSwapNetworkStatus,
|
|
127
|
+
};
|
package/src/pages/Home.tsx
CHANGED
|
@@ -9,8 +9,6 @@ import { SwitchFromAndToButton } from '../components/SwitchFromAndTo';
|
|
|
9
9
|
import { errorMessages } from '../constants/errors';
|
|
10
10
|
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
11
11
|
import {
|
|
12
|
-
BALANCE_MAX_DECIMALS,
|
|
13
|
-
BALANCE_MIN_DECIMALS,
|
|
14
12
|
PERCENTAGE_CHANGE_MAX_DECIMALS,
|
|
15
13
|
PERCENTAGE_CHANGE_MIN_DECIMALS,
|
|
16
14
|
TOKEN_AMOUNT_MAX_DECIMALS,
|
|
@@ -27,7 +25,7 @@ import { useWalletsStore } from '../store/wallets';
|
|
|
27
25
|
import { numberToString } from '../utils/numbers';
|
|
28
26
|
import { getPriceImpact, getPriceImpactLevel } from '../utils/quote';
|
|
29
27
|
import { canComputePriceImpact, getSwapButtonState } from '../utils/swap';
|
|
30
|
-
import {
|
|
28
|
+
import { formatBalance } from '../utils/wallets';
|
|
31
29
|
|
|
32
30
|
const Container = styled('div', {
|
|
33
31
|
display: 'flex',
|
|
@@ -73,7 +71,7 @@ export function Home() {
|
|
|
73
71
|
|
|
74
72
|
const fetchMetaStatus = useAppStore().fetchStatus;
|
|
75
73
|
|
|
76
|
-
const connectedWallets = useWalletsStore
|
|
74
|
+
const { connectedWallets, getBalanceFor } = useWalletsStore();
|
|
77
75
|
const setCurrentPage = useUiStore.use.setCurrentPage();
|
|
78
76
|
const [showQuoteWarningModal, setShowQuoteWarningModal] = useState(false);
|
|
79
77
|
const layoutRef = useRef<HTMLDivElement>(null);
|
|
@@ -103,36 +101,14 @@ export function Home() {
|
|
|
103
101
|
needsToWarnEthOnPath,
|
|
104
102
|
});
|
|
105
103
|
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
connectedWallets,
|
|
111
|
-
fromBlockchain?.name,
|
|
112
|
-
fromToken?.symbol,
|
|
113
|
-
fromToken?.address
|
|
114
|
-
)?.amount || '0',
|
|
115
|
-
BALANCE_MIN_DECIMALS,
|
|
116
|
-
BALANCE_MAX_DECIMALS
|
|
117
|
-
)
|
|
118
|
-
: '0';
|
|
104
|
+
const fromTokenBalance = fromToken ? getBalanceFor(fromToken) : null;
|
|
105
|
+
|
|
106
|
+
const fromTokenFormattedBalance =
|
|
107
|
+
formatBalance(fromTokenBalance)?.amount ?? '0';
|
|
119
108
|
|
|
120
109
|
const tokenBalanceReal =
|
|
121
110
|
!!fromBlockchain && !!fromToken
|
|
122
|
-
? numberToString(
|
|
123
|
-
getBalanceFromWallet(
|
|
124
|
-
connectedWallets,
|
|
125
|
-
fromBlockchain?.name,
|
|
126
|
-
fromToken?.symbol,
|
|
127
|
-
fromToken?.address
|
|
128
|
-
)?.amount || '0',
|
|
129
|
-
getBalanceFromWallet(
|
|
130
|
-
connectedWallets,
|
|
131
|
-
fromBlockchain?.name,
|
|
132
|
-
fromToken?.symbol,
|
|
133
|
-
fromToken?.address
|
|
134
|
-
)?.decimal
|
|
135
|
-
)
|
|
111
|
+
? numberToString(fromTokenBalance?.amount, fromTokenBalance?.decimals)
|
|
136
112
|
: '0';
|
|
137
113
|
|
|
138
114
|
useEffect(() => {
|
|
@@ -194,7 +170,7 @@ export function Home() {
|
|
|
194
170
|
label={i18n.t('From')}
|
|
195
171
|
mode="From"
|
|
196
172
|
onInputChange={setInputAmount}
|
|
197
|
-
balance={
|
|
173
|
+
balance={fromTokenFormattedBalance}
|
|
198
174
|
chain={{
|
|
199
175
|
displayName: fromBlockchain?.displayName || '',
|
|
200
176
|
image: fromBlockchain?.logo || '',
|
|
@@ -220,7 +196,7 @@ export function Home() {
|
|
|
220
196
|
disabled={fetchMetaStatus === 'failed'}
|
|
221
197
|
loading={fetchMetaStatus === 'loading'}
|
|
222
198
|
onSelectMaxBalance={() => {
|
|
223
|
-
if (
|
|
199
|
+
if (fromTokenFormattedBalance !== '0') {
|
|
224
200
|
setInputAmount(tokenBalanceReal.split(',').join(''));
|
|
225
201
|
}
|
|
226
202
|
}}
|
|
@@ -14,7 +14,7 @@ import { useNavigateBack } from '../hooks/useNavigateBack';
|
|
|
14
14
|
import { useAppStore } from '../store/AppStore';
|
|
15
15
|
import { useQuoteStore } from '../store/quote';
|
|
16
16
|
import { useWalletsStore } from '../store/wallets';
|
|
17
|
-
import {
|
|
17
|
+
import { sortTokensByBalance } from '../utils/wallets';
|
|
18
18
|
|
|
19
19
|
interface PropTypes {
|
|
20
20
|
type: 'source' | 'destination';
|
|
@@ -32,7 +32,7 @@ export function SelectSwapItemsPage(props: PropTypes) {
|
|
|
32
32
|
setFromBlockchain,
|
|
33
33
|
setToBlockchain,
|
|
34
34
|
} = useQuoteStore();
|
|
35
|
-
const
|
|
35
|
+
const getBalanceFor = useWalletsStore.use.getBalanceFor();
|
|
36
36
|
const [searchedFor, setSearchedFor] = useState<string>('');
|
|
37
37
|
|
|
38
38
|
const selectedBlockchain = type === 'source' ? fromBlockchain : toBlockchain;
|
|
@@ -47,10 +47,7 @@ export function SelectSwapItemsPage(props: PropTypes) {
|
|
|
47
47
|
blockchain: selectedBlockchainName,
|
|
48
48
|
searchFor: searchedFor,
|
|
49
49
|
});
|
|
50
|
-
const tokensList =
|
|
51
|
-
tokens,
|
|
52
|
-
connectedWallets
|
|
53
|
-
);
|
|
50
|
+
const tokensList = sortTokensByBalance(tokens, getBalanceFor);
|
|
54
51
|
|
|
55
52
|
// Actions
|
|
56
53
|
const updateBlockchain = (blockchain: BlockchainMeta) => {
|
package/src/store/quote.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { TokenWithBalance } from '../components/TokenList';
|
|
2
1
|
import type { Wallet } from '../types';
|
|
3
2
|
import type { PendingSwap } from '@rango-dev/queue-manager-rango-preset/dist/shared';
|
|
4
3
|
import type {
|
|
@@ -38,8 +37,8 @@ export interface QuoteState {
|
|
|
38
37
|
inputUsdValue: BigNumber | null;
|
|
39
38
|
outputAmount: BigNumber | null;
|
|
40
39
|
outputUsdValue: BigNumber | null;
|
|
41
|
-
fromToken:
|
|
42
|
-
toToken:
|
|
40
|
+
fromToken: Token | null;
|
|
41
|
+
toToken: Token | null;
|
|
43
42
|
quoteWalletsConfirmed: boolean;
|
|
44
43
|
selectedWallets: Wallet[];
|
|
45
44
|
quoteWarningsConfirmed: boolean;
|