@embarkai/ui-kit 0.4.6 → 0.4.8
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 +121 -99
- package/dist/index.d.cts +22 -20
- package/dist/index.d.ts +22 -20
- package/dist/index.js +85 -68
- 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.8</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.8";
|
|
6266
6266
|
var IframeWallet = class {
|
|
6267
6267
|
constructor() {
|
|
6268
6268
|
console.log("=".repeat(60));
|
package/dist/index.cjs
CHANGED
|
@@ -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.8",
|
|
19171
19171
|
description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
|
|
19172
19172
|
type: "module",
|
|
19173
19173
|
main: "./dist/index.cjs",
|
|
@@ -19900,19 +19900,6 @@ Timestamp: ${timestamp}
|
|
|
19900
19900
|
|
|
19901
19901
|
Sign this message to link your wallet to ${projectName} Wallet`;
|
|
19902
19902
|
}
|
|
19903
|
-
function createNativeWalletSignatureMessage(address, projectName, nonce) {
|
|
19904
|
-
const timestamp = Date.now();
|
|
19905
|
-
const nonceValue = nonce || crypto.randomUUID();
|
|
19906
|
-
return [
|
|
19907
|
-
`${projectName} Wallet Sign`,
|
|
19908
|
-
"",
|
|
19909
|
-
`Address: ${address}`,
|
|
19910
|
-
`Nonce: ${nonceValue}`,
|
|
19911
|
-
`Timestamp: ${timestamp}`,
|
|
19912
|
-
"",
|
|
19913
|
-
`Project ${projectName} signature request for wallet operation`
|
|
19914
|
-
].join("\n");
|
|
19915
|
-
}
|
|
19916
19903
|
function createLoginMessage(address, projectName) {
|
|
19917
19904
|
const nonce = crypto.randomUUID();
|
|
19918
19905
|
const timestamp = Date.now();
|
|
@@ -20268,10 +20255,10 @@ function DirectWalletHandler() {
|
|
|
20268
20255
|
}
|
|
20269
20256
|
}, [walletMode, setConfigMode, setActiveMode]);
|
|
20270
20257
|
(0, import_react76.useEffect)(() => {
|
|
20271
|
-
if (isConnected && address && !isExternalConnected && connector) {
|
|
20258
|
+
if (isConnected && address && !isExternalConnected && connector && chain?.id) {
|
|
20272
20259
|
setExternalWallet({
|
|
20273
20260
|
address,
|
|
20274
|
-
chainId: chain
|
|
20261
|
+
chainId: chain.id,
|
|
20275
20262
|
connectorName: connector.name || "Unknown Wallet"
|
|
20276
20263
|
});
|
|
20277
20264
|
}
|
|
@@ -20287,10 +20274,10 @@ function DirectWalletHandler() {
|
|
|
20287
20274
|
}
|
|
20288
20275
|
}, [chain?.id, isConnected, isExternalConnected, setExternalChainId]);
|
|
20289
20276
|
(0, import_react76.useEffect)(() => {
|
|
20290
|
-
if (isExternalConnected && isConnected && address && address !== externalAddress && connector) {
|
|
20277
|
+
if (isExternalConnected && isConnected && address && address !== externalAddress && connector && chain?.id) {
|
|
20291
20278
|
setExternalWallet({
|
|
20292
20279
|
address,
|
|
20293
|
-
chainId: chain
|
|
20280
|
+
chainId: chain.id,
|
|
20294
20281
|
connectorName: connector.name || "Unknown Wallet"
|
|
20295
20282
|
});
|
|
20296
20283
|
}
|
|
@@ -21411,7 +21398,6 @@ __export(auth_exports, {
|
|
|
21411
21398
|
createInitialAuthState: () => createInitialAuthState,
|
|
21412
21399
|
createJwtTokenManager: () => import_auth20.createJwtTokenManager,
|
|
21413
21400
|
createLoginMessage: () => createLoginMessage,
|
|
21414
|
-
createNativeWalletSignatureMessage: () => createNativeWalletSignatureMessage,
|
|
21415
21401
|
createPasskeyHelpers: () => createPasskeyHelpers,
|
|
21416
21402
|
createSignatureMessage: () => createSignatureMessage,
|
|
21417
21403
|
deriveDemoPrivateKey: () => deriveDemoPrivateKey,
|
|
@@ -22756,11 +22742,13 @@ var init_iframe_manager = __esm({
|
|
|
22756
22742
|
});
|
|
22757
22743
|
|
|
22758
22744
|
// src/config/rainbowkit.ts
|
|
22759
|
-
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;
|
|
22760
22746
|
var init_rainbowkit = __esm({
|
|
22761
22747
|
"src/config/rainbowkit.ts"() {
|
|
22748
|
+
import_read17 = require("@embarkai/core/read");
|
|
22762
22749
|
import_rainbowkit2 = require("@rainbow-me/rainbowkit");
|
|
22763
22750
|
import_wallets = require("@rainbow-me/rainbowkit/wallets");
|
|
22751
|
+
import_wagmi4 = require("wagmi");
|
|
22764
22752
|
import_chains = require("wagmi/chains");
|
|
22765
22753
|
getProjectId2 = (configProjectId) => {
|
|
22766
22754
|
if (configProjectId) return configProjectId;
|
|
@@ -22775,12 +22763,41 @@ var init_rainbowkit = __esm({
|
|
|
22775
22763
|
coinbase: import_wallets.coinbaseWallet,
|
|
22776
22764
|
rainbow: import_wallets.rainbowWallet
|
|
22777
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
|
+
};
|
|
22778
22794
|
createRainbowConfig = (options) => {
|
|
22779
22795
|
const opts = typeof options === "string" ? { projectId: options } : options || {};
|
|
22780
22796
|
const config = {
|
|
22781
22797
|
appName: "EmbarkAI Wallet",
|
|
22782
22798
|
projectId: getProjectId2(opts.projectId),
|
|
22783
|
-
chains:
|
|
22799
|
+
chains: buildRainbowChains(opts.supportedChains, opts.preferredChainId),
|
|
22800
|
+
storage: (0, import_wagmi4.createStorage)({ key: getWagmiStorageKey(opts) }),
|
|
22784
22801
|
ssr: false
|
|
22785
22802
|
};
|
|
22786
22803
|
if (opts.allowedWallets && opts.allowedWallets.length > 0) {
|
|
@@ -22990,9 +23007,16 @@ function RainbowKitProvider({ children }) {
|
|
|
22990
23007
|
const rainbowConfig = (0, import_react78.useMemo)(
|
|
22991
23008
|
() => createRainbowConfig({
|
|
22992
23009
|
projectId: config.current?.wallet?.walletConnectProjectId,
|
|
22993
|
-
allowedWallets: config.current?.wallet?.allowedWallets
|
|
23010
|
+
allowedWallets: config.current?.wallet?.allowedWallets,
|
|
23011
|
+
supportedChains: config.current?.wallet?.supportedChains,
|
|
23012
|
+
preferredChainId: config.current?.network?.chainId
|
|
22994
23013
|
}),
|
|
22995
|
-
[
|
|
23014
|
+
[
|
|
23015
|
+
config.current?.network?.chainId,
|
|
23016
|
+
config.current?.wallet?.allowedWallets,
|
|
23017
|
+
config.current?.wallet?.supportedChains,
|
|
23018
|
+
config.current?.wallet?.walletConnectProjectId
|
|
23019
|
+
]
|
|
22996
23020
|
);
|
|
22997
23021
|
const customTheme = (0, import_react78.useMemo)(() => {
|
|
22998
23022
|
if (!config.current?.wallet?.enabled) return {};
|
|
@@ -23009,14 +23033,14 @@ function RainbowKitProvider({ children }) {
|
|
|
23009
23033
|
};
|
|
23010
23034
|
}, [colorMode]);
|
|
23011
23035
|
if (!config.current?.wallet?.enabled) return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(import_jsx_runtime110.Fragment, { children });
|
|
23012
|
-
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 }) });
|
|
23013
23037
|
}
|
|
23014
|
-
var import_rainbowkit3, import_react78,
|
|
23038
|
+
var import_rainbowkit3, import_react78, import_wagmi5, import_styles, import_jsx_runtime110;
|
|
23015
23039
|
var init_RainbowKitContext = __esm({
|
|
23016
23040
|
"src/context/RainbowKitContext.tsx"() {
|
|
23017
23041
|
import_rainbowkit3 = require("@rainbow-me/rainbowkit");
|
|
23018
23042
|
import_react78 = require("react");
|
|
23019
|
-
|
|
23043
|
+
import_wagmi5 = require("wagmi");
|
|
23020
23044
|
init_rainbowkit();
|
|
23021
23045
|
init_useLayoutStore();
|
|
23022
23046
|
init_ProviderContext();
|
|
@@ -23043,7 +23067,7 @@ var init_utils10 = __esm({
|
|
|
23043
23067
|
// src/config/wagmi.ts
|
|
23044
23068
|
function buildTransport(urls) {
|
|
23045
23069
|
const transports = urls.map(
|
|
23046
|
-
(url) => (0,
|
|
23070
|
+
(url) => (0, import_wagmi6.http)(url, {
|
|
23047
23071
|
timeout: 1e4,
|
|
23048
23072
|
retryCount: 0,
|
|
23049
23073
|
batch: false,
|
|
@@ -23059,36 +23083,52 @@ function buildTransport(urls) {
|
|
|
23059
23083
|
retryCount: 0
|
|
23060
23084
|
});
|
|
23061
23085
|
}
|
|
23062
|
-
var
|
|
23086
|
+
var import_read18, import_viem17, import_wagmi6, wagmiConfig;
|
|
23063
23087
|
var init_wagmi = __esm({
|
|
23064
23088
|
"src/config/wagmi.ts"() {
|
|
23065
|
-
|
|
23089
|
+
import_read18 = require("@embarkai/core/read");
|
|
23066
23090
|
import_viem17 = require("viem");
|
|
23067
|
-
|
|
23068
|
-
wagmiConfig = (0,
|
|
23069
|
-
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" }),
|
|
23070
23095
|
transports: {
|
|
23071
|
-
[
|
|
23072
|
-
[
|
|
23096
|
+
[import_read18.lumiaTestnetChain.id]: buildTransport(import_read18.lumiaTestnetChain.rpcUrls.default.http),
|
|
23097
|
+
[import_read18.lumiaMainnetChain.id]: buildTransport(import_read18.lumiaMainnetChain.rpcUrls.default.http)
|
|
23073
23098
|
}
|
|
23074
23099
|
});
|
|
23075
23100
|
}
|
|
23076
23101
|
});
|
|
23077
23102
|
|
|
23078
23103
|
// src/context/WagmiContext.tsx
|
|
23079
|
-
var
|
|
23104
|
+
var import_wagmi7, import_jsx_runtime111, WagmiProvider2;
|
|
23080
23105
|
var init_WagmiContext = __esm({
|
|
23081
23106
|
"src/context/WagmiContext.tsx"() {
|
|
23082
|
-
|
|
23107
|
+
import_wagmi7 = require("wagmi");
|
|
23083
23108
|
init_wagmi();
|
|
23084
23109
|
import_jsx_runtime111 = require("react/jsx-runtime");
|
|
23085
23110
|
WagmiProvider2 = ({ children }) => {
|
|
23086
|
-
return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
|
|
23111
|
+
return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_wagmi7.WagmiProvider, { config: wagmiConfig, children });
|
|
23087
23112
|
};
|
|
23088
23113
|
}
|
|
23089
23114
|
});
|
|
23090
23115
|
|
|
23091
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
|
+
}
|
|
23092
23132
|
function Provider(props) {
|
|
23093
23133
|
const { children, projectId, initialConfig = {}, callbacks } = props;
|
|
23094
23134
|
const callbacksRef = (0, import_react79.useRef)(callbacks);
|
|
@@ -23136,6 +23176,9 @@ function Provider(props) {
|
|
|
23136
23176
|
if (typeof window === "undefined" || !projectId) return;
|
|
23137
23177
|
const mergedConfig = (0, import_lodash_es8.merge)(DEFAULT_PROVIDER_CONFIG, initialConfig);
|
|
23138
23178
|
updateConfig(mergedConfig);
|
|
23179
|
+
if (mergedConfig.wallet?.enabled) {
|
|
23180
|
+
clearLegacyWagmiStorage();
|
|
23181
|
+
}
|
|
23139
23182
|
try {
|
|
23140
23183
|
if (typeof window !== "undefined") {
|
|
23141
23184
|
window.__EMBARK_SERVICES__ = mergedConfig.services;
|
|
@@ -23548,7 +23591,7 @@ var init_LangToggle = __esm({
|
|
|
23548
23591
|
// src/clients/bundler/getUserOperationByHash.ts
|
|
23549
23592
|
async function getUserOperationByHash(userOpHash, chainId) {
|
|
23550
23593
|
const targetChainId = chainId ?? requireActiveChainId();
|
|
23551
|
-
const chainConfig = (0,
|
|
23594
|
+
const chainConfig = (0, import_read19.getChainConfig)(targetChainId);
|
|
23552
23595
|
if (!chainConfig) {
|
|
23553
23596
|
throw new Error(`Chain ${targetChainId} is not supported`);
|
|
23554
23597
|
}
|
|
@@ -23576,19 +23619,19 @@ async function getUserOperationByHash(userOpHash, chainId) {
|
|
|
23576
23619
|
return null;
|
|
23577
23620
|
}
|
|
23578
23621
|
}
|
|
23579
|
-
var import_core3,
|
|
23622
|
+
var import_core3, import_read19;
|
|
23580
23623
|
var init_getUserOperationByHash = __esm({
|
|
23581
23624
|
"src/clients/bundler/getUserOperationByHash.ts"() {
|
|
23582
23625
|
init_SessionContext();
|
|
23583
23626
|
import_core3 = require("@embarkai/core");
|
|
23584
|
-
|
|
23627
|
+
import_read19 = require("@embarkai/core/read");
|
|
23585
23628
|
}
|
|
23586
23629
|
});
|
|
23587
23630
|
|
|
23588
23631
|
// src/clients/bundler/getUserOperationReceipt.ts
|
|
23589
23632
|
async function getUserOperationReceipt(userOpHash, chainId) {
|
|
23590
23633
|
const targetChainId = chainId ?? requireActiveChainId();
|
|
23591
|
-
const chainConfig = (0,
|
|
23634
|
+
const chainConfig = (0, import_read20.getChainConfig)(targetChainId);
|
|
23592
23635
|
if (!chainConfig) {
|
|
23593
23636
|
throw new Error(`Chain ${targetChainId} is not supported`);
|
|
23594
23637
|
}
|
|
@@ -23622,12 +23665,12 @@ async function getUserOperationReceipt(userOpHash, chainId) {
|
|
|
23622
23665
|
return null;
|
|
23623
23666
|
}
|
|
23624
23667
|
}
|
|
23625
|
-
var import_core4,
|
|
23668
|
+
var import_core4, import_read20;
|
|
23626
23669
|
var init_getUserOperationReceipt = __esm({
|
|
23627
23670
|
"src/clients/bundler/getUserOperationReceipt.ts"() {
|
|
23628
23671
|
init_SessionContext();
|
|
23629
23672
|
import_core4 = require("@embarkai/core");
|
|
23630
|
-
|
|
23673
|
+
import_read20 = require("@embarkai/core/read");
|
|
23631
23674
|
}
|
|
23632
23675
|
});
|
|
23633
23676
|
|
|
@@ -24376,7 +24419,7 @@ function useDirectWallet() {
|
|
|
24376
24419
|
const isConnected = useExternalWalletStore((st) => st.isExternalConnected);
|
|
24377
24420
|
const connectorName = useExternalWalletStore((st) => st.connectorName);
|
|
24378
24421
|
const clearExternalWallet = useExternalWalletStore((st) => st.clearExternalWallet);
|
|
24379
|
-
const { disconnect: wagmiDisconnect } = (0,
|
|
24422
|
+
const { disconnect: wagmiDisconnect } = (0, import_wagmi9.useDisconnect)();
|
|
24380
24423
|
const { openConnectModal } = (0, import_rainbowkit5.useConnectModal)();
|
|
24381
24424
|
const setIsWalletLinking = useLayoutDataStore((st) => st.setIsWalletLinking);
|
|
24382
24425
|
const connect = (0, import_react84.useCallback)(() => {
|
|
@@ -24399,12 +24442,12 @@ function useDirectWallet() {
|
|
|
24399
24442
|
disconnect
|
|
24400
24443
|
};
|
|
24401
24444
|
}
|
|
24402
|
-
var import_react84, import_rainbowkit5,
|
|
24445
|
+
var import_react84, import_rainbowkit5, import_wagmi9;
|
|
24403
24446
|
var init_useDirectWallet = __esm({
|
|
24404
24447
|
"src/hooks/useDirectWallet.ts"() {
|
|
24405
24448
|
import_react84 = require("react");
|
|
24406
24449
|
import_rainbowkit5 = require("@rainbow-me/rainbowkit");
|
|
24407
|
-
|
|
24450
|
+
import_wagmi9 = require("wagmi");
|
|
24408
24451
|
init_useExternalWalletStore();
|
|
24409
24452
|
init_useLayoutDataStore();
|
|
24410
24453
|
}
|
|
@@ -24414,8 +24457,8 @@ var init_useDirectWallet = __esm({
|
|
|
24414
24457
|
function useSendDirectTransaction() {
|
|
24415
24458
|
const isConnected = useExternalWalletStore((st) => st.isExternalConnected);
|
|
24416
24459
|
const externalChainId = useExternalWalletStore((st) => st.externalChainId);
|
|
24417
|
-
const { sendTransactionAsync } = (0,
|
|
24418
|
-
const { switchChainAsync } = (0,
|
|
24460
|
+
const { sendTransactionAsync } = (0, import_wagmi10.useSendTransaction)();
|
|
24461
|
+
const { switchChainAsync } = (0, import_wagmi10.useSwitchChain)();
|
|
24419
24462
|
const [isPending, setIsPending] = (0, import_react85.useState)(false);
|
|
24420
24463
|
const [error, setError] = (0, import_react85.useState)(null);
|
|
24421
24464
|
const [txHash, setTxHash] = (0, import_react85.useState)(null);
|
|
@@ -24460,12 +24503,12 @@ function useSendDirectTransaction() {
|
|
|
24460
24503
|
}, []);
|
|
24461
24504
|
return { sendTransaction, isPending, error, txHash, reset };
|
|
24462
24505
|
}
|
|
24463
|
-
var import_react85, import_viem18,
|
|
24506
|
+
var import_react85, import_viem18, import_wagmi10;
|
|
24464
24507
|
var init_useSendDirectTransaction = __esm({
|
|
24465
24508
|
"src/hooks/useSendDirectTransaction.ts"() {
|
|
24466
24509
|
import_react85 = require("react");
|
|
24467
24510
|
import_viem18 = require("viem");
|
|
24468
|
-
|
|
24511
|
+
import_wagmi10 = require("wagmi");
|
|
24469
24512
|
init_useExternalWalletStore();
|
|
24470
24513
|
}
|
|
24471
24514
|
});
|
|
@@ -24563,40 +24606,19 @@ var init_useTransferToLinkedWallet = __esm({
|
|
|
24563
24606
|
|
|
24564
24607
|
// src/hooks/useNativeWalletSignature.ts
|
|
24565
24608
|
function useNativeWalletSignature() {
|
|
24566
|
-
const
|
|
24567
|
-
const
|
|
24568
|
-
|
|
24569
|
-
|
|
24570
|
-
|
|
24571
|
-
|
|
24572
|
-
|
|
24573
|
-
|
|
24574
|
-
"\nNative account:",
|
|
24575
|
-
nativeAccount
|
|
24576
|
-
);
|
|
24577
|
-
const projectName = projectId ? await fetchProjectName(projectId) : "EmbarkAI";
|
|
24578
|
-
const message = createNativeWalletSignatureMessage(nativeWalletAddress, projectName, nonce);
|
|
24579
|
-
const signature = await Promise.race([
|
|
24580
|
-
signMessageAsync({ message, account: nativeWalletAddress }),
|
|
24581
|
-
new Promise((_, rej) => setTimeout(() => rej(new Error("Singing timed out. Please try again.")), 12e4))
|
|
24582
|
-
]).catch((err) => {
|
|
24583
|
-
console.error("[GET WALLET SIGNATURE]", err);
|
|
24584
|
-
throw err;
|
|
24585
|
-
});
|
|
24586
|
-
return {
|
|
24587
|
-
message,
|
|
24588
|
-
signature
|
|
24589
|
-
};
|
|
24590
|
-
},
|
|
24591
|
-
[signMessageAsync]
|
|
24592
|
-
);
|
|
24593
|
-
return { getNativeWalletSignature };
|
|
24609
|
+
const signMessage = (0, import_wagmi11.useSignMessage)();
|
|
24610
|
+
const signTypedMessage = (0, import_wagmi11.useSignTypedData)();
|
|
24611
|
+
return {
|
|
24612
|
+
signMessage,
|
|
24613
|
+
/** EIP-712 signature */
|
|
24614
|
+
signTypedMessage,
|
|
24615
|
+
fetchProjectNameById: fetchProjectName
|
|
24616
|
+
};
|
|
24594
24617
|
}
|
|
24595
|
-
var
|
|
24618
|
+
var import_wagmi11;
|
|
24596
24619
|
var init_useNativeWalletSignature = __esm({
|
|
24597
24620
|
"src/hooks/useNativeWalletSignature.ts"() {
|
|
24598
|
-
|
|
24599
|
-
import_wagmi10 = require("wagmi");
|
|
24621
|
+
import_wagmi11 = require("wagmi");
|
|
24600
24622
|
init_providers();
|
|
24601
24623
|
}
|
|
24602
24624
|
});
|
|
@@ -24605,7 +24627,7 @@ var init_useNativeWalletSignature = __esm({
|
|
|
24605
24627
|
function useLogout() {
|
|
24606
24628
|
const { setSession, setIsLoading, setAddress, setStatus, setError, address } = useSession();
|
|
24607
24629
|
const { callbacksRef } = useProviderConfig();
|
|
24608
|
-
const logout2 = (0,
|
|
24630
|
+
const logout2 = (0, import_react87.useCallback)(async () => {
|
|
24609
24631
|
const prevAddress = address;
|
|
24610
24632
|
let userId = null;
|
|
24611
24633
|
setIsLoading(true);
|
|
@@ -24635,11 +24657,11 @@ function useLogout() {
|
|
|
24635
24657
|
}, [address, setAddress, setError, setSession, setStatus]);
|
|
24636
24658
|
return { logout: logout2 };
|
|
24637
24659
|
}
|
|
24638
|
-
var import_auth22,
|
|
24660
|
+
var import_auth22, import_react87;
|
|
24639
24661
|
var init_useLogout = __esm({
|
|
24640
24662
|
"src/hooks/useLogout.ts"() {
|
|
24641
24663
|
import_auth22 = require("@embarkai/core/auth");
|
|
24642
|
-
|
|
24664
|
+
import_react87 = require("react");
|
|
24643
24665
|
init_ProviderContext();
|
|
24644
24666
|
init_SessionContext();
|
|
24645
24667
|
}
|
|
@@ -24699,10 +24721,10 @@ var init_clients2 = __esm({
|
|
|
24699
24721
|
// src/modules/transactions.ts
|
|
24700
24722
|
function useTransactions() {
|
|
24701
24723
|
const chainId = requireActiveChainId();
|
|
24702
|
-
const viemChain = (0,
|
|
24703
|
-
const publicClient = (0,
|
|
24704
|
-
const { data: walletClient } = (0,
|
|
24705
|
-
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)();
|
|
24706
24728
|
const sendTransaction = async (params) => {
|
|
24707
24729
|
if (!walletClient) {
|
|
24708
24730
|
throw new Error("Wallet not connected");
|
|
@@ -24757,13 +24779,13 @@ function useTransactions() {
|
|
|
24757
24779
|
isConnected: !!address && !!walletClient
|
|
24758
24780
|
};
|
|
24759
24781
|
}
|
|
24760
|
-
var
|
|
24782
|
+
var import_read21, import_viem20, import_wagmi12;
|
|
24761
24783
|
var init_transactions = __esm({
|
|
24762
24784
|
"src/modules/transactions.ts"() {
|
|
24763
24785
|
init_SessionContext();
|
|
24764
|
-
|
|
24786
|
+
import_read21 = require("@embarkai/core/read");
|
|
24765
24787
|
import_viem20 = require("viem");
|
|
24766
|
-
|
|
24788
|
+
import_wagmi12 = require("wagmi");
|
|
24767
24789
|
}
|
|
24768
24790
|
});
|
|
24769
24791
|
|
|
@@ -24774,7 +24796,7 @@ function useAssets(address) {
|
|
|
24774
24796
|
data: nativeBalance,
|
|
24775
24797
|
isLoading: nativeBalanceLoading,
|
|
24776
24798
|
refetch: refetchNativeBalance
|
|
24777
|
-
} = (0,
|
|
24799
|
+
} = (0, import_wagmi13.useBalance)({
|
|
24778
24800
|
address,
|
|
24779
24801
|
chainId,
|
|
24780
24802
|
query: {
|
|
@@ -24788,7 +24810,7 @@ function useAssets(address) {
|
|
|
24788
24810
|
args: [address],
|
|
24789
24811
|
chainId
|
|
24790
24812
|
}));
|
|
24791
|
-
const readContractsResult = (0,
|
|
24813
|
+
const readContractsResult = (0, import_wagmi13.useReadContracts)({
|
|
24792
24814
|
contracts: tokenContracts,
|
|
24793
24815
|
query: {
|
|
24794
24816
|
enabled: !!address && COMMON_TOKENS.length > 0
|
|
@@ -24869,7 +24891,7 @@ function useAssets(address) {
|
|
|
24869
24891
|
}
|
|
24870
24892
|
function useTokenInfo(tokenAddress) {
|
|
24871
24893
|
const chainId = requireActiveChainId();
|
|
24872
|
-
const readContractsResult = (0,
|
|
24894
|
+
const readContractsResult = (0, import_wagmi13.useReadContracts)({
|
|
24873
24895
|
contracts: [
|
|
24874
24896
|
{ address: tokenAddress, abi: import_viem21.erc20Abi, functionName: "name", chainId },
|
|
24875
24897
|
{ address: tokenAddress, abi: import_viem21.erc20Abi, functionName: "symbol", chainId },
|
|
@@ -24900,7 +24922,7 @@ function useTokenBalance(tokenAddress, userAddress) {
|
|
|
24900
24922
|
data: balance,
|
|
24901
24923
|
isLoading,
|
|
24902
24924
|
refetch
|
|
24903
|
-
} = (0,
|
|
24925
|
+
} = (0, import_wagmi13.useReadContract)({
|
|
24904
24926
|
address: tokenAddress,
|
|
24905
24927
|
abi: import_viem21.erc20Abi,
|
|
24906
24928
|
functionName: "balanceOf",
|
|
@@ -24911,7 +24933,7 @@ function useTokenBalance(tokenAddress, userAddress) {
|
|
|
24911
24933
|
}
|
|
24912
24934
|
});
|
|
24913
24935
|
const { tokenInfo } = useTokenInfo(tokenAddress);
|
|
24914
|
-
const formattedBalance =
|
|
24936
|
+
const formattedBalance = import_react88.default.useMemo(() => {
|
|
24915
24937
|
if (!balance || !tokenInfo) return "0";
|
|
24916
24938
|
return (0, import_viem21.formatUnits)(balance, tokenInfo.decimals);
|
|
24917
24939
|
}, [balance, tokenInfo]);
|
|
@@ -24923,13 +24945,13 @@ function useTokenBalance(tokenAddress, userAddress) {
|
|
|
24923
24945
|
refetch
|
|
24924
24946
|
};
|
|
24925
24947
|
}
|
|
24926
|
-
var
|
|
24948
|
+
var import_react88, import_viem21, import_wagmi13, COMMON_TOKENS;
|
|
24927
24949
|
var init_assets2 = __esm({
|
|
24928
24950
|
"src/modules/assets.ts"() {
|
|
24929
24951
|
init_SessionContext();
|
|
24930
|
-
|
|
24952
|
+
import_react88 = __toESM(require("react"), 1);
|
|
24931
24953
|
import_viem21 = require("viem");
|
|
24932
|
-
|
|
24954
|
+
import_wagmi13 = require("wagmi");
|
|
24933
24955
|
COMMON_TOKENS = [
|
|
24934
24956
|
// Add real token addresses here when available
|
|
24935
24957
|
// {
|
package/dist/index.d.cts
CHANGED
|
@@ -11,8 +11,8 @@ import { BundlerClient } from 'viem/account-abstraction';
|
|
|
11
11
|
import { UserOperationV07 } from '@embarkai/core/bundler';
|
|
12
12
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
13
13
|
import { VariantProps } from 'class-variance-authority';
|
|
14
|
-
export { JwtTokens, LoginResponse, VerifyResponse, getValidTokens, jwtTokenManager, logout } from '@embarkai/core/auth';
|
|
15
14
|
import * as wagmi from 'wagmi';
|
|
15
|
+
export { JwtTokens, LoginResponse, VerifyResponse, getValidTokens, jwtTokenManager, logout } from '@embarkai/core/auth';
|
|
16
16
|
|
|
17
17
|
interface TokenBalance {
|
|
18
18
|
address: `0x${string}`;
|
|
@@ -1357,11 +1357,28 @@ interface UseTransferToLinkedReturn {
|
|
|
1357
1357
|
}
|
|
1358
1358
|
declare function useTransferToLinkedWallet(): UseTransferToLinkedReturn;
|
|
1359
1359
|
|
|
1360
|
+
interface AuthProviderMeta extends Record<string, unknown> {
|
|
1361
|
+
walletName?: string;
|
|
1362
|
+
walletType?: string;
|
|
1363
|
+
chainId?: number;
|
|
1364
|
+
email?: string;
|
|
1365
|
+
}
|
|
1366
|
+
interface AuthProvider {
|
|
1367
|
+
provider: 'passkey' | 'email' | 'telegram' | 'google' | 'discord' | 'twitter' | 'wallet';
|
|
1368
|
+
verified: boolean;
|
|
1369
|
+
linkedAt: string;
|
|
1370
|
+
lastUsedAt?: string;
|
|
1371
|
+
externalId: string;
|
|
1372
|
+
meta?: AuthProviderMeta;
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
declare function fetchProjectName(projectId: string): Promise<string>;
|
|
1376
|
+
|
|
1360
1377
|
declare function useNativeWalletSignature(): {
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1378
|
+
signMessage: wagmi.UseSignMessageReturnType<unknown>;
|
|
1379
|
+
/** EIP-712 signature */
|
|
1380
|
+
signTypedMessage: wagmi.UseSignTypedDataReturnType<unknown>;
|
|
1381
|
+
fetchProjectNameById: typeof fetchProjectName;
|
|
1365
1382
|
};
|
|
1366
1383
|
|
|
1367
1384
|
interface UseLogoutReturn {
|
|
@@ -1733,21 +1750,6 @@ declare global {
|
|
|
1733
1750
|
}
|
|
1734
1751
|
}
|
|
1735
1752
|
|
|
1736
|
-
interface AuthProviderMeta extends Record<string, unknown> {
|
|
1737
|
-
walletName?: string;
|
|
1738
|
-
walletType?: string;
|
|
1739
|
-
chainId?: number;
|
|
1740
|
-
email?: string;
|
|
1741
|
-
}
|
|
1742
|
-
interface AuthProvider {
|
|
1743
|
-
provider: 'passkey' | 'email' | 'telegram' | 'google' | 'discord' | 'twitter' | 'wallet';
|
|
1744
|
-
verified: boolean;
|
|
1745
|
-
linkedAt: string;
|
|
1746
|
-
lastUsedAt?: string;
|
|
1747
|
-
externalId: string;
|
|
1748
|
-
meta?: AuthProviderMeta;
|
|
1749
|
-
}
|
|
1750
|
-
|
|
1751
1753
|
/**
|
|
1752
1754
|
* Provider information in user profile
|
|
1753
1755
|
* Matches the structure returned by backend /api/auth/profile
|
package/dist/index.d.ts
CHANGED
|
@@ -11,8 +11,8 @@ import { BundlerClient } from 'viem/account-abstraction';
|
|
|
11
11
|
import { UserOperationV07 } from '@embarkai/core/bundler';
|
|
12
12
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
13
13
|
import { VariantProps } from 'class-variance-authority';
|
|
14
|
-
export { JwtTokens, LoginResponse, VerifyResponse, getValidTokens, jwtTokenManager, logout } from '@embarkai/core/auth';
|
|
15
14
|
import * as wagmi from 'wagmi';
|
|
15
|
+
export { JwtTokens, LoginResponse, VerifyResponse, getValidTokens, jwtTokenManager, logout } from '@embarkai/core/auth';
|
|
16
16
|
|
|
17
17
|
interface TokenBalance {
|
|
18
18
|
address: `0x${string}`;
|
|
@@ -1357,11 +1357,28 @@ interface UseTransferToLinkedReturn {
|
|
|
1357
1357
|
}
|
|
1358
1358
|
declare function useTransferToLinkedWallet(): UseTransferToLinkedReturn;
|
|
1359
1359
|
|
|
1360
|
+
interface AuthProviderMeta extends Record<string, unknown> {
|
|
1361
|
+
walletName?: string;
|
|
1362
|
+
walletType?: string;
|
|
1363
|
+
chainId?: number;
|
|
1364
|
+
email?: string;
|
|
1365
|
+
}
|
|
1366
|
+
interface AuthProvider {
|
|
1367
|
+
provider: 'passkey' | 'email' | 'telegram' | 'google' | 'discord' | 'twitter' | 'wallet';
|
|
1368
|
+
verified: boolean;
|
|
1369
|
+
linkedAt: string;
|
|
1370
|
+
lastUsedAt?: string;
|
|
1371
|
+
externalId: string;
|
|
1372
|
+
meta?: AuthProviderMeta;
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
declare function fetchProjectName(projectId: string): Promise<string>;
|
|
1376
|
+
|
|
1360
1377
|
declare function useNativeWalletSignature(): {
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1378
|
+
signMessage: wagmi.UseSignMessageReturnType<unknown>;
|
|
1379
|
+
/** EIP-712 signature */
|
|
1380
|
+
signTypedMessage: wagmi.UseSignTypedDataReturnType<unknown>;
|
|
1381
|
+
fetchProjectNameById: typeof fetchProjectName;
|
|
1365
1382
|
};
|
|
1366
1383
|
|
|
1367
1384
|
interface UseLogoutReturn {
|
|
@@ -1733,21 +1750,6 @@ declare global {
|
|
|
1733
1750
|
}
|
|
1734
1751
|
}
|
|
1735
1752
|
|
|
1736
|
-
interface AuthProviderMeta extends Record<string, unknown> {
|
|
1737
|
-
walletName?: string;
|
|
1738
|
-
walletType?: string;
|
|
1739
|
-
chainId?: number;
|
|
1740
|
-
email?: string;
|
|
1741
|
-
}
|
|
1742
|
-
interface AuthProvider {
|
|
1743
|
-
provider: 'passkey' | 'email' | 'telegram' | 'google' | 'discord' | 'twitter' | 'wallet';
|
|
1744
|
-
verified: boolean;
|
|
1745
|
-
linkedAt: string;
|
|
1746
|
-
lastUsedAt?: string;
|
|
1747
|
-
externalId: string;
|
|
1748
|
-
meta?: AuthProviderMeta;
|
|
1749
|
-
}
|
|
1750
|
-
|
|
1751
1753
|
/**
|
|
1752
1754
|
* Provider information in user profile
|
|
1753
1755
|
* Matches the structure returned by backend /api/auth/profile
|
package/dist/index.js
CHANGED
|
@@ -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.8",
|
|
19090
19090
|
description: "React UI components and hooks for EmbarkAI authentication and Account Abstraction",
|
|
19091
19091
|
type: "module",
|
|
19092
19092
|
main: "./dist/index.cjs",
|
|
@@ -19816,19 +19816,6 @@ Timestamp: ${timestamp}
|
|
|
19816
19816
|
|
|
19817
19817
|
Sign this message to link your wallet to ${projectName} Wallet`;
|
|
19818
19818
|
}
|
|
19819
|
-
function createNativeWalletSignatureMessage(address, projectName, nonce) {
|
|
19820
|
-
const timestamp = Date.now();
|
|
19821
|
-
const nonceValue = nonce || crypto.randomUUID();
|
|
19822
|
-
return [
|
|
19823
|
-
`${projectName} Wallet Sign`,
|
|
19824
|
-
"",
|
|
19825
|
-
`Address: ${address}`,
|
|
19826
|
-
`Nonce: ${nonceValue}`,
|
|
19827
|
-
`Timestamp: ${timestamp}`,
|
|
19828
|
-
"",
|
|
19829
|
-
`Project ${projectName} signature request for wallet operation`
|
|
19830
|
-
].join("\n");
|
|
19831
|
-
}
|
|
19832
19819
|
function createLoginMessage(address, projectName) {
|
|
19833
19820
|
const nonce = crypto.randomUUID();
|
|
19834
19821
|
const timestamp = Date.now();
|
|
@@ -20185,10 +20172,10 @@ function DirectWalletHandler() {
|
|
|
20185
20172
|
}
|
|
20186
20173
|
}, [walletMode, setConfigMode, setActiveMode]);
|
|
20187
20174
|
useEffect42(() => {
|
|
20188
|
-
if (isConnected && address && !isExternalConnected && connector) {
|
|
20175
|
+
if (isConnected && address && !isExternalConnected && connector && chain?.id) {
|
|
20189
20176
|
setExternalWallet({
|
|
20190
20177
|
address,
|
|
20191
|
-
chainId: chain
|
|
20178
|
+
chainId: chain.id,
|
|
20192
20179
|
connectorName: connector.name || "Unknown Wallet"
|
|
20193
20180
|
});
|
|
20194
20181
|
}
|
|
@@ -20204,10 +20191,10 @@ function DirectWalletHandler() {
|
|
|
20204
20191
|
}
|
|
20205
20192
|
}, [chain?.id, isConnected, isExternalConnected, setExternalChainId]);
|
|
20206
20193
|
useEffect42(() => {
|
|
20207
|
-
if (isExternalConnected && isConnected && address && address !== externalAddress && connector) {
|
|
20194
|
+
if (isExternalConnected && isConnected && address && address !== externalAddress && connector && chain?.id) {
|
|
20208
20195
|
setExternalWallet({
|
|
20209
20196
|
address,
|
|
20210
|
-
chainId: chain
|
|
20197
|
+
chainId: chain.id,
|
|
20211
20198
|
connectorName: connector.name || "Unknown Wallet"
|
|
20212
20199
|
});
|
|
20213
20200
|
}
|
|
@@ -21331,7 +21318,6 @@ __export(auth_exports, {
|
|
|
21331
21318
|
createInitialAuthState: () => createInitialAuthState,
|
|
21332
21319
|
createJwtTokenManager: () => createJwtTokenManager,
|
|
21333
21320
|
createLoginMessage: () => createLoginMessage,
|
|
21334
|
-
createNativeWalletSignatureMessage: () => createNativeWalletSignatureMessage,
|
|
21335
21321
|
createPasskeyHelpers: () => createPasskeyHelpers,
|
|
21336
21322
|
createSignatureMessage: () => createSignatureMessage,
|
|
21337
21323
|
deriveDemoPrivateKey: () => deriveDemoPrivateKey,
|
|
@@ -22690,15 +22676,12 @@ var init_iframe_manager = __esm({
|
|
|
22690
22676
|
});
|
|
22691
22677
|
|
|
22692
22678
|
// src/config/rainbowkit.ts
|
|
22679
|
+
import { lumiaMainnetChain as lumiaMainnetChain2, lumiaTestnetChain as lumiaTestnetChain2 } from "@embarkai/core/read";
|
|
22693
22680
|
import { getDefaultConfig } from "@rainbow-me/rainbowkit";
|
|
22694
|
-
import {
|
|
22695
|
-
|
|
22696
|
-
metaMaskWallet,
|
|
22697
|
-
rainbowWallet,
|
|
22698
|
-
walletConnectWallet
|
|
22699
|
-
} from "@rainbow-me/rainbowkit/wallets";
|
|
22681
|
+
import { coinbaseWallet, metaMaskWallet, rainbowWallet, walletConnectWallet } from "@rainbow-me/rainbowkit/wallets";
|
|
22682
|
+
import { createStorage } from "wagmi";
|
|
22700
22683
|
import { arbitrum, avalanche, base, bsc, mainnet, optimism, polygon, zora } from "wagmi/chains";
|
|
22701
|
-
var getProjectId2, WALLET_MAP, createRainbowConfig, rainbowTheme;
|
|
22684
|
+
var getProjectId2, WALLET_MAP, getWagmiStorageKey, buildRainbowChains, createRainbowConfig, rainbowTheme;
|
|
22702
22685
|
var init_rainbowkit = __esm({
|
|
22703
22686
|
"src/config/rainbowkit.ts"() {
|
|
22704
22687
|
getProjectId2 = (configProjectId) => {
|
|
@@ -22714,12 +22697,41 @@ var init_rainbowkit = __esm({
|
|
|
22714
22697
|
coinbase: coinbaseWallet,
|
|
22715
22698
|
rainbow: rainbowWallet
|
|
22716
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
|
+
};
|
|
22717
22728
|
createRainbowConfig = (options) => {
|
|
22718
22729
|
const opts = typeof options === "string" ? { projectId: options } : options || {};
|
|
22719
22730
|
const config = {
|
|
22720
22731
|
appName: "EmbarkAI Wallet",
|
|
22721
22732
|
projectId: getProjectId2(opts.projectId),
|
|
22722
|
-
chains:
|
|
22733
|
+
chains: buildRainbowChains(opts.supportedChains, opts.preferredChainId),
|
|
22734
|
+
storage: createStorage({ key: getWagmiStorageKey(opts) }),
|
|
22723
22735
|
ssr: false
|
|
22724
22736
|
};
|
|
22725
22737
|
if (opts.allowedWallets && opts.allowedWallets.length > 0) {
|
|
@@ -22934,9 +22946,16 @@ function RainbowKitProvider({ children }) {
|
|
|
22934
22946
|
const rainbowConfig = useMemo9(
|
|
22935
22947
|
() => createRainbowConfig({
|
|
22936
22948
|
projectId: config.current?.wallet?.walletConnectProjectId,
|
|
22937
|
-
allowedWallets: config.current?.wallet?.allowedWallets
|
|
22949
|
+
allowedWallets: config.current?.wallet?.allowedWallets,
|
|
22950
|
+
supportedChains: config.current?.wallet?.supportedChains,
|
|
22951
|
+
preferredChainId: config.current?.network?.chainId
|
|
22938
22952
|
}),
|
|
22939
|
-
[
|
|
22953
|
+
[
|
|
22954
|
+
config.current?.network?.chainId,
|
|
22955
|
+
config.current?.wallet?.allowedWallets,
|
|
22956
|
+
config.current?.wallet?.supportedChains,
|
|
22957
|
+
config.current?.wallet?.walletConnectProjectId
|
|
22958
|
+
]
|
|
22940
22959
|
);
|
|
22941
22960
|
const customTheme = useMemo9(() => {
|
|
22942
22961
|
if (!config.current?.wallet?.enabled) return {};
|
|
@@ -22979,9 +22998,9 @@ var init_utils10 = __esm({
|
|
|
22979
22998
|
});
|
|
22980
22999
|
|
|
22981
23000
|
// src/config/wagmi.ts
|
|
22982
|
-
import { lumiaMainnetChain as
|
|
23001
|
+
import { lumiaMainnetChain as lumiaMainnetChain3, lumiaTestnetChain as lumiaTestnetChain3 } from "@embarkai/core/read";
|
|
22983
23002
|
import { fallback } from "viem";
|
|
22984
|
-
import { createConfig, http as http4 } from "wagmi";
|
|
23003
|
+
import { createConfig, createStorage as createStorage2, http as http4 } from "wagmi";
|
|
22985
23004
|
function buildTransport(urls) {
|
|
22986
23005
|
const transports = urls.map(
|
|
22987
23006
|
(url) => http4(url, {
|
|
@@ -23004,10 +23023,11 @@ var wagmiConfig;
|
|
|
23004
23023
|
var init_wagmi = __esm({
|
|
23005
23024
|
"src/config/wagmi.ts"() {
|
|
23006
23025
|
wagmiConfig = createConfig({
|
|
23007
|
-
chains: [
|
|
23026
|
+
chains: [lumiaMainnetChain3, lumiaTestnetChain3],
|
|
23027
|
+
storage: createStorage2({ key: "embark-wagmi-static-v2" }),
|
|
23008
23028
|
transports: {
|
|
23009
|
-
[
|
|
23010
|
-
[
|
|
23029
|
+
[lumiaTestnetChain3.id]: buildTransport(lumiaTestnetChain3.rpcUrls.default.http),
|
|
23030
|
+
[lumiaMainnetChain3.id]: buildTransport(lumiaMainnetChain3.rpcUrls.default.http)
|
|
23011
23031
|
}
|
|
23012
23032
|
});
|
|
23013
23033
|
}
|
|
@@ -23038,6 +23058,21 @@ import {
|
|
|
23038
23058
|
useRef as useRef18
|
|
23039
23059
|
} from "react";
|
|
23040
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
|
+
}
|
|
23041
23076
|
function Provider(props) {
|
|
23042
23077
|
const { children, projectId, initialConfig = {}, callbacks } = props;
|
|
23043
23078
|
const callbacksRef = useRef18(callbacks);
|
|
@@ -23085,6 +23120,9 @@ function Provider(props) {
|
|
|
23085
23120
|
if (typeof window === "undefined" || !projectId) return;
|
|
23086
23121
|
const mergedConfig = merge3(DEFAULT_PROVIDER_CONFIG, initialConfig);
|
|
23087
23122
|
updateConfig(mergedConfig);
|
|
23123
|
+
if (mergedConfig.wallet?.enabled) {
|
|
23124
|
+
clearLegacyWagmiStorage();
|
|
23125
|
+
}
|
|
23088
23126
|
try {
|
|
23089
23127
|
if (typeof window !== "undefined") {
|
|
23090
23128
|
window.__EMBARK_SERVICES__ = mergedConfig.services;
|
|
@@ -24497,37 +24535,16 @@ var init_useTransferToLinkedWallet = __esm({
|
|
|
24497
24535
|
});
|
|
24498
24536
|
|
|
24499
24537
|
// src/hooks/useNativeWalletSignature.ts
|
|
24500
|
-
import {
|
|
24501
|
-
import { useAccount as useAccount3, useSignMessage as useSignMessage2 } from "wagmi";
|
|
24538
|
+
import { useSignMessage as useSignMessage2, useSignTypedData } from "wagmi";
|
|
24502
24539
|
function useNativeWalletSignature() {
|
|
24503
|
-
const
|
|
24504
|
-
const
|
|
24505
|
-
|
|
24506
|
-
|
|
24507
|
-
|
|
24508
|
-
|
|
24509
|
-
|
|
24510
|
-
|
|
24511
|
-
"\nNative account:",
|
|
24512
|
-
nativeAccount
|
|
24513
|
-
);
|
|
24514
|
-
const projectName = projectId ? await fetchProjectName(projectId) : "EmbarkAI";
|
|
24515
|
-
const message = createNativeWalletSignatureMessage(nativeWalletAddress, projectName, nonce);
|
|
24516
|
-
const signature = await Promise.race([
|
|
24517
|
-
signMessageAsync({ message, account: nativeWalletAddress }),
|
|
24518
|
-
new Promise((_, rej) => setTimeout(() => rej(new Error("Singing timed out. Please try again.")), 12e4))
|
|
24519
|
-
]).catch((err) => {
|
|
24520
|
-
console.error("[GET WALLET SIGNATURE]", err);
|
|
24521
|
-
throw err;
|
|
24522
|
-
});
|
|
24523
|
-
return {
|
|
24524
|
-
message,
|
|
24525
|
-
signature
|
|
24526
|
-
};
|
|
24527
|
-
},
|
|
24528
|
-
[signMessageAsync]
|
|
24529
|
-
);
|
|
24530
|
-
return { getNativeWalletSignature };
|
|
24540
|
+
const signMessage = useSignMessage2();
|
|
24541
|
+
const signTypedMessage = useSignTypedData();
|
|
24542
|
+
return {
|
|
24543
|
+
signMessage,
|
|
24544
|
+
/** EIP-712 signature */
|
|
24545
|
+
signTypedMessage,
|
|
24546
|
+
fetchProjectNameById: fetchProjectName
|
|
24547
|
+
};
|
|
24531
24548
|
}
|
|
24532
24549
|
var init_useNativeWalletSignature = __esm({
|
|
24533
24550
|
"src/hooks/useNativeWalletSignature.ts"() {
|
|
@@ -24537,11 +24554,11 @@ var init_useNativeWalletSignature = __esm({
|
|
|
24537
24554
|
|
|
24538
24555
|
// src/hooks/useLogout.ts
|
|
24539
24556
|
import { logout as coreLogout, jwtTokenManager as jwtTokenManager3 } from "@embarkai/core/auth";
|
|
24540
|
-
import { useCallback as
|
|
24557
|
+
import { useCallback as useCallback36 } from "react";
|
|
24541
24558
|
function useLogout() {
|
|
24542
24559
|
const { setSession, setIsLoading, setAddress, setStatus, setError, address } = useSession();
|
|
24543
24560
|
const { callbacksRef } = useProviderConfig();
|
|
24544
|
-
const logout2 =
|
|
24561
|
+
const logout2 = useCallback36(async () => {
|
|
24545
24562
|
const prevAddress = address;
|
|
24546
24563
|
let userId = null;
|
|
24547
24564
|
setIsLoading(true);
|
|
@@ -24632,13 +24649,13 @@ var init_clients2 = __esm({
|
|
|
24632
24649
|
// src/modules/transactions.ts
|
|
24633
24650
|
import { getViemChain as getViemChain4 } from "@embarkai/core/read";
|
|
24634
24651
|
import { parseEther as parseEther6 } from "viem";
|
|
24635
|
-
import { useAccount as
|
|
24652
|
+
import { useAccount as useAccount3, usePublicClient, useWalletClient } from "wagmi";
|
|
24636
24653
|
function useTransactions() {
|
|
24637
24654
|
const chainId = requireActiveChainId();
|
|
24638
24655
|
const viemChain = getViemChain4(chainId);
|
|
24639
24656
|
const publicClient = usePublicClient({ chainId });
|
|
24640
24657
|
const { data: walletClient } = useWalletClient();
|
|
24641
|
-
const { address } =
|
|
24658
|
+
const { address } = useAccount3();
|
|
24642
24659
|
const sendTransaction = async (params) => {
|
|
24643
24660
|
if (!walletClient) {
|
|
24644
24661
|
throw new Error("Wallet not connected");
|