@orderly.network/wallet-connector-privy 2.11.1 → 2.11.2-alpha.0
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/index.js +221 -127
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +223 -129
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
package/dist/index.mjs
CHANGED
|
@@ -5,8 +5,8 @@ import { createConfig, injected, createStorage, http, WagmiProvider, useConnect,
|
|
|
5
5
|
import * as WagmiConnectorsExport from 'wagmi/connectors';
|
|
6
6
|
import React19, { createContext, useState, useEffect, useMemo, useContext, useRef, useCallback } from 'react';
|
|
7
7
|
import { mainnet, abstract, abstractTestnet } from 'viem/chains';
|
|
8
|
-
import { useWalletConnector, useAccount, useMainnetChainsStore, useTestnetChainsStore, WalletConnectorContext,
|
|
9
|
-
import { SOLANA_TESTNET_CHAINID, SOLANA_MAINNET_CHAINID, ChainNamespace, ABSTRACT_CHAIN_ID_MAP, AccountStatusEnum, ABSTRACT_TESTNET_CHAINID, ABSTRACT_MAINNET_CHAINID, SolanaChains as SolanaChains$1, AbstractChains, ArbitrumSepoliaChainInfo, SolanaDevnetChainInfo, EMPTY_OBJECT, defaultMainnetChains, defaultTestnetChains,
|
|
8
|
+
import { useWalletConnector, useAccount, useMainnetChainsStore, useTestnetChainsStore, WalletConnectorContext, useEventEmitter, useStorageLedgerAddress, useTrack, useLocalStorage, useStorageChain } from '@orderly.network/hooks';
|
|
9
|
+
import { SOLANA_TESTNET_CHAINID, SOLANA_MAINNET_CHAINID, ChainNamespace, ABSTRACT_CHAIN_ID_MAP, AccountStatusEnum, ABSTRACT_TESTNET_CHAINID, ABSTRACT_MAINNET_CHAINID, SolanaChains as SolanaChains$1, AbstractChains, ArbitrumSepoliaChainInfo, SolanaDevnetChainInfo, EMPTY_OBJECT, defaultMainnetChains, defaultTestnetChains, ConnectorKey, TrackerEventName } from '@orderly.network/types';
|
|
10
10
|
import { modal, useModal, SimpleSheet, SheetHeader, Text, Flex, Divider, cn, installExtension, ExtensionPositionEnum, useScreen, formatAddress, Button, SimpleDialog, TooltipProvider, CloseSquareFillIcon, ScrollArea, ExclamationFillIcon, Tooltip, CopyIcon, Checkbox, toast, DropdownMenuRoot, DropdownMenuTrigger, DropdownMenuPortal, DropdownMenuContent, DropdownMenuItem, ChevronDownIcon, ChevronUpIcon, Grid, ChainIcon, Popover } from '@orderly.network/ui';
|
|
11
11
|
import { useTranslation, Trans } from '@orderly.network/i18n';
|
|
12
12
|
import { AbstractWalletProvider as AbstractWalletProvider$1, useLoginWithAbstract, useAbstractClient, useGlobalWalletSignerAccount } from '@abstract-foundation/agw-react';
|
|
@@ -163,16 +163,35 @@ var getPrivyEmbeddedWalletChainId = (chainId) => {
|
|
|
163
163
|
}
|
|
164
164
|
return parseInt(chainId.split("eip155:")[1]);
|
|
165
165
|
};
|
|
166
|
-
var
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
166
|
+
var defaultPrivyWalletContextValue = {
|
|
167
|
+
connect: () => {
|
|
168
|
+
},
|
|
169
|
+
walletEVM: null,
|
|
170
|
+
walletSOL: null,
|
|
171
|
+
allWalletsEVM: [],
|
|
172
|
+
allWalletsSOL: [],
|
|
173
|
+
isConnected: false,
|
|
174
|
+
switchChain: () => Promise.reject(new Error("Privy is disabled")),
|
|
175
|
+
linkedAccount: null,
|
|
176
|
+
exportWallet: () => Promise.reject(new Error("Privy is disabled")),
|
|
177
|
+
createEvmWallet: () => Promise.reject(new Error("Privy is disabled")),
|
|
178
|
+
createSolanaWallet: () => Promise.reject(new Error("Privy is disabled")),
|
|
179
|
+
selectWallet: () => {
|
|
180
|
+
},
|
|
181
|
+
disconnect: () => Promise.resolve()
|
|
171
182
|
};
|
|
172
|
-
var defaultUseWallets = { wallets: [] };
|
|
173
183
|
var PrivyWalletContext = createContext(null);
|
|
174
184
|
var PrivyWalletProvider = ({
|
|
175
185
|
children
|
|
186
|
+
}) => {
|
|
187
|
+
const { connectorWalletType } = useWalletConnectorPrivy();
|
|
188
|
+
if (connectorWalletType.disablePrivy) {
|
|
189
|
+
return /* @__PURE__ */ React19.createElement(PrivyWalletContext.Provider, { value: defaultPrivyWalletContextValue }, children);
|
|
190
|
+
}
|
|
191
|
+
return /* @__PURE__ */ React19.createElement(PrivyWalletProviderInner, null, children);
|
|
192
|
+
};
|
|
193
|
+
var PrivyWalletProviderInner = ({
|
|
194
|
+
children
|
|
176
195
|
}) => {
|
|
177
196
|
const { network, solanaInfo, setSolanaInfo, connectorWalletType } = useWalletConnectorPrivy();
|
|
178
197
|
const {
|
|
@@ -184,66 +203,115 @@ var PrivyWalletProvider = ({
|
|
|
184
203
|
exportWallet: exportEvmWallet,
|
|
185
204
|
createWallet: createEvmWallet
|
|
186
205
|
} = usePrivy();
|
|
187
|
-
const { wallets: walletsEVM } =
|
|
206
|
+
const { wallets: walletsEVM } = useWallets();
|
|
188
207
|
const connectedRef = useRef(false);
|
|
189
208
|
const {
|
|
190
209
|
ready: solanaReady,
|
|
191
210
|
wallets: walletsSOL,
|
|
192
211
|
createWallet: createSolanaWallet,
|
|
193
212
|
exportWallet: exportSolanaWallet
|
|
194
|
-
} =
|
|
213
|
+
} = useSolanaWallets();
|
|
195
214
|
const [walletEVM, setWalletEVM] = useState(null);
|
|
196
215
|
const [walletSOL, setWalletSOL] = useState(null);
|
|
216
|
+
const [allWalletsEVM, setAllWalletsEVM] = useState([]);
|
|
217
|
+
const [allWalletsSOL, setAllWalletsSOL] = useState([]);
|
|
218
|
+
const [selectedEvmAddress, setSelectedEvmAddress] = useLocalStorage(
|
|
219
|
+
"privy_selected_evm_address",
|
|
220
|
+
""
|
|
221
|
+
);
|
|
222
|
+
const [selectedSolAddress, setSelectedSolAddress] = useLocalStorage(
|
|
223
|
+
"privy_selected_sol_address",
|
|
224
|
+
""
|
|
225
|
+
);
|
|
226
|
+
const rawEvmWalletsRef = useRef(/* @__PURE__ */ new Map());
|
|
197
227
|
const { track } = useTrack();
|
|
198
228
|
const linkedAccount = useMemo(() => {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
if (account.type === "email") {
|
|
205
|
-
address = account.address;
|
|
206
|
-
} else if (account.type === "twitter_oauth") {
|
|
207
|
-
address = `@${account.username}`;
|
|
208
|
-
} else if (account.type === "google_oauth") {
|
|
209
|
-
address = `@${account.name}`;
|
|
210
|
-
} else if (account.type === "telegram") {
|
|
211
|
-
address = `@${account.username}`;
|
|
212
|
-
}
|
|
213
|
-
return {
|
|
214
|
-
type: account.type,
|
|
215
|
-
address
|
|
216
|
-
};
|
|
229
|
+
const account = user?.linkedAccounts?.filter((item) => item.type !== "wallet" && item.type !== "smart_wallet").sort(
|
|
230
|
+
(a, b) => (b.latestVerifiedAt?.getTime() ?? 0) - (a.latestVerifiedAt?.getTime() ?? 0)
|
|
231
|
+
)[0];
|
|
232
|
+
if (!account) {
|
|
233
|
+
return null;
|
|
217
234
|
}
|
|
218
|
-
|
|
235
|
+
let address = null;
|
|
236
|
+
if (account.type === "email") {
|
|
237
|
+
address = account.address;
|
|
238
|
+
} else if (account.type === "twitter_oauth") {
|
|
239
|
+
address = `@${account.username}`;
|
|
240
|
+
} else if (account.type === "google_oauth") {
|
|
241
|
+
address = `@${account.name}`;
|
|
242
|
+
} else if (account.type === "telegram") {
|
|
243
|
+
address = `@${account.username}`;
|
|
244
|
+
}
|
|
245
|
+
return {
|
|
246
|
+
type: account.type,
|
|
247
|
+
address
|
|
248
|
+
};
|
|
219
249
|
}, [user]);
|
|
220
250
|
const switchChain = (chainId) => {
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
251
|
+
const selectedAddress = walletEVM?.accounts[0]?.address;
|
|
252
|
+
const rawWallet = selectedAddress ? rawEvmWalletsRef.current.get(selectedAddress) : void 0;
|
|
253
|
+
if (rawWallet) {
|
|
254
|
+
return rawWallet.switchChain(chainId);
|
|
255
|
+
}
|
|
256
|
+
const fallback = walletsEVM.find((w) => w.connectorType === "embedded") ?? walletsEVM[0];
|
|
257
|
+
if (fallback) {
|
|
258
|
+
return fallback.switchChain(chainId);
|
|
224
259
|
}
|
|
225
260
|
return Promise.reject("no wallet");
|
|
226
261
|
};
|
|
227
|
-
const connect = () => {
|
|
262
|
+
const connect = (params) => {
|
|
263
|
+
if (params?.extraType) {
|
|
264
|
+
login({ loginMethods: [params.extraType] });
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
228
267
|
login();
|
|
229
268
|
};
|
|
230
269
|
const disconnect = () => {
|
|
231
270
|
return logout();
|
|
232
271
|
};
|
|
233
|
-
const exportWallet = (namespace) => {
|
|
272
|
+
const exportWallet = (namespace, address) => {
|
|
234
273
|
if (namespace === ChainNamespace.evm) {
|
|
235
274
|
track(TrackerEventName.clickExportPrivateKey, {
|
|
236
275
|
type: "evm"
|
|
237
276
|
});
|
|
238
|
-
|
|
277
|
+
const addr = address ?? walletEVM?.accounts[0]?.address;
|
|
278
|
+
return exportEvmWallet(addr ? { address: addr } : void 0);
|
|
239
279
|
} else if (namespace === ChainNamespace.solana) {
|
|
240
280
|
track(TrackerEventName.clickExportPrivateKey, {
|
|
241
281
|
type: "solana"
|
|
242
282
|
});
|
|
243
|
-
|
|
283
|
+
const addr = address ?? walletSOL?.accounts[0]?.address;
|
|
284
|
+
return exportSolanaWallet(addr ? { address: addr } : void 0);
|
|
244
285
|
}
|
|
245
286
|
return Promise.reject("no namespace");
|
|
246
287
|
};
|
|
288
|
+
const selectWallet = useCallback(
|
|
289
|
+
(namespace, address) => {
|
|
290
|
+
if (namespace === ChainNamespace.evm) {
|
|
291
|
+
const found = allWalletsEVM.find(
|
|
292
|
+
(w) => w.accounts[0]?.address === address
|
|
293
|
+
);
|
|
294
|
+
if (found) {
|
|
295
|
+
setWalletEVM(found);
|
|
296
|
+
setSelectedEvmAddress(address);
|
|
297
|
+
}
|
|
298
|
+
} else if (namespace === ChainNamespace.solana) {
|
|
299
|
+
const found = allWalletsSOL.find(
|
|
300
|
+
(w) => w.accounts[0]?.address === address
|
|
301
|
+
);
|
|
302
|
+
if (found) {
|
|
303
|
+
setWalletSOL(found);
|
|
304
|
+
setSelectedSolAddress(address);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
},
|
|
308
|
+
[
|
|
309
|
+
allWalletsEVM,
|
|
310
|
+
allWalletsSOL,
|
|
311
|
+
setSelectedEvmAddress,
|
|
312
|
+
setSelectedSolAddress
|
|
313
|
+
]
|
|
314
|
+
);
|
|
247
315
|
const isConnected = useMemo(() => {
|
|
248
316
|
if (ready && authenticated) {
|
|
249
317
|
return true;
|
|
@@ -252,76 +320,81 @@ var PrivyWalletProvider = ({
|
|
|
252
320
|
}, [ready, authenticated]);
|
|
253
321
|
useEffect(() => {
|
|
254
322
|
if (!authenticated || !walletsEVM || !walletsEVM[0]) {
|
|
323
|
+
setAllWalletsEVM([]);
|
|
255
324
|
setWalletEVM(null);
|
|
256
325
|
return;
|
|
257
326
|
}
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
{
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
327
|
+
const embeddedWallets = walletsEVM.filter(
|
|
328
|
+
(w) => w.connectorType === "embedded"
|
|
329
|
+
);
|
|
330
|
+
const wallets = embeddedWallets.length > 0 ? embeddedWallets : [walletsEVM[0]];
|
|
331
|
+
const newMap = /* @__PURE__ */ new Map();
|
|
332
|
+
for (const w of wallets) {
|
|
333
|
+
newMap.set(w.address, w);
|
|
334
|
+
}
|
|
335
|
+
rawEvmWalletsRef.current = newMap;
|
|
336
|
+
Promise.all(
|
|
337
|
+
wallets.map(
|
|
338
|
+
(w) => w.getEthereumProvider().then(
|
|
339
|
+
(provider) => ({
|
|
340
|
+
label: "privy",
|
|
341
|
+
icon: "",
|
|
342
|
+
provider,
|
|
343
|
+
accounts: [{ address: w.address }],
|
|
344
|
+
chains: [
|
|
345
|
+
{
|
|
346
|
+
id: getPrivyEmbeddedWalletChainId(w.chainId) ?? 1,
|
|
347
|
+
namespace: ChainNamespace.evm
|
|
348
|
+
}
|
|
349
|
+
],
|
|
350
|
+
chain: {
|
|
351
|
+
id: getPrivyEmbeddedWalletChainId(w.chainId) ?? 1,
|
|
352
|
+
namespace: ChainNamespace.evm
|
|
353
|
+
}
|
|
354
|
+
})
|
|
355
|
+
)
|
|
356
|
+
)
|
|
357
|
+
).then((builtWallets) => {
|
|
358
|
+
setAllWalletsEVM(builtWallets);
|
|
359
|
+
const preferred = selectedEvmAddress ? builtWallets.find(
|
|
360
|
+
(w) => w.accounts[0]?.address === selectedEvmAddress
|
|
361
|
+
) : void 0;
|
|
362
|
+
setWalletEVM(preferred ?? builtWallets[0] ?? null);
|
|
363
|
+
}).catch((e) => {
|
|
364
|
+
setAllWalletsEVM([]);
|
|
365
|
+
setWalletEVM(null);
|
|
280
366
|
});
|
|
281
367
|
}, [walletsEVM, authenticated]);
|
|
282
368
|
useEffect(() => {
|
|
283
369
|
if (!authenticated) {
|
|
370
|
+
setAllWalletsSOL([]);
|
|
284
371
|
setWalletSOL(null);
|
|
285
372
|
return;
|
|
286
373
|
}
|
|
287
374
|
if (!solanaReady) {
|
|
288
375
|
return;
|
|
289
376
|
}
|
|
290
|
-
if (!user) {
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
const embededSolanaWallet = (user?.linkedAccounts).find(
|
|
294
|
-
(item) => item.chainType === "solana" && item.connectorType === "embedded"
|
|
295
|
-
);
|
|
296
|
-
if (!embededSolanaWallet) {
|
|
297
|
-
createSolanaWallet().then();
|
|
298
|
-
return;
|
|
299
|
-
}
|
|
300
377
|
if (!walletsSOL || !walletsSOL[0]) {
|
|
378
|
+
setAllWalletsSOL([]);
|
|
379
|
+
setWalletSOL(null);
|
|
301
380
|
return;
|
|
302
381
|
}
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
}
|
|
310
|
-
setWalletSOL({
|
|
382
|
+
const embeddedWallets = walletsSOL.filter(
|
|
383
|
+
(w) => w.connectorType === "embedded"
|
|
384
|
+
);
|
|
385
|
+
const wallets = embeddedWallets.length > 0 ? embeddedWallets : [walletsSOL[0]];
|
|
386
|
+
const builtWallets = wallets.map(
|
|
387
|
+
(w) => ({
|
|
311
388
|
label: "privy",
|
|
312
389
|
icon: "",
|
|
313
390
|
provider: {
|
|
314
|
-
signMessage:
|
|
315
|
-
signTransaction:
|
|
316
|
-
sendTransaction:
|
|
391
|
+
signMessage: w.signMessage,
|
|
392
|
+
signTransaction: w.signTransaction,
|
|
393
|
+
sendTransaction: w.sendTransaction,
|
|
317
394
|
network: solanaInfo?.network ?? WalletAdapterNetwork.Devnet,
|
|
318
395
|
rpcUrl: solanaInfo?.rpcUrl ?? void 0
|
|
319
396
|
},
|
|
320
|
-
accounts: [
|
|
321
|
-
{
|
|
322
|
-
address: wallet.address
|
|
323
|
-
}
|
|
324
|
-
],
|
|
397
|
+
accounts: [{ address: w.address }],
|
|
325
398
|
chains: [
|
|
326
399
|
{
|
|
327
400
|
id: SolanaChainsMap.get(network),
|
|
@@ -332,18 +405,12 @@ var PrivyWalletProvider = ({
|
|
|
332
405
|
id: SolanaChainsMap.get(network),
|
|
333
406
|
namespace: ChainNamespace.solana
|
|
334
407
|
}
|
|
335
|
-
})
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
solanaReady,
|
|
342
|
-
user,
|
|
343
|
-
walletSOL,
|
|
344
|
-
network,
|
|
345
|
-
solanaInfo
|
|
346
|
-
]);
|
|
408
|
+
})
|
|
409
|
+
);
|
|
410
|
+
setAllWalletsSOL(builtWallets);
|
|
411
|
+
const preferred = selectedSolAddress ? builtWallets.find((w) => w.accounts[0]?.address === selectedSolAddress) : void 0;
|
|
412
|
+
setWalletSOL(preferred ?? builtWallets[0] ?? null);
|
|
413
|
+
}, [walletsSOL, authenticated, solanaReady, network, solanaInfo]);
|
|
347
414
|
useEffect(() => {
|
|
348
415
|
if (isConnected && linkedAccount) {
|
|
349
416
|
if (connectedRef.current) {
|
|
@@ -361,25 +428,31 @@ var PrivyWalletProvider = ({
|
|
|
361
428
|
connect,
|
|
362
429
|
walletEVM,
|
|
363
430
|
walletSOL,
|
|
431
|
+
allWalletsEVM,
|
|
432
|
+
allWalletsSOL,
|
|
364
433
|
isConnected,
|
|
365
434
|
disconnect,
|
|
366
435
|
switchChain,
|
|
367
436
|
linkedAccount,
|
|
368
437
|
exportWallet,
|
|
369
438
|
createEvmWallet,
|
|
370
|
-
createSolanaWallet
|
|
439
|
+
createSolanaWallet,
|
|
440
|
+
selectWallet
|
|
371
441
|
}),
|
|
372
442
|
[
|
|
373
443
|
connect,
|
|
374
444
|
walletEVM,
|
|
375
445
|
walletSOL,
|
|
446
|
+
allWalletsEVM,
|
|
447
|
+
allWalletsSOL,
|
|
376
448
|
isConnected,
|
|
377
449
|
disconnect,
|
|
378
450
|
switchChain,
|
|
379
451
|
linkedAccount,
|
|
380
452
|
exportWallet,
|
|
381
453
|
createEvmWallet,
|
|
382
|
-
createSolanaWallet
|
|
454
|
+
createSolanaWallet,
|
|
455
|
+
selectWallet
|
|
383
456
|
]
|
|
384
457
|
);
|
|
385
458
|
return /* @__PURE__ */ React19.createElement(PrivyWalletContext.Provider, { value }, children);
|
|
@@ -1966,7 +2039,8 @@ function PrivyWalletHandleOption({
|
|
|
1966
2039
|
{
|
|
1967
2040
|
className: "oui-cursor-pointer oui-px-2 oui-py-1 oui-text-2xs oui-text-base-contrast-54 hover:oui-text-base-contrast",
|
|
1968
2041
|
onClick: () => {
|
|
1969
|
-
|
|
2042
|
+
const ns = type === "EVM" /* EVM */ ? ChainNamespace.evm : ChainNamespace.solana;
|
|
2043
|
+
exportWallet(ns, address);
|
|
1970
2044
|
}
|
|
1971
2045
|
},
|
|
1972
2046
|
/* @__PURE__ */ React19.createElement("div", null, t("common.export"))
|
|
@@ -2485,33 +2559,38 @@ function RenderPrivyWallet() {
|
|
|
2485
2559
|
walletChainTypeConfig,
|
|
2486
2560
|
connectorWalletType
|
|
2487
2561
|
} = useWalletConnectorPrivy();
|
|
2488
|
-
const {
|
|
2562
|
+
const {
|
|
2563
|
+
walletEVM,
|
|
2564
|
+
walletSOL,
|
|
2565
|
+
allWalletsEVM,
|
|
2566
|
+
allWalletsSOL,
|
|
2567
|
+
linkedAccount,
|
|
2568
|
+
selectWallet
|
|
2569
|
+
} = usePrivyWallet();
|
|
2489
2570
|
const { switchWallet, disconnect } = useWallet2();
|
|
2490
2571
|
const { storageChain } = useStorageChain();
|
|
2491
2572
|
const [walletList, setWalletList] = useState([]);
|
|
2492
2573
|
const [addWallet, setAddWallet] = useState([]);
|
|
2493
2574
|
const [loading, setLoading] = useState(true);
|
|
2494
2575
|
const isActive = useCallback(
|
|
2495
|
-
(walletType) => {
|
|
2576
|
+
(walletType, address) => {
|
|
2496
2577
|
if (storageChain?.namespace === ChainNamespace.evm) {
|
|
2497
2578
|
if (walletType === "EVM" /* EVM */) {
|
|
2498
|
-
|
|
2579
|
+
if (AbstractChains.has(storageChain?.chainId)) return false;
|
|
2580
|
+
return walletEVM?.accounts[0]?.address === address;
|
|
2499
2581
|
}
|
|
2500
2582
|
return false;
|
|
2501
2583
|
}
|
|
2502
2584
|
if (storageChain?.namespace === ChainNamespace.solana) {
|
|
2503
|
-
|
|
2585
|
+
if (walletType === "SOL" /* SOL */) {
|
|
2586
|
+
return walletSOL?.accounts[0]?.address === address;
|
|
2587
|
+
}
|
|
2588
|
+
return false;
|
|
2504
2589
|
}
|
|
2505
2590
|
return false;
|
|
2506
2591
|
},
|
|
2507
|
-
[storageChain]
|
|
2592
|
+
[storageChain, walletEVM, walletSOL]
|
|
2508
2593
|
);
|
|
2509
|
-
const isHaveEvmWallet = useMemo(() => {
|
|
2510
|
-
return walletEVM && walletEVM.accounts.length;
|
|
2511
|
-
}, [walletEVM]);
|
|
2512
|
-
const isHaveSolWallet = useMemo(() => {
|
|
2513
|
-
return walletSOL && walletSOL.accounts.length;
|
|
2514
|
-
}, [walletSOL]);
|
|
2515
2594
|
const renderWarning = useCallback(() => {
|
|
2516
2595
|
let showWarning = false;
|
|
2517
2596
|
if (AbstractChains.has(storageChain?.chainId)) {
|
|
@@ -2552,18 +2631,31 @@ function RenderPrivyWallet() {
|
|
|
2552
2631
|
return /* @__PURE__ */ React19.createElement("div", { className: "oui-mt-5 oui-flex oui-flex-col oui-gap-5" }, walletList.map((wallet) => /* @__PURE__ */ React19.createElement(
|
|
2553
2632
|
WalletCard,
|
|
2554
2633
|
{
|
|
2555
|
-
key: wallet.
|
|
2634
|
+
key: wallet.address,
|
|
2556
2635
|
type: wallet.type,
|
|
2557
2636
|
address: wallet.address,
|
|
2558
|
-
isActive: isActive(wallet.type),
|
|
2637
|
+
isActive: isActive(wallet.type, wallet.address),
|
|
2559
2638
|
isPrivy: true,
|
|
2560
2639
|
isMulti: walletList.length > 1,
|
|
2561
2640
|
onActiveChange: () => {
|
|
2562
|
-
|
|
2641
|
+
const walletNamespace = wallet.type === "EVM" /* EVM */ ? ChainNamespace.evm : ChainNamespace.solana;
|
|
2642
|
+
selectWallet(walletNamespace, wallet.address);
|
|
2643
|
+
if (storageChain?.namespace !== walletNamespace) {
|
|
2644
|
+
switchWallet(wallet.type);
|
|
2645
|
+
}
|
|
2563
2646
|
}
|
|
2564
2647
|
}
|
|
2565
2648
|
)), addWallet.map((node, index) => /* @__PURE__ */ React19.createElement("div", { key: index }, /* @__PURE__ */ React19.createElement("div", { className: "oui-my-5 oui-h-px oui-w-full oui-bg-line" }), /* @__PURE__ */ React19.createElement("div", { className: "oui-flex oui-w-full oui-flex-col oui-gap-2" }, node))));
|
|
2566
|
-
}, [
|
|
2649
|
+
}, [
|
|
2650
|
+
walletList,
|
|
2651
|
+
addWallet,
|
|
2652
|
+
isActive,
|
|
2653
|
+
switchWallet,
|
|
2654
|
+
selectWallet,
|
|
2655
|
+
storageChain,
|
|
2656
|
+
t,
|
|
2657
|
+
loading
|
|
2658
|
+
]);
|
|
2567
2659
|
useEffect(() => {
|
|
2568
2660
|
new Promise(
|
|
2569
2661
|
(resolve) => setTimeout(() => {
|
|
@@ -2576,21 +2668,25 @@ function RenderPrivyWallet() {
|
|
|
2576
2668
|
const tempWalletList = [];
|
|
2577
2669
|
const tempAddWallet = [];
|
|
2578
2670
|
if (!connectorWalletType.disableWagmi && walletChainTypeConfig.hasEvm) {
|
|
2579
|
-
if (
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2671
|
+
if (allWalletsEVM.length > 0) {
|
|
2672
|
+
for (const w of allWalletsEVM) {
|
|
2673
|
+
tempWalletList.push({
|
|
2674
|
+
type: "EVM" /* EVM */,
|
|
2675
|
+
address: w.accounts[0].address
|
|
2676
|
+
});
|
|
2677
|
+
}
|
|
2584
2678
|
} else {
|
|
2585
2679
|
tempAddWallet.push(/* @__PURE__ */ React19.createElement(CreateEVMWallet, null));
|
|
2586
2680
|
}
|
|
2587
2681
|
}
|
|
2588
2682
|
if (!connectorWalletType.disableSolana && walletChainTypeConfig.hasSol) {
|
|
2589
|
-
if (
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2683
|
+
if (allWalletsSOL.length > 0) {
|
|
2684
|
+
for (const w of allWalletsSOL) {
|
|
2685
|
+
tempWalletList.push({
|
|
2686
|
+
type: "SOL" /* SOL */,
|
|
2687
|
+
address: w.accounts[0].address
|
|
2688
|
+
});
|
|
2689
|
+
}
|
|
2594
2690
|
} else {
|
|
2595
2691
|
tempAddWallet.push(/* @__PURE__ */ React19.createElement(CreateSOLWallet, null));
|
|
2596
2692
|
}
|
|
@@ -2600,10 +2696,8 @@ function RenderPrivyWallet() {
|
|
|
2600
2696
|
}, [
|
|
2601
2697
|
connectorWalletType,
|
|
2602
2698
|
walletChainTypeConfig,
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
isHaveEvmWallet,
|
|
2606
|
-
isHaveSolWallet
|
|
2699
|
+
allWalletsEVM,
|
|
2700
|
+
allWalletsSOL
|
|
2607
2701
|
]);
|
|
2608
2702
|
useEffect(() => {
|
|
2609
2703
|
if (targetWalletType === "Abstract" /* ABSTRACT */) {
|
|
@@ -2614,7 +2708,7 @@ function RenderPrivyWallet() {
|
|
|
2614
2708
|
});
|
|
2615
2709
|
}
|
|
2616
2710
|
}, [targetWalletType, setTargetWalletType]);
|
|
2617
|
-
return /* @__PURE__ */ React19.createElement("div",
|
|
2711
|
+
return /* @__PURE__ */ React19.createElement("div", { className: "oui-flex oui-max-h-[70vh] oui-flex-col oui-overflow-y-auto oui-custom-scrollbar" }, /* @__PURE__ */ React19.createElement("div", { className: "oui-flex oui-items-center oui-justify-between" }, linkedAccount && /* @__PURE__ */ React19.createElement("div", { className: "oui-flex oui-items-center oui-justify-start oui-gap-2 oui-text-base-contrast" }, /* @__PURE__ */ React19.createElement("div", null, /* @__PURE__ */ React19.createElement(RenderPrivyTypeIcon, { type: linkedAccount.type, size: 24 })), /* @__PURE__ */ React19.createElement("div", { className: "oui-text-xs" }, linkedAccount.address)), /* @__PURE__ */ React19.createElement(
|
|
2618
2712
|
"div",
|
|
2619
2713
|
{
|
|
2620
2714
|
className: "oui-cursor-pointer oui-text-2xs oui-font-semibold oui-text-primary",
|