@rango-dev/widget-embedded 0.1.10-next.75 → 0.1.10-next.77
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/pages/ConfirmWalletsPage.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +2 -0
- package/dist/utils/wallets.d.ts.map +1 -1
- package/dist/widget-embedded.cjs.development.js +28 -7
- package/dist/widget-embedded.cjs.development.js.map +1 -1
- package/dist/widget-embedded.cjs.production.min.js +28 -7
- package/dist/widget-embedded.cjs.production.min.js.map +1 -1
- package/dist/widget-embedded.esm.js +29 -8
- package/dist/widget-embedded.esm.js.map +1 -1
- package/package.json +2 -3
- package/src/pages/ConfirmWalletsPage.tsx +23 -9
- package/src/utils/wallets.ts +147 -55
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmWalletsPage.d.ts","sourceRoot":"","sources":["../src/pages/ConfirmWalletsPage.tsx"],"names":[],"mappings":"AAOA,OAAO,
|
|
1
|
+
{"version":3,"file":"ConfirmWalletsPage.d.ts","sourceRoot":"","sources":["../src/pages/ConfirmWalletsPage.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAoG,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKpJ,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACtD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,kBAAkB,gBA+CjC"}
|
package/dist/utils/wallets.d.ts
CHANGED
|
@@ -20,4 +20,6 @@ export declare function resetBalanceState(balance: Balance): Balance;
|
|
|
20
20
|
export declare const calculateWalletUsdValue: (balance: Balance[]) => string;
|
|
21
21
|
export declare const sortedTokens: (tokens: TokenWithBalance[], position: 'from' | 'to', balance: Balance[]) => TokenWithBalance[];
|
|
22
22
|
export declare const getUsdPrice: (blockchain: string, symbol: string, address: string | null, allTokens: Token[]) => number | null;
|
|
23
|
+
export declare const isExperimentalChain: (blockchains: BlockchainMeta[], wallet: string) => boolean;
|
|
24
|
+
export declare const getKeplrCompatibleConnectedWallets: (selectableWallets: SelectableWallet[]) => WalletType[];
|
|
23
25
|
//# sourceMappingURL=wallets.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallets.d.ts","sourceRoot":"","sources":["../src/utils/wallets.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"wallets.d.ts","sourceRoot":"","sources":["../src/utils/wallets.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,OAAO,EACP,UAAU,EACV,WAAW,EACX,UAAU,EAEX,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,UAAU,IAAI,eAAe,EAC7B,WAAW,IAAI,YAAY,EAC5B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,KAAK,EACL,YAAY,EACb,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGlE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAG5D,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,GAAG,YAAY,CAW/D;AAED,eAAO,MAAM,eAAe,cAI3B,CAAC;AAEF,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,WAAW,EAC3C,aAAa,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,UAAU,EAC/C,IAAI,EAAE,UAAU,EAAE,GACjB,eAAe,EAAE,CAoBnB;AAED,wBAAgB,6BAA6B,CAC3C,eAAe,EAAE,cAAc,EAAE,GAChC,OAAO,EAAE,GAAG,IAAI,CAQlB;AAED,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,MAAM,EAAE,EA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pC,UAAU,EAQZ,CAAC"}
|
|
@@ -383,10 +383,11 @@ function getSelectableWallets(accounts, selectedWallets, getWalletInfo, required
|
|
|
383
383
|
name: getWalletInfo(account.walletType).name,
|
|
384
384
|
selected: !!selectedWallets.find(wallet => wallet.chain === account.chain && wallet.walletType === account.walletType)
|
|
385
385
|
}));
|
|
386
|
-
return requiredChains ? connectedWallets.filter(wallet => requiredChains.includes(wallet.chain)) : removeDuplicateWallets(connectedWallets, 'walletType');
|
|
386
|
+
return requiredChains ? connectedWallets.filter((wallet, index, array) => requiredChains.includes(wallet.chain) && array.findIndex(w => w.address === wallet.address) === index) : removeDuplicateWallets(connectedWallets, 'walletType');
|
|
387
387
|
}
|
|
388
388
|
const removeDuplicateWallets = (arr, key) => {
|
|
389
|
-
|
|
389
|
+
const map = new Map(arr.map(item => [item[key], item]));
|
|
390
|
+
return Array.from(map.values());
|
|
390
391
|
};
|
|
391
392
|
function getBalanceFromWallet(balances, chain, symbol, address) {
|
|
392
393
|
if (balances.length === 0) return null;
|
|
@@ -450,8 +451,6 @@ const calculateWalletUsdValue = balance => {
|
|
|
450
451
|
return modifiedWalletBlockchain;
|
|
451
452
|
});
|
|
452
453
|
const total = numberToString(modifiedWalletBlockchains?.flatMap(b => b.accounts)?.flatMap(a => a?.balances)?.map(b => new BigNumber__default(b?.amount || ZERO).multipliedBy(b?.usdPrice || 0))?.reduce((a, b) => a.plus(b), ZERO) || ZERO).toString();
|
|
453
|
-
console.log('total');
|
|
454
|
-
console.log(total);
|
|
455
454
|
return numberWithThousandSeperator(total);
|
|
456
455
|
};
|
|
457
456
|
function numberWithThousandSeperator(number) {
|
|
@@ -476,6 +475,17 @@ const getUsdPrice = (blockchain, symbol, address, allTokens) => {
|
|
|
476
475
|
const token = allTokens?.find(t => t.blockchain === blockchain && t.symbol?.toUpperCase() === symbol?.toUpperCase() && t.address === address);
|
|
477
476
|
return token?.usdPrice || null;
|
|
478
477
|
};
|
|
478
|
+
const isExperimentalChain = (blockchains, wallet) => {
|
|
479
|
+
const cosmosExperimentalChainInfo = walletsShared.getCosmosExperimentalChainInfo(Object.entries(blockchains).map(_ref => {
|
|
480
|
+
let [, blockchainMeta] = _ref;
|
|
481
|
+
return blockchainMeta;
|
|
482
|
+
}).filter(walletsShared.isCosmosBlockchain));
|
|
483
|
+
return cosmosExperimentalChainInfo && !!cosmosExperimentalChainInfo[wallet];
|
|
484
|
+
};
|
|
485
|
+
const getKeplrCompatibleConnectedWallets = selectableWallets => {
|
|
486
|
+
const connectedWalletTypes = new Set(selectableWallets.map(a => a.walletType.toString()));
|
|
487
|
+
return walletsShared.KEPLR_COMPATIBLE_WALLETS.filter(compatibleWallet => connectedWalletTypes.has(compatibleWallet));
|
|
488
|
+
};
|
|
479
489
|
|
|
480
490
|
const useWalletsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/zustand.create()(set => ({
|
|
481
491
|
accounts: [],
|
|
@@ -2208,25 +2218,36 @@ function WalletsPage() {
|
|
|
2208
2218
|
function ConfirmWalletsPage() {
|
|
2209
2219
|
const navigate = reactRouterDom.useNavigate();
|
|
2210
2220
|
const bestRoute = useBestRouteStore.use.bestRoute();
|
|
2221
|
+
const {
|
|
2222
|
+
blockchains
|
|
2223
|
+
} = useMetaStore.use.meta();
|
|
2211
2224
|
const accounts = useWalletsStore.use.accounts();
|
|
2212
2225
|
const selectedWallets = useWalletsStore.use.selectedWallets();
|
|
2213
2226
|
const initSelectedWallets = useWalletsStore.use.initSelectedWallets();
|
|
2214
2227
|
const setSelectedWallet = useWalletsStore.use.setSelectedWallet();
|
|
2215
2228
|
const {
|
|
2216
|
-
getWalletInfo
|
|
2229
|
+
getWalletInfo,
|
|
2230
|
+
connect
|
|
2217
2231
|
} = walletsCore.useWallets();
|
|
2218
2232
|
const confirmDisabled = !requiredWallets(bestRoute).every(chain => selectedWallets.map(wallet => wallet.chain).includes(chain));
|
|
2219
2233
|
React.useEffect(() => {
|
|
2220
2234
|
initSelectedWallets();
|
|
2221
2235
|
}, []);
|
|
2236
|
+
const selectableWallets = getSelectableWallets(accounts, selectedWallets, getWalletInfo, getRequiredChains(bestRoute));
|
|
2237
|
+
const handleConnectChain = wallet => {
|
|
2238
|
+
const network = wallet;
|
|
2239
|
+
getKeplrCompatibleConnectedWallets(selectableWallets).forEach(compatibleWallet => connect?.(compatibleWallet, network));
|
|
2240
|
+
};
|
|
2222
2241
|
return React__default.createElement(ui.ConfirmWallets, {
|
|
2223
2242
|
requiredWallets: getRequiredChains(bestRoute),
|
|
2224
|
-
selectableWallets:
|
|
2243
|
+
selectableWallets: selectableWallets,
|
|
2225
2244
|
onBack: () => navigate(-1),
|
|
2226
2245
|
swap: bestRoute,
|
|
2227
2246
|
onConfirm: () => navigate(navigationRoutes.confirmSwap),
|
|
2228
2247
|
onChange: wallet => setSelectedWallet(wallet),
|
|
2229
|
-
confirmDisabled: confirmDisabled
|
|
2248
|
+
confirmDisabled: confirmDisabled,
|
|
2249
|
+
handleConnectChain: wallet => handleConnectChain(wallet),
|
|
2250
|
+
isExperimentalChain: wallet => getKeplrCompatibleConnectedWallets(selectableWallets).length > 0 ? isExperimentalChain(blockchains, wallet) : false
|
|
2230
2251
|
});
|
|
2231
2252
|
}
|
|
2232
2253
|
|