@embarkai/ui-kit 0.4.7 → 0.4.9
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 +113 -56
- package/dist/index.js +75 -23
- 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.9</title>
|
|
19
19
|
|
|
20
20
|
<!-- Styles will be injected by build process -->
|
|
21
21
|
<style>
|
package/dist/iframe/main.js
CHANGED
|
@@ -6262,7 +6262,7 @@ var SigningManager = class extends TokenRefreshApiClient {
|
|
|
6262
6262
|
};
|
|
6263
6263
|
|
|
6264
6264
|
// src/iframe/main.ts
|
|
6265
|
-
var IFRAME_VERSION = "0.4.
|
|
6265
|
+
var IFRAME_VERSION = "0.4.9";
|
|
6266
6266
|
var IframeWallet = class {
|
|
6267
6267
|
constructor() {
|
|
6268
6268
|
console.log("=".repeat(60));
|
package/dist/index.cjs
CHANGED
|
@@ -15180,7 +15180,7 @@ function mapBlockscoutToAsset(balance) {
|
|
|
15180
15180
|
}
|
|
15181
15181
|
const asset = {
|
|
15182
15182
|
type,
|
|
15183
|
-
address: token.
|
|
15183
|
+
address: token.address_hash,
|
|
15184
15184
|
name: token.name || "Unknown Token",
|
|
15185
15185
|
symbol: token.symbol || "???",
|
|
15186
15186
|
balance: value,
|
|
@@ -15211,7 +15211,7 @@ function mapBlockscoutNftToAsset(nft) {
|
|
|
15211
15211
|
const imageUrl = image_url || (metadata?.image ? resolveIpfsUri(metadata.image) : void 0);
|
|
15212
15212
|
const asset = {
|
|
15213
15213
|
type,
|
|
15214
|
-
address: token.
|
|
15214
|
+
address: token.address_hash,
|
|
15215
15215
|
name: token.name || "Unknown NFT",
|
|
15216
15216
|
symbol: token.symbol || "???",
|
|
15217
15217
|
balance: value || "1",
|
|
@@ -15334,7 +15334,7 @@ function useBlockscoutAssets(options) {
|
|
|
15334
15334
|
});
|
|
15335
15335
|
const erc20TokenAddresses = (0, import_react57.useMemo)(() => {
|
|
15336
15336
|
if (!tokenBalances) return [];
|
|
15337
|
-
return tokenBalances.filter((tb) => tb.token.type === "ERC-20").map((tb) => tb.token.
|
|
15337
|
+
return tokenBalances.filter((tb) => tb.token.type === "ERC-20").map((tb) => tb.token.address_hash);
|
|
15338
15338
|
}, [tokenBalances]);
|
|
15339
15339
|
const { data: erc3643Results } = (0, import_react_query39.useQuery)({
|
|
15340
15340
|
queryKey: [ERC3643_DETECTION_QUERY_KEY, address, erc20TokenAddresses],
|
|
@@ -19167,7 +19167,7 @@ var init_package = __esm({
|
|
|
19167
19167
|
"package.json"() {
|
|
19168
19168
|
package_default = {
|
|
19169
19169
|
name: "@embarkai/ui-kit",
|
|
19170
|
-
version: "0.4.
|
|
19170
|
+
version: "0.4.9",
|
|
19171
19171
|
description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
|
|
19172
19172
|
type: "module",
|
|
19173
19173
|
main: "./dist/index.cjs",
|
|
@@ -20255,10 +20255,10 @@ function DirectWalletHandler() {
|
|
|
20255
20255
|
}
|
|
20256
20256
|
}, [walletMode, setConfigMode, setActiveMode]);
|
|
20257
20257
|
(0, import_react76.useEffect)(() => {
|
|
20258
|
-
if (isConnected && address && !isExternalConnected && connector) {
|
|
20258
|
+
if (isConnected && address && !isExternalConnected && connector && chain?.id) {
|
|
20259
20259
|
setExternalWallet({
|
|
20260
20260
|
address,
|
|
20261
|
-
chainId: chain
|
|
20261
|
+
chainId: chain.id,
|
|
20262
20262
|
connectorName: connector.name || "Unknown Wallet"
|
|
20263
20263
|
});
|
|
20264
20264
|
}
|
|
@@ -20274,10 +20274,10 @@ function DirectWalletHandler() {
|
|
|
20274
20274
|
}
|
|
20275
20275
|
}, [chain?.id, isConnected, isExternalConnected, setExternalChainId]);
|
|
20276
20276
|
(0, import_react76.useEffect)(() => {
|
|
20277
|
-
if (isExternalConnected && isConnected && address && address !== externalAddress && connector) {
|
|
20277
|
+
if (isExternalConnected && isConnected && address && address !== externalAddress && connector && chain?.id) {
|
|
20278
20278
|
setExternalWallet({
|
|
20279
20279
|
address,
|
|
20280
|
-
chainId: chain
|
|
20280
|
+
chainId: chain.id,
|
|
20281
20281
|
connectorName: connector.name || "Unknown Wallet"
|
|
20282
20282
|
});
|
|
20283
20283
|
}
|
|
@@ -22742,11 +22742,13 @@ var init_iframe_manager = __esm({
|
|
|
22742
22742
|
});
|
|
22743
22743
|
|
|
22744
22744
|
// src/config/rainbowkit.ts
|
|
22745
|
-
var import_rainbowkit2, import_wallets, import_chains, getProjectId2, WALLET_MAP, createRainbowConfig, rainbowTheme;
|
|
22745
|
+
var import_read17, import_rainbowkit2, import_wallets, import_wagmi4, import_chains, getProjectId2, WALLET_MAP, getWagmiStorageKey, buildRainbowChains, createRainbowConfig, rainbowTheme;
|
|
22746
22746
|
var init_rainbowkit = __esm({
|
|
22747
22747
|
"src/config/rainbowkit.ts"() {
|
|
22748
|
+
import_read17 = require("@embarkai/core/read");
|
|
22748
22749
|
import_rainbowkit2 = require("@rainbow-me/rainbowkit");
|
|
22749
22750
|
import_wallets = require("@rainbow-me/rainbowkit/wallets");
|
|
22751
|
+
import_wagmi4 = require("wagmi");
|
|
22750
22752
|
import_chains = require("wagmi/chains");
|
|
22751
22753
|
getProjectId2 = (configProjectId) => {
|
|
22752
22754
|
if (configProjectId) return configProjectId;
|
|
@@ -22761,12 +22763,41 @@ var init_rainbowkit = __esm({
|
|
|
22761
22763
|
coinbase: import_wallets.coinbaseWallet,
|
|
22762
22764
|
rainbow: import_wallets.rainbowWallet
|
|
22763
22765
|
};
|
|
22766
|
+
getWagmiStorageKey = (options) => {
|
|
22767
|
+
const projectId = options?.projectId || "default";
|
|
22768
|
+
const preferredChainId = options?.preferredChainId || "default";
|
|
22769
|
+
return `embark-wagmi-v2-${projectId}-${preferredChainId}`;
|
|
22770
|
+
};
|
|
22771
|
+
buildRainbowChains = (supportedChains, preferredChainId) => {
|
|
22772
|
+
const availableChains = [
|
|
22773
|
+
import_read17.lumiaMainnetChain,
|
|
22774
|
+
import_read17.lumiaTestnetChain,
|
|
22775
|
+
import_chains.mainnet,
|
|
22776
|
+
import_chains.polygon,
|
|
22777
|
+
import_chains.bsc,
|
|
22778
|
+
import_chains.arbitrum,
|
|
22779
|
+
import_chains.optimism,
|
|
22780
|
+
import_chains.avalanche,
|
|
22781
|
+
import_chains.base,
|
|
22782
|
+
import_chains.zora
|
|
22783
|
+
];
|
|
22784
|
+
const chains = (supportedChains?.length ? availableChains.filter((chain) => supportedChains.includes(chain.id)) : availableChains).filter((chain, index, collection) => collection.findIndex((candidate) => candidate.id === chain.id) === index);
|
|
22785
|
+
if (preferredChainId == null) {
|
|
22786
|
+
return chains;
|
|
22787
|
+
}
|
|
22788
|
+
const preferredChain = chains.find((chain) => chain.id === preferredChainId);
|
|
22789
|
+
if (!preferredChain) {
|
|
22790
|
+
return chains;
|
|
22791
|
+
}
|
|
22792
|
+
return [preferredChain, ...chains.filter((chain) => chain.id !== preferredChainId)];
|
|
22793
|
+
};
|
|
22764
22794
|
createRainbowConfig = (options) => {
|
|
22765
22795
|
const opts = typeof options === "string" ? { projectId: options } : options || {};
|
|
22766
22796
|
const config = {
|
|
22767
22797
|
appName: "EmbarkAI Wallet",
|
|
22768
22798
|
projectId: getProjectId2(opts.projectId),
|
|
22769
|
-
chains:
|
|
22799
|
+
chains: buildRainbowChains(opts.supportedChains, opts.preferredChainId),
|
|
22800
|
+
storage: (0, import_wagmi4.createStorage)({ key: getWagmiStorageKey(opts) }),
|
|
22770
22801
|
ssr: false
|
|
22771
22802
|
};
|
|
22772
22803
|
if (opts.allowedWallets && opts.allowedWallets.length > 0) {
|
|
@@ -22976,9 +23007,16 @@ function RainbowKitProvider({ children }) {
|
|
|
22976
23007
|
const rainbowConfig = (0, import_react78.useMemo)(
|
|
22977
23008
|
() => createRainbowConfig({
|
|
22978
23009
|
projectId: config.current?.wallet?.walletConnectProjectId,
|
|
22979
|
-
allowedWallets: config.current?.wallet?.allowedWallets
|
|
23010
|
+
allowedWallets: config.current?.wallet?.allowedWallets,
|
|
23011
|
+
supportedChains: config.current?.wallet?.supportedChains,
|
|
23012
|
+
preferredChainId: config.current?.network?.chainId
|
|
22980
23013
|
}),
|
|
22981
|
-
[
|
|
23014
|
+
[
|
|
23015
|
+
config.current?.network?.chainId,
|
|
23016
|
+
config.current?.wallet?.allowedWallets,
|
|
23017
|
+
config.current?.wallet?.supportedChains,
|
|
23018
|
+
config.current?.wallet?.walletConnectProjectId
|
|
23019
|
+
]
|
|
22982
23020
|
);
|
|
22983
23021
|
const customTheme = (0, import_react78.useMemo)(() => {
|
|
22984
23022
|
if (!config.current?.wallet?.enabled) return {};
|
|
@@ -22995,14 +23033,14 @@ function RainbowKitProvider({ children }) {
|
|
|
22995
23033
|
};
|
|
22996
23034
|
}, [colorMode]);
|
|
22997
23035
|
if (!config.current?.wallet?.enabled) return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(import_jsx_runtime110.Fragment, { children });
|
|
22998
|
-
return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
|
|
23036
|
+
return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(import_wagmi5.WagmiProvider, { config: rainbowConfig, children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(import_rainbowkit3.RainbowKitProvider, { theme: customTheme, modalSize: "compact", showRecentTransactions: true, children }) });
|
|
22999
23037
|
}
|
|
23000
|
-
var import_rainbowkit3, import_react78,
|
|
23038
|
+
var import_rainbowkit3, import_react78, import_wagmi5, import_styles, import_jsx_runtime110;
|
|
23001
23039
|
var init_RainbowKitContext = __esm({
|
|
23002
23040
|
"src/context/RainbowKitContext.tsx"() {
|
|
23003
23041
|
import_rainbowkit3 = require("@rainbow-me/rainbowkit");
|
|
23004
23042
|
import_react78 = require("react");
|
|
23005
|
-
|
|
23043
|
+
import_wagmi5 = require("wagmi");
|
|
23006
23044
|
init_rainbowkit();
|
|
23007
23045
|
init_useLayoutStore();
|
|
23008
23046
|
init_ProviderContext();
|
|
@@ -23029,7 +23067,7 @@ var init_utils10 = __esm({
|
|
|
23029
23067
|
// src/config/wagmi.ts
|
|
23030
23068
|
function buildTransport(urls) {
|
|
23031
23069
|
const transports = urls.map(
|
|
23032
|
-
(url) => (0,
|
|
23070
|
+
(url) => (0, import_wagmi6.http)(url, {
|
|
23033
23071
|
timeout: 1e4,
|
|
23034
23072
|
retryCount: 0,
|
|
23035
23073
|
batch: false,
|
|
@@ -23045,36 +23083,52 @@ function buildTransport(urls) {
|
|
|
23045
23083
|
retryCount: 0
|
|
23046
23084
|
});
|
|
23047
23085
|
}
|
|
23048
|
-
var
|
|
23086
|
+
var import_read18, import_viem17, import_wagmi6, wagmiConfig;
|
|
23049
23087
|
var init_wagmi = __esm({
|
|
23050
23088
|
"src/config/wagmi.ts"() {
|
|
23051
|
-
|
|
23089
|
+
import_read18 = require("@embarkai/core/read");
|
|
23052
23090
|
import_viem17 = require("viem");
|
|
23053
|
-
|
|
23054
|
-
wagmiConfig = (0,
|
|
23055
|
-
chains: [
|
|
23091
|
+
import_wagmi6 = require("wagmi");
|
|
23092
|
+
wagmiConfig = (0, import_wagmi6.createConfig)({
|
|
23093
|
+
chains: [import_read18.lumiaMainnetChain, import_read18.lumiaTestnetChain],
|
|
23094
|
+
storage: (0, import_wagmi6.createStorage)({ key: "embark-wagmi-static-v2" }),
|
|
23056
23095
|
transports: {
|
|
23057
|
-
[
|
|
23058
|
-
[
|
|
23096
|
+
[import_read18.lumiaTestnetChain.id]: buildTransport(import_read18.lumiaTestnetChain.rpcUrls.default.http),
|
|
23097
|
+
[import_read18.lumiaMainnetChain.id]: buildTransport(import_read18.lumiaMainnetChain.rpcUrls.default.http)
|
|
23059
23098
|
}
|
|
23060
23099
|
});
|
|
23061
23100
|
}
|
|
23062
23101
|
});
|
|
23063
23102
|
|
|
23064
23103
|
// src/context/WagmiContext.tsx
|
|
23065
|
-
var
|
|
23104
|
+
var import_wagmi7, import_jsx_runtime111, WagmiProvider2;
|
|
23066
23105
|
var init_WagmiContext = __esm({
|
|
23067
23106
|
"src/context/WagmiContext.tsx"() {
|
|
23068
|
-
|
|
23107
|
+
import_wagmi7 = require("wagmi");
|
|
23069
23108
|
init_wagmi();
|
|
23070
23109
|
import_jsx_runtime111 = require("react/jsx-runtime");
|
|
23071
23110
|
WagmiProvider2 = ({ children }) => {
|
|
23072
|
-
return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
|
|
23111
|
+
return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_wagmi7.WagmiProvider, { config: wagmiConfig, children });
|
|
23073
23112
|
};
|
|
23074
23113
|
}
|
|
23075
23114
|
});
|
|
23076
23115
|
|
|
23077
23116
|
// src/context/ProviderContext.tsx
|
|
23117
|
+
function clearLegacyWagmiStorage() {
|
|
23118
|
+
if (typeof window === "undefined" || !window.localStorage) return;
|
|
23119
|
+
const legacyKeys = [
|
|
23120
|
+
"wagmi.state",
|
|
23121
|
+
"wagmi.recentConnectorId",
|
|
23122
|
+
"embark-wagmi-static-v1.state",
|
|
23123
|
+
"embark-wagmi-static-v1.recentConnectorId"
|
|
23124
|
+
];
|
|
23125
|
+
for (const key of legacyKeys) {
|
|
23126
|
+
try {
|
|
23127
|
+
window.localStorage.removeItem(key);
|
|
23128
|
+
} catch {
|
|
23129
|
+
}
|
|
23130
|
+
}
|
|
23131
|
+
}
|
|
23078
23132
|
function Provider(props) {
|
|
23079
23133
|
const { children, projectId, initialConfig = {}, callbacks } = props;
|
|
23080
23134
|
const callbacksRef = (0, import_react79.useRef)(callbacks);
|
|
@@ -23122,6 +23176,9 @@ function Provider(props) {
|
|
|
23122
23176
|
if (typeof window === "undefined" || !projectId) return;
|
|
23123
23177
|
const mergedConfig = (0, import_lodash_es8.merge)(DEFAULT_PROVIDER_CONFIG, initialConfig);
|
|
23124
23178
|
updateConfig(mergedConfig);
|
|
23179
|
+
if (mergedConfig.wallet?.enabled) {
|
|
23180
|
+
clearLegacyWagmiStorage();
|
|
23181
|
+
}
|
|
23125
23182
|
try {
|
|
23126
23183
|
if (typeof window !== "undefined") {
|
|
23127
23184
|
window.__EMBARK_SERVICES__ = mergedConfig.services;
|
|
@@ -23534,7 +23591,7 @@ var init_LangToggle = __esm({
|
|
|
23534
23591
|
// src/clients/bundler/getUserOperationByHash.ts
|
|
23535
23592
|
async function getUserOperationByHash(userOpHash, chainId) {
|
|
23536
23593
|
const targetChainId = chainId ?? requireActiveChainId();
|
|
23537
|
-
const chainConfig = (0,
|
|
23594
|
+
const chainConfig = (0, import_read19.getChainConfig)(targetChainId);
|
|
23538
23595
|
if (!chainConfig) {
|
|
23539
23596
|
throw new Error(`Chain ${targetChainId} is not supported`);
|
|
23540
23597
|
}
|
|
@@ -23562,19 +23619,19 @@ async function getUserOperationByHash(userOpHash, chainId) {
|
|
|
23562
23619
|
return null;
|
|
23563
23620
|
}
|
|
23564
23621
|
}
|
|
23565
|
-
var import_core3,
|
|
23622
|
+
var import_core3, import_read19;
|
|
23566
23623
|
var init_getUserOperationByHash = __esm({
|
|
23567
23624
|
"src/clients/bundler/getUserOperationByHash.ts"() {
|
|
23568
23625
|
init_SessionContext();
|
|
23569
23626
|
import_core3 = require("@embarkai/core");
|
|
23570
|
-
|
|
23627
|
+
import_read19 = require("@embarkai/core/read");
|
|
23571
23628
|
}
|
|
23572
23629
|
});
|
|
23573
23630
|
|
|
23574
23631
|
// src/clients/bundler/getUserOperationReceipt.ts
|
|
23575
23632
|
async function getUserOperationReceipt(userOpHash, chainId) {
|
|
23576
23633
|
const targetChainId = chainId ?? requireActiveChainId();
|
|
23577
|
-
const chainConfig = (0,
|
|
23634
|
+
const chainConfig = (0, import_read20.getChainConfig)(targetChainId);
|
|
23578
23635
|
if (!chainConfig) {
|
|
23579
23636
|
throw new Error(`Chain ${targetChainId} is not supported`);
|
|
23580
23637
|
}
|
|
@@ -23608,12 +23665,12 @@ async function getUserOperationReceipt(userOpHash, chainId) {
|
|
|
23608
23665
|
return null;
|
|
23609
23666
|
}
|
|
23610
23667
|
}
|
|
23611
|
-
var import_core4,
|
|
23668
|
+
var import_core4, import_read20;
|
|
23612
23669
|
var init_getUserOperationReceipt = __esm({
|
|
23613
23670
|
"src/clients/bundler/getUserOperationReceipt.ts"() {
|
|
23614
23671
|
init_SessionContext();
|
|
23615
23672
|
import_core4 = require("@embarkai/core");
|
|
23616
|
-
|
|
23673
|
+
import_read20 = require("@embarkai/core/read");
|
|
23617
23674
|
}
|
|
23618
23675
|
});
|
|
23619
23676
|
|
|
@@ -24362,7 +24419,7 @@ function useDirectWallet() {
|
|
|
24362
24419
|
const isConnected = useExternalWalletStore((st) => st.isExternalConnected);
|
|
24363
24420
|
const connectorName = useExternalWalletStore((st) => st.connectorName);
|
|
24364
24421
|
const clearExternalWallet = useExternalWalletStore((st) => st.clearExternalWallet);
|
|
24365
|
-
const { disconnect: wagmiDisconnect } = (0,
|
|
24422
|
+
const { disconnect: wagmiDisconnect } = (0, import_wagmi9.useDisconnect)();
|
|
24366
24423
|
const { openConnectModal } = (0, import_rainbowkit5.useConnectModal)();
|
|
24367
24424
|
const setIsWalletLinking = useLayoutDataStore((st) => st.setIsWalletLinking);
|
|
24368
24425
|
const connect = (0, import_react84.useCallback)(() => {
|
|
@@ -24385,12 +24442,12 @@ function useDirectWallet() {
|
|
|
24385
24442
|
disconnect
|
|
24386
24443
|
};
|
|
24387
24444
|
}
|
|
24388
|
-
var import_react84, import_rainbowkit5,
|
|
24445
|
+
var import_react84, import_rainbowkit5, import_wagmi9;
|
|
24389
24446
|
var init_useDirectWallet = __esm({
|
|
24390
24447
|
"src/hooks/useDirectWallet.ts"() {
|
|
24391
24448
|
import_react84 = require("react");
|
|
24392
24449
|
import_rainbowkit5 = require("@rainbow-me/rainbowkit");
|
|
24393
|
-
|
|
24450
|
+
import_wagmi9 = require("wagmi");
|
|
24394
24451
|
init_useExternalWalletStore();
|
|
24395
24452
|
init_useLayoutDataStore();
|
|
24396
24453
|
}
|
|
@@ -24400,8 +24457,8 @@ var init_useDirectWallet = __esm({
|
|
|
24400
24457
|
function useSendDirectTransaction() {
|
|
24401
24458
|
const isConnected = useExternalWalletStore((st) => st.isExternalConnected);
|
|
24402
24459
|
const externalChainId = useExternalWalletStore((st) => st.externalChainId);
|
|
24403
|
-
const { sendTransactionAsync } = (0,
|
|
24404
|
-
const { switchChainAsync } = (0,
|
|
24460
|
+
const { sendTransactionAsync } = (0, import_wagmi10.useSendTransaction)();
|
|
24461
|
+
const { switchChainAsync } = (0, import_wagmi10.useSwitchChain)();
|
|
24405
24462
|
const [isPending, setIsPending] = (0, import_react85.useState)(false);
|
|
24406
24463
|
const [error, setError] = (0, import_react85.useState)(null);
|
|
24407
24464
|
const [txHash, setTxHash] = (0, import_react85.useState)(null);
|
|
@@ -24446,12 +24503,12 @@ function useSendDirectTransaction() {
|
|
|
24446
24503
|
}, []);
|
|
24447
24504
|
return { sendTransaction, isPending, error, txHash, reset };
|
|
24448
24505
|
}
|
|
24449
|
-
var import_react85, import_viem18,
|
|
24506
|
+
var import_react85, import_viem18, import_wagmi10;
|
|
24450
24507
|
var init_useSendDirectTransaction = __esm({
|
|
24451
24508
|
"src/hooks/useSendDirectTransaction.ts"() {
|
|
24452
24509
|
import_react85 = require("react");
|
|
24453
24510
|
import_viem18 = require("viem");
|
|
24454
|
-
|
|
24511
|
+
import_wagmi10 = require("wagmi");
|
|
24455
24512
|
init_useExternalWalletStore();
|
|
24456
24513
|
}
|
|
24457
24514
|
});
|
|
@@ -24549,8 +24606,8 @@ var init_useTransferToLinkedWallet = __esm({
|
|
|
24549
24606
|
|
|
24550
24607
|
// src/hooks/useNativeWalletSignature.ts
|
|
24551
24608
|
function useNativeWalletSignature() {
|
|
24552
|
-
const signMessage = (0,
|
|
24553
|
-
const signTypedMessage = (0,
|
|
24609
|
+
const signMessage = (0, import_wagmi11.useSignMessage)();
|
|
24610
|
+
const signTypedMessage = (0, import_wagmi11.useSignTypedData)();
|
|
24554
24611
|
return {
|
|
24555
24612
|
signMessage,
|
|
24556
24613
|
/** EIP-712 signature */
|
|
@@ -24558,10 +24615,10 @@ function useNativeWalletSignature() {
|
|
|
24558
24615
|
fetchProjectNameById: fetchProjectName
|
|
24559
24616
|
};
|
|
24560
24617
|
}
|
|
24561
|
-
var
|
|
24618
|
+
var import_wagmi11;
|
|
24562
24619
|
var init_useNativeWalletSignature = __esm({
|
|
24563
24620
|
"src/hooks/useNativeWalletSignature.ts"() {
|
|
24564
|
-
|
|
24621
|
+
import_wagmi11 = require("wagmi");
|
|
24565
24622
|
init_providers();
|
|
24566
24623
|
}
|
|
24567
24624
|
});
|
|
@@ -24664,10 +24721,10 @@ var init_clients2 = __esm({
|
|
|
24664
24721
|
// src/modules/transactions.ts
|
|
24665
24722
|
function useTransactions() {
|
|
24666
24723
|
const chainId = requireActiveChainId();
|
|
24667
|
-
const viemChain = (0,
|
|
24668
|
-
const publicClient = (0,
|
|
24669
|
-
const { data: walletClient } = (0,
|
|
24670
|
-
const { address } = (0,
|
|
24724
|
+
const viemChain = (0, import_read21.getViemChain)(chainId);
|
|
24725
|
+
const publicClient = (0, import_wagmi12.usePublicClient)({ chainId });
|
|
24726
|
+
const { data: walletClient } = (0, import_wagmi12.useWalletClient)();
|
|
24727
|
+
const { address } = (0, import_wagmi12.useAccount)();
|
|
24671
24728
|
const sendTransaction = async (params) => {
|
|
24672
24729
|
if (!walletClient) {
|
|
24673
24730
|
throw new Error("Wallet not connected");
|
|
@@ -24722,13 +24779,13 @@ function useTransactions() {
|
|
|
24722
24779
|
isConnected: !!address && !!walletClient
|
|
24723
24780
|
};
|
|
24724
24781
|
}
|
|
24725
|
-
var
|
|
24782
|
+
var import_read21, import_viem20, import_wagmi12;
|
|
24726
24783
|
var init_transactions = __esm({
|
|
24727
24784
|
"src/modules/transactions.ts"() {
|
|
24728
24785
|
init_SessionContext();
|
|
24729
|
-
|
|
24786
|
+
import_read21 = require("@embarkai/core/read");
|
|
24730
24787
|
import_viem20 = require("viem");
|
|
24731
|
-
|
|
24788
|
+
import_wagmi12 = require("wagmi");
|
|
24732
24789
|
}
|
|
24733
24790
|
});
|
|
24734
24791
|
|
|
@@ -24739,7 +24796,7 @@ function useAssets(address) {
|
|
|
24739
24796
|
data: nativeBalance,
|
|
24740
24797
|
isLoading: nativeBalanceLoading,
|
|
24741
24798
|
refetch: refetchNativeBalance
|
|
24742
|
-
} = (0,
|
|
24799
|
+
} = (0, import_wagmi13.useBalance)({
|
|
24743
24800
|
address,
|
|
24744
24801
|
chainId,
|
|
24745
24802
|
query: {
|
|
@@ -24753,7 +24810,7 @@ function useAssets(address) {
|
|
|
24753
24810
|
args: [address],
|
|
24754
24811
|
chainId
|
|
24755
24812
|
}));
|
|
24756
|
-
const readContractsResult = (0,
|
|
24813
|
+
const readContractsResult = (0, import_wagmi13.useReadContracts)({
|
|
24757
24814
|
contracts: tokenContracts,
|
|
24758
24815
|
query: {
|
|
24759
24816
|
enabled: !!address && COMMON_TOKENS.length > 0
|
|
@@ -24834,7 +24891,7 @@ function useAssets(address) {
|
|
|
24834
24891
|
}
|
|
24835
24892
|
function useTokenInfo(tokenAddress) {
|
|
24836
24893
|
const chainId = requireActiveChainId();
|
|
24837
|
-
const readContractsResult = (0,
|
|
24894
|
+
const readContractsResult = (0, import_wagmi13.useReadContracts)({
|
|
24838
24895
|
contracts: [
|
|
24839
24896
|
{ address: tokenAddress, abi: import_viem21.erc20Abi, functionName: "name", chainId },
|
|
24840
24897
|
{ address: tokenAddress, abi: import_viem21.erc20Abi, functionName: "symbol", chainId },
|
|
@@ -24865,7 +24922,7 @@ function useTokenBalance(tokenAddress, userAddress) {
|
|
|
24865
24922
|
data: balance,
|
|
24866
24923
|
isLoading,
|
|
24867
24924
|
refetch
|
|
24868
|
-
} = (0,
|
|
24925
|
+
} = (0, import_wagmi13.useReadContract)({
|
|
24869
24926
|
address: tokenAddress,
|
|
24870
24927
|
abi: import_viem21.erc20Abi,
|
|
24871
24928
|
functionName: "balanceOf",
|
|
@@ -24888,13 +24945,13 @@ function useTokenBalance(tokenAddress, userAddress) {
|
|
|
24888
24945
|
refetch
|
|
24889
24946
|
};
|
|
24890
24947
|
}
|
|
24891
|
-
var import_react88, import_viem21,
|
|
24948
|
+
var import_react88, import_viem21, import_wagmi13, COMMON_TOKENS;
|
|
24892
24949
|
var init_assets2 = __esm({
|
|
24893
24950
|
"src/modules/assets.ts"() {
|
|
24894
24951
|
init_SessionContext();
|
|
24895
24952
|
import_react88 = __toESM(require("react"), 1);
|
|
24896
24953
|
import_viem21 = require("viem");
|
|
24897
|
-
|
|
24954
|
+
import_wagmi13 = require("wagmi");
|
|
24898
24955
|
COMMON_TOKENS = [
|
|
24899
24956
|
// Add real token addresses here when available
|
|
24900
24957
|
// {
|
package/dist/index.js
CHANGED
|
@@ -15117,7 +15117,7 @@ function mapBlockscoutToAsset(balance) {
|
|
|
15117
15117
|
}
|
|
15118
15118
|
const asset = {
|
|
15119
15119
|
type,
|
|
15120
|
-
address: token.
|
|
15120
|
+
address: token.address_hash,
|
|
15121
15121
|
name: token.name || "Unknown Token",
|
|
15122
15122
|
symbol: token.symbol || "???",
|
|
15123
15123
|
balance: value,
|
|
@@ -15148,7 +15148,7 @@ function mapBlockscoutNftToAsset(nft) {
|
|
|
15148
15148
|
const imageUrl = image_url || (metadata?.image ? resolveIpfsUri(metadata.image) : void 0);
|
|
15149
15149
|
const asset = {
|
|
15150
15150
|
type,
|
|
15151
|
-
address: token.
|
|
15151
|
+
address: token.address_hash,
|
|
15152
15152
|
name: token.name || "Unknown NFT",
|
|
15153
15153
|
symbol: token.symbol || "???",
|
|
15154
15154
|
balance: value || "1",
|
|
@@ -15271,7 +15271,7 @@ function useBlockscoutAssets(options) {
|
|
|
15271
15271
|
});
|
|
15272
15272
|
const erc20TokenAddresses = useMemo5(() => {
|
|
15273
15273
|
if (!tokenBalances) return [];
|
|
15274
|
-
return tokenBalances.filter((tb) => tb.token.type === "ERC-20").map((tb) => tb.token.
|
|
15274
|
+
return tokenBalances.filter((tb) => tb.token.type === "ERC-20").map((tb) => tb.token.address_hash);
|
|
15275
15275
|
}, [tokenBalances]);
|
|
15276
15276
|
const { data: erc3643Results } = useQuery16({
|
|
15277
15277
|
queryKey: [ERC3643_DETECTION_QUERY_KEY, address, erc20TokenAddresses],
|
|
@@ -19086,7 +19086,7 @@ var init_package = __esm({
|
|
|
19086
19086
|
"package.json"() {
|
|
19087
19087
|
package_default = {
|
|
19088
19088
|
name: "@embarkai/ui-kit",
|
|
19089
|
-
version: "0.4.
|
|
19089
|
+
version: "0.4.9",
|
|
19090
19090
|
description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
|
|
19091
19091
|
type: "module",
|
|
19092
19092
|
main: "./dist/index.cjs",
|
|
@@ -20172,10 +20172,10 @@ function DirectWalletHandler() {
|
|
|
20172
20172
|
}
|
|
20173
20173
|
}, [walletMode, setConfigMode, setActiveMode]);
|
|
20174
20174
|
useEffect42(() => {
|
|
20175
|
-
if (isConnected && address && !isExternalConnected && connector) {
|
|
20175
|
+
if (isConnected && address && !isExternalConnected && connector && chain?.id) {
|
|
20176
20176
|
setExternalWallet({
|
|
20177
20177
|
address,
|
|
20178
|
-
chainId: chain
|
|
20178
|
+
chainId: chain.id,
|
|
20179
20179
|
connectorName: connector.name || "Unknown Wallet"
|
|
20180
20180
|
});
|
|
20181
20181
|
}
|
|
@@ -20191,10 +20191,10 @@ function DirectWalletHandler() {
|
|
|
20191
20191
|
}
|
|
20192
20192
|
}, [chain?.id, isConnected, isExternalConnected, setExternalChainId]);
|
|
20193
20193
|
useEffect42(() => {
|
|
20194
|
-
if (isExternalConnected && isConnected && address && address !== externalAddress && connector) {
|
|
20194
|
+
if (isExternalConnected && isConnected && address && address !== externalAddress && connector && chain?.id) {
|
|
20195
20195
|
setExternalWallet({
|
|
20196
20196
|
address,
|
|
20197
|
-
chainId: chain
|
|
20197
|
+
chainId: chain.id,
|
|
20198
20198
|
connectorName: connector.name || "Unknown Wallet"
|
|
20199
20199
|
});
|
|
20200
20200
|
}
|
|
@@ -22676,15 +22676,12 @@ var init_iframe_manager = __esm({
|
|
|
22676
22676
|
});
|
|
22677
22677
|
|
|
22678
22678
|
// src/config/rainbowkit.ts
|
|
22679
|
+
import { lumiaMainnetChain as lumiaMainnetChain2, lumiaTestnetChain as lumiaTestnetChain2 } from "@embarkai/core/read";
|
|
22679
22680
|
import { getDefaultConfig } from "@rainbow-me/rainbowkit";
|
|
22680
|
-
import {
|
|
22681
|
-
|
|
22682
|
-
metaMaskWallet,
|
|
22683
|
-
rainbowWallet,
|
|
22684
|
-
walletConnectWallet
|
|
22685
|
-
} from "@rainbow-me/rainbowkit/wallets";
|
|
22681
|
+
import { coinbaseWallet, metaMaskWallet, rainbowWallet, walletConnectWallet } from "@rainbow-me/rainbowkit/wallets";
|
|
22682
|
+
import { createStorage } from "wagmi";
|
|
22686
22683
|
import { arbitrum, avalanche, base, bsc, mainnet, optimism, polygon, zora } from "wagmi/chains";
|
|
22687
|
-
var getProjectId2, WALLET_MAP, createRainbowConfig, rainbowTheme;
|
|
22684
|
+
var getProjectId2, WALLET_MAP, getWagmiStorageKey, buildRainbowChains, createRainbowConfig, rainbowTheme;
|
|
22688
22685
|
var init_rainbowkit = __esm({
|
|
22689
22686
|
"src/config/rainbowkit.ts"() {
|
|
22690
22687
|
getProjectId2 = (configProjectId) => {
|
|
@@ -22700,12 +22697,41 @@ var init_rainbowkit = __esm({
|
|
|
22700
22697
|
coinbase: coinbaseWallet,
|
|
22701
22698
|
rainbow: rainbowWallet
|
|
22702
22699
|
};
|
|
22700
|
+
getWagmiStorageKey = (options) => {
|
|
22701
|
+
const projectId = options?.projectId || "default";
|
|
22702
|
+
const preferredChainId = options?.preferredChainId || "default";
|
|
22703
|
+
return `embark-wagmi-v2-${projectId}-${preferredChainId}`;
|
|
22704
|
+
};
|
|
22705
|
+
buildRainbowChains = (supportedChains, preferredChainId) => {
|
|
22706
|
+
const availableChains = [
|
|
22707
|
+
lumiaMainnetChain2,
|
|
22708
|
+
lumiaTestnetChain2,
|
|
22709
|
+
mainnet,
|
|
22710
|
+
polygon,
|
|
22711
|
+
bsc,
|
|
22712
|
+
arbitrum,
|
|
22713
|
+
optimism,
|
|
22714
|
+
avalanche,
|
|
22715
|
+
base,
|
|
22716
|
+
zora
|
|
22717
|
+
];
|
|
22718
|
+
const chains = (supportedChains?.length ? availableChains.filter((chain) => supportedChains.includes(chain.id)) : availableChains).filter((chain, index, collection) => collection.findIndex((candidate) => candidate.id === chain.id) === index);
|
|
22719
|
+
if (preferredChainId == null) {
|
|
22720
|
+
return chains;
|
|
22721
|
+
}
|
|
22722
|
+
const preferredChain = chains.find((chain) => chain.id === preferredChainId);
|
|
22723
|
+
if (!preferredChain) {
|
|
22724
|
+
return chains;
|
|
22725
|
+
}
|
|
22726
|
+
return [preferredChain, ...chains.filter((chain) => chain.id !== preferredChainId)];
|
|
22727
|
+
};
|
|
22703
22728
|
createRainbowConfig = (options) => {
|
|
22704
22729
|
const opts = typeof options === "string" ? { projectId: options } : options || {};
|
|
22705
22730
|
const config = {
|
|
22706
22731
|
appName: "EmbarkAI Wallet",
|
|
22707
22732
|
projectId: getProjectId2(opts.projectId),
|
|
22708
|
-
chains:
|
|
22733
|
+
chains: buildRainbowChains(opts.supportedChains, opts.preferredChainId),
|
|
22734
|
+
storage: createStorage({ key: getWagmiStorageKey(opts) }),
|
|
22709
22735
|
ssr: false
|
|
22710
22736
|
};
|
|
22711
22737
|
if (opts.allowedWallets && opts.allowedWallets.length > 0) {
|
|
@@ -22920,9 +22946,16 @@ function RainbowKitProvider({ children }) {
|
|
|
22920
22946
|
const rainbowConfig = useMemo9(
|
|
22921
22947
|
() => createRainbowConfig({
|
|
22922
22948
|
projectId: config.current?.wallet?.walletConnectProjectId,
|
|
22923
|
-
allowedWallets: config.current?.wallet?.allowedWallets
|
|
22949
|
+
allowedWallets: config.current?.wallet?.allowedWallets,
|
|
22950
|
+
supportedChains: config.current?.wallet?.supportedChains,
|
|
22951
|
+
preferredChainId: config.current?.network?.chainId
|
|
22924
22952
|
}),
|
|
22925
|
-
[
|
|
22953
|
+
[
|
|
22954
|
+
config.current?.network?.chainId,
|
|
22955
|
+
config.current?.wallet?.allowedWallets,
|
|
22956
|
+
config.current?.wallet?.supportedChains,
|
|
22957
|
+
config.current?.wallet?.walletConnectProjectId
|
|
22958
|
+
]
|
|
22926
22959
|
);
|
|
22927
22960
|
const customTheme = useMemo9(() => {
|
|
22928
22961
|
if (!config.current?.wallet?.enabled) return {};
|
|
@@ -22965,9 +22998,9 @@ var init_utils10 = __esm({
|
|
|
22965
22998
|
});
|
|
22966
22999
|
|
|
22967
23000
|
// src/config/wagmi.ts
|
|
22968
|
-
import { lumiaMainnetChain as
|
|
23001
|
+
import { lumiaMainnetChain as lumiaMainnetChain3, lumiaTestnetChain as lumiaTestnetChain3 } from "@embarkai/core/read";
|
|
22969
23002
|
import { fallback } from "viem";
|
|
22970
|
-
import { createConfig, http as http4 } from "wagmi";
|
|
23003
|
+
import { createConfig, createStorage as createStorage2, http as http4 } from "wagmi";
|
|
22971
23004
|
function buildTransport(urls) {
|
|
22972
23005
|
const transports = urls.map(
|
|
22973
23006
|
(url) => http4(url, {
|
|
@@ -22990,10 +23023,11 @@ var wagmiConfig;
|
|
|
22990
23023
|
var init_wagmi = __esm({
|
|
22991
23024
|
"src/config/wagmi.ts"() {
|
|
22992
23025
|
wagmiConfig = createConfig({
|
|
22993
|
-
chains: [
|
|
23026
|
+
chains: [lumiaMainnetChain3, lumiaTestnetChain3],
|
|
23027
|
+
storage: createStorage2({ key: "embark-wagmi-static-v2" }),
|
|
22994
23028
|
transports: {
|
|
22995
|
-
[
|
|
22996
|
-
[
|
|
23029
|
+
[lumiaTestnetChain3.id]: buildTransport(lumiaTestnetChain3.rpcUrls.default.http),
|
|
23030
|
+
[lumiaMainnetChain3.id]: buildTransport(lumiaMainnetChain3.rpcUrls.default.http)
|
|
22997
23031
|
}
|
|
22998
23032
|
});
|
|
22999
23033
|
}
|
|
@@ -23024,6 +23058,21 @@ import {
|
|
|
23024
23058
|
useRef as useRef18
|
|
23025
23059
|
} from "react";
|
|
23026
23060
|
import { jsx as jsx112 } from "react/jsx-runtime";
|
|
23061
|
+
function clearLegacyWagmiStorage() {
|
|
23062
|
+
if (typeof window === "undefined" || !window.localStorage) return;
|
|
23063
|
+
const legacyKeys = [
|
|
23064
|
+
"wagmi.state",
|
|
23065
|
+
"wagmi.recentConnectorId",
|
|
23066
|
+
"embark-wagmi-static-v1.state",
|
|
23067
|
+
"embark-wagmi-static-v1.recentConnectorId"
|
|
23068
|
+
];
|
|
23069
|
+
for (const key of legacyKeys) {
|
|
23070
|
+
try {
|
|
23071
|
+
window.localStorage.removeItem(key);
|
|
23072
|
+
} catch {
|
|
23073
|
+
}
|
|
23074
|
+
}
|
|
23075
|
+
}
|
|
23027
23076
|
function Provider(props) {
|
|
23028
23077
|
const { children, projectId, initialConfig = {}, callbacks } = props;
|
|
23029
23078
|
const callbacksRef = useRef18(callbacks);
|
|
@@ -23071,6 +23120,9 @@ function Provider(props) {
|
|
|
23071
23120
|
if (typeof window === "undefined" || !projectId) return;
|
|
23072
23121
|
const mergedConfig = merge3(DEFAULT_PROVIDER_CONFIG, initialConfig);
|
|
23073
23122
|
updateConfig(mergedConfig);
|
|
23123
|
+
if (mergedConfig.wallet?.enabled) {
|
|
23124
|
+
clearLegacyWagmiStorage();
|
|
23125
|
+
}
|
|
23074
23126
|
try {
|
|
23075
23127
|
if (typeof window !== "undefined") {
|
|
23076
23128
|
window.__EMBARK_SERVICES__ = mergedConfig.services;
|