@embarkai/ui-kit 0.4.88 → 0.4.89
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/iframe/index.html +1 -1
- package/dist/iframe/main.js +1 -1
- package/dist/index.cjs +99 -35
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +155 -91
- package/package.json +1 -1
package/dist/iframe/index.html
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
<meta http-equiv="X-Content-Type-Options" content="nosniff" />
|
|
16
16
|
<meta http-equiv="Referrer-Policy" content="strict-origin-when-cross-origin" />
|
|
17
17
|
|
|
18
|
-
<title>EmbarkAI Secure Wallet - iframe version 0.4.
|
|
18
|
+
<title>EmbarkAI Secure Wallet - iframe version 0.4.89</title>
|
|
19
19
|
|
|
20
20
|
<!-- Styles will be injected by build process -->
|
|
21
21
|
<style>
|
package/dist/iframe/main.js
CHANGED
|
@@ -6414,7 +6414,7 @@ var SigningManager = class extends TokenRefreshApiClient {
|
|
|
6414
6414
|
};
|
|
6415
6415
|
|
|
6416
6416
|
// src/iframe/main.ts
|
|
6417
|
-
var IFRAME_VERSION = "0.4.
|
|
6417
|
+
var IFRAME_VERSION = "0.4.89";
|
|
6418
6418
|
var IframeWallet = class {
|
|
6419
6419
|
constructor() {
|
|
6420
6420
|
__publicField(this, "messenger");
|
package/dist/index.cjs
CHANGED
|
@@ -5511,11 +5511,12 @@ var init_useLayoutDataStore = __esm({
|
|
|
5511
5511
|
});
|
|
5512
5512
|
|
|
5513
5513
|
// src/internal/components/BalanceFeedProvider/constants.ts
|
|
5514
|
-
var BALANCE_POLLING_INTERVAL, NATIVE_BALANCE_QUERY_KEY, CUSTOM_BALANCE_QUERY_KEY, ASSET_RATE_QUERY_KEY, SKIP_SYMBOLS, WRAPPED_TOKENS;
|
|
5514
|
+
var BALANCE_POLLING_INTERVAL, NATIVE_BALANCE_QUERY_KEY, BLOCKSCOUTS_BALANCE_QUERY_KEY, CUSTOM_BALANCE_QUERY_KEY, ASSET_RATE_QUERY_KEY, SKIP_SYMBOLS, WRAPPED_TOKENS;
|
|
5515
5515
|
var init_constants2 = __esm({
|
|
5516
5516
|
"src/internal/components/BalanceFeedProvider/constants.ts"() {
|
|
5517
5517
|
BALANCE_POLLING_INTERVAL = 3e4;
|
|
5518
5518
|
NATIVE_BALANCE_QUERY_KEY = "embarkai-native-balance-query-key";
|
|
5519
|
+
BLOCKSCOUTS_BALANCE_QUERY_KEY = "embarkai-blockscouts-balance-query-key";
|
|
5519
5520
|
CUSTOM_BALANCE_QUERY_KEY = "embarkai-custom-balance-query-key";
|
|
5520
5521
|
ASSET_RATE_QUERY_KEY = "embarkai-asset-rate-query-key";
|
|
5521
5522
|
SKIP_SYMBOLS = ["TEST", "USDT", "P", "$P USDT"];
|
|
@@ -5562,27 +5563,69 @@ var init_useAssetRate = __esm({
|
|
|
5562
5563
|
});
|
|
5563
5564
|
|
|
5564
5565
|
// src/internal/components/BalanceFeedProvider/BalanceFeedProvider.tsx
|
|
5566
|
+
function isAddress(value) {
|
|
5567
|
+
if (!value) return false;
|
|
5568
|
+
return /^0x[a-fA-F0-9]*/.test(value);
|
|
5569
|
+
}
|
|
5570
|
+
async function getBlockscoutsAssets(embarkaiAddress, blockscoutApiUrl) {
|
|
5571
|
+
const blockscoutClient = (0, import_core.createBlockscoutClient)({ baseUrl: blockscoutApiUrl });
|
|
5572
|
+
const blockscoutTokens = await blockscoutClient.getTokenBalances(embarkaiAddress);
|
|
5573
|
+
return blockscoutTokens.map((el) => ({
|
|
5574
|
+
address: el.token.address_hash,
|
|
5575
|
+
decimals: Number(el.token.decimals),
|
|
5576
|
+
symbol: el.token.symbol
|
|
5577
|
+
}));
|
|
5578
|
+
}
|
|
5579
|
+
function getShowBalanceAsValue(showBalanceAs, chainId) {
|
|
5580
|
+
if (!showBalanceAs || !chainId) return null;
|
|
5581
|
+
if (typeof showBalanceAs === "string") return showBalanceAs;
|
|
5582
|
+
return showBalanceAs[chainId] || null;
|
|
5583
|
+
}
|
|
5565
5584
|
function BalanceFeedProvider() {
|
|
5566
5585
|
const config = useProviderConfig().config;
|
|
5567
5586
|
const embarkaiAddress = useSession((st) => st.address);
|
|
5568
5587
|
const chainConfig = useSession((st) => st.chainConfig);
|
|
5569
5588
|
const publicClient = useSession((st) => st.publicClient);
|
|
5570
5589
|
const [balanceSymbol, setBalanceSymbol] = (0, import_react5.useState)(null);
|
|
5571
|
-
(0, import_react5.
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
|
|
5590
|
+
const blockscoutApiUrl = (0, import_react5.useMemo)(() => getBlockscoutApiUrl(chainConfig), [chainConfig]);
|
|
5591
|
+
(0, import_react5.useEffect)(() => {
|
|
5592
|
+
useLayoutDataStore.getState().setCryptoSymbol(chainConfig?.nativeCurrency?.symbol || "LUMIA");
|
|
5593
|
+
const showBalanceAsSymbol = getShowBalanceAsValue(config?.current?.showBalanceAs || null, chainConfig?.id || 0);
|
|
5594
|
+
setBalanceSymbol(showBalanceAsSymbol || chainConfig.nativeCurrency.symbol);
|
|
5595
|
+
}, [config, embarkaiAddress, chainConfig]);
|
|
5596
|
+
const {
|
|
5597
|
+
data: assets,
|
|
5598
|
+
refetch: getBlockscoutsAndWatchAssetList
|
|
5599
|
+
// hack to get updated data inside another useQuery & revalidate the query
|
|
5600
|
+
} = (0, import_react_query2.useQuery)({
|
|
5601
|
+
retry: false,
|
|
5602
|
+
enabled: !!embarkaiAddress && !!blockscoutApiUrl,
|
|
5603
|
+
queryKey: [BLOCKSCOUTS_BALANCE_QUERY_KEY, embarkaiAddress, blockscoutApiUrl],
|
|
5604
|
+
queryFn: async () => {
|
|
5605
|
+
if (!embarkaiAddress || !blockscoutApiUrl) return;
|
|
5606
|
+
const watchTokensList = (config?.current?.watchTokens?.[chainConfig?.id] || []).map((el) => ({
|
|
5607
|
+
address: el.address,
|
|
5608
|
+
decimals: el.decimals,
|
|
5609
|
+
symbol: el.symbol
|
|
5610
|
+
}));
|
|
5611
|
+
const blockscoutAssets = await getBlockscoutsAssets(embarkaiAddress, blockscoutApiUrl);
|
|
5612
|
+
return [...watchTokensList, ...blockscoutAssets];
|
|
5613
|
+
}
|
|
5614
|
+
});
|
|
5615
|
+
const assetUsdtRateSymbol = (0, import_react5.useMemo)(() => {
|
|
5616
|
+
if (!balanceSymbol) return null;
|
|
5617
|
+
if (isAddress(balanceSymbol)) {
|
|
5618
|
+
return assets?.find((el) => el.address === balanceSymbol)?.symbol || null;
|
|
5619
|
+
}
|
|
5620
|
+
return balanceSymbol;
|
|
5621
|
+
}, [assets, balanceSymbol]);
|
|
5622
|
+
const { data: cryptoRate } = useAssetUsdtRate(assetUsdtRateSymbol);
|
|
5580
5623
|
const isNativeBalanceFeedEnabled = !!balanceSymbol && !!chainConfig?.nativeCurrency.symbol && balanceSymbol === chainConfig?.nativeCurrency.symbol;
|
|
5581
5624
|
const { data: nativeBalance } = (0, import_react_query2.useQuery)({
|
|
5582
5625
|
enabled: !!isNativeBalanceFeedEnabled && !!embarkaiAddress && !!publicClient,
|
|
5583
5626
|
retry: false,
|
|
5584
5627
|
refetchInterval: BALANCE_POLLING_INTERVAL,
|
|
5585
|
-
queryKey: [NATIVE_BALANCE_QUERY_KEY, embarkaiAddress,
|
|
5628
|
+
queryKey: [NATIVE_BALANCE_QUERY_KEY, embarkaiAddress, balanceSymbol],
|
|
5586
5629
|
// Include chainId in query key to refetch when chain changes
|
|
5587
5630
|
queryFn: async () => {
|
|
5588
5631
|
const balanceValue = await publicClient.getBalance({ address: embarkaiAddress });
|
|
@@ -5636,38 +5679,42 @@ function BalanceFeedProvider() {
|
|
|
5636
5679
|
});
|
|
5637
5680
|
}, [isProjectAssetBalanceEnabled, projectAssetBalance]);
|
|
5638
5681
|
const isCustomAssetBalanceEnabled = !isNativeBalanceFeedEnabled && !isProjectAssetBalanceEnabled;
|
|
5639
|
-
const {
|
|
5682
|
+
const {
|
|
5683
|
+
data: customBalance,
|
|
5684
|
+
isLoading: isCustomBalanceLoading,
|
|
5685
|
+
isError: isCustomBalanceError
|
|
5686
|
+
} = (0, import_react_query2.useQuery)({
|
|
5640
5687
|
enabled: !!isCustomAssetBalanceEnabled && !!balanceSymbol && !!chainConfig?.id && !!embarkaiAddress && !!publicClient,
|
|
5641
5688
|
retry: false,
|
|
5642
5689
|
refetchInterval: BALANCE_POLLING_INTERVAL,
|
|
5643
|
-
// staleTime: 0,
|
|
5644
5690
|
queryKey: [CUSTOM_BALANCE_QUERY_KEY, chainConfig?.id, embarkaiAddress, balanceSymbol],
|
|
5645
5691
|
// Include chainId in query key to refetch when chain changes
|
|
5646
5692
|
queryFn: async () => {
|
|
5647
|
-
const blockscoutApiUrl = getBlockscoutApiUrl(chainConfig);
|
|
5648
|
-
const watchTokensList = (config?.current?.watchTokens?.[chainConfig?.id] || []).map((el) => ({
|
|
5649
|
-
address: el.address,
|
|
5650
|
-
decimals: el.decimals,
|
|
5651
|
-
symbol: el.symbol
|
|
5652
|
-
}));
|
|
5653
5693
|
const customAssetList = [];
|
|
5654
5694
|
if (blockscoutApiUrl) {
|
|
5655
|
-
const
|
|
5656
|
-
|
|
5657
|
-
const blockscoutAssets = blockscoutTokens.map((el) => ({
|
|
5658
|
-
address: el.token.address_hash,
|
|
5659
|
-
decimals: Number(el.token.decimals),
|
|
5660
|
-
symbol: el.token.symbol
|
|
5661
|
-
}));
|
|
5662
|
-
customAssetList.push(...watchTokensList, ...blockscoutAssets);
|
|
5695
|
+
const blockscoutAssets = await getBlockscoutsAndWatchAssetList().then((res) => res.data || []);
|
|
5696
|
+
customAssetList.push(...blockscoutAssets);
|
|
5663
5697
|
} else {
|
|
5698
|
+
const watchTokensList = (config?.current?.watchTokens?.[chainConfig?.id] || []).map((el) => ({
|
|
5699
|
+
address: el.address,
|
|
5700
|
+
decimals: el.decimals,
|
|
5701
|
+
symbol: el.symbol
|
|
5702
|
+
}));
|
|
5664
5703
|
const coreTokenList = import_read2.NON_BLOCKSCOUT_CORE_TOKENS[chainConfig?.id] || [];
|
|
5665
5704
|
customAssetList.push(...watchTokensList, ...coreTokenList);
|
|
5666
5705
|
}
|
|
5667
|
-
const {
|
|
5706
|
+
const {
|
|
5707
|
+
address: customAssetAddress,
|
|
5708
|
+
decimals: customAssetDecimals,
|
|
5709
|
+
symbol: customAssetSymbol
|
|
5710
|
+
} = customAssetList.find((el) => {
|
|
5711
|
+
return (isAddress(balanceSymbol) ? el.address : el.symbol) === balanceSymbol;
|
|
5712
|
+
}) || {};
|
|
5668
5713
|
if (!customAssetAddress) {
|
|
5669
5714
|
console.warn(`[BALANCE FEED] No token address found for symbol ${balanceSymbol} on chain ${chainConfig?.name}`);
|
|
5670
|
-
|
|
5715
|
+
throw new Error(
|
|
5716
|
+
`[BALANCE FEED] No token address found for symbol ${balanceSymbol} on chain ${chainConfig?.name}`
|
|
5717
|
+
);
|
|
5671
5718
|
}
|
|
5672
5719
|
const balanceValue = await await publicClient.readContract({
|
|
5673
5720
|
address: customAssetAddress,
|
|
@@ -5677,15 +5724,24 @@ function BalanceFeedProvider() {
|
|
|
5677
5724
|
authorizationList: void 0
|
|
5678
5725
|
});
|
|
5679
5726
|
return {
|
|
5680
|
-
decimals:
|
|
5681
|
-
formatted: (0, import_viem2.formatUnits)(balanceValue,
|
|
5682
|
-
symbol:
|
|
5727
|
+
decimals: customAssetDecimals || 18,
|
|
5728
|
+
formatted: (0, import_viem2.formatUnits)(balanceValue, customAssetDecimals || 18),
|
|
5729
|
+
symbol: customAssetSymbol,
|
|
5683
5730
|
value: balanceValue
|
|
5684
5731
|
};
|
|
5685
5732
|
}
|
|
5686
5733
|
});
|
|
5734
|
+
(0, import_react5.useEffect)(() => {
|
|
5735
|
+
if (!isCustomAssetBalanceEnabled || !!isCustomBalanceLoading) return;
|
|
5736
|
+
if (!!isCustomAssetBalanceEnabled && !isCustomBalanceLoading && !!isCustomBalanceError && !!chainConfig?.id) {
|
|
5737
|
+
setTimeout(() => {
|
|
5738
|
+
setBalanceSymbol(chainConfig.nativeCurrency.symbol);
|
|
5739
|
+
}, 0);
|
|
5740
|
+
}
|
|
5741
|
+
}, [isCustomAssetBalanceEnabled, isCustomBalanceLoading, isCustomBalanceError, chainConfig]);
|
|
5687
5742
|
(0, import_react5.useEffect)(() => {
|
|
5688
5743
|
if (!isCustomAssetBalanceEnabled || !customBalance) return;
|
|
5744
|
+
if (!!isCustomAssetBalanceEnabled && isCustomBalanceLoading) return;
|
|
5689
5745
|
const rate = Number(cryptoRate?.price || "1");
|
|
5690
5746
|
const formattedBalance = Number((0, import_viem2.formatUnits)(BigInt(customBalance?.value || "0"), customBalance?.decimals || 18));
|
|
5691
5747
|
const { setCryptoRate, setFiatBalance, setBalance, setCryptoSymbol, setFiatSymbol } = useLayoutDataStore.getState();
|
|
@@ -5694,7 +5750,14 @@ function BalanceFeedProvider() {
|
|
|
5694
5750
|
setFiatSymbol("USD");
|
|
5695
5751
|
setFiatBalance(formattedBalance * rate);
|
|
5696
5752
|
setBalance(customBalance);
|
|
5697
|
-
}, [
|
|
5753
|
+
}, [
|
|
5754
|
+
isCustomAssetBalanceEnabled,
|
|
5755
|
+
customBalance,
|
|
5756
|
+
cryptoRate,
|
|
5757
|
+
chainConfig,
|
|
5758
|
+
isCustomBalanceError,
|
|
5759
|
+
isCustomBalanceLoading
|
|
5760
|
+
]);
|
|
5698
5761
|
return null;
|
|
5699
5762
|
}
|
|
5700
5763
|
var import_core, import_read2, import_react_query2, import_react5, import_viem2;
|
|
@@ -11944,6 +12007,7 @@ var init_tokens = __esm({
|
|
|
11944
12007
|
//
|
|
11945
12008
|
"$P USDT": parlayToken_default,
|
|
11946
12009
|
"P": parlayToken_default,
|
|
12010
|
+
"$P": parlayToken_default,
|
|
11947
12011
|
//
|
|
11948
12012
|
"EMBARKAI": embarkAI_default
|
|
11949
12013
|
};
|
|
@@ -22150,7 +22214,7 @@ function BalanceView(props) {
|
|
|
22150
22214
|
const cryptoBalance = Number((0, import_viem9.formatUnits)(balance?.value || BigInt(0), balance?.decimals || 18));
|
|
22151
22215
|
const fiatBalance = useLayoutDataStore((st) => st.fiatBalance);
|
|
22152
22216
|
const fiatSymbol = useLayoutDataStore((st) => st.fiatSymbol);
|
|
22153
|
-
const BalanceIcon = showFiatBalance
|
|
22217
|
+
const BalanceIcon = showFiatBalance ? TOKENS_ICONS[cryptoSymbol] : null;
|
|
22154
22218
|
return /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(
|
|
22155
22219
|
"p",
|
|
22156
22220
|
{
|
|
@@ -28734,7 +28798,7 @@ var init_package = __esm({
|
|
|
28734
28798
|
"package.json"() {
|
|
28735
28799
|
package_default = {
|
|
28736
28800
|
name: "@embarkai/ui-kit",
|
|
28737
|
-
version: "0.4.
|
|
28801
|
+
version: "0.4.89",
|
|
28738
28802
|
description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
|
|
28739
28803
|
type: "module",
|
|
28740
28804
|
main: "./dist/index.cjs",
|
package/dist/index.d.cts
CHANGED
|
@@ -238,7 +238,7 @@ interface ProviderConfig {
|
|
|
238
238
|
* Display header balance as asset supposed to be used by projects' dApp.
|
|
239
239
|
* Unprovided means 'native' for selected chain.
|
|
240
240
|
*/
|
|
241
|
-
showBalanceAs?: Asset['symbol']
|
|
241
|
+
showBalanceAs?: Asset['symbol'] | Record<number, Asset['symbol']>;
|
|
242
242
|
projectAssets?: {
|
|
243
243
|
assets: ProjectAsset[];
|
|
244
244
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -238,7 +238,7 @@ interface ProviderConfig {
|
|
|
238
238
|
* Display header balance as asset supposed to be used by projects' dApp.
|
|
239
239
|
* Unprovided means 'native' for selected chain.
|
|
240
240
|
*/
|
|
241
|
-
showBalanceAs?: Asset['symbol']
|
|
241
|
+
showBalanceAs?: Asset['symbol'] | Record<number, Asset['symbol']>;
|
|
242
242
|
projectAssets?: {
|
|
243
243
|
assets: ProjectAsset[];
|
|
244
244
|
};
|
package/dist/index.js
CHANGED
|
@@ -5496,11 +5496,12 @@ var init_useLayoutDataStore = __esm({
|
|
|
5496
5496
|
});
|
|
5497
5497
|
|
|
5498
5498
|
// src/internal/components/BalanceFeedProvider/constants.ts
|
|
5499
|
-
var BALANCE_POLLING_INTERVAL, NATIVE_BALANCE_QUERY_KEY, CUSTOM_BALANCE_QUERY_KEY, ASSET_RATE_QUERY_KEY, SKIP_SYMBOLS, WRAPPED_TOKENS;
|
|
5499
|
+
var BALANCE_POLLING_INTERVAL, NATIVE_BALANCE_QUERY_KEY, BLOCKSCOUTS_BALANCE_QUERY_KEY, CUSTOM_BALANCE_QUERY_KEY, ASSET_RATE_QUERY_KEY, SKIP_SYMBOLS, WRAPPED_TOKENS;
|
|
5500
5500
|
var init_constants2 = __esm({
|
|
5501
5501
|
"src/internal/components/BalanceFeedProvider/constants.ts"() {
|
|
5502
5502
|
BALANCE_POLLING_INTERVAL = 3e4;
|
|
5503
5503
|
NATIVE_BALANCE_QUERY_KEY = "embarkai-native-balance-query-key";
|
|
5504
|
+
BLOCKSCOUTS_BALANCE_QUERY_KEY = "embarkai-blockscouts-balance-query-key";
|
|
5504
5505
|
CUSTOM_BALANCE_QUERY_KEY = "embarkai-custom-balance-query-key";
|
|
5505
5506
|
ASSET_RATE_QUERY_KEY = "embarkai-asset-rate-query-key";
|
|
5506
5507
|
SKIP_SYMBOLS = ["TEST", "USDT", "P", "$P USDT"];
|
|
@@ -5552,29 +5553,71 @@ import {
|
|
|
5552
5553
|
} from "@embarkai/core";
|
|
5553
5554
|
import { NON_BLOCKSCOUT_CORE_TOKENS } from "@embarkai/core/read";
|
|
5554
5555
|
import { useQuery as useQuery2 } from "@tanstack/react-query";
|
|
5555
|
-
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
5556
|
+
import { useEffect as useEffect2, useMemo, useState as useState2 } from "react";
|
|
5556
5557
|
import { erc20Abi, formatUnits } from "viem";
|
|
5558
|
+
function isAddress(value) {
|
|
5559
|
+
if (!value) return false;
|
|
5560
|
+
return /^0x[a-fA-F0-9]*/.test(value);
|
|
5561
|
+
}
|
|
5562
|
+
async function getBlockscoutsAssets(embarkaiAddress, blockscoutApiUrl) {
|
|
5563
|
+
const blockscoutClient = createBlockscoutClient({ baseUrl: blockscoutApiUrl });
|
|
5564
|
+
const blockscoutTokens = await blockscoutClient.getTokenBalances(embarkaiAddress);
|
|
5565
|
+
return blockscoutTokens.map((el) => ({
|
|
5566
|
+
address: el.token.address_hash,
|
|
5567
|
+
decimals: Number(el.token.decimals),
|
|
5568
|
+
symbol: el.token.symbol
|
|
5569
|
+
}));
|
|
5570
|
+
}
|
|
5571
|
+
function getShowBalanceAsValue(showBalanceAs, chainId) {
|
|
5572
|
+
if (!showBalanceAs || !chainId) return null;
|
|
5573
|
+
if (typeof showBalanceAs === "string") return showBalanceAs;
|
|
5574
|
+
return showBalanceAs[chainId] || null;
|
|
5575
|
+
}
|
|
5557
5576
|
function BalanceFeedProvider() {
|
|
5558
5577
|
const config = useProviderConfig().config;
|
|
5559
5578
|
const embarkaiAddress = useSession((st) => st.address);
|
|
5560
5579
|
const chainConfig = useSession((st) => st.chainConfig);
|
|
5561
5580
|
const publicClient = useSession((st) => st.publicClient);
|
|
5562
5581
|
const [balanceSymbol, setBalanceSymbol] = useState2(null);
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
|
|
5567
|
-
|
|
5568
|
-
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
|
|
5582
|
+
const blockscoutApiUrl = useMemo(() => getBlockscoutApiUrl(chainConfig), [chainConfig]);
|
|
5583
|
+
useEffect2(() => {
|
|
5584
|
+
useLayoutDataStore.getState().setCryptoSymbol(chainConfig?.nativeCurrency?.symbol || "LUMIA");
|
|
5585
|
+
const showBalanceAsSymbol = getShowBalanceAsValue(config?.current?.showBalanceAs || null, chainConfig?.id || 0);
|
|
5586
|
+
setBalanceSymbol(showBalanceAsSymbol || chainConfig.nativeCurrency.symbol);
|
|
5587
|
+
}, [config, embarkaiAddress, chainConfig]);
|
|
5588
|
+
const {
|
|
5589
|
+
data: assets,
|
|
5590
|
+
refetch: getBlockscoutsAndWatchAssetList
|
|
5591
|
+
// hack to get updated data inside another useQuery & revalidate the query
|
|
5592
|
+
} = useQuery2({
|
|
5593
|
+
retry: false,
|
|
5594
|
+
enabled: !!embarkaiAddress && !!blockscoutApiUrl,
|
|
5595
|
+
queryKey: [BLOCKSCOUTS_BALANCE_QUERY_KEY, embarkaiAddress, blockscoutApiUrl],
|
|
5596
|
+
queryFn: async () => {
|
|
5597
|
+
if (!embarkaiAddress || !blockscoutApiUrl) return;
|
|
5598
|
+
const watchTokensList = (config?.current?.watchTokens?.[chainConfig?.id] || []).map((el) => ({
|
|
5599
|
+
address: el.address,
|
|
5600
|
+
decimals: el.decimals,
|
|
5601
|
+
symbol: el.symbol
|
|
5602
|
+
}));
|
|
5603
|
+
const blockscoutAssets = await getBlockscoutsAssets(embarkaiAddress, blockscoutApiUrl);
|
|
5604
|
+
return [...watchTokensList, ...blockscoutAssets];
|
|
5605
|
+
}
|
|
5606
|
+
});
|
|
5607
|
+
const assetUsdtRateSymbol = useMemo(() => {
|
|
5608
|
+
if (!balanceSymbol) return null;
|
|
5609
|
+
if (isAddress(balanceSymbol)) {
|
|
5610
|
+
return assets?.find((el) => el.address === balanceSymbol)?.symbol || null;
|
|
5611
|
+
}
|
|
5612
|
+
return balanceSymbol;
|
|
5613
|
+
}, [assets, balanceSymbol]);
|
|
5614
|
+
const { data: cryptoRate } = useAssetUsdtRate(assetUsdtRateSymbol);
|
|
5572
5615
|
const isNativeBalanceFeedEnabled = !!balanceSymbol && !!chainConfig?.nativeCurrency.symbol && balanceSymbol === chainConfig?.nativeCurrency.symbol;
|
|
5573
5616
|
const { data: nativeBalance } = useQuery2({
|
|
5574
5617
|
enabled: !!isNativeBalanceFeedEnabled && !!embarkaiAddress && !!publicClient,
|
|
5575
5618
|
retry: false,
|
|
5576
5619
|
refetchInterval: BALANCE_POLLING_INTERVAL,
|
|
5577
|
-
queryKey: [NATIVE_BALANCE_QUERY_KEY, embarkaiAddress,
|
|
5620
|
+
queryKey: [NATIVE_BALANCE_QUERY_KEY, embarkaiAddress, balanceSymbol],
|
|
5578
5621
|
// Include chainId in query key to refetch when chain changes
|
|
5579
5622
|
queryFn: async () => {
|
|
5580
5623
|
const balanceValue = await publicClient.getBalance({ address: embarkaiAddress });
|
|
@@ -5628,38 +5671,42 @@ function BalanceFeedProvider() {
|
|
|
5628
5671
|
});
|
|
5629
5672
|
}, [isProjectAssetBalanceEnabled, projectAssetBalance]);
|
|
5630
5673
|
const isCustomAssetBalanceEnabled = !isNativeBalanceFeedEnabled && !isProjectAssetBalanceEnabled;
|
|
5631
|
-
const {
|
|
5674
|
+
const {
|
|
5675
|
+
data: customBalance,
|
|
5676
|
+
isLoading: isCustomBalanceLoading,
|
|
5677
|
+
isError: isCustomBalanceError
|
|
5678
|
+
} = useQuery2({
|
|
5632
5679
|
enabled: !!isCustomAssetBalanceEnabled && !!balanceSymbol && !!chainConfig?.id && !!embarkaiAddress && !!publicClient,
|
|
5633
5680
|
retry: false,
|
|
5634
5681
|
refetchInterval: BALANCE_POLLING_INTERVAL,
|
|
5635
|
-
// staleTime: 0,
|
|
5636
5682
|
queryKey: [CUSTOM_BALANCE_QUERY_KEY, chainConfig?.id, embarkaiAddress, balanceSymbol],
|
|
5637
5683
|
// Include chainId in query key to refetch when chain changes
|
|
5638
5684
|
queryFn: async () => {
|
|
5639
|
-
const blockscoutApiUrl = getBlockscoutApiUrl(chainConfig);
|
|
5640
|
-
const watchTokensList = (config?.current?.watchTokens?.[chainConfig?.id] || []).map((el) => ({
|
|
5641
|
-
address: el.address,
|
|
5642
|
-
decimals: el.decimals,
|
|
5643
|
-
symbol: el.symbol
|
|
5644
|
-
}));
|
|
5645
5685
|
const customAssetList = [];
|
|
5646
5686
|
if (blockscoutApiUrl) {
|
|
5647
|
-
const
|
|
5648
|
-
|
|
5649
|
-
const blockscoutAssets = blockscoutTokens.map((el) => ({
|
|
5650
|
-
address: el.token.address_hash,
|
|
5651
|
-
decimals: Number(el.token.decimals),
|
|
5652
|
-
symbol: el.token.symbol
|
|
5653
|
-
}));
|
|
5654
|
-
customAssetList.push(...watchTokensList, ...blockscoutAssets);
|
|
5687
|
+
const blockscoutAssets = await getBlockscoutsAndWatchAssetList().then((res) => res.data || []);
|
|
5688
|
+
customAssetList.push(...blockscoutAssets);
|
|
5655
5689
|
} else {
|
|
5690
|
+
const watchTokensList = (config?.current?.watchTokens?.[chainConfig?.id] || []).map((el) => ({
|
|
5691
|
+
address: el.address,
|
|
5692
|
+
decimals: el.decimals,
|
|
5693
|
+
symbol: el.symbol
|
|
5694
|
+
}));
|
|
5656
5695
|
const coreTokenList = NON_BLOCKSCOUT_CORE_TOKENS[chainConfig?.id] || [];
|
|
5657
5696
|
customAssetList.push(...watchTokensList, ...coreTokenList);
|
|
5658
5697
|
}
|
|
5659
|
-
const {
|
|
5698
|
+
const {
|
|
5699
|
+
address: customAssetAddress,
|
|
5700
|
+
decimals: customAssetDecimals,
|
|
5701
|
+
symbol: customAssetSymbol
|
|
5702
|
+
} = customAssetList.find((el) => {
|
|
5703
|
+
return (isAddress(balanceSymbol) ? el.address : el.symbol) === balanceSymbol;
|
|
5704
|
+
}) || {};
|
|
5660
5705
|
if (!customAssetAddress) {
|
|
5661
5706
|
console.warn(`[BALANCE FEED] No token address found for symbol ${balanceSymbol} on chain ${chainConfig?.name}`);
|
|
5662
|
-
|
|
5707
|
+
throw new Error(
|
|
5708
|
+
`[BALANCE FEED] No token address found for symbol ${balanceSymbol} on chain ${chainConfig?.name}`
|
|
5709
|
+
);
|
|
5663
5710
|
}
|
|
5664
5711
|
const balanceValue = await await publicClient.readContract({
|
|
5665
5712
|
address: customAssetAddress,
|
|
@@ -5669,15 +5716,24 @@ function BalanceFeedProvider() {
|
|
|
5669
5716
|
authorizationList: void 0
|
|
5670
5717
|
});
|
|
5671
5718
|
return {
|
|
5672
|
-
decimals:
|
|
5673
|
-
formatted: formatUnits(balanceValue,
|
|
5674
|
-
symbol:
|
|
5719
|
+
decimals: customAssetDecimals || 18,
|
|
5720
|
+
formatted: formatUnits(balanceValue, customAssetDecimals || 18),
|
|
5721
|
+
symbol: customAssetSymbol,
|
|
5675
5722
|
value: balanceValue
|
|
5676
5723
|
};
|
|
5677
5724
|
}
|
|
5678
5725
|
});
|
|
5726
|
+
useEffect2(() => {
|
|
5727
|
+
if (!isCustomAssetBalanceEnabled || !!isCustomBalanceLoading) return;
|
|
5728
|
+
if (!!isCustomAssetBalanceEnabled && !isCustomBalanceLoading && !!isCustomBalanceError && !!chainConfig?.id) {
|
|
5729
|
+
setTimeout(() => {
|
|
5730
|
+
setBalanceSymbol(chainConfig.nativeCurrency.symbol);
|
|
5731
|
+
}, 0);
|
|
5732
|
+
}
|
|
5733
|
+
}, [isCustomAssetBalanceEnabled, isCustomBalanceLoading, isCustomBalanceError, chainConfig]);
|
|
5679
5734
|
useEffect2(() => {
|
|
5680
5735
|
if (!isCustomAssetBalanceEnabled || !customBalance) return;
|
|
5736
|
+
if (!!isCustomAssetBalanceEnabled && isCustomBalanceLoading) return;
|
|
5681
5737
|
const rate = Number(cryptoRate?.price || "1");
|
|
5682
5738
|
const formattedBalance = Number(formatUnits(BigInt(customBalance?.value || "0"), customBalance?.decimals || 18));
|
|
5683
5739
|
const { setCryptoRate, setFiatBalance, setBalance, setCryptoSymbol, setFiatSymbol } = useLayoutDataStore.getState();
|
|
@@ -5686,7 +5742,14 @@ function BalanceFeedProvider() {
|
|
|
5686
5742
|
setFiatSymbol("USD");
|
|
5687
5743
|
setFiatBalance(formattedBalance * rate);
|
|
5688
5744
|
setBalance(customBalance);
|
|
5689
|
-
}, [
|
|
5745
|
+
}, [
|
|
5746
|
+
isCustomAssetBalanceEnabled,
|
|
5747
|
+
customBalance,
|
|
5748
|
+
cryptoRate,
|
|
5749
|
+
chainConfig,
|
|
5750
|
+
isCustomBalanceError,
|
|
5751
|
+
isCustomBalanceLoading
|
|
5752
|
+
]);
|
|
5690
5753
|
return null;
|
|
5691
5754
|
}
|
|
5692
5755
|
var init_BalanceFeedProvider = __esm({
|
|
@@ -11002,7 +11065,7 @@ var init_VerifyStep2 = __esm({
|
|
|
11002
11065
|
|
|
11003
11066
|
// src/internal/components/AuthMenu/AuthMenu.tsx
|
|
11004
11067
|
import { Loader as Loader4 } from "lucide-react";
|
|
11005
|
-
import { useEffect as useEffect12, useMemo } from "react";
|
|
11068
|
+
import { useEffect as useEffect12, useMemo as useMemo2 } from "react";
|
|
11006
11069
|
import { jsx as jsx23, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
11007
11070
|
var AuthMenu;
|
|
11008
11071
|
var init_AuthMenu = __esm({
|
|
@@ -11058,7 +11121,7 @@ var init_AuthMenu = __esm({
|
|
|
11058
11121
|
/* @__PURE__ */ jsx23("span", { className: "text-sm text-[var(--ui-kit-fg-muted)]", children: "Initializing wallet..." })
|
|
11059
11122
|
] });
|
|
11060
11123
|
}
|
|
11061
|
-
const stepContent =
|
|
11124
|
+
const stepContent = useMemo2(
|
|
11062
11125
|
() => ({
|
|
11063
11126
|
"loading": /* @__PURE__ */ jsx23(LoadingStep, {}),
|
|
11064
11127
|
"failed": /* @__PURE__ */ jsx23(AuthFailedStep, {}),
|
|
@@ -11235,7 +11298,7 @@ var init_onboarder = __esm({
|
|
|
11235
11298
|
|
|
11236
11299
|
// src/internal/components/Onboarding/OnboardingOverlay.tsx
|
|
11237
11300
|
import { ChevronRightIcon, LoaderIcon, XIcon } from "lucide-react";
|
|
11238
|
-
import { useEffect as useEffect13, useMemo as
|
|
11301
|
+
import { useEffect as useEffect13, useMemo as useMemo3, useState as useState6 } from "react";
|
|
11239
11302
|
import { createPortal as createPortal2 } from "react-dom";
|
|
11240
11303
|
import { jsx as jsx24, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
11241
11304
|
function getTooltipXPos(params) {
|
|
@@ -11287,7 +11350,7 @@ function OnboardingOverlay() {
|
|
|
11287
11350
|
description,
|
|
11288
11351
|
forced = false
|
|
11289
11352
|
} = onboarder.getCurrentStep() || {};
|
|
11290
|
-
const position =
|
|
11353
|
+
const position = useMemo3(() => {
|
|
11291
11354
|
const posParams = {
|
|
11292
11355
|
x: elRect.x,
|
|
11293
11356
|
y: elRect.y,
|
|
@@ -11909,6 +11972,7 @@ var init_tokens = __esm({
|
|
|
11909
11972
|
//
|
|
11910
11973
|
"$P USDT": parlayToken_default,
|
|
11911
11974
|
"P": parlayToken_default,
|
|
11975
|
+
"$P": parlayToken_default,
|
|
11912
11976
|
//
|
|
11913
11977
|
"EMBARKAI": embarkAI_default
|
|
11914
11978
|
};
|
|
@@ -12064,7 +12128,7 @@ var init_useBuyMenuStore = __esm({
|
|
|
12064
12128
|
// src/internal/components/BuyMenu/components/CryptoSelector.tsx
|
|
12065
12129
|
import { debounce as debounce2, toPairs } from "lodash-es";
|
|
12066
12130
|
import { InfoIcon, PointerIcon, SearchIcon } from "lucide-react";
|
|
12067
|
-
import { useCallback as useCallback11, useMemo as
|
|
12131
|
+
import { useCallback as useCallback11, useMemo as useMemo4, useState as useState8 } from "react";
|
|
12068
12132
|
import { jsx as jsx37, jsxs as jsxs32 } from "react/jsx-runtime";
|
|
12069
12133
|
function CryptoItem(props) {
|
|
12070
12134
|
const { symbol, network } = props;
|
|
@@ -12108,7 +12172,7 @@ function CryptoSelector(props) {
|
|
|
12108
12172
|
debounce2((value) => setTarget(value), 1e3),
|
|
12109
12173
|
[]
|
|
12110
12174
|
);
|
|
12111
|
-
const filteredCoins =
|
|
12175
|
+
const filteredCoins = useMemo4(() => {
|
|
12112
12176
|
const sorted = [...coins].sort((a, b) => {
|
|
12113
12177
|
const aIdx = POPULAR_CRYPTOS.indexOf(a.symbol.toUpperCase());
|
|
12114
12178
|
const bIdx = POPULAR_CRYPTOS.indexOf(b.symbol.toUpperCase());
|
|
@@ -12286,7 +12350,7 @@ var init_ResolvedFiatIcon = __esm({
|
|
|
12286
12350
|
// src/internal/components/BuyMenu/components/FiatSelector.tsx
|
|
12287
12351
|
import { debounce as debounce3 } from "lodash-es";
|
|
12288
12352
|
import { PointerIcon as PointerIcon2, SearchIcon as SearchIcon2 } from "lucide-react";
|
|
12289
|
-
import { useCallback as useCallback12, useMemo as
|
|
12353
|
+
import { useCallback as useCallback12, useMemo as useMemo5, useState as useState9 } from "react";
|
|
12290
12354
|
import { Fragment as Fragment9, jsx as jsx39, jsxs as jsxs33 } from "react/jsx-runtime";
|
|
12291
12355
|
function getCurrencyName(ticker, locale = "en") {
|
|
12292
12356
|
try {
|
|
@@ -12330,7 +12394,7 @@ function FiatSelector(props) {
|
|
|
12330
12394
|
debounce3((value) => setTarget(value), 1e3),
|
|
12331
12395
|
[]
|
|
12332
12396
|
);
|
|
12333
|
-
const filteredFiats =
|
|
12397
|
+
const filteredFiats = useMemo5(() => {
|
|
12334
12398
|
const sorted = [...fiats].sort((a, b) => {
|
|
12335
12399
|
const aIdx = POPULAR_FIATS.indexOf(a.ticker.toUpperCase());
|
|
12336
12400
|
const bIdx = POPULAR_FIATS.indexOf(b.ticker.toUpperCase());
|
|
@@ -13004,7 +13068,7 @@ var init_statuses = __esm({
|
|
|
13004
13068
|
import { useInfiniteQuery } from "@tanstack/react-query";
|
|
13005
13069
|
import dayjs from "dayjs";
|
|
13006
13070
|
import { DownloadIcon, ExternalLinkIcon, LoaderIcon as LoaderIcon3 } from "lucide-react";
|
|
13007
|
-
import { useMemo as
|
|
13071
|
+
import { useMemo as useMemo6 } from "react";
|
|
13008
13072
|
import { jsx as jsx43, jsxs as jsxs36 } from "react/jsx-runtime";
|
|
13009
13073
|
function getStatusVariant(status) {
|
|
13010
13074
|
switch (status) {
|
|
@@ -13135,7 +13199,7 @@ function BinanceTxHistory() {
|
|
|
13135
13199
|
txStatuses: SHOW_STATUSES
|
|
13136
13200
|
})
|
|
13137
13201
|
});
|
|
13138
|
-
const txList =
|
|
13202
|
+
const txList = useMemo6(
|
|
13139
13203
|
() => historyData?.pages?.map((p) => p.data).flat(Infinity) || [],
|
|
13140
13204
|
[historyData]
|
|
13141
13205
|
);
|
|
@@ -14818,7 +14882,7 @@ import { PAYMASTER_CACHE_TTL_MS } from "@embarkai/core";
|
|
|
14818
14882
|
import { getChainConfig as getChainConfig8, SUPPORTED_MAINNETS as SUPPORTED_MAINNETS2 } from "@embarkai/core/read";
|
|
14819
14883
|
import { useQuery as useQuery5 } from "@tanstack/react-query";
|
|
14820
14884
|
import { ArrowLeft as ArrowLeft4 } from "lucide-react";
|
|
14821
|
-
import { useMemo as
|
|
14885
|
+
import { useMemo as useMemo7, useState as useState11 } from "react";
|
|
14822
14886
|
import { jsx as jsx57, jsxs as jsxs50 } from "react/jsx-runtime";
|
|
14823
14887
|
function ChainsMenu() {
|
|
14824
14888
|
const { t } = useT();
|
|
@@ -14828,7 +14892,7 @@ function ChainsMenu() {
|
|
|
14828
14892
|
const [isTestnets, setIsTestnets] = useState11(false);
|
|
14829
14893
|
const [nextChainId, setNextChainId] = useState11(null);
|
|
14830
14894
|
useOnboardingTourAvailable(true);
|
|
14831
|
-
const visibleNetworks =
|
|
14895
|
+
const visibleNetworks = useMemo7(() => {
|
|
14832
14896
|
return NETWORK_OPTIONS.filter(
|
|
14833
14897
|
(option) => option.isActive && (isTestnets ? true : SUPPORTED_MAINNETS2.includes(option.chainId))
|
|
14834
14898
|
);
|
|
@@ -16385,7 +16449,7 @@ var init_ProviderCard = __esm({
|
|
|
16385
16449
|
// src/internal/components/ManageWalletMenu/ManageWallet.tsx
|
|
16386
16450
|
import { fromPairs } from "lodash-es";
|
|
16387
16451
|
import { ArrowLeft as ArrowLeft6, Loader as Loader9, LoaderIcon as LoaderIcon8 } from "lucide-react";
|
|
16388
|
-
import { useMemo as
|
|
16452
|
+
import { useMemo as useMemo8 } from "react";
|
|
16389
16453
|
import { Fragment as Fragment17, jsx as jsx68, jsxs as jsxs60 } from "react/jsx-runtime";
|
|
16390
16454
|
function getProviderName(provider) {
|
|
16391
16455
|
return PROVIDERS_META[provider].name || provider;
|
|
@@ -16426,7 +16490,7 @@ function ManageWalletMenu() {
|
|
|
16426
16490
|
} = useManageWalletStore();
|
|
16427
16491
|
const configuredProviders = getConfiguredProviders(config.current);
|
|
16428
16492
|
const { data: providers = [], isLoading: isProvidersLoading, error: providersError } = useProvidersList();
|
|
16429
|
-
const renderProviders =
|
|
16493
|
+
const renderProviders = useMemo8(() => {
|
|
16430
16494
|
const normalizeProviderName = (name) => {
|
|
16431
16495
|
if (name === "x") return "twitter";
|
|
16432
16496
|
return name;
|
|
@@ -16742,7 +16806,7 @@ var init_useConnectExternalWalletMenuParams = __esm({
|
|
|
16742
16806
|
// src/internal/components/ConnectExternalWalletMenu/ConnectExternalWalletMenu.tsx
|
|
16743
16807
|
import { useMutation as useMutation11, useQuery as useQuery8, useQueryClient as useQueryClient14 } from "@tanstack/react-query";
|
|
16744
16808
|
import { ArrowLeft as ArrowLeft7, Loader as Loader11, Wallet2Icon as Wallet2Icon2 } from "lucide-react";
|
|
16745
|
-
import { useCallback as useCallback17, useMemo as
|
|
16809
|
+
import { useCallback as useCallback17, useMemo as useMemo9 } from "react";
|
|
16746
16810
|
import { useConnect, useConnection, useConnectors, useDisconnect as useDisconnect2, useSignMessage } from "wagmi";
|
|
16747
16811
|
import { jsx as jsx70, jsxs as jsxs62 } from "react/jsx-runtime";
|
|
16748
16812
|
function getConnectFlowType(params) {
|
|
@@ -16952,7 +17016,7 @@ function ConnectExternalWalletMenu() {
|
|
|
16952
17016
|
}
|
|
16953
17017
|
}
|
|
16954
17018
|
});
|
|
16955
|
-
const visibleConnectors =
|
|
17019
|
+
const visibleConnectors = useMemo9(() => {
|
|
16956
17020
|
const seen = /* @__PURE__ */ new Set();
|
|
16957
17021
|
const unique = connectors.filter((connector) => {
|
|
16958
17022
|
const skipConnector = seen.has(connector.uid);
|
|
@@ -19091,7 +19155,7 @@ var init_hooks = __esm({
|
|
|
19091
19155
|
|
|
19092
19156
|
// src/internal/components/KeyshareRestoreMenu/components/MethodSelector.tsx
|
|
19093
19157
|
import { Cloud, Cpu as Cpu3, FileDown, FileUp } from "lucide-react";
|
|
19094
|
-
import { Fragment as Fragment20, useMemo as
|
|
19158
|
+
import { Fragment as Fragment20, useMemo as useMemo10 } from "react";
|
|
19095
19159
|
import { jsx as jsx75, jsxs as jsxs67 } from "react/jsx-runtime";
|
|
19096
19160
|
function MethodSelector(props) {
|
|
19097
19161
|
const { mode = "restore", serverRecoveryStatus } = props;
|
|
@@ -19105,7 +19169,7 @@ function MethodSelector(props) {
|
|
|
19105
19169
|
setError,
|
|
19106
19170
|
setSuccess
|
|
19107
19171
|
} = useRestoreStore();
|
|
19108
|
-
const recoveryRenderMethods =
|
|
19172
|
+
const recoveryRenderMethods = useMemo10(() => {
|
|
19109
19173
|
const methodsWithBackupData = getRecoveryRenderMethods(mode).map((mt) => {
|
|
19110
19174
|
let data = null;
|
|
19111
19175
|
switch (true) {
|
|
@@ -21449,7 +21513,7 @@ var init_NicknameMenu2 = __esm({
|
|
|
21449
21513
|
|
|
21450
21514
|
// src/internal/hooks/useResolvedPublicClient.ts
|
|
21451
21515
|
import { createPublicClientForChain as createPublicClientForChain5, getChainConfig as getChainConfig9 } from "@embarkai/core/read";
|
|
21452
|
-
import { useMemo as
|
|
21516
|
+
import { useMemo as useMemo11 } from "react";
|
|
21453
21517
|
function getCachedPublicClient(chainId) {
|
|
21454
21518
|
const cachedClient = publicClientByChainId.get(chainId);
|
|
21455
21519
|
if (cachedClient) return cachedClient;
|
|
@@ -21463,11 +21527,11 @@ function useResolvedPublicClient(chainId, logScope = "useResolvedPublicClient")
|
|
|
21463
21527
|
const activeChainConfig = useSession((st) => st.chainConfig);
|
|
21464
21528
|
const resolvedChainId = chainId ?? activeChainId;
|
|
21465
21529
|
const shouldUseActiveClient = !chainId || chainId === activeChainId;
|
|
21466
|
-
const chainConfig =
|
|
21530
|
+
const chainConfig = useMemo11(() => {
|
|
21467
21531
|
if (shouldUseActiveClient) return activeChainConfig;
|
|
21468
21532
|
return getChainConfig9(chainId);
|
|
21469
21533
|
}, [activeChainConfig, chainId, shouldUseActiveClient]);
|
|
21470
|
-
const publicClient =
|
|
21534
|
+
const publicClient = useMemo11(() => {
|
|
21471
21535
|
if (shouldUseActiveClient) return activePublicClient;
|
|
21472
21536
|
if (!chainId) return activePublicClient;
|
|
21473
21537
|
try {
|
|
@@ -21548,12 +21612,12 @@ var init_useNativeBalance = __esm({
|
|
|
21548
21612
|
|
|
21549
21613
|
// src/internal/hooks/useBlockscoutAssets/useWatchTokens.ts
|
|
21550
21614
|
import { useQuery as useQuery16 } from "@tanstack/react-query";
|
|
21551
|
-
import { useMemo as
|
|
21615
|
+
import { useMemo as useMemo12 } from "react";
|
|
21552
21616
|
import { erc20Abi as erc20Abi2, formatUnits as formatUnits3 } from "viem";
|
|
21553
21617
|
function useWatchTokens(options) {
|
|
21554
21618
|
const { address, chainId, enabled, publicClient } = options;
|
|
21555
21619
|
const { config } = useProviderConfig();
|
|
21556
|
-
const watchTokens =
|
|
21620
|
+
const watchTokens = useMemo12(() => {
|
|
21557
21621
|
const allWatchTokens = config.current.watchTokens;
|
|
21558
21622
|
const tokensForChain = chainId ? allWatchTokens?.[chainId] || [] : [];
|
|
21559
21623
|
return tokensForChain;
|
|
@@ -21762,7 +21826,7 @@ var init_utils8 = __esm({
|
|
|
21762
21826
|
// src/internal/hooks/useBlockscoutAssets/useBlockscoutAssets.ts
|
|
21763
21827
|
import { createBlockscoutClient as createBlockscoutClient2, nonBlockscoutClient } from "@embarkai/core";
|
|
21764
21828
|
import { useQuery as useQuery17, useQueryClient as useQueryClient20 } from "@tanstack/react-query";
|
|
21765
|
-
import { useCallback as useCallback25, useMemo as
|
|
21829
|
+
import { useCallback as useCallback25, useMemo as useMemo13, useRef as useRef16 } from "react";
|
|
21766
21830
|
function useBlockscoutAssets(options) {
|
|
21767
21831
|
const { address, chainId, enabled = true, detectSecurityTokens = true } = options;
|
|
21768
21832
|
const qc = useQueryClient20();
|
|
@@ -21773,7 +21837,7 @@ function useBlockscoutAssets(options) {
|
|
|
21773
21837
|
tokenBalancesQueryKey: customTokenBalancesQueryKey
|
|
21774
21838
|
} = useProviderConfig().config?.current?.portfolio || {};
|
|
21775
21839
|
const blockscoutApiUrl = getBlockscoutApiUrl(chainConfig);
|
|
21776
|
-
const blockscoutClient =
|
|
21840
|
+
const blockscoutClient = useMemo13(
|
|
21777
21841
|
() => blockscoutApiUrl ? createBlockscoutClient2({ baseUrl: blockscoutApiUrl }) : null,
|
|
21778
21842
|
[blockscoutApiUrl]
|
|
21779
21843
|
);
|
|
@@ -21849,7 +21913,7 @@ function useBlockscoutAssets(options) {
|
|
|
21849
21913
|
queryKey: [BLOCKSCOUT_QUERY_KEY, "nfts", resolvedChainId, blockscoutApiUrl, address],
|
|
21850
21914
|
queryFn: () => blockscoutClient.getNfts(address)
|
|
21851
21915
|
});
|
|
21852
|
-
const erc20TokenAddresses =
|
|
21916
|
+
const erc20TokenAddresses = useMemo13(() => {
|
|
21853
21917
|
if (!blockscoutItems) return [];
|
|
21854
21918
|
return blockscoutItems.filter((tb) => tb.token.type === "ERC-20").map((tb) => tb.token.address_hash);
|
|
21855
21919
|
}, [blockscoutItems]);
|
|
@@ -21894,7 +21958,7 @@ function useBlockscoutAssets(options) {
|
|
|
21894
21958
|
// 1 minute
|
|
21895
21959
|
// gcTime: BLOCKSCOUT_QUERY_GC_TIME,
|
|
21896
21960
|
});
|
|
21897
|
-
const assets =
|
|
21961
|
+
const assets = useMemo13(() => {
|
|
21898
21962
|
const result = [];
|
|
21899
21963
|
const addedAddresses = /* @__PURE__ */ new Set();
|
|
21900
21964
|
if (nativeBalanceData) {
|
|
@@ -21988,7 +22052,7 @@ function useBlockscoutAssets(options) {
|
|
|
21988
22052
|
watchTokenAssets,
|
|
21989
22053
|
chainConfig
|
|
21990
22054
|
]);
|
|
21991
|
-
const nativeBalance =
|
|
22055
|
+
const nativeBalance = useMemo13(() => {
|
|
21992
22056
|
if (!nativeBalanceData) return null;
|
|
21993
22057
|
return {
|
|
21994
22058
|
value: nativeBalanceData.value,
|
|
@@ -21996,7 +22060,7 @@ function useBlockscoutAssets(options) {
|
|
|
21996
22060
|
symbol: nativeBalanceData.symbol
|
|
21997
22061
|
};
|
|
21998
22062
|
}, [nativeBalanceData]);
|
|
21999
|
-
const error =
|
|
22063
|
+
const error = useMemo13(() => {
|
|
22000
22064
|
if (!blockscoutError) return null;
|
|
22001
22065
|
return createError(blockscoutError);
|
|
22002
22066
|
}, [blockscoutError]);
|
|
@@ -22077,7 +22141,7 @@ function BalanceView(props) {
|
|
|
22077
22141
|
const cryptoBalance = Number(formatUnits5(balance?.value || BigInt(0), balance?.decimals || 18));
|
|
22078
22142
|
const fiatBalance = useLayoutDataStore((st) => st.fiatBalance);
|
|
22079
22143
|
const fiatSymbol = useLayoutDataStore((st) => st.fiatSymbol);
|
|
22080
|
-
const BalanceIcon = showFiatBalance
|
|
22144
|
+
const BalanceIcon = showFiatBalance ? TOKENS_ICONS[cryptoSymbol] : null;
|
|
22081
22145
|
return /* @__PURE__ */ jsxs84(
|
|
22082
22146
|
"p",
|
|
22083
22147
|
{
|
|
@@ -22509,7 +22573,7 @@ var init_onboarding_setup7 = __esm({
|
|
|
22509
22573
|
import { useQuery as useQuery19 } from "@tanstack/react-query";
|
|
22510
22574
|
import { ArrowLeft as ArrowLeft18, AtSignIcon as AtSignIcon2, CheckCircle2 as CheckCircle23, Copy as Copy2, FingerprintIcon, LoaderIcon as LoaderIcon12, Wallet2Icon as Wallet2Icon3 } from "lucide-react";
|
|
22511
22575
|
import QRCode from "qrcode";
|
|
22512
|
-
import { useEffect as useEffect37, useMemo as
|
|
22576
|
+
import { useEffect as useEffect37, useMemo as useMemo14, useState as useState22 } from "react";
|
|
22513
22577
|
import { Fragment as Fragment32, jsx as jsx95, jsxs as jsxs87 } from "react/jsx-runtime";
|
|
22514
22578
|
function ReceiveMenu() {
|
|
22515
22579
|
const { t } = useT();
|
|
@@ -22528,7 +22592,7 @@ function ReceiveMenu() {
|
|
|
22528
22592
|
const [isNicknameCopied, setNicknameCopied] = useState22(false);
|
|
22529
22593
|
const [fingerprintCopied, setFingerprintCopied] = useState22(false);
|
|
22530
22594
|
useOnboardingTourAvailable(true);
|
|
22531
|
-
const fingerprint =
|
|
22595
|
+
const fingerprint = useMemo14(() => {
|
|
22532
22596
|
if (!session?.ownerAddress) return null;
|
|
22533
22597
|
try {
|
|
22534
22598
|
return generateFingerprint(session.ownerAddress);
|
|
@@ -23973,7 +24037,7 @@ var init_utils9 = __esm({
|
|
|
23973
24037
|
// src/internal/components/SendMenu/hyperbridge/hooks/useHyperlaneHistory.ts
|
|
23974
24038
|
import { useInfiniteQuery as useInfiniteQuery3 } from "@tanstack/react-query";
|
|
23975
24039
|
import {
|
|
23976
|
-
useMemo as
|
|
24040
|
+
useMemo as useMemo15
|
|
23977
24041
|
} from "react";
|
|
23978
24042
|
function useHyperlaneHistory() {
|
|
23979
24043
|
const address = useSession((st) => st.address);
|
|
@@ -23989,7 +24053,7 @@ function useHyperlaneHistory() {
|
|
|
23989
24053
|
getNextPageParam: (lastPage) => lastPage.page < lastPage.pageCount ? lastPage.page + 1 : void 0,
|
|
23990
24054
|
queryFn: async ({ pageParam }) => await getHyperlaneBridgeHistory({ page: pageParam, pageSize: TX_HISTORY_PAGE_SIZE })
|
|
23991
24055
|
});
|
|
23992
|
-
const txList =
|
|
24056
|
+
const txList = useMemo15(
|
|
23993
24057
|
() => query?.data?.pages?.map((p) => p.data).flat(Infinity) || [],
|
|
23994
24058
|
[query?.data]
|
|
23995
24059
|
);
|
|
@@ -25464,13 +25528,13 @@ var init_HistoryStep = __esm({
|
|
|
25464
25528
|
|
|
25465
25529
|
// src/internal/components/SendMenu/hyperbridge/steps/SelectAssetRoute.tsx
|
|
25466
25530
|
import { ArrowLeftRightIcon as ArrowLeftRightIcon2 } from "lucide-react";
|
|
25467
|
-
import { useMemo as
|
|
25531
|
+
import { useMemo as useMemo16 } from "react";
|
|
25468
25532
|
import { jsx as jsx109, jsxs as jsxs99 } from "react/jsx-runtime";
|
|
25469
25533
|
function SelectAssetRoute(props) {
|
|
25470
25534
|
const { hyperlaneWarpRoutes } = props;
|
|
25471
25535
|
const { t } = useT();
|
|
25472
25536
|
const selectedAssetSymbol = useBridgeStore((st) => st.bridgeAssetSymbol);
|
|
25473
|
-
const tokenList =
|
|
25537
|
+
const tokenList = useMemo16(() => {
|
|
25474
25538
|
const tokens = hyperlaneWarpRoutes.map((route) => route.symbol);
|
|
25475
25539
|
const uniqueTokens = Array.from(new Set(tokens));
|
|
25476
25540
|
return uniqueTokens.map((symbol) => ({
|
|
@@ -25733,7 +25797,7 @@ var init_useErc3643Compliance = __esm({
|
|
|
25733
25797
|
|
|
25734
25798
|
// src/hooks/useNicknameResolve.ts
|
|
25735
25799
|
import { useQuery as useQuery24 } from "@tanstack/react-query";
|
|
25736
|
-
import { useEffect as useEffect43, useMemo as
|
|
25800
|
+
import { useEffect as useEffect43, useMemo as useMemo17, useState as useState24 } from "react";
|
|
25737
25801
|
function looksLikeNickname(input) {
|
|
25738
25802
|
if (!input) return false;
|
|
25739
25803
|
if (input.startsWith("0x")) return false;
|
|
@@ -25773,7 +25837,7 @@ function useNicknameResolve(input, options) {
|
|
|
25773
25837
|
const isNotFound = query.isError && query.error?.code === "NICKNAME_NOT_FOUND";
|
|
25774
25838
|
const isWalletNotSetup = !!query.data && query.data.resolvedTarget === null;
|
|
25775
25839
|
const isFrozen = query.data?.isFrozen ?? false;
|
|
25776
|
-
const fingerprintVerification =
|
|
25840
|
+
const fingerprintVerification = useMemo17(() => {
|
|
25777
25841
|
if (!query.data?.owner || !query.data?.fingerprint) {
|
|
25778
25842
|
return null;
|
|
25779
25843
|
}
|
|
@@ -25808,7 +25872,7 @@ var init_useNicknameResolve = __esm({
|
|
|
25808
25872
|
|
|
25809
25873
|
// src/hooks/useSendTransaction.ts
|
|
25810
25874
|
import { useCallback as useCallback29, useState as useState25 } from "react";
|
|
25811
|
-
import { encodeFunctionData as encodeFunctionData2, isAddress, parseEther as parseEther2, parseUnits } from "viem";
|
|
25875
|
+
import { encodeFunctionData as encodeFunctionData2, isAddress as isAddress2, parseEther as parseEther2, parseUnits } from "viem";
|
|
25812
25876
|
function useSendTransaction() {
|
|
25813
25877
|
const session = useSession((st) => st.session);
|
|
25814
25878
|
const address = useSession((st) => st.address);
|
|
@@ -25821,7 +25885,7 @@ function useSendTransaction() {
|
|
|
25821
25885
|
setError("No active session");
|
|
25822
25886
|
return null;
|
|
25823
25887
|
}
|
|
25824
|
-
if (!
|
|
25888
|
+
if (!isAddress2(params.to)) {
|
|
25825
25889
|
setError("Invalid recipient address");
|
|
25826
25890
|
return null;
|
|
25827
25891
|
}
|
|
@@ -26377,7 +26441,7 @@ var init_useTokenBalance = __esm({
|
|
|
26377
26441
|
|
|
26378
26442
|
// src/internal/components/SendMenu/send/sendSteps/InputSendStep.tsx
|
|
26379
26443
|
import { AlertCircle as AlertCircle4, AtSign as AtSign2, CheckCircle2 as CheckCircle25, Loader as Loader20, Wallet2 as Wallet24 } from "lucide-react";
|
|
26380
|
-
import { formatUnits as formatUnits12, isAddress as
|
|
26444
|
+
import { formatUnits as formatUnits12, isAddress as isAddress3 } from "viem";
|
|
26381
26445
|
import { Fragment as Fragment40, jsx as jsx116, jsxs as jsxs105 } from "react/jsx-runtime";
|
|
26382
26446
|
function InputSendStep(props) {
|
|
26383
26447
|
const { erc3643Compliance, isNicknameInput, resolvedNicknameData, isAssetsLoading } = props;
|
|
@@ -26441,7 +26505,7 @@ function InputSendStep(props) {
|
|
|
26441
26505
|
setError(isNicknameInput ? "Could not resolve nickname" : "Please enter a recipient address");
|
|
26442
26506
|
return false;
|
|
26443
26507
|
}
|
|
26444
|
-
if (!
|
|
26508
|
+
if (!isAddress3(addressToValidate)) {
|
|
26445
26509
|
setError("Invalid recipient address");
|
|
26446
26510
|
return false;
|
|
26447
26511
|
}
|
|
@@ -26789,7 +26853,7 @@ var init_sendSteps = __esm({
|
|
|
26789
26853
|
|
|
26790
26854
|
// src/internal/components/SendMenu/send/SendMenu.tsx
|
|
26791
26855
|
import { CheckCircle2 as CheckCircle26, Loader as Loader27 } from "lucide-react";
|
|
26792
|
-
import { useEffect as useEffect45, useMemo as
|
|
26856
|
+
import { useEffect as useEffect45, useMemo as useMemo18 } from "react";
|
|
26793
26857
|
import { parseUnits as parseUnits2 } from "viem";
|
|
26794
26858
|
import { Fragment as Fragment42, jsx as jsx118, jsxs as jsxs107 } from "react/jsx-runtime";
|
|
26795
26859
|
function SendMenu() {
|
|
@@ -26839,7 +26903,7 @@ function SendMenu() {
|
|
|
26839
26903
|
const isNicknameInput = looksLikeNickname(recipient);
|
|
26840
26904
|
const resolvedNicknameData = useNicknameResolve(recipient, { enabled: isNicknameInput, chainId: activeChainId });
|
|
26841
26905
|
const effectiveAddress = isNicknameInput ? resolvedNicknameData?.resolvedAddress : recipient;
|
|
26842
|
-
const complianceAmount =
|
|
26906
|
+
const complianceAmount = useMemo18(() => {
|
|
26843
26907
|
if (!isSecurity || !amount || !selectedAsset) return void 0;
|
|
26844
26908
|
try {
|
|
26845
26909
|
return parseUnits2(amount, selectedAsset.decimals || 18);
|
|
@@ -27021,7 +27085,7 @@ var init_useSendMenuParams = __esm({
|
|
|
27021
27085
|
|
|
27022
27086
|
// src/internal/components/SendMenu/SendFlowSelector.tsx
|
|
27023
27087
|
import { ArrowLeft as ArrowLeft20, ArrowRightIcon as ArrowRightIcon2, ArrowRightLeftIcon as ArrowRightLeftIcon2 } from "lucide-react";
|
|
27024
|
-
import { useEffect as useEffect47, useMemo as
|
|
27088
|
+
import { useEffect as useEffect47, useMemo as useMemo19 } from "react";
|
|
27025
27089
|
import { jsx as jsx119, jsxs as jsxs108 } from "react/jsx-runtime";
|
|
27026
27090
|
function SelectorFlowButtons() {
|
|
27027
27091
|
const { t } = useT();
|
|
@@ -27093,7 +27157,7 @@ function SendFlowSelector() {
|
|
|
27093
27157
|
if (!!config?.current?.features?.showAssetBridge) return;
|
|
27094
27158
|
if (selectorFlow === "bridge") useFlowSelectorStore.getState().setFlow("send");
|
|
27095
27159
|
}, [selectorFlow]);
|
|
27096
|
-
const availableFlows =
|
|
27160
|
+
const availableFlows = useMemo19(() => {
|
|
27097
27161
|
const selectorFlows = { send: /* @__PURE__ */ jsx119(SendMenu, {}) };
|
|
27098
27162
|
if (!!config?.current?.features?.showAssetBridge) selectorFlows.bridge = /* @__PURE__ */ jsx119(HyperlaneBridge, {});
|
|
27099
27163
|
return selectorFlows;
|
|
@@ -28632,7 +28696,7 @@ var init_package = __esm({
|
|
|
28632
28696
|
"package.json"() {
|
|
28633
28697
|
package_default = {
|
|
28634
28698
|
name: "@embarkai/ui-kit",
|
|
28635
|
-
version: "0.4.
|
|
28699
|
+
version: "0.4.89",
|
|
28636
28700
|
description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
|
|
28637
28701
|
type: "module",
|
|
28638
28702
|
main: "./dist/index.cjs",
|
|
@@ -31977,7 +32041,7 @@ import {
|
|
|
31977
32041
|
useCallback as useCallback34,
|
|
31978
32042
|
useContext,
|
|
31979
32043
|
useEffect as useEffect53,
|
|
31980
|
-
useMemo as
|
|
32044
|
+
useMemo as useMemo20,
|
|
31981
32045
|
useRef as useRef20
|
|
31982
32046
|
} from "react";
|
|
31983
32047
|
import { WagmiProvider as NativeWagmiProvider } from "wagmi";
|
|
@@ -32090,7 +32154,7 @@ function Provider(props) {
|
|
|
32090
32154
|
console.error("[PROVIDER] Error setting up iframe manager:", error);
|
|
32091
32155
|
}
|
|
32092
32156
|
}, [projectId]);
|
|
32093
|
-
const contextValue =
|
|
32157
|
+
const contextValue = useMemo20(
|
|
32094
32158
|
() => ({
|
|
32095
32159
|
config,
|
|
32096
32160
|
updateConfig,
|
|
@@ -32144,7 +32208,7 @@ init_useUserProfile();
|
|
|
32144
32208
|
init_pro_mode();
|
|
32145
32209
|
init_utils();
|
|
32146
32210
|
import { Cloud as Cloud4, Laptop as Laptop2, Loader as Loader31, Shield as Shield2 } from "lucide-react";
|
|
32147
|
-
import { useEffect as useEffect54, useMemo as
|
|
32211
|
+
import { useEffect as useEffect54, useMemo as useMemo21 } from "react";
|
|
32148
32212
|
import { Fragment as Fragment46, jsx as jsx132, jsxs as jsxs118 } from "react/jsx-runtime";
|
|
32149
32213
|
function getFormattedStatus(label, status, showStatus) {
|
|
32150
32214
|
const isStatus = showStatus && status && status !== "idle" && status !== "ready";
|
|
@@ -32167,7 +32231,7 @@ function ConnectWalletButton(props) {
|
|
|
32167
32231
|
useEffect54(() => setUsePaymaster(usePaymaster), [setUsePaymaster, usePaymaster]);
|
|
32168
32232
|
const { data: profile, isLoading: isProfileLoading } = useUserProfile();
|
|
32169
32233
|
const displayName = profile?.nicknameDisplay || profile?.displayName || jwtTokenManager2.getDisplayName();
|
|
32170
|
-
const indicators =
|
|
32234
|
+
const indicators = useMemo21(() => {
|
|
32171
32235
|
const userId = session?.mpcUserId;
|
|
32172
32236
|
if (!userId) return { server: false, local: false, backup: false };
|
|
32173
32237
|
const server = jwtTokenManager2.getHasKeyshare() ?? false;
|
|
@@ -33161,7 +33225,7 @@ function useDirectWallet() {
|
|
|
33161
33225
|
// src/hooks/useSendDirectTransaction.ts
|
|
33162
33226
|
init_useExternalWalletStore();
|
|
33163
33227
|
import { useCallback as useCallback39, useState as useState34 } from "react";
|
|
33164
|
-
import { isAddress as
|
|
33228
|
+
import { isAddress as isAddress4, parseEther as parseEther3 } from "viem";
|
|
33165
33229
|
import { useSendTransaction as useWagmiSendTransaction, useSwitchChain as useSwitchChain3 } from "wagmi";
|
|
33166
33230
|
function useSendDirectTransaction() {
|
|
33167
33231
|
const isConnected = useExternalWalletStore((st) => st.isExternalConnected);
|
|
@@ -33177,7 +33241,7 @@ function useSendDirectTransaction() {
|
|
|
33177
33241
|
setError("No external wallet connected");
|
|
33178
33242
|
return null;
|
|
33179
33243
|
}
|
|
33180
|
-
if (!
|
|
33244
|
+
if (!isAddress4(params.to)) {
|
|
33181
33245
|
setError("Invalid recipient address");
|
|
33182
33246
|
return null;
|
|
33183
33247
|
}
|
|
@@ -33217,8 +33281,8 @@ function useSendDirectTransaction() {
|
|
|
33217
33281
|
init_SessionContext();
|
|
33218
33282
|
init_account2();
|
|
33219
33283
|
init_linkedProfiles();
|
|
33220
|
-
import { useCallback as useCallback40, useMemo as
|
|
33221
|
-
import { encodeFunctionData as encodeFunctionData3, isAddress as
|
|
33284
|
+
import { useCallback as useCallback40, useMemo as useMemo22, useState as useState35 } from "react";
|
|
33285
|
+
import { encodeFunctionData as encodeFunctionData3, isAddress as isAddress5, parseEther as parseEther4, parseUnits as parseUnits3 } from "viem";
|
|
33222
33286
|
var ERC20_TRANSFER_ABI2 = [
|
|
33223
33287
|
{
|
|
33224
33288
|
type: "function",
|
|
@@ -33236,7 +33300,7 @@ function useTransferToLinkedWallet() {
|
|
|
33236
33300
|
const [isPending, setIsPending] = useState35(false);
|
|
33237
33301
|
const [error, setError] = useState35(null);
|
|
33238
33302
|
const [userOpHash, setUserOpHash] = useState35(null);
|
|
33239
|
-
const linkedWallets =
|
|
33303
|
+
const linkedWallets = useMemo22(
|
|
33240
33304
|
() => (profiles || []).filter((p) => p.provider === "wallet" && p.externalId).map((p) => p.externalId),
|
|
33241
33305
|
[profiles]
|
|
33242
33306
|
);
|
|
@@ -33247,7 +33311,7 @@ function useTransferToLinkedWallet() {
|
|
|
33247
33311
|
return null;
|
|
33248
33312
|
}
|
|
33249
33313
|
const toAddress = params.toAddress || linkedWallets[0];
|
|
33250
|
-
if (!toAddress || !
|
|
33314
|
+
if (!toAddress || !isAddress5(toAddress)) {
|
|
33251
33315
|
setError("No linked wallet address available");
|
|
33252
33316
|
return null;
|
|
33253
33317
|
}
|