@rango-dev/widget-embedded 0.17.1-next.5 → 0.17.1-next.6
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/Wallets.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/dist/utils/wallets.d.ts +1 -1
- package/dist/utils/wallets.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/Wallets.tsx +5 -10
- package/src/utils/wallets.ts +27 -15
package/dist/utils/wallets.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { WalletState as WalletStatus } from '@rango-dev/ui';
|
|
|
8
8
|
export declare function mapStatusToWalletState(state: WalletState): WalletStatus;
|
|
9
9
|
export declare function mapWalletTypesToWalletInfo(getState: (type: WalletType) => WalletState, getWalletInfo: (type: WalletType) => WalletInfo, list: WalletType[], chain?: string): ModalWalletInfo[];
|
|
10
10
|
export declare function walletAndSupportedChainsNames(supportedBlockchains: BlockchainMeta[]): Network[] | null;
|
|
11
|
-
export declare function prepareAccountsForWalletStore(wallet: WalletType, accounts: string[], evmBasedChains: string[], supportedChainNames: Network[] | null): Wallet[];
|
|
11
|
+
export declare function prepareAccountsForWalletStore(wallet: WalletType, accounts: string[], evmBasedChains: string[], supportedChainNames: Network[] | null, isContractWallet: boolean): Wallet[];
|
|
12
12
|
export declare function getRequiredChains(quote: BestRouteResponse | null): string[];
|
|
13
13
|
export declare function getBalanceFromWallet(connectedWallets: ConnectedWallet[], chain: string, symbol: string, address: string | null): TokenBalance | null;
|
|
14
14
|
export declare function isAccountAndWalletMatched(account: Wallet, connectedWallet: ConnectedWallet): boolean;
|
|
@@ -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,EAA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package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/widget-embedded",
|
|
3
|
-
"version": "0.17.1-next.
|
|
3
|
+
"version": "0.17.1-next.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@lingui/core": "4.2.1",
|
|
21
21
|
"@lingui/react": "4.2.1",
|
|
22
|
-
"@rango-dev/provider-all": "^0.22.1-next.
|
|
22
|
+
"@rango-dev/provider-all": "^0.22.1-next.3",
|
|
23
23
|
"@rango-dev/queue-manager-core": "^0.22.1-next.0",
|
|
24
|
-
"@rango-dev/queue-manager-rango-preset": "^0.22.1-next.
|
|
24
|
+
"@rango-dev/queue-manager-rango-preset": "^0.22.1-next.4",
|
|
25
25
|
"@rango-dev/queue-manager-react": "^0.22.1-next.0",
|
|
26
|
-
"@rango-dev/ui": "^0.22.1-next.
|
|
27
|
-
"@rango-dev/wallets-react": "^0.8.1-next.
|
|
28
|
-
"@rango-dev/wallets-shared": "^0.21.1-next.
|
|
26
|
+
"@rango-dev/ui": "^0.22.1-next.5",
|
|
27
|
+
"@rango-dev/wallets-react": "^0.8.1-next.2",
|
|
28
|
+
"@rango-dev/wallets-shared": "^0.21.1-next.2",
|
|
29
29
|
"bignumber.js": "^9.1.1",
|
|
30
30
|
"copy-to-clipboard": "^3.3.3",
|
|
31
31
|
"dayjs": "^1.11.7",
|
package/src/Wallets.tsx
CHANGED
|
@@ -53,22 +53,17 @@ function Main(
|
|
|
53
53
|
.filter(isEvmBlockchain)
|
|
54
54
|
.map((chain) => chain.name);
|
|
55
55
|
|
|
56
|
-
const onUpdateState: EventHandler = (
|
|
57
|
-
type,
|
|
58
|
-
event,
|
|
59
|
-
value,
|
|
60
|
-
state,
|
|
61
|
-
supportedBlockchains
|
|
62
|
-
) => {
|
|
56
|
+
const onUpdateState: EventHandler = (type, event, value, state, meta) => {
|
|
63
57
|
if (event === Events.ACCOUNTS) {
|
|
64
58
|
if (value) {
|
|
65
59
|
const supportedChainNames: Network[] | null =
|
|
66
|
-
walletAndSupportedChainsNames(supportedBlockchains);
|
|
60
|
+
walletAndSupportedChainsNames(meta.supportedBlockchains);
|
|
67
61
|
const data = prepareAccountsForWalletStore(
|
|
68
62
|
type,
|
|
69
63
|
value,
|
|
70
64
|
evmBasedChainNames,
|
|
71
|
-
supportedChainNames
|
|
65
|
+
supportedChainNames,
|
|
66
|
+
meta.isContractWallet
|
|
72
67
|
);
|
|
73
68
|
connectWallet(data, tokens);
|
|
74
69
|
} else {
|
|
@@ -100,7 +95,7 @@ function Main(
|
|
|
100
95
|
|
|
101
96
|
// propagate updates for Dapps using external wallets
|
|
102
97
|
if (props.onUpdateState) {
|
|
103
|
-
props.onUpdateState(type, event, value, state,
|
|
98
|
+
props.onUpdateState(type, event, value, state, meta);
|
|
104
99
|
}
|
|
105
100
|
};
|
|
106
101
|
return (
|
package/src/utils/wallets.ts
CHANGED
|
@@ -55,8 +55,11 @@ export function mapWalletTypesToWalletInfo(
|
|
|
55
55
|
return list
|
|
56
56
|
.filter((wallet) => !EXCLUDED_WALLETS.includes(wallet as WalletTypes))
|
|
57
57
|
.filter((wallet) => {
|
|
58
|
-
const { supportedChains,
|
|
59
|
-
|
|
58
|
+
const { supportedChains, isContractWallet } = getWalletInfo(wallet);
|
|
59
|
+
const { installed, network } = getState(wallet);
|
|
60
|
+
const filterContractWallets =
|
|
61
|
+
isContractWallet && (!installed || (!!chain && network !== chain));
|
|
62
|
+
if (filterContractWallets) {
|
|
60
63
|
return false;
|
|
61
64
|
}
|
|
62
65
|
if (chain) {
|
|
@@ -97,7 +100,8 @@ export function prepareAccountsForWalletStore(
|
|
|
97
100
|
wallet: WalletType,
|
|
98
101
|
accounts: string[],
|
|
99
102
|
evmBasedChains: string[],
|
|
100
|
-
supportedChainNames: Network[] | null
|
|
103
|
+
supportedChainNames: Network[] | null,
|
|
104
|
+
isContractWallet: boolean
|
|
101
105
|
): Wallet[] {
|
|
102
106
|
const result: Wallet[] = [];
|
|
103
107
|
|
|
@@ -151,21 +155,29 @@ export function prepareAccountsForWalletStore(
|
|
|
151
155
|
|
|
152
156
|
// If it's an evm network, we will add the address to all the evm chains.
|
|
153
157
|
if (isEvmBasedChain || isUnknownAndEvmBased) {
|
|
154
|
-
|
|
155
|
-
* all evm chains are not supported in wallets, so we are adding
|
|
156
|
-
* only to those that are supported by wallet.
|
|
157
|
-
*/
|
|
158
|
-
const evmChainsSupportedByWallet = supportedBlockchains.filter((chain) =>
|
|
159
|
-
evmBasedChains.includes(chain)
|
|
160
|
-
);
|
|
161
|
-
|
|
162
|
-
evmChainsSupportedByWallet.forEach((network) => {
|
|
158
|
+
if (isContractWallet) {
|
|
163
159
|
/*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
160
|
+
* for contract wallets like Safe wallet, we should add only account for the
|
|
161
|
+
* current connected blockchain not all of the supported blockchains
|
|
166
162
|
*/
|
|
167
163
|
addAccount(network, address.toLowerCase());
|
|
168
|
-
}
|
|
164
|
+
} else {
|
|
165
|
+
/*
|
|
166
|
+
* all evm chains are not supported in wallets, so we are adding
|
|
167
|
+
* only to those that are supported by wallet.
|
|
168
|
+
*/
|
|
169
|
+
const evmChainsSupportedByWallet = supportedBlockchains.filter(
|
|
170
|
+
(chain) => evmBasedChains.includes(chain)
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
evmChainsSupportedByWallet.forEach((network) => {
|
|
174
|
+
/*
|
|
175
|
+
* EVM addresses are not case sensitive.
|
|
176
|
+
* Some wallets like Binance-chain return some letters in uppercase which produces bugs in our wallet state.
|
|
177
|
+
*/
|
|
178
|
+
addAccount(network, address.toLowerCase());
|
|
179
|
+
});
|
|
180
|
+
}
|
|
169
181
|
} else {
|
|
170
182
|
addAccount(network, address);
|
|
171
183
|
}
|