@orderly.network/wallet-connector-privy 2.1.3 → 2.2.0-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.d.mts +36 -8
- package/dist/index.d.ts +36 -8
- package/dist/index.js +1379 -857
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1312 -792
- package/dist/index.mjs.map +1 -1
- package/package.json +22 -20
package/dist/index.mjs
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import React19, { createContext, useMemo, useContext, useState, useRef, useEffect, useCallback } from 'react';
|
|
2
|
+
import * as viemExport from 'viem';
|
|
3
|
+
import { defineChain } from 'viem';
|
|
4
|
+
import { mainnet, abstract, abstractTestnet } from 'viem/chains';
|
|
5
|
+
import { SOLANA_TESTNET_CHAINID, SOLANA_MAINNET_CHAINID, ABSTRACT_CHAIN_ID_MAP, AccountStatusEnum, ABSTRACT_TESTNET_CHAINID, ABSTRACT_MAINNET_CHAINID, SolanaChains as SolanaChains$1, AbstractChains, AbstractTestnetChainInfo, ArbitrumSepoliaChainInfo, SolanaDevnetChainInfo, ChainNamespace, TrackerEventName, ConnectorKey } from '@orderly.network/types';
|
|
6
|
+
import { installExtension, ExtensionPositionEnum, useScreen, Button, Text, formatAddress, cn, TooltipProvider, CloseIcon, ExclamationFillIcon, Tooltip, CopyIcon, Checkbox, toast, DropdownMenuRoot, DropdownMenuTrigger, DropdownMenuPortal, DropdownMenuContent, DropdownMenuItem, ChevronDownIcon, ChevronUpIcon, SimpleDialog, ChainIcon, Popover } from '@orderly.network/ui';
|
|
7
|
+
import { useWalletConnector, useAccount, WalletConnectorContext, useTrack, useStorageLedgerAddress, useLocalStorage, useStorageChain } from '@orderly.network/hooks';
|
|
8
|
+
import { useTranslation, Trans } from '@orderly.network/i18n';
|
|
9
|
+
import { AbstractWalletProvider as AbstractWalletProvider$1, useLoginWithAbstract, useAbstractClient, useGlobalWalletSignerAccount } from '@abstract-foundation/agw-react';
|
|
10
|
+
import * as WagmiExport from 'wagmi';
|
|
11
|
+
import { createConfig, injected, createStorage, http, WagmiProvider, useConnect, useDisconnect, useAccount as useAccount$1, useSwitchChain } from 'wagmi';
|
|
12
|
+
import { windowGuard } from '@orderly.network/utils';
|
|
6
13
|
import { WalletAdapterNetwork } from '@solana/wallet-adapter-base';
|
|
14
|
+
import { PrivyProvider, usePrivy, useWallets, useSolanaWallets } from '@privy-io/react-auth';
|
|
7
15
|
import { WalletProvider, useWallet } from '@solana/wallet-adapter-react';
|
|
8
|
-
import * as WagmiExport from 'wagmi';
|
|
9
|
-
import { createConfig, injected, createStorage, http, WagmiProvider, useConnect, useDisconnect, useAccount, useSwitchChain } from 'wagmi';
|
|
10
|
-
import { useTranslation, Trans } from '@orderly.network/i18n';
|
|
11
16
|
import { createPortal } from 'react-dom';
|
|
12
17
|
import { AuthGuard } from '@orderly.network/ui-connector';
|
|
13
|
-
import * as viemExport from 'viem';
|
|
14
|
-
import { defineChain } from 'viem';
|
|
15
|
-
import { mainnet } from 'viem/chains';
|
|
16
18
|
import { PhantomWalletAdapter } from '@solana/wallet-adapter-wallets';
|
|
17
19
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
18
20
|
import * as WagmiConnectorsExport from 'wagmi/connectors';
|
|
@@ -23,18 +25,32 @@ var Network = /* @__PURE__ */ ((Network2) => {
|
|
|
23
25
|
Network2["testnet"] = "testnet";
|
|
24
26
|
return Network2;
|
|
25
27
|
})(Network || {});
|
|
26
|
-
var WalletType = /* @__PURE__ */ ((
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return
|
|
28
|
+
var WalletType = /* @__PURE__ */ ((WalletType5) => {
|
|
29
|
+
WalletType5["EVM"] = "EVM";
|
|
30
|
+
WalletType5["SOL"] = "SOL";
|
|
31
|
+
WalletType5["ABSTRACT"] = "Abstract";
|
|
32
|
+
return WalletType5;
|
|
31
33
|
})(WalletType || {});
|
|
32
|
-
var
|
|
34
|
+
var WalletConnectType = /* @__PURE__ */ ((WalletConnectType2) => {
|
|
35
|
+
WalletConnectType2["EVM"] = "EVM";
|
|
36
|
+
WalletConnectType2["SOL"] = "SOL";
|
|
37
|
+
WalletConnectType2["PRIVY"] = "privy";
|
|
38
|
+
WalletConnectType2["ABSTRACT"] = "Abstract";
|
|
39
|
+
return WalletConnectType2;
|
|
40
|
+
})(WalletConnectType || {});
|
|
41
|
+
var SolanaChains = /* @__PURE__ */ new Map([
|
|
42
|
+
[WalletAdapterNetwork.Devnet, SOLANA_TESTNET_CHAINID],
|
|
43
|
+
[WalletAdapterNetwork.Mainnet, SOLANA_MAINNET_CHAINID]
|
|
44
|
+
]);
|
|
33
45
|
var SolanaChainsMap = /* @__PURE__ */ new Map([
|
|
34
|
-
[WalletAdapterNetwork.Devnet,
|
|
35
|
-
["testnet" /* testnet */,
|
|
36
|
-
["mainnet" /* mainnet */,
|
|
37
|
-
[WalletAdapterNetwork.Mainnet,
|
|
46
|
+
[WalletAdapterNetwork.Devnet, SOLANA_TESTNET_CHAINID],
|
|
47
|
+
["testnet" /* testnet */, SOLANA_TESTNET_CHAINID],
|
|
48
|
+
["mainnet" /* mainnet */, SOLANA_MAINNET_CHAINID],
|
|
49
|
+
[WalletAdapterNetwork.Mainnet, SOLANA_MAINNET_CHAINID]
|
|
50
|
+
]);
|
|
51
|
+
var AbstractChainsMap = /* @__PURE__ */ new Map([
|
|
52
|
+
["testnet" /* testnet */, ABSTRACT_TESTNET_CHAINID],
|
|
53
|
+
["mainnet" /* mainnet */, ABSTRACT_MAINNET_CHAINID]
|
|
38
54
|
]);
|
|
39
55
|
var WalletChainTypeEnum = /* @__PURE__ */ ((WalletChainTypeEnum2) => {
|
|
40
56
|
WalletChainTypeEnum2["onlyEVM"] = "onlyEVM";
|
|
@@ -43,7 +59,104 @@ var WalletChainTypeEnum = /* @__PURE__ */ ((WalletChainTypeEnum2) => {
|
|
|
43
59
|
return WalletChainTypeEnum2;
|
|
44
60
|
})(WalletChainTypeEnum || {});
|
|
45
61
|
|
|
46
|
-
// src/providers/
|
|
62
|
+
// src/providers/abstractWallet/abstractWalletProvider.tsx
|
|
63
|
+
var AbstractWalletContext = createContext(
|
|
64
|
+
null
|
|
65
|
+
);
|
|
66
|
+
var AbstractWalletProvider = (props) => {
|
|
67
|
+
const { network } = useWalletConnectorPrivy();
|
|
68
|
+
const { login, logout } = useLoginWithAbstract();
|
|
69
|
+
const [wallet, setWallet] = useState(null);
|
|
70
|
+
const { data: client, isLoading: isClientLoading } = useAbstractClient();
|
|
71
|
+
const { connector } = useAccount$1();
|
|
72
|
+
const { address, status } = useGlobalWalletSignerAccount();
|
|
73
|
+
const connect = () => {
|
|
74
|
+
return login();
|
|
75
|
+
};
|
|
76
|
+
const disconnect = () => {
|
|
77
|
+
return logout();
|
|
78
|
+
};
|
|
79
|
+
const isConnected = useMemo(() => {
|
|
80
|
+
return !!(client && connector);
|
|
81
|
+
}, [client, connector]);
|
|
82
|
+
const connectedChain = useMemo(() => {
|
|
83
|
+
if (!client || !connector) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
id: AbstractChainsMap.get(network),
|
|
88
|
+
namespace: ChainNamespace.evm
|
|
89
|
+
};
|
|
90
|
+
}, [client, connector]);
|
|
91
|
+
const value = useMemo(
|
|
92
|
+
() => ({
|
|
93
|
+
isConnected,
|
|
94
|
+
connect,
|
|
95
|
+
disconnect,
|
|
96
|
+
wallet,
|
|
97
|
+
connectedChain
|
|
98
|
+
}),
|
|
99
|
+
[connect, disconnect, isConnected, wallet, connectedChain]
|
|
100
|
+
);
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
if (!client || !connector || !address) {
|
|
103
|
+
setWallet(null);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
connector?.getProvider().then((provider) => {
|
|
107
|
+
const tempWallet = {
|
|
108
|
+
label: "AGW",
|
|
109
|
+
icon: "",
|
|
110
|
+
provider: {
|
|
111
|
+
...provider,
|
|
112
|
+
agwWallet: true,
|
|
113
|
+
sendTransaction: async (params) => {
|
|
114
|
+
return client.sendTransaction(params);
|
|
115
|
+
},
|
|
116
|
+
writeContract: async (params) => {
|
|
117
|
+
return client.writeContract(params);
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
accounts: [
|
|
121
|
+
{
|
|
122
|
+
address
|
|
123
|
+
}
|
|
124
|
+
],
|
|
125
|
+
chains: [
|
|
126
|
+
{
|
|
127
|
+
id: AbstractChainsMap.get(network),
|
|
128
|
+
namespace: ChainNamespace.evm
|
|
129
|
+
}
|
|
130
|
+
],
|
|
131
|
+
chain: connectedChain,
|
|
132
|
+
additionalInfo: {
|
|
133
|
+
AGWAddress: client.account.address
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
setWallet(tempWallet);
|
|
137
|
+
});
|
|
138
|
+
}, [client, connectedChain, connector, address, isClientLoading]);
|
|
139
|
+
useEffect(() => {
|
|
140
|
+
windowGuard(() => {
|
|
141
|
+
const connection = localStorage.getItem(
|
|
142
|
+
"privy-caw:cm04asygd041fmry9zmcyn5o5:connection"
|
|
143
|
+
);
|
|
144
|
+
if (connection) {
|
|
145
|
+
login();
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}, []);
|
|
149
|
+
return /* @__PURE__ */ React19.createElement(AbstractWalletContext.Provider, { value }, props.children);
|
|
150
|
+
};
|
|
151
|
+
function useAbstractWallet() {
|
|
152
|
+
const context = useContext(AbstractWalletContext);
|
|
153
|
+
if (!context) {
|
|
154
|
+
throw new Error(
|
|
155
|
+
"useAbstractWallet must be used within a AbstractWalletProvider"
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
return context;
|
|
159
|
+
}
|
|
47
160
|
var getPrivyEmbeddedWalletChainId = (chainId) => {
|
|
48
161
|
if (!chainId) {
|
|
49
162
|
return null;
|
|
@@ -265,7 +378,7 @@ var PrivyWalletProvider = ({
|
|
|
265
378
|
createSolanaWallet
|
|
266
379
|
]
|
|
267
380
|
);
|
|
268
|
-
return /* @__PURE__ */
|
|
381
|
+
return /* @__PURE__ */ React19.createElement(PrivyWalletContext.Provider, { value }, children);
|
|
269
382
|
};
|
|
270
383
|
function usePrivyWallet() {
|
|
271
384
|
const context = useContext(PrivyWalletContext);
|
|
@@ -488,7 +601,7 @@ var SolanaWalletProvider = ({
|
|
|
488
601
|
}),
|
|
489
602
|
[wallets, connectedChain, wallet, isConnected]
|
|
490
603
|
);
|
|
491
|
-
return /* @__PURE__ */
|
|
604
|
+
return /* @__PURE__ */ React19.createElement(SolanaWalletContext.Provider, { value }, children);
|
|
492
605
|
};
|
|
493
606
|
function useSolanaWallet() {
|
|
494
607
|
const context = useContext(SolanaWalletContext);
|
|
@@ -507,7 +620,7 @@ var WagmiWalletProvider = ({
|
|
|
507
620
|
const [wallet, setWallet] = useState(void 0);
|
|
508
621
|
const { connect, connectors: wagmiConnectors2 } = connectorWalletType.disableWagmi ? { connect: () => Promise.resolve(), connectors: [] } : useConnect();
|
|
509
622
|
const { disconnect } = connectorWalletType.disableWagmi ? { disconnect: () => Promise.resolve() } : useDisconnect();
|
|
510
|
-
const { connector, isConnected, address, chainId } = connectorWalletType.disableWagmi ? { connector: null, isConnected: false, address: null, chainId: null } : useAccount();
|
|
623
|
+
const { connector, isConnected, address, chainId } = connectorWalletType.disableWagmi ? { connector: null, isConnected: false, address: null, chainId: null } : useAccount$1();
|
|
511
624
|
const { switchChain } = connectorWalletType.disableWagmi ? { switchChain: () => Promise.resolve() } : useSwitchChain();
|
|
512
625
|
const connectedChain = useMemo(() => {
|
|
513
626
|
if (chainId) {
|
|
@@ -584,7 +697,7 @@ var WagmiWalletProvider = ({
|
|
|
584
697
|
isConnected
|
|
585
698
|
]
|
|
586
699
|
);
|
|
587
|
-
return /* @__PURE__ */
|
|
700
|
+
return /* @__PURE__ */ React19.createElement(WagmiWalletContext.Provider, { value }, children);
|
|
588
701
|
};
|
|
589
702
|
function useWagmiWallet() {
|
|
590
703
|
const context = useContext(WagmiWalletContext);
|
|
@@ -593,11 +706,92 @@ function useWagmiWallet() {
|
|
|
593
706
|
}
|
|
594
707
|
return context;
|
|
595
708
|
}
|
|
709
|
+
function Drawer({ children, isOpen, onClose }) {
|
|
710
|
+
const [windowHeight, setWindowHeight] = useState(0);
|
|
711
|
+
const { isMobile } = useScreen();
|
|
712
|
+
useEffect(() => {
|
|
713
|
+
setWindowHeight(window.innerHeight);
|
|
714
|
+
const handleResize = () => {
|
|
715
|
+
setWindowHeight(window.innerHeight);
|
|
716
|
+
};
|
|
717
|
+
window.addEventListener("resize", handleResize);
|
|
718
|
+
if (isOpen) {
|
|
719
|
+
document.body.style.overflow = "hidden";
|
|
720
|
+
} else {
|
|
721
|
+
document.body.style.overflow = "auto";
|
|
722
|
+
}
|
|
723
|
+
return () => {
|
|
724
|
+
document.body.style.overflow = "auto";
|
|
725
|
+
window.removeEventListener("resize", handleResize);
|
|
726
|
+
};
|
|
727
|
+
}, [isOpen, isMobile]);
|
|
728
|
+
if (!isOpen)
|
|
729
|
+
return null;
|
|
730
|
+
const drawerHeight = isMobile ? windowHeight : windowHeight - 72 - 24;
|
|
731
|
+
return createPortal(
|
|
732
|
+
/* @__PURE__ */ React19.createElement("div", { className: "oui-fixed oui-inset-0 oui-z-[60]" }, /* @__PURE__ */ React19.createElement(
|
|
733
|
+
"div",
|
|
734
|
+
{
|
|
735
|
+
className: "oui-absolute oui-inset-0 oui-bg-[rgba(0,0,0,0.48)] oui-transition-opacity",
|
|
736
|
+
onClick: onClose
|
|
737
|
+
}
|
|
738
|
+
), /* @__PURE__ */ React19.createElement(
|
|
739
|
+
"div",
|
|
740
|
+
{
|
|
741
|
+
style: { height: `${drawerHeight}px` },
|
|
742
|
+
className: cn(
|
|
743
|
+
"oui-overflow-hidden",
|
|
744
|
+
"oui-fixed oui-top-0 oui-right-0",
|
|
745
|
+
"oui-bg-[#131519] oui-shadow-lg",
|
|
746
|
+
"oui-border oui-border-line-12",
|
|
747
|
+
"oui-w-[276px]",
|
|
748
|
+
"md:oui-w-[300px]",
|
|
749
|
+
"md:oui-top-1/2 md:oui-translate-y-[-50%]",
|
|
750
|
+
"oui-rounded-0 md:oui-rounded-2xl",
|
|
751
|
+
"md:oui-rounded-0",
|
|
752
|
+
"oui-p-4",
|
|
753
|
+
"oui-transform oui-transition-transform oui-duration-300 oui-ease-in-out",
|
|
754
|
+
"oui-flex oui-flex-col oui-justify-between",
|
|
755
|
+
"oui-m-0 md:oui-m-3",
|
|
756
|
+
isOpen ? "oui-translate-x-0" : "oui--translate-x-full"
|
|
757
|
+
)
|
|
758
|
+
},
|
|
759
|
+
children
|
|
760
|
+
)),
|
|
761
|
+
document.body
|
|
762
|
+
);
|
|
763
|
+
}
|
|
764
|
+
var OrderlyOSS = "https://oss.orderly.network";
|
|
765
|
+
var PrivyConnectorImagePath = `${OrderlyOSS}/static/sdk/privy`;
|
|
766
|
+
var WALLET_ICONS = {
|
|
767
|
+
metamask: "https://oss.orderly.network/static/sdk/evm_wallets/metamask.png",
|
|
768
|
+
walletconnect: "https://oss.orderly.network/static/sdk/evm_wallets/walletConnect.png",
|
|
769
|
+
binance: "https://oss.orderly.network/static/sdk/evm_wallets/binance.png",
|
|
770
|
+
ledger: "https://oss.orderly.network/static/sdk/evm_wallets/ledger.png",
|
|
771
|
+
coinbase: "https://oss.orderly.network/static/sdk/evm_wallets/coinbase.png",
|
|
772
|
+
magic: "https://oss.orderly.network/static/sdk/evm_wallets/magic.png",
|
|
773
|
+
trezor: "https://oss.orderly.network/static/sdk/evm_wallets/trezor.png",
|
|
774
|
+
exodus: "https://oss.orderly.network/static/sdk/evm_wallets/exodus.png",
|
|
775
|
+
frame: "https://oss.orderly.network/static/sdk/evm_wallets/frame.png",
|
|
776
|
+
rabby: "https://oss.orderly.network/static/sdk/evm_wallets/rabby.png"
|
|
777
|
+
};
|
|
778
|
+
var getWalletIcon = (type) => {
|
|
779
|
+
return WALLET_ICONS[type.toLowerCase()];
|
|
780
|
+
};
|
|
781
|
+
var getChainType = (chainId) => {
|
|
782
|
+
if (AbstractChains.has(chainId)) {
|
|
783
|
+
return "Abstract" /* ABSTRACT */;
|
|
784
|
+
}
|
|
785
|
+
if (SolanaChains$1.has(chainId)) {
|
|
786
|
+
return "SOL" /* SOL */;
|
|
787
|
+
}
|
|
788
|
+
return "EVM" /* EVM */;
|
|
789
|
+
};
|
|
596
790
|
|
|
597
791
|
// src/hooks/useWallet.tsx
|
|
598
792
|
function useWallet2() {
|
|
599
793
|
const { track } = useTrack();
|
|
600
|
-
const {
|
|
794
|
+
const { walletChainTypeConfig } = useWalletConnectorPrivy();
|
|
601
795
|
const [connectorKey, setConnectorKey] = useLocalStorage(ConnectorKey, "");
|
|
602
796
|
const {
|
|
603
797
|
disconnect: disconnectEVM,
|
|
@@ -622,13 +816,20 @@ function useWallet2() {
|
|
|
622
816
|
isConnected: isConnectedPrivy,
|
|
623
817
|
switchChain: setChainPrivy
|
|
624
818
|
} = usePrivyWallet();
|
|
819
|
+
const {
|
|
820
|
+
connect: connectAbstract,
|
|
821
|
+
wallet: walletAbstract,
|
|
822
|
+
connectedChain: connectedChainAbstract,
|
|
823
|
+
isConnected: isConnectedAbstract,
|
|
824
|
+
disconnect: disconnectAbstract
|
|
825
|
+
} = useAbstractWallet();
|
|
625
826
|
const [wallet, setWallet] = useState(null);
|
|
626
827
|
const [namespace, setNamespace] = useState(null);
|
|
627
828
|
const { storageChain, setStorageChain } = useStorageChain();
|
|
628
|
-
const { setOpenConnectDrawer,
|
|
829
|
+
const { setOpenConnectDrawer, targetWalletType, setTargetWalletType } = useWalletConnectorPrivy();
|
|
629
830
|
const isManual = useRef(false);
|
|
630
831
|
const connect = (params) => {
|
|
631
|
-
|
|
832
|
+
setTargetWalletType(void 0);
|
|
632
833
|
try {
|
|
633
834
|
if (params.walletType === "EVM" /* EVM */) {
|
|
634
835
|
setConnectorKey("EVM" /* EVM */);
|
|
@@ -642,6 +843,10 @@ function useWallet2() {
|
|
|
642
843
|
setConnectorKey("privy" /* PRIVY */);
|
|
643
844
|
connectPrivy();
|
|
644
845
|
}
|
|
846
|
+
if (params.walletType === "Abstract" /* ABSTRACT */) {
|
|
847
|
+
setConnectorKey("Abstract" /* ABSTRACT */);
|
|
848
|
+
connectAbstract();
|
|
849
|
+
}
|
|
645
850
|
} catch (e) {
|
|
646
851
|
}
|
|
647
852
|
};
|
|
@@ -653,15 +858,10 @@ function useWallet2() {
|
|
|
653
858
|
}, [connectorKey]);
|
|
654
859
|
const [connectedChain, setConnectedChain] = useState();
|
|
655
860
|
const setChain = async (chain) => {
|
|
656
|
-
|
|
657
|
-
if (Array.from(SolanaChains.values()).includes(
|
|
658
|
-
parseInt(chain.chainId)
|
|
659
|
-
)) {
|
|
660
|
-
tempNamespace = ChainNamespace.solana;
|
|
661
|
-
}
|
|
861
|
+
const chainType = getChainType(parseInt(chain.chainId));
|
|
662
862
|
if (isPrivy) {
|
|
663
|
-
if (
|
|
664
|
-
if (
|
|
863
|
+
if (chainType === "EVM" /* EVM */) {
|
|
864
|
+
if (!walletChainTypeConfig.hasEvm) {
|
|
665
865
|
return Promise.reject(new Error("No evm wallet found"));
|
|
666
866
|
}
|
|
667
867
|
isManual.current = true;
|
|
@@ -676,79 +876,99 @@ function useWallet2() {
|
|
|
676
876
|
return Promise.reject(e);
|
|
677
877
|
});
|
|
678
878
|
}
|
|
679
|
-
if (
|
|
879
|
+
if (chainType === "Abstract" /* ABSTRACT */) {
|
|
880
|
+
setOpenConnectDrawer(true);
|
|
881
|
+
setTargetWalletType("Abstract" /* ABSTRACT */);
|
|
882
|
+
}
|
|
883
|
+
if (chainType === "SOL" /* SOL */) {
|
|
680
884
|
isManual.current = true;
|
|
681
|
-
if (
|
|
682
|
-
return Promise.reject(new Error("
|
|
885
|
+
if (!walletChainTypeConfig.hasSol) {
|
|
886
|
+
return Promise.reject(new Error("No solana wallet found"));
|
|
683
887
|
}
|
|
684
888
|
if (privyWalletSOL) {
|
|
685
889
|
setStorageChain(parseInt(chain.chainId));
|
|
686
890
|
return Promise.resolve(true);
|
|
687
891
|
} else {
|
|
688
892
|
setOpenConnectDrawer(true);
|
|
689
|
-
|
|
893
|
+
setTargetWalletType("SOL" /* SOL */);
|
|
690
894
|
return Promise.reject(new Error("No solana wallet found"));
|
|
691
895
|
}
|
|
692
896
|
}
|
|
693
897
|
} else {
|
|
694
|
-
if (
|
|
695
|
-
if (
|
|
898
|
+
if (chainType === "EVM" /* EVM */) {
|
|
899
|
+
if (isConnectedEVM && walletEVM) {
|
|
696
900
|
await setChainEvm(parseInt(chain.chainId));
|
|
697
901
|
setStorageChain(parseInt(chain.chainId));
|
|
698
902
|
track(TrackerEventName.switchNetworkSuccess, {
|
|
699
903
|
from_chain: storageChain?.chainId,
|
|
700
904
|
to_chain: chain.chainId
|
|
701
905
|
});
|
|
906
|
+
} else {
|
|
907
|
+
setOpenConnectDrawer(true);
|
|
908
|
+
setTargetWalletType("EVM" /* EVM */);
|
|
702
909
|
return Promise.resolve(true);
|
|
703
910
|
}
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
911
|
+
return Promise.resolve(true);
|
|
912
|
+
}
|
|
913
|
+
if (chainType === "SOL" /* SOL */) {
|
|
914
|
+
if (isConnectedSOL && walletSOL) {
|
|
915
|
+
setStorageChain(parseInt(chain.chainId));
|
|
916
|
+
} else {
|
|
917
|
+
setOpenConnectDrawer(true);
|
|
918
|
+
setTargetWalletType("SOL" /* SOL */);
|
|
919
|
+
return Promise.resolve(true);
|
|
712
920
|
}
|
|
713
921
|
}
|
|
714
|
-
if (
|
|
715
|
-
if (
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
922
|
+
if (chainType === "Abstract" /* ABSTRACT */) {
|
|
923
|
+
if (isConnectedAbstract && walletAbstract) {
|
|
924
|
+
setStorageChain(parseInt(chain.chainId));
|
|
925
|
+
return Promise.resolve(true);
|
|
926
|
+
} else {
|
|
927
|
+
setOpenConnectDrawer(true);
|
|
928
|
+
setTargetWalletType("Abstract" /* ABSTRACT */);
|
|
929
|
+
return Promise.reject(new Error("No abstract wallet found"));
|
|
722
930
|
}
|
|
723
931
|
}
|
|
724
932
|
}
|
|
725
933
|
};
|
|
726
|
-
const switchWallet = (
|
|
934
|
+
const switchWallet = (walletType) => {
|
|
727
935
|
const fromWallet = wallet?.accounts[0].address;
|
|
728
936
|
let toWallet;
|
|
729
937
|
if (isPrivy) {
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
938
|
+
switch (walletType) {
|
|
939
|
+
case "EVM" /* EVM */:
|
|
940
|
+
if (privyWalletEVM) {
|
|
941
|
+
setStorageChain(privyWalletEVM.chain.id);
|
|
942
|
+
toWallet = privyWalletEVM.accounts[0].address;
|
|
943
|
+
}
|
|
944
|
+
break;
|
|
945
|
+
case "SOL" /* SOL */:
|
|
946
|
+
if (privyWalletSOL) {
|
|
947
|
+
setStorageChain(privyWalletSOL.chain.id);
|
|
948
|
+
toWallet = privyWalletSOL.accounts[0].address;
|
|
949
|
+
}
|
|
950
|
+
break;
|
|
740
951
|
}
|
|
741
952
|
} else {
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
953
|
+
switch (walletType) {
|
|
954
|
+
case "EVM" /* EVM */:
|
|
955
|
+
if (walletEVM) {
|
|
956
|
+
setStorageChain(walletEVM.chain.id);
|
|
957
|
+
toWallet = walletEVM.accounts[0].address;
|
|
958
|
+
}
|
|
959
|
+
break;
|
|
960
|
+
case "SOL" /* SOL */:
|
|
961
|
+
if (walletSOL) {
|
|
962
|
+
setStorageChain(walletSOL.chain.id);
|
|
963
|
+
toWallet = walletSOL.accounts[0].address;
|
|
964
|
+
}
|
|
965
|
+
break;
|
|
966
|
+
case "Abstract" /* ABSTRACT */:
|
|
967
|
+
if (walletAbstract) {
|
|
968
|
+
setStorageChain(walletAbstract.chain.id);
|
|
969
|
+
toWallet = walletAbstract.accounts[0].address;
|
|
970
|
+
}
|
|
971
|
+
break;
|
|
752
972
|
}
|
|
753
973
|
}
|
|
754
974
|
track(TrackerEventName.clickSwitchWallet, {
|
|
@@ -757,14 +977,15 @@ function useWallet2() {
|
|
|
757
977
|
});
|
|
758
978
|
};
|
|
759
979
|
const disconnect = async (walletType) => {
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
980
|
+
switch (walletType) {
|
|
981
|
+
case "privy" /* PRIVY */:
|
|
982
|
+
return await disconnectPrivy();
|
|
983
|
+
case "EVM" /* EVM */:
|
|
984
|
+
return disconnectEVM();
|
|
985
|
+
case "SOL" /* SOL */:
|
|
986
|
+
return disconnectSOL();
|
|
987
|
+
case "Abstract" /* ABSTRACT */:
|
|
988
|
+
return disconnectAbstract();
|
|
768
989
|
}
|
|
769
990
|
};
|
|
770
991
|
const setNullWalletStatus = () => {
|
|
@@ -777,6 +998,9 @@ function useWallet2() {
|
|
|
777
998
|
return;
|
|
778
999
|
}
|
|
779
1000
|
if (storageChain?.namespace === ChainNamespace.evm) {
|
|
1001
|
+
if (AbstractChains.has(storageChain.chainId)) {
|
|
1002
|
+
return setNullWalletStatus();
|
|
1003
|
+
}
|
|
780
1004
|
if (privyWalletEVM) {
|
|
781
1005
|
setWallet(privyWalletEVM);
|
|
782
1006
|
setConnectedChain(privyWalletEVM.chain);
|
|
@@ -800,12 +1024,22 @@ function useWallet2() {
|
|
|
800
1024
|
return;
|
|
801
1025
|
}
|
|
802
1026
|
if (storageChain?.namespace === ChainNamespace.evm) {
|
|
803
|
-
if (
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
1027
|
+
if (AbstractChains.has(storageChain.chainId)) {
|
|
1028
|
+
if (isConnectedAbstract && walletAbstract) {
|
|
1029
|
+
setWallet(walletAbstract);
|
|
1030
|
+
setConnectedChain(connectedChainAbstract);
|
|
1031
|
+
setNamespace(ChainNamespace.evm);
|
|
1032
|
+
} else {
|
|
1033
|
+
setNullWalletStatus();
|
|
1034
|
+
}
|
|
807
1035
|
} else {
|
|
808
|
-
|
|
1036
|
+
if (isConnectedEVM && walletEVM) {
|
|
1037
|
+
setWallet(walletEVM);
|
|
1038
|
+
setConnectedChain(connectedChainEvm);
|
|
1039
|
+
setNamespace(ChainNamespace.evm);
|
|
1040
|
+
} else {
|
|
1041
|
+
setNullWalletStatus();
|
|
1042
|
+
}
|
|
809
1043
|
}
|
|
810
1044
|
}
|
|
811
1045
|
if (storageChain?.namespace === ChainNamespace.solana) {
|
|
@@ -823,7 +1057,10 @@ function useWallet2() {
|
|
|
823
1057
|
walletEVM,
|
|
824
1058
|
walletSOL,
|
|
825
1059
|
isConnectedEVM,
|
|
826
|
-
isConnectedSOL
|
|
1060
|
+
isConnectedSOL,
|
|
1061
|
+
isConnectedAbstract,
|
|
1062
|
+
walletAbstract,
|
|
1063
|
+
connectedChainAbstract
|
|
827
1064
|
]);
|
|
828
1065
|
return {
|
|
829
1066
|
connect,
|
|
@@ -835,30 +1072,115 @@ function useWallet2() {
|
|
|
835
1072
|
disconnect
|
|
836
1073
|
};
|
|
837
1074
|
}
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
1075
|
+
function AbstractConnectArea({ connect }) {
|
|
1076
|
+
return /* @__PURE__ */ React19.createElement("div", null, /* @__PURE__ */ React19.createElement("div", { className: "oui-mb-2 oui-text-sm oui-font-semibold oui-text-base-contrast-80" }, "Abstract"), /* @__PURE__ */ React19.createElement("div", { className: "oui-grid oui-grid-cols-2 oui-gap-2" }, /* @__PURE__ */ React19.createElement(
|
|
1077
|
+
"div",
|
|
1078
|
+
{
|
|
1079
|
+
className: " oui-flex oui-flex-1 oui-cursor-pointer oui-items-center oui-justify-start oui-gap-1 oui-rounded-[6px] oui-bg-[#07080A] oui-px-2 oui-py-[11px]",
|
|
1080
|
+
onClick: () => connect()
|
|
1081
|
+
},
|
|
1082
|
+
/* @__PURE__ */ React19.createElement("div", { className: "oui-flex oui-size-[18px] oui-items-center oui-justify-center" }, /* @__PURE__ */ React19.createElement(
|
|
1083
|
+
"img",
|
|
1084
|
+
{
|
|
1085
|
+
className: cn("oui-size-[12px]"),
|
|
1086
|
+
src: `${PrivyConnectorImagePath}/abstract.png`,
|
|
1087
|
+
alt: "abstract wallet"
|
|
1088
|
+
}
|
|
1089
|
+
)),
|
|
1090
|
+
/* @__PURE__ */ React19.createElement("div", { className: "oui-text-2xs oui-text-base-contrast" }, "Abstract")
|
|
1091
|
+
)));
|
|
1092
|
+
}
|
|
1093
|
+
function PrivyConnectArea({
|
|
1094
|
+
connect
|
|
1095
|
+
}) {
|
|
1096
|
+
const { t } = useTranslation();
|
|
1097
|
+
const { isMobile, isDesktop } = useScreen();
|
|
1098
|
+
const { connectorWalletType } = useWalletConnectorPrivy();
|
|
1099
|
+
return /* @__PURE__ */ React19.createElement("div", { className: "" }, /* @__PURE__ */ React19.createElement(
|
|
1100
|
+
"div",
|
|
1101
|
+
{
|
|
1102
|
+
className: cn(
|
|
1103
|
+
"oui-flex oui-items-center oui-justify-between",
|
|
1104
|
+
"oui-mb-3 oui-text-sm oui-font-semibold oui-text-base-contrast-80",
|
|
1105
|
+
"md:oui-mb-2"
|
|
1106
|
+
)
|
|
1107
|
+
},
|
|
1108
|
+
t("connector.privy.loginIn"),
|
|
1109
|
+
isMobile && /* @__PURE__ */ React19.createElement("div", { className: "oui-flex oui-h-3 oui-justify-center" }, /* @__PURE__ */ React19.createElement(
|
|
1110
|
+
"img",
|
|
1111
|
+
{
|
|
1112
|
+
src: "https://oss.orderly.network/static/sdk/privy/privy-logo.png",
|
|
1113
|
+
className: " oui-h-[10px]"
|
|
1114
|
+
}
|
|
1115
|
+
))
|
|
1116
|
+
), /* @__PURE__ */ React19.createElement(
|
|
1117
|
+
"div",
|
|
1118
|
+
{
|
|
1119
|
+
className: cn(
|
|
1120
|
+
"oui-grid oui-grid-cols-2 oui-gap-2",
|
|
1121
|
+
"md:oui-flex md:oui-flex-col md:oui-gap-2"
|
|
1122
|
+
)
|
|
1123
|
+
},
|
|
1124
|
+
/* @__PURE__ */ React19.createElement(
|
|
1125
|
+
"div",
|
|
1126
|
+
{
|
|
1127
|
+
className: "oui-flex oui-cursor-pointer oui-items-center oui-justify-center oui-gap-1 oui-rounded-[6px] oui-bg-[#333948] oui-px-2 oui-py-[11px]",
|
|
1128
|
+
onClick: () => connect({ walletType: "privy", extraType: "email" })
|
|
1129
|
+
},
|
|
1130
|
+
/* @__PURE__ */ React19.createElement(
|
|
1131
|
+
"img",
|
|
1132
|
+
{
|
|
1133
|
+
src: "https://oss.orderly.network/static/sdk/privy/email.svg",
|
|
1134
|
+
className: "oui-size-[18px]"
|
|
1135
|
+
}
|
|
1136
|
+
),
|
|
1137
|
+
/* @__PURE__ */ React19.createElement("div", { className: "oui-text-2xs oui-text-base-contrast" }, t("connector.privy.email"))
|
|
1138
|
+
),
|
|
1139
|
+
/* @__PURE__ */ React19.createElement(
|
|
1140
|
+
"div",
|
|
1141
|
+
{
|
|
1142
|
+
className: "oui-flex oui-cursor-pointer oui-items-center oui-justify-center oui-gap-1 oui-rounded-[6px] oui-bg-[#335FFC] oui-px-2 oui-py-[11px]",
|
|
1143
|
+
onClick: () => connect({ walletType: "privy", extraType: "google" })
|
|
1144
|
+
},
|
|
1145
|
+
/* @__PURE__ */ React19.createElement(
|
|
1146
|
+
"img",
|
|
1147
|
+
{
|
|
1148
|
+
src: "https://oss.orderly.network/static/sdk/privy/google.svg",
|
|
1149
|
+
className: "oui-size-[18px]"
|
|
1150
|
+
}
|
|
1151
|
+
),
|
|
1152
|
+
/* @__PURE__ */ React19.createElement("div", { className: "oui-text-2xs oui-text-base-contrast" }, t("connector.privy.google"))
|
|
1153
|
+
),
|
|
1154
|
+
/* @__PURE__ */ React19.createElement(
|
|
1155
|
+
"div",
|
|
1156
|
+
{
|
|
1157
|
+
className: "oui-flex oui-cursor-pointer oui-items-center oui-justify-center oui-gap-1 oui-rounded-[6px] oui-bg-[#07080A] oui-px-2 oui-py-[11px]",
|
|
1158
|
+
onClick: () => connect({ walletType: "privy", extraType: "twitter" })
|
|
1159
|
+
},
|
|
1160
|
+
/* @__PURE__ */ React19.createElement(
|
|
1161
|
+
"img",
|
|
1162
|
+
{
|
|
1163
|
+
src: "https://oss.orderly.network/static/sdk/privy/twitter.svg",
|
|
1164
|
+
className: "oui-size-[18px]"
|
|
1165
|
+
}
|
|
1166
|
+
),
|
|
1167
|
+
/* @__PURE__ */ React19.createElement("div", { className: "oui-text-2xs oui-text-base-contrast" }, t("connector.privy.twitter"))
|
|
1168
|
+
)
|
|
1169
|
+
), isDesktop && /* @__PURE__ */ React19.createElement("div", { className: "oui-mt-4 oui-flex oui-h-3 oui-justify-center" }, /* @__PURE__ */ React19.createElement(
|
|
1170
|
+
"img",
|
|
1171
|
+
{
|
|
1172
|
+
src: "https://oss.orderly.network/static/sdk/privy/privy-logo.png",
|
|
1173
|
+
className: " oui-h-[10px]"
|
|
1174
|
+
}
|
|
1175
|
+
)), (!connectorWalletType.disableWagmi || !connectorWalletType.disableSolana) && /* @__PURE__ */ React19.createElement("div", { className: "oui-mt-4 oui-h-px oui-w-full oui-bg-line md:oui-mt-5" }));
|
|
1176
|
+
}
|
|
855
1177
|
function RenderPrivyTypeIcon({
|
|
856
1178
|
type,
|
|
857
1179
|
size,
|
|
858
1180
|
black
|
|
859
1181
|
}) {
|
|
860
1182
|
if (type === "email") {
|
|
861
|
-
return /* @__PURE__ */
|
|
1183
|
+
return /* @__PURE__ */ React19.createElement(
|
|
862
1184
|
"img",
|
|
863
1185
|
{
|
|
864
1186
|
src: `https://oss.orderly.network/static/sdk/privy/email${black ? "-black" : ""}.svg`,
|
|
@@ -867,7 +1189,7 @@ function RenderPrivyTypeIcon({
|
|
|
867
1189
|
);
|
|
868
1190
|
}
|
|
869
1191
|
if (type === "google_oauth") {
|
|
870
|
-
return /* @__PURE__ */
|
|
1192
|
+
return /* @__PURE__ */ React19.createElement(
|
|
871
1193
|
"img",
|
|
872
1194
|
{
|
|
873
1195
|
src: "https://oss.orderly.network/static/sdk/privy/google.svg",
|
|
@@ -876,7 +1198,7 @@ function RenderPrivyTypeIcon({
|
|
|
876
1198
|
);
|
|
877
1199
|
}
|
|
878
1200
|
if (type === "twitter_oauth") {
|
|
879
|
-
return /* @__PURE__ */
|
|
1201
|
+
return /* @__PURE__ */ React19.createElement(
|
|
880
1202
|
"img",
|
|
881
1203
|
{
|
|
882
1204
|
src: `https://oss.orderly.network/static/sdk/privy/twitter${black ? "-black" : ""}.svg`,
|
|
@@ -884,7 +1206,7 @@ function RenderPrivyTypeIcon({
|
|
|
884
1206
|
}
|
|
885
1207
|
);
|
|
886
1208
|
}
|
|
887
|
-
return /* @__PURE__ */
|
|
1209
|
+
return /* @__PURE__ */ React19.createElement(
|
|
888
1210
|
"img",
|
|
889
1211
|
{
|
|
890
1212
|
src: `https://oss.orderly.network/static/sdk/privy/email${black ? "-black" : ""}.svg`,
|
|
@@ -896,7 +1218,7 @@ function RenderWalletIcon({
|
|
|
896
1218
|
connector
|
|
897
1219
|
}) {
|
|
898
1220
|
const icon = connector.icon ? connector.icon : getWalletIcon(connector.type);
|
|
899
|
-
return /* @__PURE__ */
|
|
1221
|
+
return /* @__PURE__ */ React19.createElement("div", { className: "oui-w-[18px] oui-h-[18px] oui-flex oui-items-center oui-justify-center" }, /* @__PURE__ */ React19.createElement(
|
|
900
1222
|
"img",
|
|
901
1223
|
{
|
|
902
1224
|
className: cn(
|
|
@@ -907,73 +1229,282 @@ function RenderWalletIcon({
|
|
|
907
1229
|
}
|
|
908
1230
|
));
|
|
909
1231
|
}
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
1232
|
+
function EVMChainPopover({ children }) {
|
|
1233
|
+
const { getChainsByNetwork } = useWalletConnectorPrivy();
|
|
1234
|
+
const [chains] = useState(getChainsByNetwork("mainnet"));
|
|
1235
|
+
const { t } = useTranslation();
|
|
1236
|
+
const { isMobile } = useScreen();
|
|
1237
|
+
const [open, setOpen] = useState(false);
|
|
1238
|
+
if (isMobile) {
|
|
1239
|
+
return /* @__PURE__ */ React19.createElement(React19.Fragment, null, /* @__PURE__ */ React19.createElement(
|
|
1240
|
+
SimpleDialog,
|
|
1241
|
+
{
|
|
1242
|
+
open,
|
|
1243
|
+
size: "xs",
|
|
1244
|
+
onOpenChange: setOpen,
|
|
1245
|
+
classNames: {
|
|
1246
|
+
content: "oui-p-4 oui-z-[99]",
|
|
1247
|
+
overlay: "oui-z-[99]"
|
|
1248
|
+
},
|
|
1249
|
+
title: t("connector.privy.supportedEvmChain")
|
|
1250
|
+
},
|
|
1251
|
+
/* @__PURE__ */ React19.createElement("div", { className: "oui-p-1 oui-grid oui-grid-cols-2 oui-gap-x-2 oui-gap-y-3 oui-text-2xs oui-text-base-contrast-54" }, chains.map((item, key) => /* @__PURE__ */ React19.createElement(
|
|
1252
|
+
"div",
|
|
1253
|
+
{
|
|
1254
|
+
key,
|
|
1255
|
+
className: "oui-flex oui-items-center oui-justify-start oui-gap-1"
|
|
1256
|
+
},
|
|
1257
|
+
/* @__PURE__ */ React19.createElement(ChainIcon, { chainId: item.id, size: "2xs" }),
|
|
1258
|
+
/* @__PURE__ */ React19.createElement("div", null, item.name)
|
|
1259
|
+
)))
|
|
1260
|
+
), /* @__PURE__ */ React19.createElement("button", { onClick: () => setOpen(true) }, children));
|
|
1261
|
+
}
|
|
1262
|
+
return /* @__PURE__ */ React19.createElement(
|
|
1263
|
+
Popover,
|
|
1264
|
+
{
|
|
1265
|
+
content: /* @__PURE__ */ React19.createElement("div", null, /* @__PURE__ */ React19.createElement("div", { className: "oui-text-2xs oui-font-semibold oui-text-base-contrast" }, t("connector.privy.supportedEvmChain")), /* @__PURE__ */ React19.createElement("div", { className: "oui-mt-3 oui-grid oui-grid-cols-3 oui-gap-x-2 oui-gap-y-3 oui-text-2xs oui-text-base-contrast-54" }, chains.map((item, key) => /* @__PURE__ */ React19.createElement(
|
|
1266
|
+
"div",
|
|
1267
|
+
{
|
|
1268
|
+
key,
|
|
1269
|
+
className: "oui-flex oui-items-center oui-justify-start oui-gap-1"
|
|
1270
|
+
},
|
|
1271
|
+
/* @__PURE__ */ React19.createElement(ChainIcon, { chainId: item.id, size: "2xs" }),
|
|
1272
|
+
/* @__PURE__ */ React19.createElement("div", null, item.name)
|
|
1273
|
+
)))),
|
|
1274
|
+
arrow: true,
|
|
1275
|
+
contentProps: {
|
|
1276
|
+
side: "bottom",
|
|
1277
|
+
align: "center",
|
|
1278
|
+
className: "oui-p-2 oui-z-[65]"
|
|
1279
|
+
}
|
|
1280
|
+
},
|
|
1281
|
+
/* @__PURE__ */ React19.createElement("button", null, children)
|
|
1282
|
+
);
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
// src/components/renderConnector/solanaConnector.tsx
|
|
1286
|
+
function SOLConnectArea({
|
|
1287
|
+
connect
|
|
1288
|
+
}) {
|
|
1289
|
+
const { wallets } = useSolanaWallet();
|
|
1290
|
+
return /* @__PURE__ */ React19.createElement("div", null, /* @__PURE__ */ React19.createElement("div", { className: "oui-mb-2 oui-text-sm oui-font-semibold oui-text-base-contrast-80" }, "Solana"), /* @__PURE__ */ React19.createElement("div", { className: "oui-grid oui-grid-cols-2 oui-gap-2" }, wallets.map((item, key) => /* @__PURE__ */ React19.createElement(
|
|
1291
|
+
"div",
|
|
1292
|
+
{
|
|
1293
|
+
key,
|
|
1294
|
+
className: " oui-flex oui-flex-1 oui-cursor-pointer oui-items-center oui-justify-start oui-gap-1 oui-rounded-[6px] oui-bg-[#07080A] oui-px-2 oui-py-[11px]",
|
|
1295
|
+
onClick: () => connect(item.adapter)
|
|
1296
|
+
},
|
|
1297
|
+
/* @__PURE__ */ React19.createElement(RenderWalletIcon, { connector: item.adapter }),
|
|
1298
|
+
/* @__PURE__ */ React19.createElement("div", { className: "oui-text-2xs oui-text-base-contrast" }, item.adapter.name)
|
|
1299
|
+
))));
|
|
1300
|
+
}
|
|
1301
|
+
function EVMConnectArea({ connect }) {
|
|
1302
|
+
const { connectors } = useWagmiWallet();
|
|
1303
|
+
return /* @__PURE__ */ React19.createElement("div", { className: "" }, /* @__PURE__ */ React19.createElement("div", { className: "oui-mb-2 oui-text-sm oui-font-semibold oui-text-base-contrast-80" }, "EVM"), /* @__PURE__ */ React19.createElement("div", { className: "oui-grid oui-grid-cols-2 oui-gap-2" }, connectors.map((item, key) => /* @__PURE__ */ React19.createElement(
|
|
1304
|
+
"div",
|
|
1305
|
+
{
|
|
1306
|
+
key,
|
|
1307
|
+
className: " oui-flex oui-flex-1 oui-cursor-pointer oui-items-center oui-justify-start oui-gap-1 oui-rounded-[6px] oui-bg-[#07080A] oui-px-2 oui-py-[11px]",
|
|
1308
|
+
onClick: () => connect(item)
|
|
1309
|
+
},
|
|
1310
|
+
/* @__PURE__ */ React19.createElement(RenderWalletIcon, { connector: item }),
|
|
1311
|
+
/* @__PURE__ */ React19.createElement("div", { className: "oui-text-2xs oui-text-base-contrast" }, item.name)
|
|
1312
|
+
))));
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
// src/components/renderConnector/index.tsx
|
|
1316
|
+
function RenderConnector() {
|
|
1317
|
+
const { connect } = useWallet2();
|
|
1318
|
+
const { setOpenConnectDrawer, connectorWalletType, walletChainTypeConfig } = useWalletConnectorPrivy();
|
|
1319
|
+
const handleConnect = (params) => {
|
|
1320
|
+
connect(params);
|
|
1321
|
+
if (params.walletType === "privy" /* PRIVY */) {
|
|
1322
|
+
setOpenConnectDrawer(false);
|
|
1323
|
+
}
|
|
1324
|
+
};
|
|
1325
|
+
const renderPrivyConnectArea = () => {
|
|
1326
|
+
if (connectorWalletType.disablePrivy) {
|
|
1327
|
+
return null;
|
|
1328
|
+
}
|
|
1329
|
+
return /* @__PURE__ */ React19.createElement(
|
|
1330
|
+
PrivyConnectArea,
|
|
1331
|
+
{
|
|
1332
|
+
connect: (type) => handleConnect({
|
|
1333
|
+
walletType: "privy" /* PRIVY */,
|
|
1334
|
+
extraType: type
|
|
1335
|
+
})
|
|
1336
|
+
}
|
|
1337
|
+
);
|
|
1338
|
+
};
|
|
1339
|
+
const renderWagmiConnectArea = () => {
|
|
1340
|
+
if (connectorWalletType.disableWagmi) {
|
|
1341
|
+
return null;
|
|
1342
|
+
}
|
|
1343
|
+
if (!walletChainTypeConfig.hasEvm) {
|
|
1344
|
+
return null;
|
|
1345
|
+
}
|
|
1346
|
+
return /* @__PURE__ */ React19.createElement(
|
|
1347
|
+
EVMConnectArea,
|
|
1348
|
+
{
|
|
1349
|
+
connect: (connector) => handleConnect({
|
|
1350
|
+
walletType: "EVM" /* EVM */,
|
|
1351
|
+
connector
|
|
1352
|
+
})
|
|
1353
|
+
}
|
|
1354
|
+
);
|
|
1355
|
+
};
|
|
1356
|
+
const renderSolanaConnectArea = () => {
|
|
1357
|
+
if (connectorWalletType.disableSolana) {
|
|
1358
|
+
return null;
|
|
1359
|
+
}
|
|
1360
|
+
if (!walletChainTypeConfig.hasSol) {
|
|
1361
|
+
return null;
|
|
1362
|
+
}
|
|
1363
|
+
return /* @__PURE__ */ React19.createElement(
|
|
1364
|
+
SOLConnectArea,
|
|
1365
|
+
{
|
|
1366
|
+
connect: (walletAdapter) => handleConnect({
|
|
1367
|
+
walletType: "SOL" /* SOL */,
|
|
1368
|
+
walletAdapter
|
|
1369
|
+
})
|
|
1370
|
+
}
|
|
1371
|
+
);
|
|
1372
|
+
};
|
|
1373
|
+
const renderAbstractConnectArea = () => {
|
|
1374
|
+
if (connectorWalletType.disableAGW) {
|
|
1375
|
+
return null;
|
|
1376
|
+
}
|
|
1377
|
+
if (!walletChainTypeConfig.hasAbstract) {
|
|
1378
|
+
return null;
|
|
1379
|
+
}
|
|
1380
|
+
return /* @__PURE__ */ React19.createElement(
|
|
1381
|
+
AbstractConnectArea,
|
|
1382
|
+
{
|
|
1383
|
+
connect: () => handleConnect({ walletType: "Abstract" /* ABSTRACT */ })
|
|
1384
|
+
}
|
|
1385
|
+
);
|
|
1386
|
+
};
|
|
1387
|
+
return /* @__PURE__ */ React19.createElement("div", { className: cn("oui-flex oui-flex-col oui-gap-4", "md:oui-gap-5") }, renderPrivyConnectArea(), renderWagmiConnectArea(), renderSolanaConnectArea(), renderAbstractConnectArea());
|
|
1388
|
+
}
|
|
1389
|
+
function SwitchNetworkTips({
|
|
1390
|
+
tipsContent
|
|
1391
|
+
}) {
|
|
1392
|
+
const { t } = useTranslation();
|
|
1393
|
+
if (!tipsContent) {
|
|
1394
|
+
return null;
|
|
1395
|
+
}
|
|
1396
|
+
return /* @__PURE__ */ React19.createElement("div", { className: "oui-flex oui-mb-3 oui-items-center oui-gap-1 oui-px-2 oui-py-[6px] oui-bg-[rgba(255,125,0,0.1)] oui-rounded-[8px] " }, /* @__PURE__ */ React19.createElement(
|
|
1397
|
+
ExclamationFillIcon,
|
|
1398
|
+
{
|
|
1399
|
+
size: 14,
|
|
1400
|
+
className: " oui-text-warning-darken oui-flex-shrink-0"
|
|
1401
|
+
}
|
|
1402
|
+
), /* @__PURE__ */ React19.createElement("div", { className: "oui-text-2xs oui-text-warning-darken" }, t("connector.privy.switchNetwork.tips", {
|
|
1403
|
+
chainName: tipsContent
|
|
1404
|
+
})));
|
|
1405
|
+
}
|
|
1406
|
+
var StorageChainNotCurrentWalletType = ({
|
|
1407
|
+
currentWalletType
|
|
1408
|
+
}) => {
|
|
1409
|
+
const { storageChain } = useStorageChain();
|
|
1410
|
+
const tipsContent = useMemo(() => {
|
|
1411
|
+
if (!currentWalletType || currentWalletType.size === 0 || !storageChain) {
|
|
1412
|
+
return null;
|
|
1413
|
+
}
|
|
1414
|
+
let text = null;
|
|
1415
|
+
const isSolana = SolanaChains$1.has(parseInt(storageChain?.chainId));
|
|
1416
|
+
const isAbstract = AbstractChains.has(parseInt(storageChain?.chainId));
|
|
1417
|
+
const isEvm = !isSolana && !isAbstract;
|
|
1418
|
+
if (isSolana && currentWalletType.has("SOL" /* SOL */)) {
|
|
1419
|
+
return null;
|
|
1420
|
+
} else if (isAbstract && currentWalletType.has("Abstract" /* ABSTRACT */)) {
|
|
1421
|
+
return null;
|
|
1422
|
+
} else if (isEvm && currentWalletType.has("EVM" /* EVM */)) {
|
|
1423
|
+
return null;
|
|
1424
|
+
}
|
|
1425
|
+
text = Array.from(currentWalletType).map((item) => {
|
|
1426
|
+
if (item === "EVM" /* EVM */) {
|
|
1427
|
+
return "Evm";
|
|
1428
|
+
} else if (item === "SOL" /* SOL */) {
|
|
1429
|
+
return "Solana";
|
|
1430
|
+
} else if (item === "Abstract" /* ABSTRACT */) {
|
|
1431
|
+
return "Abstract";
|
|
1432
|
+
}
|
|
1433
|
+
}).join("/");
|
|
1434
|
+
return text;
|
|
1435
|
+
}, [storageChain, currentWalletType]);
|
|
1436
|
+
return /* @__PURE__ */ React19.createElement(SwitchNetworkTips, { tipsContent });
|
|
1437
|
+
};
|
|
1438
|
+
var MoreIcon = (props) => /* @__PURE__ */ React19.createElement(
|
|
1439
|
+
"svg",
|
|
1440
|
+
{
|
|
1441
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
927
1442
|
width: "16",
|
|
928
1443
|
height: "16",
|
|
929
1444
|
viewBox: "0 0 16 16",
|
|
930
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
931
1445
|
fill: "currentColor",
|
|
932
1446
|
...props
|
|
933
1447
|
},
|
|
934
|
-
/* @__PURE__ */
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
id: "Vector",
|
|
938
|
-
d: "M1.99365 4.66056C1.99365 3.1879 3.18759 1.9939 4.66032 1.9939H7.32698C8.79965 1.9939 9.99365 3.1879 9.99365 4.66056C9.99365 5.02856 9.69498 5.32723 9.32698 5.32723C8.95898 5.32723 8.66032 5.02856 8.66032 4.66056C8.66032 3.92389 8.06365 3.32723 7.32698 3.32723H4.66032C3.92392 3.32723 3.32699 3.92389 3.32699 4.66056V11.3272C3.32699 12.0639 3.92392 12.6606 4.66032 12.6606H7.32698C8.06365 12.6606 8.66032 12.0639 8.66032 11.3272C8.66032 10.9592 8.95898 10.6606 9.32698 10.6606C9.69498 10.6606 9.99365 10.9592 9.99365 11.3272C9.99365 12.7999 8.79965 13.9939 7.32698 13.9939H4.66032C3.18759 13.9939 1.99365 12.7999 1.99365 11.3272V4.66056ZM6.66032 7.99389C6.66032 7.62589 6.95898 7.32722 7.32698 7.32722H12.369L11.0563 5.99389L11.9937 5.05656L14.473 7.51456C14.733 7.77523 14.733 8.21255 14.473 8.47322L11.9937 10.9312L11.0563 9.99389L12.369 8.66056H7.32698C6.95898 8.66056 6.66032 8.36189 6.66032 7.99389Z"
|
|
939
|
-
}
|
|
940
|
-
))
|
|
1448
|
+
/* @__PURE__ */ React19.createElement("path", { d: "M8.00521 6.66797C8.74161 6.66797 9.33854 7.26464 9.33854 8.0013C9.33854 8.73797 8.74161 9.33464 8.00521 9.33464C7.26881 9.33464 6.67188 8.73797 6.67188 8.0013C6.67188 7.26464 7.26881 6.66797 8.00521 6.66797Z" }),
|
|
1449
|
+
/* @__PURE__ */ React19.createElement("path", { d: "M3.33333 6.66797C4.06973 6.66797 4.66667 7.26464 4.66667 8.0013C4.66667 8.73797 4.06973 9.33464 3.33333 9.33464C2.59693 9.33464 2 8.73797 2 8.0013C2 7.26464 2.59693 6.66797 3.33333 6.66797Z" }),
|
|
1450
|
+
/* @__PURE__ */ React19.createElement("path", { d: "M12.6666 6.66797C13.403 6.66797 14 7.26464 14 8.0013C14 8.73797 13.403 9.33464 12.6666 9.33464C11.9302 9.33464 11.3333 8.73797 11.3333 8.0013C11.3333 7.26464 11.9302 6.66797 12.6666 6.66797Z" })
|
|
941
1451
|
);
|
|
942
|
-
var
|
|
1452
|
+
var DisconnectIcon = (props) => /* @__PURE__ */ React19.createElement(
|
|
943
1453
|
"svg",
|
|
944
1454
|
{
|
|
945
|
-
width: "
|
|
946
|
-
height: "
|
|
947
|
-
viewBox: "0 0
|
|
948
|
-
fill: "currentColor",
|
|
1455
|
+
width: "16",
|
|
1456
|
+
height: "16",
|
|
1457
|
+
viewBox: "0 0 16 16",
|
|
949
1458
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1459
|
+
fill: "currentColor",
|
|
950
1460
|
...props
|
|
951
1461
|
},
|
|
952
|
-
/* @__PURE__ */
|
|
1462
|
+
/* @__PURE__ */ React19.createElement("g", { id: "box-arrow-right" }, /* @__PURE__ */ React19.createElement(
|
|
953
1463
|
"path",
|
|
954
1464
|
{
|
|
955
1465
|
id: "Vector",
|
|
956
|
-
d: "
|
|
1466
|
+
d: "M1.99365 4.66056C1.99365 3.1879 3.18759 1.9939 4.66032 1.9939H7.32698C8.79965 1.9939 9.99365 3.1879 9.99365 4.66056C9.99365 5.02856 9.69498 5.32723 9.32698 5.32723C8.95898 5.32723 8.66032 5.02856 8.66032 4.66056C8.66032 3.92389 8.06365 3.32723 7.32698 3.32723H4.66032C3.92392 3.32723 3.32699 3.92389 3.32699 4.66056V11.3272C3.32699 12.0639 3.92392 12.6606 4.66032 12.6606H7.32698C8.06365 12.6606 8.66032 12.0639 8.66032 11.3272C8.66032 10.9592 8.95898 10.6606 9.32698 10.6606C9.69498 10.6606 9.99365 10.9592 9.99365 11.3272C9.99365 12.7999 8.79965 13.9939 7.32698 13.9939H4.66032C3.18759 13.9939 1.99365 12.7999 1.99365 11.3272V4.66056ZM6.66032 7.99389C6.66032 7.62589 6.95898 7.32722 7.32698 7.32722H12.369L11.0563 5.99389L11.9937 5.05656L14.473 7.51456C14.733 7.77523 14.733 8.21255 14.473 8.47322L11.9937 10.9312L11.0563 9.99389L12.369 8.66056H7.32698C6.95898 8.66056 6.66032 8.36189 6.66032 7.99389Z"
|
|
957
1467
|
}
|
|
958
1468
|
))
|
|
959
1469
|
);
|
|
1470
|
+
|
|
1471
|
+
// src/components/walletCard.tsx
|
|
1472
|
+
var getCardBgClassName = (type = "EVM" /* EVM */) => {
|
|
1473
|
+
const cardBgColorMap = {
|
|
1474
|
+
["EVM" /* EVM */]: "oui-bg-[#283BEE]",
|
|
1475
|
+
["Abstract" /* ABSTRACT */]: "oui-bg-[#00A858]",
|
|
1476
|
+
["SOL" /* SOL */]: "oui-bg-[#630EAD]"
|
|
1477
|
+
};
|
|
1478
|
+
return cardBgColorMap[type];
|
|
1479
|
+
};
|
|
1480
|
+
var getCardActiveClassName = (isActive, isMulti, type = "EVM" /* EVM */) => {
|
|
1481
|
+
const cardActiveColorMap = {
|
|
1482
|
+
["EVM" /* EVM */]: "oui-border-[2px] oui-border-[#B9D1FF]",
|
|
1483
|
+
["Abstract" /* ABSTRACT */]: "oui-border-[2px] oui-border-[#B9D1FF]",
|
|
1484
|
+
["SOL" /* SOL */]: "oui-border-[2px] oui-border-[#faedff]"
|
|
1485
|
+
};
|
|
1486
|
+
return isActive && isMulti && cardActiveColorMap[type];
|
|
1487
|
+
};
|
|
960
1488
|
function WalletCard(props) {
|
|
961
1489
|
const { t } = useTranslation();
|
|
962
1490
|
const copyAddress = async (address) => {
|
|
963
1491
|
await navigator.clipboard.writeText(address);
|
|
964
1492
|
toast.success(t("common.copy.copied"));
|
|
965
1493
|
};
|
|
966
|
-
return /* @__PURE__ */
|
|
1494
|
+
return /* @__PURE__ */ React19.createElement(
|
|
967
1495
|
"div",
|
|
968
1496
|
{
|
|
969
1497
|
className: cn(
|
|
970
|
-
"oui-
|
|
971
|
-
props.type
|
|
972
|
-
|
|
973
|
-
|
|
1498
|
+
"oui-relative oui-h-[110px] oui-overflow-hidden oui-rounded-2xl oui-p-4",
|
|
1499
|
+
getCardBgClassName(props.type),
|
|
1500
|
+
getCardActiveClassName(
|
|
1501
|
+
props.isActive,
|
|
1502
|
+
props.isMulti || false,
|
|
1503
|
+
props.type
|
|
1504
|
+
)
|
|
974
1505
|
)
|
|
975
1506
|
},
|
|
976
|
-
/* @__PURE__ */
|
|
1507
|
+
/* @__PURE__ */ React19.createElement(
|
|
977
1508
|
"div",
|
|
978
1509
|
{
|
|
979
1510
|
style: {
|
|
@@ -990,39 +1521,21 @@ function WalletCard(props) {
|
|
|
990
1521
|
}
|
|
991
1522
|
}
|
|
992
1523
|
),
|
|
993
|
-
/* @__PURE__ */
|
|
1524
|
+
/* @__PURE__ */ React19.createElement("div", { className: "oui-relative oui-z-10 oui-flex oui-h-full oui-flex-col oui-justify-between" }, /* @__PURE__ */ React19.createElement("div", { className: "oui-flex oui-items-center oui-justify-between" }, /* @__PURE__ */ React19.createElement("div", { className: "oui-text-sm oui-font-semibold oui-text-base-contrast" }, formatAddress(props.address)), /* @__PURE__ */ React19.createElement("div", { className: "oui-flex oui-items-center oui-justify-center oui-gap-2" }, /* @__PURE__ */ React19.createElement(Tooltip, { content: t("common.copy"), className: "oui-z-[65]" }, /* @__PURE__ */ React19.createElement(
|
|
994
1525
|
CopyIcon,
|
|
995
1526
|
{
|
|
996
1527
|
size: 16,
|
|
997
1528
|
opacity: 1,
|
|
998
|
-
className: "oui-text-base-contrast-80
|
|
1529
|
+
className: "oui-cursor-pointer oui-text-base-contrast-80 hover:oui-text-base-contrast",
|
|
999
1530
|
onClick: () => copyAddress(props.address)
|
|
1000
1531
|
}
|
|
1001
|
-
)), props.isPrivy ? /* @__PURE__ */
|
|
1532
|
+
)), props.isPrivy ? /* @__PURE__ */ React19.createElement(
|
|
1002
1533
|
PrivyWalletHandleOption,
|
|
1003
1534
|
{
|
|
1004
1535
|
address: props.address,
|
|
1005
1536
|
type: props.type
|
|
1006
1537
|
}
|
|
1007
|
-
) : /* @__PURE__ */
|
|
1008
|
-
"img",
|
|
1009
|
-
{
|
|
1010
|
-
src: "https://oss.orderly.network/static/sdk/chains.png",
|
|
1011
|
-
className: "oui-h-[18px] oui-w-[49px] oui-relative oui-z-0"
|
|
1012
|
-
}
|
|
1013
|
-
)), /* @__PURE__ */ React12.createElement("div", { className: "oui-flex oui-items-center oui-justify-center oui-gap-1 oui-relative oui-left-[-9px]" }, /* @__PURE__ */ React12.createElement("div", { className: "oui-rounded-full oui-bg-[#282e3a] oui-w-[18px] oui-h-[18px] oui-flex oui-items-center oui-justify-center" }, /* @__PURE__ */ React12.createElement(EVMChainPopover, null, /* @__PURE__ */ React12.createElement(
|
|
1014
|
-
MoreIcon,
|
|
1015
|
-
{
|
|
1016
|
-
className: "oui-text-base-contrast-54 hover:oui-text-base-contrast oui-h-3 oui-w-3 oui-relative oui-z-10",
|
|
1017
|
-
style: { zIndex: 1 }
|
|
1018
|
-
}
|
|
1019
|
-
))), /* @__PURE__ */ React12.createElement("div", { className: "oui-text-base-contrast oui-text-2xs oui-font-semibold" }, "EVM")))) : /* @__PURE__ */ React12.createElement("div", { className: "oui-flex oui-items-center oui-justify-start oui-gap-1" }, /* @__PURE__ */ React12.createElement("div", { className: "" }, /* @__PURE__ */ React12.createElement(
|
|
1020
|
-
"img",
|
|
1021
|
-
{
|
|
1022
|
-
src: "https://oss.orderly.network/static/sdk/solana-logo.png",
|
|
1023
|
-
className: "oui-w-4"
|
|
1024
|
-
}
|
|
1025
|
-
)), /* @__PURE__ */ React12.createElement("div", { className: "oui-text-base-contrast oui-text-2xs oui-font-semibold" }, "Solana")), props.isBoth && /* @__PURE__ */ React12.createElement("div", null, /* @__PURE__ */ React12.createElement(
|
|
1538
|
+
) : /* @__PURE__ */ React19.createElement(NonPrivyWalletHandleOption, { walletType: props.type }))), /* @__PURE__ */ React19.createElement("div", { className: "oui-flex oui-items-center oui-justify-between" }, /* @__PURE__ */ React19.createElement(RenderWalletType, { walletType: props.type }), props.isMulti && /* @__PURE__ */ React19.createElement("div", null, /* @__PURE__ */ React19.createElement(
|
|
1026
1539
|
Checkbox,
|
|
1027
1540
|
{
|
|
1028
1541
|
checked: props.isActive,
|
|
@@ -1035,7 +1548,22 @@ function NonPrivyWalletHandleOption({
|
|
|
1035
1548
|
walletType
|
|
1036
1549
|
}) {
|
|
1037
1550
|
const { disconnect } = useWallet2();
|
|
1038
|
-
|
|
1551
|
+
const disconnectWallet = () => {
|
|
1552
|
+
let walletConnectType = "EVM" /* EVM */;
|
|
1553
|
+
switch (walletType) {
|
|
1554
|
+
case "EVM" /* EVM */:
|
|
1555
|
+
walletConnectType = "EVM" /* EVM */;
|
|
1556
|
+
break;
|
|
1557
|
+
case "SOL" /* SOL */:
|
|
1558
|
+
walletConnectType = "SOL" /* SOL */;
|
|
1559
|
+
break;
|
|
1560
|
+
case "Abstract" /* ABSTRACT */:
|
|
1561
|
+
walletConnectType = "Abstract" /* ABSTRACT */;
|
|
1562
|
+
break;
|
|
1563
|
+
}
|
|
1564
|
+
disconnect(walletConnectType);
|
|
1565
|
+
};
|
|
1566
|
+
return /* @__PURE__ */ React19.createElement("div", { onClick: () => disconnectWallet() }, /* @__PURE__ */ React19.createElement(DisconnectIcon, { className: "oui-size-4 oui-cursor-pointer oui-text-base-contrast-80 hover:oui-text-base-contrast" }));
|
|
1039
1567
|
}
|
|
1040
1568
|
function PrivyWalletHandleOption({
|
|
1041
1569
|
address,
|
|
@@ -1043,69 +1571,76 @@ function PrivyWalletHandleOption({
|
|
|
1043
1571
|
}) {
|
|
1044
1572
|
const { t } = useTranslation();
|
|
1045
1573
|
const { exportWallet } = usePrivyWallet();
|
|
1046
|
-
return /* @__PURE__ */
|
|
1574
|
+
return /* @__PURE__ */ React19.createElement(DropdownMenuRoot, null, /* @__PURE__ */ React19.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React19.createElement("button", null, /* @__PURE__ */ React19.createElement(MoreIcon, { className: "oui-cursor-pointer oui-text-base-contrast-80 hover:oui-text-base-contrast" }))), /* @__PURE__ */ React19.createElement(DropdownMenuPortal, null, /* @__PURE__ */ React19.createElement(
|
|
1047
1575
|
DropdownMenuContent,
|
|
1048
1576
|
{
|
|
1049
1577
|
size: "xl",
|
|
1050
1578
|
align: "end",
|
|
1051
1579
|
side: "top",
|
|
1052
1580
|
style: { width: "100px" },
|
|
1053
|
-
className: "oui-
|
|
1581
|
+
className: "oui-z-[65] oui-rounded oui-p-1 oui-font-semibold",
|
|
1054
1582
|
sideOffset: 0
|
|
1055
1583
|
},
|
|
1056
|
-
/* @__PURE__ */
|
|
1584
|
+
/* @__PURE__ */ React19.createElement(
|
|
1057
1585
|
DropdownMenuItem,
|
|
1058
1586
|
{
|
|
1059
|
-
className: "oui-
|
|
1587
|
+
className: "oui-cursor-pointer oui-px-2 oui-py-1 oui-text-2xs oui-text-base-contrast-54 hover:oui-text-base-contrast",
|
|
1060
1588
|
onClick: () => {
|
|
1061
1589
|
exportWallet(type);
|
|
1062
1590
|
}
|
|
1063
1591
|
},
|
|
1064
|
-
/* @__PURE__ */
|
|
1592
|
+
/* @__PURE__ */ React19.createElement("div", null, t("common.export"))
|
|
1065
1593
|
)
|
|
1066
1594
|
)));
|
|
1067
1595
|
}
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
Popover,
|
|
1076
|
-
{
|
|
1077
|
-
content: /* @__PURE__ */ React12.createElement("div", null, /* @__PURE__ */ React12.createElement("div", { className: "oui-text-2xs oui-text-base-contrast oui-font-semibold" }, t("connector.privy.supportedEvmChain")), /* @__PURE__ */ React12.createElement("div", { className: "oui-grid oui-grid-cols-3 oui-gap-y-3 oui-gap-x-2 oui-mt-3 oui-text-2xs oui-text-base-contrast-54" }, chains.map((item, key) => /* @__PURE__ */ React12.createElement(
|
|
1078
|
-
"div",
|
|
1079
|
-
{
|
|
1080
|
-
key,
|
|
1081
|
-
className: "oui-flex oui-items-center oui-justify-start oui-gap-1"
|
|
1082
|
-
},
|
|
1083
|
-
/* @__PURE__ */ React12.createElement(ChainIcon, { chainId: item.id, size: "2xs" }),
|
|
1084
|
-
/* @__PURE__ */ React12.createElement("div", null, item.name)
|
|
1085
|
-
)))),
|
|
1086
|
-
arrow: true,
|
|
1087
|
-
contentProps: {
|
|
1088
|
-
side: "bottom",
|
|
1089
|
-
align: "center",
|
|
1090
|
-
className: "oui-p-2 oui-z-[65]"
|
|
1596
|
+
var RenderWalletType = ({ walletType }) => {
|
|
1597
|
+
if (walletType === "SOL" /* SOL */) {
|
|
1598
|
+
return /* @__PURE__ */ React19.createElement("div", { className: "oui-flex oui-items-center oui-justify-start oui-gap-1" }, /* @__PURE__ */ React19.createElement("div", { className: "" }, /* @__PURE__ */ React19.createElement(
|
|
1599
|
+
"img",
|
|
1600
|
+
{
|
|
1601
|
+
src: "https://oss.orderly.network/static/sdk/solana-logo.png",
|
|
1602
|
+
className: "oui-w-4"
|
|
1091
1603
|
}
|
|
1092
|
-
},
|
|
1093
|
-
|
|
1094
|
-
)
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1604
|
+
)), /* @__PURE__ */ React19.createElement("div", { className: "oui-text-2xs oui-font-semibold oui-text-base-contrast" }, "Solana"));
|
|
1605
|
+
}
|
|
1606
|
+
if (walletType === "Abstract" /* ABSTRACT */) {
|
|
1607
|
+
return /* @__PURE__ */ React19.createElement("div", { className: "oui-flex oui-items-center oui-justify-start oui-gap-[6px]" }, /* @__PURE__ */ React19.createElement(
|
|
1608
|
+
"img",
|
|
1609
|
+
{
|
|
1610
|
+
src: `${PrivyConnectorImagePath}/abstract-transparent.png`,
|
|
1611
|
+
className: "oui-w-4"
|
|
1612
|
+
}
|
|
1613
|
+
), /* @__PURE__ */ React19.createElement("div", { className: "oui-text-2xs oui-font-semibold oui-text-base-contrast" }, "Abstract"));
|
|
1614
|
+
}
|
|
1615
|
+
if (walletType === "EVM" /* EVM */) {
|
|
1616
|
+
return /* @__PURE__ */ React19.createElement("div", { className: "oui-flex oui-items-center oui-justify-center oui-gap-1" }, /* @__PURE__ */ React19.createElement("div", { className: "oui-relative oui-flex oui-items-center oui-justify-center" }, /* @__PURE__ */ React19.createElement("div", { className: "oui-flex oui-h-[18px] oui-items-center oui-justify-center " }, /* @__PURE__ */ React19.createElement(
|
|
1617
|
+
"img",
|
|
1618
|
+
{
|
|
1619
|
+
src: "https://oss.orderly.network/static/sdk/chains.png",
|
|
1620
|
+
className: "oui-relative oui-z-0 oui-h-[18px] oui-w-[49px]"
|
|
1621
|
+
}
|
|
1622
|
+
)), /* @__PURE__ */ React19.createElement("div", { className: "oui-relative oui-left-[-9px] oui-flex oui-items-center oui-justify-center oui-gap-1" }, /* @__PURE__ */ React19.createElement("div", { className: "oui-flex oui-size-[18px] oui-items-center oui-justify-center oui-rounded-full oui-bg-[#282e3a]" }, /* @__PURE__ */ React19.createElement(EVMChainPopover, null, /* @__PURE__ */ React19.createElement(
|
|
1623
|
+
MoreIcon,
|
|
1624
|
+
{
|
|
1625
|
+
className: "oui-relative oui-z-10 oui-size-3 oui-text-base-contrast-54 hover:oui-text-base-contrast",
|
|
1626
|
+
style: { zIndex: 1 }
|
|
1627
|
+
}
|
|
1628
|
+
))), /* @__PURE__ */ React19.createElement("div", { className: "oui-text-2xs oui-font-semibold oui-text-base-contrast" }, "Evm"))));
|
|
1629
|
+
}
|
|
1630
|
+
return /* @__PURE__ */ React19.createElement(React19.Fragment, null);
|
|
1631
|
+
};
|
|
1632
|
+
function AddAbstractWallet() {
|
|
1100
1633
|
const [visible, setVisible] = useState(false);
|
|
1101
1634
|
const onToggleVisibility = () => {
|
|
1102
1635
|
setVisible(!visible);
|
|
1103
1636
|
};
|
|
1104
|
-
const {
|
|
1637
|
+
const { connect } = useWallet2();
|
|
1638
|
+
const { targetWalletType } = useWalletConnectorPrivy();
|
|
1105
1639
|
const [open, setOpen] = useState(false);
|
|
1640
|
+
const { t } = useTranslation();
|
|
1106
1641
|
useEffect(() => {
|
|
1107
1642
|
let timer = 0;
|
|
1108
|
-
if (
|
|
1643
|
+
if (targetWalletType === "Abstract" /* ABSTRACT */) {
|
|
1109
1644
|
timer = window.setTimeout(() => {
|
|
1110
1645
|
setOpen(true);
|
|
1111
1646
|
}, 200);
|
|
@@ -1115,7 +1650,7 @@ function AddSolanaWallet() {
|
|
|
1115
1650
|
window.clearTimeout(timer);
|
|
1116
1651
|
}
|
|
1117
1652
|
};
|
|
1118
|
-
}, [
|
|
1653
|
+
}, [targetWalletType]);
|
|
1119
1654
|
useEffect(() => {
|
|
1120
1655
|
if (open === false) {
|
|
1121
1656
|
return;
|
|
@@ -1129,27 +1664,27 @@ function AddSolanaWallet() {
|
|
|
1129
1664
|
}
|
|
1130
1665
|
};
|
|
1131
1666
|
}, [open]);
|
|
1132
|
-
return /* @__PURE__ */
|
|
1667
|
+
return /* @__PURE__ */ React19.createElement("div", { className: "oui-rounded-[8px] oui-bg-[#07080A] oui-px-2 oui-py-[11px]" }, /* @__PURE__ */ React19.createElement(
|
|
1133
1668
|
Tooltip,
|
|
1134
1669
|
{
|
|
1135
|
-
className: "oui-
|
|
1670
|
+
className: "oui-z-[65] oui-max-w-[200px] oui-text-warning-darken",
|
|
1136
1671
|
open,
|
|
1137
|
-
content: t("connector.privy.
|
|
1672
|
+
content: t("connector.privy.addAbstractWallet.tips")
|
|
1138
1673
|
},
|
|
1139
|
-
/* @__PURE__ */
|
|
1674
|
+
/* @__PURE__ */ React19.createElement("div", { className: "oui-flex oui-items-center oui-justify-center oui-gap-1 " }, /* @__PURE__ */ React19.createElement(
|
|
1140
1675
|
"img",
|
|
1141
1676
|
{
|
|
1142
|
-
src:
|
|
1143
|
-
className: "oui-
|
|
1677
|
+
src: `${PrivyConnectorImagePath}/abstract-transparent.png`,
|
|
1678
|
+
className: "oui-size-[15px]"
|
|
1144
1679
|
}
|
|
1145
|
-
), /* @__PURE__ */
|
|
1680
|
+
), /* @__PURE__ */ React19.createElement("div", { className: "oui-text-2xs oui-font-semibold oui-text-base-contrast-80" }, t("connector.privy.addAbstractWallet")), /* @__PURE__ */ React19.createElement("button", { onClick: onToggleVisibility }, visible ? /* @__PURE__ */ React19.createElement(
|
|
1146
1681
|
ChevronDownIcon,
|
|
1147
1682
|
{
|
|
1148
1683
|
size: 16,
|
|
1149
1684
|
opacity: 1,
|
|
1150
1685
|
className: "oui-text-base-contrast-36"
|
|
1151
1686
|
}
|
|
1152
|
-
) : /* @__PURE__ */
|
|
1687
|
+
) : /* @__PURE__ */ React19.createElement(
|
|
1153
1688
|
ChevronUpIcon,
|
|
1154
1689
|
{
|
|
1155
1690
|
size: 16,
|
|
@@ -1157,27 +1692,32 @@ function AddSolanaWallet() {
|
|
|
1157
1692
|
className: "oui-text-base-contrast"
|
|
1158
1693
|
}
|
|
1159
1694
|
)))
|
|
1160
|
-
), /* @__PURE__ */
|
|
1695
|
+
), /* @__PURE__ */ React19.createElement(
|
|
1161
1696
|
"div",
|
|
1162
1697
|
{
|
|
1163
1698
|
className: cn(
|
|
1164
|
-
"oui-grid oui-grid-cols-2 oui-gap-2 oui-
|
|
1165
|
-
visible ? "oui-
|
|
1699
|
+
"oui-transition-height oui-grid oui-grid-cols-2 oui-gap-2 oui-overflow-hidden oui-duration-150",
|
|
1700
|
+
visible ? "oui-mt-0 oui-max-h-0" : "oui-mt-3 oui-max-h-[400px]"
|
|
1166
1701
|
)
|
|
1167
1702
|
},
|
|
1168
|
-
|
|
1703
|
+
/* @__PURE__ */ React19.createElement(
|
|
1169
1704
|
"div",
|
|
1170
1705
|
{
|
|
1171
|
-
|
|
1172
|
-
className: "oui-flex oui-items-center oui-justify-start oui-gap-1 oui-px-2 oui-py-[11px] oui-bg-[#131519] oui-cursor-pointer",
|
|
1706
|
+
className: "oui-flex oui-cursor-pointer oui-items-center oui-justify-start oui-gap-1 oui-bg-[#131519] oui-px-2 oui-py-[11px]",
|
|
1173
1707
|
onClick: () => connect({
|
|
1174
|
-
walletType: "
|
|
1175
|
-
walletAdapter: item.adapter
|
|
1708
|
+
walletType: "Abstract" /* ABSTRACT */
|
|
1176
1709
|
})
|
|
1177
1710
|
},
|
|
1178
|
-
/* @__PURE__ */
|
|
1179
|
-
|
|
1180
|
-
|
|
1711
|
+
/* @__PURE__ */ React19.createElement(
|
|
1712
|
+
"img",
|
|
1713
|
+
{
|
|
1714
|
+
className: cn("oui-size-[12px]"),
|
|
1715
|
+
src: `${PrivyConnectorImagePath}/abstract.png`,
|
|
1716
|
+
alt: "abstract wallet"
|
|
1717
|
+
}
|
|
1718
|
+
),
|
|
1719
|
+
/* @__PURE__ */ React19.createElement("div", { className: "oui-text-2xs oui-text-base-contrast" }, "Abstract")
|
|
1720
|
+
)
|
|
1181
1721
|
));
|
|
1182
1722
|
}
|
|
1183
1723
|
function AddEvmWallet() {
|
|
@@ -1186,10 +1726,10 @@ function AddEvmWallet() {
|
|
|
1186
1726
|
const { connect } = useWallet2();
|
|
1187
1727
|
const [open, setOpen] = useState(false);
|
|
1188
1728
|
const { connectors } = useWagmiWallet();
|
|
1189
|
-
const {
|
|
1729
|
+
const { targetWalletType } = useWalletConnectorPrivy();
|
|
1190
1730
|
useEffect(() => {
|
|
1191
1731
|
let timer = 0;
|
|
1192
|
-
if (
|
|
1732
|
+
if (targetWalletType === "EVM" /* EVM */) {
|
|
1193
1733
|
timer = window.setTimeout(() => {
|
|
1194
1734
|
setOpen(true);
|
|
1195
1735
|
}, 200);
|
|
@@ -1199,7 +1739,7 @@ function AddEvmWallet() {
|
|
|
1199
1739
|
window.clearTimeout(timer);
|
|
1200
1740
|
}
|
|
1201
1741
|
};
|
|
1202
|
-
}, [
|
|
1742
|
+
}, [targetWalletType]);
|
|
1203
1743
|
useEffect(() => {
|
|
1204
1744
|
if (open === false) {
|
|
1205
1745
|
return;
|
|
@@ -1213,33 +1753,33 @@ function AddEvmWallet() {
|
|
|
1213
1753
|
}
|
|
1214
1754
|
};
|
|
1215
1755
|
}, [open]);
|
|
1216
|
-
return /* @__PURE__ */
|
|
1756
|
+
return /* @__PURE__ */ React19.createElement("div", { className: "oui-rounded-[8px] oui-bg-[#07080A] oui-px-2 oui-py-[11px]" }, /* @__PURE__ */ React19.createElement(
|
|
1217
1757
|
Tooltip,
|
|
1218
1758
|
{
|
|
1219
|
-
className: "oui-
|
|
1759
|
+
className: "oui-z-[65] oui-max-w-[200px] oui-text-warning-darken",
|
|
1220
1760
|
open,
|
|
1221
1761
|
content: t("connector.privy.addEvmWallet.tips")
|
|
1222
1762
|
},
|
|
1223
|
-
/* @__PURE__ */
|
|
1763
|
+
/* @__PURE__ */ React19.createElement("div", { className: "oui-flex oui-items-center oui-justify-center oui-gap-1 " }, /* @__PURE__ */ React19.createElement("div", { className: "oui-flex oui-items-center oui-justify-center oui-gap-1" }, /* @__PURE__ */ React19.createElement("div", { className: "oui-relative oui-flex oui-w-[55px] oui-items-center oui-justify-start" }, /* @__PURE__ */ React19.createElement(
|
|
1224
1764
|
"img",
|
|
1225
1765
|
{
|
|
1226
1766
|
src: "https://oss.orderly.network/static/sdk/chains.png",
|
|
1227
|
-
className: "oui-
|
|
1767
|
+
className: "oui-relative oui-z-0 oui-h-[18px]"
|
|
1228
1768
|
}
|
|
1229
|
-
), /* @__PURE__ */
|
|
1769
|
+
), /* @__PURE__ */ React19.createElement("div", { className: "oui-absolute oui-right-0 oui-flex oui-size-[18px] oui-items-center oui-justify-center oui-rounded-full oui-bg-[#282e3a]" }, /* @__PURE__ */ React19.createElement(EVMChainPopover, null, /* @__PURE__ */ React19.createElement(
|
|
1230
1770
|
MoreIcon,
|
|
1231
1771
|
{
|
|
1232
|
-
className: "oui-
|
|
1772
|
+
className: "oui-relative oui-z-10 oui-size-3 oui-text-base-contrast-54 hover:oui-text-base-contrast",
|
|
1233
1773
|
style: { zIndex: 1 }
|
|
1234
1774
|
}
|
|
1235
|
-
))))), /* @__PURE__ */
|
|
1775
|
+
))))), /* @__PURE__ */ React19.createElement("div", { className: "oui-text-2xs oui-font-semibold oui-text-base-contrast-80" }, t("connector.privy.addEvmWallet")), /* @__PURE__ */ React19.createElement("button", { onClick: () => setVisible(!visible) }, visible ? /* @__PURE__ */ React19.createElement(
|
|
1236
1776
|
ChevronDownIcon,
|
|
1237
1777
|
{
|
|
1238
1778
|
size: 16,
|
|
1239
1779
|
opacity: 1,
|
|
1240
1780
|
className: "oui-text-base-contrast-36"
|
|
1241
1781
|
}
|
|
1242
|
-
) : /* @__PURE__ */
|
|
1782
|
+
) : /* @__PURE__ */ React19.createElement(
|
|
1243
1783
|
ChevronUpIcon,
|
|
1244
1784
|
{
|
|
1245
1785
|
size: 16,
|
|
@@ -1247,241 +1787,243 @@ function AddEvmWallet() {
|
|
|
1247
1787
|
className: "oui-text-base-contrast"
|
|
1248
1788
|
}
|
|
1249
1789
|
)))
|
|
1250
|
-
), /* @__PURE__ */
|
|
1790
|
+
), /* @__PURE__ */ React19.createElement(
|
|
1251
1791
|
"div",
|
|
1252
1792
|
{
|
|
1253
1793
|
className: cn(
|
|
1254
|
-
"oui-grid oui-grid-cols-2 oui-gap-2 oui-
|
|
1255
|
-
visible ? "oui-
|
|
1794
|
+
"oui-transition-height oui-grid oui-grid-cols-2 oui-gap-2 oui-overflow-hidden oui-duration-150",
|
|
1795
|
+
visible ? "oui-mt-0 oui-max-h-0" : "oui-mt-3 oui-max-h-[400px]"
|
|
1256
1796
|
)
|
|
1257
1797
|
},
|
|
1258
|
-
connectors.map((item, index) => /* @__PURE__ */
|
|
1798
|
+
connectors.map((item, index) => /* @__PURE__ */ React19.createElement(
|
|
1259
1799
|
"div",
|
|
1260
1800
|
{
|
|
1261
1801
|
key: index,
|
|
1262
|
-
className: "oui-flex oui-items-center oui-justify-center
|
|
1802
|
+
className: "oui-flex oui-cursor-pointer oui-items-center oui-justify-center oui-gap-1 oui-bg-[#131519] oui-px-2 oui-py-[11px] oui-text-2xs",
|
|
1263
1803
|
onClick: () => connect({ walletType: "EVM" /* EVM */, connector: item })
|
|
1264
1804
|
},
|
|
1265
|
-
/* @__PURE__ */
|
|
1266
|
-
/* @__PURE__ */
|
|
1805
|
+
/* @__PURE__ */ React19.createElement(RenderWalletIcon, { connector: item }),
|
|
1806
|
+
/* @__PURE__ */ React19.createElement("div", { className: "oui-text-base-contrast" }, item.name)
|
|
1267
1807
|
))
|
|
1268
1808
|
));
|
|
1269
1809
|
}
|
|
1270
|
-
function
|
|
1271
|
-
chainNamespace
|
|
1272
|
-
}) {
|
|
1810
|
+
function AddSolanaWallet() {
|
|
1273
1811
|
const { t } = useTranslation();
|
|
1274
|
-
const
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1812
|
+
const { wallets } = useSolanaWallet();
|
|
1813
|
+
const { connect } = useWallet2();
|
|
1814
|
+
const [visible, setVisible] = useState(false);
|
|
1815
|
+
const onToggleVisibility = () => {
|
|
1816
|
+
setVisible(!visible);
|
|
1279
1817
|
};
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1818
|
+
const { targetWalletType } = useWalletConnectorPrivy();
|
|
1819
|
+
const [open, setOpen] = useState(false);
|
|
1820
|
+
useEffect(() => {
|
|
1821
|
+
let timer = 0;
|
|
1822
|
+
if (targetWalletType === "SOL" /* SOL */) {
|
|
1823
|
+
timer = window.setTimeout(() => {
|
|
1824
|
+
setOpen(true);
|
|
1825
|
+
}, 200);
|
|
1285
1826
|
}
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1827
|
+
return () => {
|
|
1828
|
+
if (timer) {
|
|
1829
|
+
window.clearTimeout(timer);
|
|
1830
|
+
}
|
|
1831
|
+
};
|
|
1832
|
+
}, [targetWalletType]);
|
|
1833
|
+
useEffect(() => {
|
|
1834
|
+
if (open === false) {
|
|
1835
|
+
return;
|
|
1836
|
+
}
|
|
1837
|
+
const timeId = window.setTimeout(() => {
|
|
1838
|
+
setOpen(false);
|
|
1839
|
+
}, 5e3);
|
|
1840
|
+
return () => {
|
|
1841
|
+
if (timeId) {
|
|
1842
|
+
window.clearTimeout(timeId);
|
|
1843
|
+
}
|
|
1844
|
+
};
|
|
1845
|
+
}, [open]);
|
|
1846
|
+
return /* @__PURE__ */ React19.createElement("div", { className: "oui-rounded-[8px] oui-bg-[#07080A] oui-px-2 oui-py-[11px]" }, /* @__PURE__ */ React19.createElement(
|
|
1847
|
+
Tooltip,
|
|
1848
|
+
{
|
|
1849
|
+
className: "oui-z-[65] oui-max-w-[200px] oui-text-warning-darken",
|
|
1850
|
+
open,
|
|
1851
|
+
content: t("connector.privy.addSolanaWallet.tips")
|
|
1852
|
+
},
|
|
1853
|
+
/* @__PURE__ */ React19.createElement("div", { className: "oui-flex oui-items-center oui-justify-center oui-gap-1 " }, /* @__PURE__ */ React19.createElement(
|
|
1854
|
+
"img",
|
|
1855
|
+
{
|
|
1856
|
+
src: "https://oss.orderly.network/static/sdk/solana-logo.png",
|
|
1857
|
+
className: "oui-size-[15px]"
|
|
1858
|
+
}
|
|
1859
|
+
), /* @__PURE__ */ React19.createElement("div", { className: "oui-text-2xs oui-font-semibold oui-text-base-contrast-80" }, t("connector.privy.addSolanaWallet")), /* @__PURE__ */ React19.createElement("button", { onClick: onToggleVisibility }, visible ? /* @__PURE__ */ React19.createElement(
|
|
1860
|
+
ChevronDownIcon,
|
|
1861
|
+
{
|
|
1862
|
+
size: 16,
|
|
1863
|
+
opacity: 1,
|
|
1864
|
+
className: "oui-text-base-contrast-36"
|
|
1865
|
+
}
|
|
1866
|
+
) : /* @__PURE__ */ React19.createElement(
|
|
1867
|
+
ChevronUpIcon,
|
|
1868
|
+
{
|
|
1869
|
+
size: 16,
|
|
1870
|
+
opacity: 1,
|
|
1871
|
+
className: "oui-text-base-contrast"
|
|
1872
|
+
}
|
|
1873
|
+
)))
|
|
1874
|
+
), /* @__PURE__ */ React19.createElement(
|
|
1875
|
+
"div",
|
|
1876
|
+
{
|
|
1877
|
+
className: cn(
|
|
1878
|
+
"oui-transition-height oui-grid oui-grid-cols-2 oui-gap-2 oui-overflow-hidden oui-duration-150",
|
|
1879
|
+
visible ? "oui-mt-0 oui-max-h-0" : "oui-mt-3 oui-max-h-[400px]"
|
|
1880
|
+
)
|
|
1881
|
+
},
|
|
1882
|
+
wallets.map((item, index) => /* @__PURE__ */ React19.createElement(
|
|
1883
|
+
"div",
|
|
1884
|
+
{
|
|
1885
|
+
key: index,
|
|
1886
|
+
className: "oui-flex oui-cursor-pointer oui-items-center oui-justify-start oui-gap-1 oui-bg-[#131519] oui-px-2 oui-py-[11px]",
|
|
1887
|
+
onClick: () => connect({
|
|
1888
|
+
walletType: "SOL" /* SOL */,
|
|
1889
|
+
walletAdapter: item.adapter
|
|
1890
|
+
})
|
|
1891
|
+
},
|
|
1892
|
+
/* @__PURE__ */ React19.createElement(RenderWalletIcon, { connector: item.adapter }),
|
|
1893
|
+
/* @__PURE__ */ React19.createElement("div", { className: "oui-text-2xs oui-text-base-contrast" }, item.adapter.name)
|
|
1894
|
+
))
|
|
1895
|
+
));
|
|
1289
1896
|
}
|
|
1290
|
-
var StorageChainNotCurrentWalletType = ({
|
|
1291
|
-
currentWalletChainType
|
|
1292
|
-
}) => {
|
|
1293
|
-
const { storageChain } = useStorageChain();
|
|
1294
|
-
if (currentWalletChainType === storageChain?.namespace) {
|
|
1295
|
-
return null;
|
|
1296
|
-
}
|
|
1297
|
-
if (storageChain?.namespace === ChainNamespace.evm) {
|
|
1298
|
-
return /* @__PURE__ */ React12.createElement(SwitchNetworkTips, { chainNamespace: ChainNamespace.solana });
|
|
1299
|
-
}
|
|
1300
|
-
return /* @__PURE__ */ React12.createElement(SwitchNetworkTips, { chainNamespace: ChainNamespace.evm });
|
|
1301
|
-
};
|
|
1302
1897
|
|
|
1303
|
-
// src/components/
|
|
1304
|
-
function
|
|
1898
|
+
// src/components/renderNonPrivyWallet/index.tsx
|
|
1899
|
+
function RenderNonPrivyWallet() {
|
|
1900
|
+
const [walletList, setWalletList] = useState([]);
|
|
1901
|
+
const [addWalletList, setAddWalletList] = useState([]);
|
|
1902
|
+
const { storageChain } = useStorageChain();
|
|
1903
|
+
const { connectorWalletType, walletChainTypeConfig } = useWalletConnectorPrivy();
|
|
1305
1904
|
const { wallet: walletInWagmi, isConnected: isConnectedEvm } = useWagmiWallet();
|
|
1306
1905
|
const { wallet: walletInSolana, isConnected: isConnectedSolana } = useSolanaWallet();
|
|
1906
|
+
const { wallet: walletInAbstract, isConnected: isConnectedAbstract } = useAbstractWallet();
|
|
1307
1907
|
const { namespace, switchWallet } = useWallet2();
|
|
1308
|
-
const
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
onActiveChange: () => {
|
|
1318
|
-
switchWallet(ChainNamespace.evm);
|
|
1319
|
-
},
|
|
1320
|
-
isPrivy: false,
|
|
1321
|
-
isBoth: true
|
|
1322
|
-
}
|
|
1323
|
-
), /* @__PURE__ */ React12.createElement(
|
|
1324
|
-
WalletCard,
|
|
1325
|
-
{
|
|
1326
|
-
type: "SOL" /* SOL */,
|
|
1327
|
-
address: walletInSolana?.accounts[0].address,
|
|
1328
|
-
isActive: namespace === ChainNamespace.solana,
|
|
1329
|
-
onActiveChange: () => {
|
|
1330
|
-
switchWallet(ChainNamespace.solana);
|
|
1331
|
-
},
|
|
1332
|
-
isPrivy: false,
|
|
1333
|
-
isBoth: true
|
|
1334
|
-
}
|
|
1335
|
-
));
|
|
1336
|
-
}
|
|
1337
|
-
if (isConnectedEvm && !isConnectedSolana) {
|
|
1338
|
-
return /* @__PURE__ */ React12.createElement("div", { className: "" }, /* @__PURE__ */ React12.createElement(
|
|
1339
|
-
StorageChainNotCurrentWalletType,
|
|
1340
|
-
{
|
|
1341
|
-
currentWalletChainType: ChainNamespace.evm
|
|
1342
|
-
}
|
|
1343
|
-
), /* @__PURE__ */ React12.createElement(
|
|
1344
|
-
WalletCard,
|
|
1345
|
-
{
|
|
1346
|
-
type: "EVM" /* EVM */,
|
|
1347
|
-
address: walletInWagmi?.accounts[0].address,
|
|
1348
|
-
isActive: namespace === ChainNamespace.evm,
|
|
1349
|
-
onActiveChange: () => {
|
|
1350
|
-
switchWallet(ChainNamespace.evm);
|
|
1351
|
-
},
|
|
1352
|
-
isPrivy: false,
|
|
1353
|
-
isBoth: false
|
|
1354
|
-
}
|
|
1355
|
-
), !connectorWalletType.disableSolana && /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement("div", { className: "oui-h-[1px] oui-bg-line oui-my-5" }), /* @__PURE__ */ React12.createElement(AddSolanaWallet, null)));
|
|
1356
|
-
}
|
|
1357
|
-
if (!isConnectedEvm && isConnectedSolana) {
|
|
1358
|
-
return /* @__PURE__ */ React12.createElement("div", { className: "" }, /* @__PURE__ */ React12.createElement(
|
|
1359
|
-
StorageChainNotCurrentWalletType,
|
|
1360
|
-
{
|
|
1361
|
-
currentWalletChainType: ChainNamespace.solana
|
|
1362
|
-
}
|
|
1363
|
-
), /* @__PURE__ */ React12.createElement(
|
|
1364
|
-
WalletCard,
|
|
1365
|
-
{
|
|
1366
|
-
type: "SOL" /* SOL */,
|
|
1367
|
-
address: walletInSolana?.accounts[0].address,
|
|
1368
|
-
isActive: namespace === ChainNamespace.solana,
|
|
1369
|
-
onActiveChange: () => {
|
|
1370
|
-
switchWallet(ChainNamespace.solana);
|
|
1371
|
-
},
|
|
1372
|
-
isPrivy: false,
|
|
1373
|
-
isBoth: false
|
|
1374
|
-
}
|
|
1375
|
-
), !connectorWalletType.disableWagmi && /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement("div", { className: "oui-h-[1px] oui-bg-line oui-my-5" }), /* @__PURE__ */ React12.createElement(AddEvmWallet, null)));
|
|
1376
|
-
}
|
|
1377
|
-
}
|
|
1378
|
-
if (walletChainType === "onlySOL" /* onlySOL */) {
|
|
1379
|
-
if (isConnectedSolana) {
|
|
1380
|
-
return /* @__PURE__ */ React12.createElement("div", { className: "" }, /* @__PURE__ */ React12.createElement(
|
|
1381
|
-
WalletCard,
|
|
1382
|
-
{
|
|
1383
|
-
type: "SOL" /* SOL */,
|
|
1384
|
-
address: walletInSolana?.accounts[0].address,
|
|
1385
|
-
isActive: namespace === ChainNamespace.solana,
|
|
1386
|
-
onActiveChange: () => {
|
|
1387
|
-
switchWallet(ChainNamespace.solana);
|
|
1388
|
-
},
|
|
1389
|
-
isPrivy: false,
|
|
1390
|
-
isBoth: false
|
|
1391
|
-
}
|
|
1392
|
-
));
|
|
1908
|
+
const isActive = (walletType) => {
|
|
1909
|
+
if (namespace === ChainNamespace.evm) {
|
|
1910
|
+
if (walletType === "Abstract" /* ABSTRACT */) {
|
|
1911
|
+
return AbstractChains.has(storageChain?.chainId);
|
|
1912
|
+
}
|
|
1913
|
+
if (walletType === "EVM" /* EVM */) {
|
|
1914
|
+
return !AbstractChains.has(storageChain?.chainId);
|
|
1915
|
+
}
|
|
1916
|
+
return false;
|
|
1393
1917
|
}
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
if (isConnectedEvm) {
|
|
1397
|
-
return /* @__PURE__ */ React12.createElement("div", { className: "" }, /* @__PURE__ */ React12.createElement(
|
|
1398
|
-
WalletCard,
|
|
1399
|
-
{
|
|
1400
|
-
type: "EVM" /* EVM */,
|
|
1401
|
-
address: walletInWagmi?.accounts[0].address,
|
|
1402
|
-
isActive: namespace === ChainNamespace.evm,
|
|
1403
|
-
onActiveChange: () => {
|
|
1404
|
-
switchWallet(ChainNamespace.evm);
|
|
1405
|
-
},
|
|
1406
|
-
isPrivy: false,
|
|
1407
|
-
isBoth: false
|
|
1408
|
-
}
|
|
1409
|
-
));
|
|
1918
|
+
if (namespace === ChainNamespace.solana) {
|
|
1919
|
+
return walletType === "SOL" /* SOL */;
|
|
1410
1920
|
}
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1921
|
+
return false;
|
|
1922
|
+
};
|
|
1923
|
+
const currentConnectWalletType = useMemo(() => {
|
|
1924
|
+
const temp = /* @__PURE__ */ new Set();
|
|
1925
|
+
walletList.forEach((wallet) => {
|
|
1926
|
+
temp.add(wallet.type);
|
|
1927
|
+
});
|
|
1928
|
+
return temp;
|
|
1929
|
+
}, [walletList]);
|
|
1417
1930
|
useEffect(() => {
|
|
1418
|
-
|
|
1419
|
-
const
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
return () => {
|
|
1429
|
-
document.body.style.overflow = "auto";
|
|
1430
|
-
window.removeEventListener("resize", handleResize);
|
|
1431
|
-
};
|
|
1432
|
-
}, [isOpen, isMobile]);
|
|
1433
|
-
if (!isOpen)
|
|
1434
|
-
return null;
|
|
1435
|
-
const drawerHeight = isMobile ? windowHeight : windowHeight - 72 - 24;
|
|
1436
|
-
return createPortal(
|
|
1437
|
-
/* @__PURE__ */ React12.createElement("div", { className: "oui-fixed oui-inset-0 oui-z-[60]" }, /* @__PURE__ */ React12.createElement(
|
|
1438
|
-
"div",
|
|
1439
|
-
{
|
|
1440
|
-
className: "oui-absolute oui-inset-0 oui-bg-[rgba(0,0,0,0.48)] oui-transition-opacity",
|
|
1441
|
-
onClick: onClose
|
|
1931
|
+
const tempWalletList = [];
|
|
1932
|
+
const tempAddWallet = [];
|
|
1933
|
+
if (!connectorWalletType.disableWagmi && walletChainTypeConfig.hasEvm) {
|
|
1934
|
+
if (isConnectedEvm) {
|
|
1935
|
+
tempWalletList.push({
|
|
1936
|
+
type: "EVM" /* EVM */,
|
|
1937
|
+
address: walletInWagmi?.accounts[0].address
|
|
1938
|
+
});
|
|
1939
|
+
} else {
|
|
1940
|
+
tempAddWallet.push("EVM" /* EVM */);
|
|
1442
1941
|
}
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
{
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
"
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1942
|
+
}
|
|
1943
|
+
if (!connectorWalletType.disableSolana && walletChainTypeConfig.hasSol) {
|
|
1944
|
+
if (isConnectedSolana) {
|
|
1945
|
+
tempWalletList.push({
|
|
1946
|
+
type: "SOL" /* SOL */,
|
|
1947
|
+
address: walletInSolana?.accounts[0].address
|
|
1948
|
+
});
|
|
1949
|
+
} else {
|
|
1950
|
+
tempAddWallet.push("SOL" /* SOL */);
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
if (!connectorWalletType.disableAGW && walletChainTypeConfig.hasAbstract) {
|
|
1954
|
+
if (isConnectedAbstract) {
|
|
1955
|
+
tempWalletList.push({
|
|
1956
|
+
type: "Abstract" /* ABSTRACT */,
|
|
1957
|
+
address: walletInAbstract?.additionalInfo?.AGWAddress
|
|
1958
|
+
});
|
|
1959
|
+
} else {
|
|
1960
|
+
tempAddWallet.push("Abstract" /* ABSTRACT */);
|
|
1961
|
+
}
|
|
1962
|
+
}
|
|
1963
|
+
setWalletList(tempWalletList);
|
|
1964
|
+
setAddWalletList(tempAddWallet);
|
|
1965
|
+
}, [
|
|
1966
|
+
isConnectedEvm,
|
|
1967
|
+
isConnectedSolana,
|
|
1968
|
+
isConnectedAbstract,
|
|
1969
|
+
walletInWagmi,
|
|
1970
|
+
walletInSolana,
|
|
1971
|
+
walletInAbstract,
|
|
1972
|
+
walletChainTypeConfig,
|
|
1973
|
+
connectorWalletType
|
|
1974
|
+
]);
|
|
1975
|
+
return /* @__PURE__ */ React19.createElement(React19.Fragment, null, walletList.length && /* @__PURE__ */ React19.createElement(
|
|
1976
|
+
StorageChainNotCurrentWalletType,
|
|
1977
|
+
{
|
|
1978
|
+
currentWalletType: currentConnectWalletType
|
|
1979
|
+
}
|
|
1980
|
+
), /* @__PURE__ */ React19.createElement("div", { className: "oui-flex oui-flex-col oui-gap-5" }, walletList.map((wallet) => /* @__PURE__ */ React19.createElement(
|
|
1981
|
+
WalletCard,
|
|
1982
|
+
{
|
|
1983
|
+
key: wallet.type,
|
|
1984
|
+
type: wallet.type,
|
|
1985
|
+
address: wallet.address,
|
|
1986
|
+
isActive: isActive(wallet.type),
|
|
1987
|
+
onActiveChange: () => {
|
|
1988
|
+
switchWallet(wallet.type);
|
|
1463
1989
|
},
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
);
|
|
1990
|
+
isPrivy: false,
|
|
1991
|
+
isMulti: walletList.length > 1
|
|
1992
|
+
}
|
|
1993
|
+
))), /* @__PURE__ */ React19.createElement(RenderAddWallet, { addWalletList }));
|
|
1994
|
+
}
|
|
1995
|
+
function RenderAddWallet({ addWalletList }) {
|
|
1996
|
+
if (addWalletList.length === 0) {
|
|
1997
|
+
return null;
|
|
1998
|
+
}
|
|
1999
|
+
return /* @__PURE__ */ React19.createElement(React19.Fragment, null, /* @__PURE__ */ React19.createElement("div", { className: "oui-my-5 oui-h-px oui-bg-line" }), /* @__PURE__ */ React19.createElement("div", { className: "oui-flex oui-flex-col oui-gap-5" }, addWalletList.map((wallet, index) => {
|
|
2000
|
+
if (wallet === "EVM" /* EVM */) {
|
|
2001
|
+
return /* @__PURE__ */ React19.createElement(AddEvmWallet, { key: index });
|
|
2002
|
+
}
|
|
2003
|
+
if (wallet === "SOL" /* SOL */) {
|
|
2004
|
+
return /* @__PURE__ */ React19.createElement(AddSolanaWallet, { key: index });
|
|
2005
|
+
}
|
|
2006
|
+
if (wallet === "Abstract" /* ABSTRACT */) {
|
|
2007
|
+
return /* @__PURE__ */ React19.createElement(AddAbstractWallet, { key: index });
|
|
2008
|
+
}
|
|
2009
|
+
})));
|
|
1468
2010
|
}
|
|
1469
2011
|
function NoWallet() {
|
|
1470
2012
|
const { walletChainType } = useWalletConnectorPrivy();
|
|
1471
2013
|
const { t } = useTranslation();
|
|
1472
|
-
return /* @__PURE__ */
|
|
2014
|
+
return /* @__PURE__ */ React19.createElement("div", { className: "oui-mt-5 oui-flex oui-w-full oui-flex-col oui-items-center oui-justify-center" }, /* @__PURE__ */ React19.createElement("div", { className: "oui-flex oui-w-full oui-flex-col oui-items-center oui-justify-center oui-gap-3" }, /* @__PURE__ */ React19.createElement("div", { className: "oui-flex oui-w-full oui-flex-col oui-items-center oui-justify-center oui-gap-1 oui-rounded-[8px] oui-border oui-border-line-12 oui-px-2 oui-py-[13px] " }, /* @__PURE__ */ React19.createElement(
|
|
1473
2015
|
"img",
|
|
1474
2016
|
{
|
|
1475
2017
|
src: "https://oss.orderly.network/static/sdk/privy/no-wallet.png",
|
|
1476
|
-
className: "oui-
|
|
2018
|
+
className: "oui-size-[64px]"
|
|
1477
2019
|
}
|
|
1478
|
-
), /* @__PURE__ */
|
|
2020
|
+
), /* @__PURE__ */ React19.createElement("div", { className: "oui-text-2xs oui-font-semibold oui-text-base-contrast-36" }, t("connector.privy.noWallet"))), /* @__PURE__ */ React19.createElement("div", { className: "oui-flex oui-items-start oui-gap-1 oui-rounded-[4px] oui-bg-[rgba(232,136,0,0.15)] oui-px-2 oui-py-[6px] " }, /* @__PURE__ */ React19.createElement(
|
|
1479
2021
|
ExclamationFillIcon,
|
|
1480
2022
|
{
|
|
1481
2023
|
size: 10,
|
|
1482
|
-
className: "oui-mt-1 oui-
|
|
2024
|
+
className: "oui-mt-1 oui-size-[10px] oui-shrink-0 oui-text-warning-darken"
|
|
1483
2025
|
}
|
|
1484
|
-
), /* @__PURE__ */
|
|
2026
|
+
), /* @__PURE__ */ React19.createElement("div", { className: "oui-text-2xs oui-text-warning-darken" }, t("connector.privy.noWallet.description")))), /* @__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" }, walletChainType === "EVM_SOL" /* EVM_SOL */ && /* @__PURE__ */ React19.createElement(React19.Fragment, null, /* @__PURE__ */ React19.createElement(CreateEVMWallet, null), /* @__PURE__ */ React19.createElement(CreateSOLWallet, null)), walletChainType === "onlyEVM" /* onlyEVM */ && /* @__PURE__ */ React19.createElement(CreateEVMWallet, null), walletChainType === "onlySOL" /* onlySOL */ && /* @__PURE__ */ React19.createElement(CreateSOLWallet, null)));
|
|
1485
2027
|
}
|
|
1486
2028
|
function CreateEVMWallet() {
|
|
1487
2029
|
const { t } = useTranslation();
|
|
@@ -1498,23 +2040,23 @@ function CreateEVMWallet() {
|
|
|
1498
2040
|
setLoading(false);
|
|
1499
2041
|
});
|
|
1500
2042
|
};
|
|
1501
|
-
return /* @__PURE__ */
|
|
2043
|
+
return /* @__PURE__ */ React19.createElement("div", { className: "oui-w-full oui-rounded-[8px] oui-bg-[#07080A] oui-px-2 oui-py-[11px]" }, /* @__PURE__ */ React19.createElement("div", { className: "oui-flex oui-items-center oui-justify-center oui-gap-1 " }, /* @__PURE__ */ React19.createElement("div", { className: "oui-flex oui-items-center oui-justify-center oui-gap-1" }, /* @__PURE__ */ React19.createElement("div", { className: "oui-relative oui-flex oui-w-[55px] oui-items-center oui-justify-start" }, /* @__PURE__ */ React19.createElement(
|
|
1502
2044
|
"img",
|
|
1503
2045
|
{
|
|
1504
2046
|
src: "https://oss.orderly.network/static/sdk/chains.png",
|
|
1505
|
-
className: "oui-
|
|
2047
|
+
className: "oui-relative oui-z-0 oui-h-[18px]"
|
|
1506
2048
|
}
|
|
1507
|
-
), /* @__PURE__ */
|
|
2049
|
+
), /* @__PURE__ */ React19.createElement("div", { className: "oui-absolute oui-right-0 oui-flex oui-size-[18px] oui-items-center oui-justify-center oui-rounded-full oui-bg-[#282e3a]" }, /* @__PURE__ */ React19.createElement(EVMChainPopover, null, /* @__PURE__ */ React19.createElement(
|
|
1508
2050
|
MoreIcon,
|
|
1509
2051
|
{
|
|
1510
|
-
className: "oui-
|
|
2052
|
+
className: "oui-relative oui-z-10 oui-size-3 oui-text-base-contrast-54 hover:oui-text-base-contrast",
|
|
1511
2053
|
style: { zIndex: 1 }
|
|
1512
2054
|
}
|
|
1513
|
-
))))), /* @__PURE__ */
|
|
2055
|
+
))))), /* @__PURE__ */ React19.createElement(
|
|
1514
2056
|
"div",
|
|
1515
2057
|
{
|
|
1516
2058
|
className: cn(
|
|
1517
|
-
"oui-
|
|
2059
|
+
"oui-cursor-pointer oui-text-2xs oui-font-semibold oui-text-base-contrast-80",
|
|
1518
2060
|
loading && "oui-opacity-50"
|
|
1519
2061
|
),
|
|
1520
2062
|
onClick: doCreate
|
|
@@ -1537,17 +2079,17 @@ function CreateSOLWallet() {
|
|
|
1537
2079
|
setLoading(false);
|
|
1538
2080
|
});
|
|
1539
2081
|
};
|
|
1540
|
-
return /* @__PURE__ */
|
|
2082
|
+
return /* @__PURE__ */ React19.createElement("div", { className: "oui-w-full oui-rounded-[8px] oui-bg-[#07080A] oui-px-2 oui-py-[11px]" }, /* @__PURE__ */ React19.createElement("div", { className: "oui-flex oui-items-center oui-justify-center oui-gap-1 " }, /* @__PURE__ */ React19.createElement(
|
|
1541
2083
|
"img",
|
|
1542
2084
|
{
|
|
1543
2085
|
src: "https://oss.orderly.network/static/sdk/solana-logo.png",
|
|
1544
|
-
className: "oui-
|
|
2086
|
+
className: "oui-size-[15px]"
|
|
1545
2087
|
}
|
|
1546
|
-
), /* @__PURE__ */
|
|
2088
|
+
), /* @__PURE__ */ React19.createElement(
|
|
1547
2089
|
"div",
|
|
1548
2090
|
{
|
|
1549
2091
|
className: cn(
|
|
1550
|
-
"oui-
|
|
2092
|
+
"oui-cursor-pointer oui-text-2xs oui-font-semibold oui-text-base-contrast-80",
|
|
1551
2093
|
loading && "oui-opacity-50"
|
|
1552
2094
|
),
|
|
1553
2095
|
onClick: doCreate
|
|
@@ -1557,282 +2099,164 @@ function CreateSOLWallet() {
|
|
|
1557
2099
|
}
|
|
1558
2100
|
function RenderPrivyWallet() {
|
|
1559
2101
|
const { t } = useTranslation();
|
|
1560
|
-
const {
|
|
2102
|
+
const {
|
|
2103
|
+
targetWalletType,
|
|
2104
|
+
setTargetWalletType,
|
|
2105
|
+
walletChainTypeConfig,
|
|
2106
|
+
connectorWalletType
|
|
2107
|
+
} = useWalletConnectorPrivy();
|
|
1561
2108
|
const { walletEVM, walletSOL, linkedAccount } = usePrivyWallet();
|
|
1562
|
-
const {
|
|
1563
|
-
const
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
2109
|
+
const { switchWallet, disconnect } = useWallet2();
|
|
2110
|
+
const { storageChain } = useStorageChain();
|
|
2111
|
+
const [walletList, setWalletList] = useState([]);
|
|
2112
|
+
const [addWallet, setAddWallet] = useState([]);
|
|
2113
|
+
const [loading, setLoading] = useState(true);
|
|
2114
|
+
const isActive = useCallback(
|
|
2115
|
+
(walletType) => {
|
|
2116
|
+
if (storageChain?.namespace === ChainNamespace.evm) {
|
|
2117
|
+
if (walletType === "EVM" /* EVM */) {
|
|
2118
|
+
return !AbstractChains.has(storageChain?.chainId);
|
|
2119
|
+
}
|
|
2120
|
+
return false;
|
|
1567
2121
|
}
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
if (walletChainType === "onlySOL" /* onlySOL */) {
|
|
1571
|
-
if (walletSOL && walletSOL.accounts.length) {
|
|
1572
|
-
return "onlySOL" /* onlySOL */;
|
|
2122
|
+
if (storageChain?.namespace === ChainNamespace.solana) {
|
|
2123
|
+
return walletType === "SOL" /* SOL */;
|
|
1573
2124
|
}
|
|
1574
|
-
return
|
|
1575
|
-
}
|
|
1576
|
-
if ((!walletEVM || !walletEVM.accounts.length) && (!walletSOL || !walletSOL.accounts.length)) {
|
|
1577
|
-
return "noWallet" /* noWallet */;
|
|
1578
|
-
}
|
|
1579
|
-
if (walletEVM && walletEVM.accounts.length && (!walletSOL || !walletSOL.accounts.length)) {
|
|
1580
|
-
return "onlyEVM" /* onlyEVM */;
|
|
1581
|
-
}
|
|
1582
|
-
if ((!walletEVM || !walletEVM.accounts.length) && walletSOL && walletSOL.accounts.length) {
|
|
1583
|
-
return "onlySOL" /* onlySOL */;
|
|
1584
|
-
}
|
|
1585
|
-
return "both" /* both */;
|
|
1586
|
-
}, [walletEVM, walletSOL, walletChainType]);
|
|
1587
|
-
return /* @__PURE__ */ React12.createElement("div", null, /* @__PURE__ */ React12.createElement("div", { className: "oui-flex oui-justify-between oui-items-center" }, linkedAccount && /* @__PURE__ */ React12.createElement("div", { className: "oui-flex oui-items-center oui-justify-start oui-gap-2 oui-text-base-contrast" }, /* @__PURE__ */ React12.createElement("div", null, /* @__PURE__ */ React12.createElement(RenderPrivyTypeIcon, { type: linkedAccount.type, size: 24 })), /* @__PURE__ */ React12.createElement("div", { className: "oui-text-xs" }, linkedAccount.address)), /* @__PURE__ */ React12.createElement(
|
|
1588
|
-
"div",
|
|
1589
|
-
{
|
|
1590
|
-
className: "oui-cursor-pointer oui-text-primary oui-text-2xs oui-font-semibold",
|
|
1591
|
-
onClick: () => disconnect("privy" /* PRIVY */)
|
|
2125
|
+
return false;
|
|
1592
2126
|
},
|
|
1593
|
-
|
|
1594
|
-
)
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
}
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
isActive: namespace === ChainNamespace.solana,
|
|
1612
|
-
onActiveChange: () => {
|
|
1613
|
-
switchWallet(ChainNamespace.solana);
|
|
1614
|
-
},
|
|
1615
|
-
isPrivy: true,
|
|
1616
|
-
isBoth: true
|
|
1617
|
-
}
|
|
1618
|
-
)), walletChainType === "onlyEVM" /* onlyEVM */ && /* @__PURE__ */ React12.createElement(
|
|
1619
|
-
WalletCard,
|
|
1620
|
-
{
|
|
1621
|
-
type: "EVM" /* EVM */,
|
|
1622
|
-
address: walletEVM?.accounts[0].address ?? "",
|
|
1623
|
-
isActive: namespace === ChainNamespace.evm,
|
|
1624
|
-
onActiveChange: () => {
|
|
1625
|
-
switchWallet(ChainNamespace.evm);
|
|
1626
|
-
},
|
|
1627
|
-
isPrivy: true,
|
|
1628
|
-
isBoth: false
|
|
1629
|
-
}
|
|
1630
|
-
), walletChainType === "onlySOL" /* onlySOL */ && /* @__PURE__ */ React12.createElement(
|
|
1631
|
-
WalletCard,
|
|
1632
|
-
{
|
|
1633
|
-
type: "SOL" /* SOL */,
|
|
1634
|
-
address: walletSOL?.accounts[0].address ?? "",
|
|
1635
|
-
isActive: namespace === ChainNamespace.solana,
|
|
1636
|
-
onActiveChange: () => {
|
|
1637
|
-
switchWallet(ChainNamespace.solana);
|
|
1638
|
-
},
|
|
1639
|
-
isPrivy: true,
|
|
1640
|
-
isBoth: false
|
|
1641
|
-
}
|
|
1642
|
-
)), renderWalletType === "onlyEVM" /* onlyEVM */ && /* @__PURE__ */ React12.createElement("div", { className: "oui-flex oui-flex-col oui-gap-0 oui-mt-5" }, /* @__PURE__ */ React12.createElement(
|
|
1643
|
-
WalletCard,
|
|
1644
|
-
{
|
|
1645
|
-
type: "EVM" /* EVM */,
|
|
1646
|
-
address: walletEVM?.accounts[0].address ?? "",
|
|
1647
|
-
isActive: namespace === ChainNamespace.evm,
|
|
1648
|
-
onActiveChange: () => {
|
|
1649
|
-
switchWallet(ChainNamespace.evm);
|
|
1650
|
-
},
|
|
1651
|
-
isPrivy: true,
|
|
1652
|
-
isBoth: false
|
|
1653
|
-
}
|
|
1654
|
-
), walletChainType === "EVM_SOL" /* EVM_SOL */ && /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement("div", { className: "oui-h-[1px] oui-bg-line oui-my-5 oui-w-full" }), /* @__PURE__ */ React12.createElement("div", { className: "oui-flex oui-flex-col oui-gap-2 oui-w-full" }, /* @__PURE__ */ React12.createElement(CreateSOLWallet, null)))), renderWalletType === "onlySOL" /* onlySOL */ && /* @__PURE__ */ React12.createElement("div", { className: "oui-flex oui-flex-col oui-gap-0 oui-mt-5" }, /* @__PURE__ */ React12.createElement(
|
|
1655
|
-
WalletCard,
|
|
1656
|
-
{
|
|
1657
|
-
type: "SOL" /* SOL */,
|
|
1658
|
-
address: walletSOL?.accounts[0].address ?? "",
|
|
1659
|
-
isActive: namespace === ChainNamespace.solana,
|
|
1660
|
-
onActiveChange: () => {
|
|
1661
|
-
switchWallet(ChainNamespace.solana);
|
|
1662
|
-
},
|
|
1663
|
-
isPrivy: true,
|
|
1664
|
-
isBoth: false
|
|
2127
|
+
[storageChain]
|
|
2128
|
+
);
|
|
2129
|
+
const isHaveEvmWallet = useMemo(() => {
|
|
2130
|
+
return walletEVM && walletEVM.accounts.length;
|
|
2131
|
+
}, [walletEVM]);
|
|
2132
|
+
const isHaveSolWallet = useMemo(() => {
|
|
2133
|
+
return walletSOL && walletSOL.accounts.length;
|
|
2134
|
+
}, [walletSOL]);
|
|
2135
|
+
const renderWarning = useCallback(() => {
|
|
2136
|
+
let showWarning = false;
|
|
2137
|
+
if (AbstractChains.has(storageChain?.chainId)) {
|
|
2138
|
+
showWarning = true;
|
|
2139
|
+
}
|
|
2140
|
+
if (targetWalletType === "Abstract" /* ABSTRACT */) {
|
|
2141
|
+
showWarning = true;
|
|
2142
|
+
}
|
|
2143
|
+
if (!showWarning) {
|
|
2144
|
+
return;
|
|
1665
2145
|
}
|
|
1666
|
-
|
|
1667
|
-
}
|
|
1668
|
-
|
|
1669
|
-
// src/components/connectDrawer.tsx
|
|
1670
|
-
function PrivyConnectArea({ connect }) {
|
|
1671
|
-
const { t } = useTranslation();
|
|
1672
|
-
const { isMobile, isDesktop } = useScreen();
|
|
1673
|
-
const { connectorWalletType } = useWalletConnectorPrivy();
|
|
1674
|
-
return /* @__PURE__ */ React12.createElement("div", { className: "" }, /* @__PURE__ */ React12.createElement(
|
|
1675
|
-
"div",
|
|
1676
|
-
{
|
|
1677
|
-
className: cn(
|
|
1678
|
-
"oui-flex oui-items-center oui-justify-between",
|
|
1679
|
-
"oui-text-base-contrast-80 oui-text-sm oui-font-semibold oui-mb-3",
|
|
1680
|
-
"md:oui-mb-2"
|
|
1681
|
-
)
|
|
1682
|
-
},
|
|
1683
|
-
t("connector.privy.loginIn"),
|
|
1684
|
-
isMobile && /* @__PURE__ */ React12.createElement("div", { className: "oui-h-3 oui-flex oui-justify-center" }, /* @__PURE__ */ React12.createElement(
|
|
1685
|
-
"img",
|
|
1686
|
-
{
|
|
1687
|
-
src: "https://oss.orderly.network/static/sdk/privy/privy-logo.png",
|
|
1688
|
-
className: " oui-h-[10px]"
|
|
1689
|
-
}
|
|
1690
|
-
))
|
|
1691
|
-
), /* @__PURE__ */ React12.createElement(
|
|
1692
|
-
"div",
|
|
1693
|
-
{
|
|
1694
|
-
className: cn(
|
|
1695
|
-
"oui-grid oui-grid-cols-2 oui-gap-2",
|
|
1696
|
-
"md:oui-flex md:oui-flex-col md:oui-gap-2"
|
|
1697
|
-
)
|
|
1698
|
-
},
|
|
1699
|
-
/* @__PURE__ */ React12.createElement(
|
|
1700
|
-
"div",
|
|
1701
|
-
{
|
|
1702
|
-
className: "oui-cursor-pointer oui-rounded-[6px] oui-bg-[#333948] oui-px-2 oui-py-[11px] oui-flex oui-justify-center oui-items-center oui-gap-1",
|
|
1703
|
-
onClick: () => connect({ walletType: "privy", extraType: "email" })
|
|
1704
|
-
},
|
|
1705
|
-
/* @__PURE__ */ React12.createElement(
|
|
1706
|
-
"img",
|
|
1707
|
-
{
|
|
1708
|
-
src: "https://oss.orderly.network/static/sdk/privy/email.svg",
|
|
1709
|
-
className: "oui-w-[18px] oui-h-[18px]"
|
|
1710
|
-
}
|
|
1711
|
-
),
|
|
1712
|
-
/* @__PURE__ */ React12.createElement("div", { className: "oui-text-base-contrast oui-text-2xs" }, t("connector.privy.email"))
|
|
1713
|
-
),
|
|
1714
|
-
/* @__PURE__ */ React12.createElement(
|
|
1715
|
-
"div",
|
|
1716
|
-
{
|
|
1717
|
-
className: "oui-rounded-[6px] oui-bg-[#335FFC] oui-px-2 oui-py-[11px] oui-flex oui-justify-center oui-items-center oui-gap-1 oui-cursor-pointer",
|
|
1718
|
-
onClick: () => connect({ walletType: "privy", extraType: "google" })
|
|
1719
|
-
},
|
|
1720
|
-
/* @__PURE__ */ React12.createElement(
|
|
1721
|
-
"img",
|
|
1722
|
-
{
|
|
1723
|
-
src: "https://oss.orderly.network/static/sdk/privy/google.svg",
|
|
1724
|
-
className: "oui-w-[18px] oui-h-[18px]"
|
|
1725
|
-
}
|
|
1726
|
-
),
|
|
1727
|
-
/* @__PURE__ */ React12.createElement("div", { className: "oui-text-base-contrast oui-text-2xs" }, t("connector.privy.google"))
|
|
1728
|
-
),
|
|
1729
|
-
/* @__PURE__ */ React12.createElement(
|
|
2146
|
+
return /* @__PURE__ */ React19.createElement("div", { className: "oui-mt-5 oui-border-b oui-border-line oui-pb-5" }, /* @__PURE__ */ React19.createElement(
|
|
1730
2147
|
"div",
|
|
1731
2148
|
{
|
|
1732
|
-
className:
|
|
1733
|
-
|
|
2149
|
+
className: cn(
|
|
2150
|
+
"oui-flex oui-items-start oui-justify-center oui-gap-1",
|
|
2151
|
+
"oui-w-full oui-rounded-[8px] oui-px-2 oui-py-[13px]",
|
|
2152
|
+
"oui-bg-warning-darken/10"
|
|
2153
|
+
)
|
|
1734
2154
|
},
|
|
1735
|
-
/* @__PURE__ */
|
|
1736
|
-
|
|
2155
|
+
/* @__PURE__ */ React19.createElement(
|
|
2156
|
+
ExclamationFillIcon,
|
|
1737
2157
|
{
|
|
1738
|
-
|
|
1739
|
-
className: "oui-
|
|
2158
|
+
size: 14,
|
|
2159
|
+
className: "oui-mt-[2px] oui-size-[14px] oui-shrink-0 oui-text-warning-darken"
|
|
1740
2160
|
}
|
|
1741
2161
|
),
|
|
1742
|
-
/* @__PURE__ */
|
|
1743
|
-
)
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
{
|
|
1747
|
-
|
|
1748
|
-
className: " oui-h-[10px]"
|
|
1749
|
-
}
|
|
1750
|
-
)), (!connectorWalletType.disableWagmi || !connectorWalletType.disableSolana) && /* @__PURE__ */ React12.createElement("div", { className: "oui-h-[1px] oui-bg-line oui-w-full oui-mt-4 md:oui-mt-5" }));
|
|
1751
|
-
}
|
|
1752
|
-
function EVMConnectArea({ connect }) {
|
|
1753
|
-
const { connectors } = useWagmiWallet();
|
|
1754
|
-
return /* @__PURE__ */ React12.createElement("div", { className: "" }, /* @__PURE__ */ React12.createElement("div", { className: "oui-text-base-contrast-80 oui-text-sm oui-font-semibold oui-mb-2" }, "EVM"), /* @__PURE__ */ React12.createElement("div", { className: "oui-grid oui-grid-cols-2 oui-gap-2" }, connectors.map((item, key) => /* @__PURE__ */ React12.createElement(
|
|
1755
|
-
"div",
|
|
1756
|
-
{
|
|
1757
|
-
key,
|
|
1758
|
-
className: " oui-flex oui-items-center oui-justify-start oui-gap-1 oui-rounded-[6px] oui-px-2 oui-bg-[#07080A] oui-py-[11px] oui-flex-1 oui-cursor-pointer",
|
|
1759
|
-
onClick: () => connect(item)
|
|
1760
|
-
},
|
|
1761
|
-
/* @__PURE__ */ React12.createElement(RenderWalletIcon, { connector: item }),
|
|
1762
|
-
/* @__PURE__ */ React12.createElement("div", { className: "oui-text-base-contrast oui-text-2xs" }, item.name)
|
|
1763
|
-
))));
|
|
1764
|
-
}
|
|
1765
|
-
function SOLConnectArea({
|
|
1766
|
-
connect
|
|
1767
|
-
}) {
|
|
1768
|
-
const { wallets } = useSolanaWallet();
|
|
1769
|
-
return /* @__PURE__ */ React12.createElement("div", null, /* @__PURE__ */ React12.createElement("div", { className: "oui-text-base-contrast-80 oui-text-sm oui-font-semibold oui-mb-2" }, "Solana"), /* @__PURE__ */ React12.createElement("div", { className: "oui-grid oui-grid-cols-2 oui-gap-2" }, wallets.map((item, key) => /* @__PURE__ */ React12.createElement(
|
|
1770
|
-
"div",
|
|
1771
|
-
{
|
|
1772
|
-
key,
|
|
1773
|
-
className: " oui-flex oui-items-center oui-justify-start oui-gap-1 oui-rounded-[6px] oui-px-2 oui-bg-[#07080A] oui-py-[11px] oui-flex-1 oui-cursor-pointer",
|
|
1774
|
-
onClick: () => connect(item.adapter)
|
|
1775
|
-
},
|
|
1776
|
-
/* @__PURE__ */ React12.createElement(RenderWalletIcon, { connector: item.adapter }),
|
|
1777
|
-
/* @__PURE__ */ React12.createElement("div", { className: "oui-text-base-contrast oui-text-2xs" }, item.adapter.name)
|
|
1778
|
-
))));
|
|
1779
|
-
}
|
|
1780
|
-
function ConnectWallet() {
|
|
1781
|
-
const { connect } = useWallet2();
|
|
1782
|
-
const { setOpenConnectDrawer, walletChainType, connectorWalletType } = useWalletConnectorPrivy();
|
|
1783
|
-
const handleConnect = (params) => {
|
|
1784
|
-
connect(params);
|
|
1785
|
-
if (params.walletType === "privy" /* PRIVY */) {
|
|
1786
|
-
setOpenConnectDrawer(false);
|
|
2162
|
+
/* @__PURE__ */ React19.createElement("div", { className: "oui-text-2xs oui-leading-[18px] oui-text-warning-darken" }, "Abstract Chain access requires Abstract Global Wallet. Privy connection is currently unsupported.")
|
|
2163
|
+
));
|
|
2164
|
+
}, [targetWalletType]);
|
|
2165
|
+
const renderWallet = useCallback(() => {
|
|
2166
|
+
if (loading) {
|
|
2167
|
+
return;
|
|
1787
2168
|
}
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
PrivyConnectArea,
|
|
1791
|
-
{
|
|
1792
|
-
connect: (type) => handleConnect({ walletType: "privy" /* PRIVY */, extraType: type })
|
|
2169
|
+
if (!walletList.length) {
|
|
2170
|
+
return /* @__PURE__ */ React19.createElement(NoWallet, null);
|
|
1793
2171
|
}
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
2172
|
+
return /* @__PURE__ */ React19.createElement("div", { className: "oui-mt-5 oui-flex oui-flex-col oui-gap-5" }, walletList.map((wallet) => /* @__PURE__ */ React19.createElement(
|
|
2173
|
+
WalletCard,
|
|
2174
|
+
{
|
|
2175
|
+
key: wallet.type,
|
|
2176
|
+
type: wallet.type,
|
|
2177
|
+
address: wallet.address,
|
|
2178
|
+
isActive: isActive(wallet.type),
|
|
2179
|
+
isPrivy: true,
|
|
2180
|
+
isMulti: walletList.length > 1,
|
|
2181
|
+
onActiveChange: () => {
|
|
2182
|
+
switchWallet(wallet.type);
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2185
|
+
)), 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))));
|
|
2186
|
+
}, [walletList, addWallet, isActive, switchWallet, t, loading]);
|
|
2187
|
+
useEffect(() => {
|
|
2188
|
+
new Promise(
|
|
2189
|
+
(resolve) => setTimeout(() => {
|
|
2190
|
+
setLoading(false);
|
|
2191
|
+
resolve(true);
|
|
2192
|
+
}, 200)
|
|
2193
|
+
);
|
|
2194
|
+
}, []);
|
|
2195
|
+
useEffect(() => {
|
|
2196
|
+
const tempWalletList = [];
|
|
2197
|
+
const tempAddWallet = [];
|
|
2198
|
+
if (!connectorWalletType.disableWagmi && walletChainTypeConfig.hasEvm) {
|
|
2199
|
+
if (isHaveEvmWallet) {
|
|
2200
|
+
tempWalletList.push({
|
|
2201
|
+
type: "EVM" /* EVM */,
|
|
2202
|
+
address: walletEVM.accounts[0].address
|
|
2203
|
+
});
|
|
2204
|
+
} else {
|
|
2205
|
+
tempAddWallet.push(/* @__PURE__ */ React19.createElement(CreateEVMWallet, null));
|
|
2206
|
+
}
|
|
1801
2207
|
}
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
}
|
|
2208
|
+
if (!connectorWalletType.disableSolana && walletChainTypeConfig.hasSol) {
|
|
2209
|
+
if (isHaveSolWallet) {
|
|
2210
|
+
tempWalletList.push({
|
|
2211
|
+
type: "SOL" /* SOL */,
|
|
2212
|
+
address: walletSOL.accounts[0].address
|
|
2213
|
+
});
|
|
2214
|
+
} else {
|
|
2215
|
+
tempAddWallet.push(/* @__PURE__ */ React19.createElement(CreateSOLWallet, null));
|
|
2216
|
+
}
|
|
1809
2217
|
}
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
2218
|
+
setWalletList(tempWalletList);
|
|
2219
|
+
setAddWallet(tempAddWallet);
|
|
2220
|
+
}, [
|
|
2221
|
+
connectorWalletType,
|
|
2222
|
+
walletChainTypeConfig,
|
|
2223
|
+
walletEVM,
|
|
2224
|
+
walletSOL,
|
|
2225
|
+
isHaveEvmWallet,
|
|
2226
|
+
isHaveSolWallet
|
|
2227
|
+
]);
|
|
2228
|
+
useEffect(() => {
|
|
2229
|
+
if (targetWalletType === "Abstract" /* ABSTRACT */) {
|
|
2230
|
+
windowGuard(() => {
|
|
2231
|
+
setTimeout(() => {
|
|
2232
|
+
setTargetWalletType(void 0);
|
|
2233
|
+
}, 5e3);
|
|
2234
|
+
});
|
|
1814
2235
|
}
|
|
1815
|
-
|
|
1816
|
-
|
|
2236
|
+
}, [targetWalletType, setTargetWalletType]);
|
|
2237
|
+
return /* @__PURE__ */ React19.createElement("div", null, /* @__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(
|
|
2238
|
+
"div",
|
|
1817
2239
|
{
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
));
|
|
2240
|
+
className: "oui-cursor-pointer oui-text-2xs oui-font-semibold oui-text-primary",
|
|
2241
|
+
onClick: () => disconnect("privy" /* PRIVY */)
|
|
2242
|
+
},
|
|
2243
|
+
t("connector.privy.logout")
|
|
2244
|
+
)), renderWarning(), renderWallet());
|
|
1824
2245
|
}
|
|
2246
|
+
|
|
2247
|
+
// src/components/connectDrawer.tsx
|
|
1825
2248
|
function MyWallet() {
|
|
1826
2249
|
const [connectorKey, setConnectorKey] = useLocalStorage(ConnectorKey, "");
|
|
1827
|
-
return /* @__PURE__ */
|
|
2250
|
+
return /* @__PURE__ */ React19.createElement("div", null, connectorKey === "privy" && /* @__PURE__ */ React19.createElement(RenderPrivyWallet, null), connectorKey !== "privy" && /* @__PURE__ */ React19.createElement(RenderNonPrivyWallet, null));
|
|
1828
2251
|
}
|
|
1829
2252
|
function ConnectDrawer(props) {
|
|
1830
2253
|
const { t } = useTranslation();
|
|
1831
2254
|
const { isConnected: isConnectedPrivy } = usePrivyWallet();
|
|
1832
2255
|
const { isConnected: isConnectedEvm } = useWagmiWallet();
|
|
1833
2256
|
const { isConnected: isConnectedSolana } = useSolanaWallet();
|
|
1834
|
-
const {
|
|
1835
|
-
const
|
|
2257
|
+
const { isConnected: isConnectedAbstract } = useAbstractWallet();
|
|
2258
|
+
const { termsOfUse } = useWalletConnectorPrivy();
|
|
2259
|
+
const [connectorKey] = useLocalStorage(ConnectorKey, "");
|
|
1836
2260
|
const isConnected = useMemo(() => {
|
|
1837
2261
|
if (connectorKey === "privy" /* PRIVY */ && isConnectedPrivy) {
|
|
1838
2262
|
return true;
|
|
@@ -1844,46 +2268,63 @@ function ConnectDrawer(props) {
|
|
|
1844
2268
|
if (isConnectedSolana) {
|
|
1845
2269
|
return true;
|
|
1846
2270
|
}
|
|
2271
|
+
if (isConnectedAbstract) {
|
|
2272
|
+
return true;
|
|
2273
|
+
}
|
|
1847
2274
|
}
|
|
1848
2275
|
return false;
|
|
1849
|
-
}, [
|
|
2276
|
+
}, [
|
|
2277
|
+
isConnectedPrivy,
|
|
2278
|
+
isConnectedEvm,
|
|
2279
|
+
isConnectedSolana,
|
|
2280
|
+
isConnectedAbstract,
|
|
2281
|
+
connectorKey
|
|
2282
|
+
]);
|
|
1850
2283
|
const { isMobile } = useScreen();
|
|
1851
|
-
|
|
2284
|
+
const renderHeader = useCallback(() => {
|
|
2285
|
+
if (isMobile && props.headerProps?.mobile) {
|
|
2286
|
+
return props.headerProps?.mobile;
|
|
2287
|
+
}
|
|
2288
|
+
return /* @__PURE__ */ React19.createElement(
|
|
2289
|
+
"div",
|
|
2290
|
+
{
|
|
2291
|
+
className: cn(
|
|
2292
|
+
"oui-font-semibold oui-text-base-contrast-80 ",
|
|
2293
|
+
"oui-py-2 oui-text-[20px]",
|
|
2294
|
+
"md:oui-py-0 md:oui-text-base"
|
|
2295
|
+
)
|
|
2296
|
+
},
|
|
2297
|
+
isConnected ? t("connector.privy.myWallet") : t("connector.connectWallet")
|
|
2298
|
+
);
|
|
2299
|
+
}, [isMobile, props.headerProps?.mobile, isConnected]);
|
|
2300
|
+
return /* @__PURE__ */ React19.createElement(Drawer, { isOpen: props.open, onClose: () => props.onChangeOpen(false) }, !isMobile && /* @__PURE__ */ React19.createElement(
|
|
1852
2301
|
"div",
|
|
1853
2302
|
{
|
|
1854
|
-
className: "oui-
|
|
2303
|
+
className: "oui-absolute oui-inset-x-[50px] -oui-top-[calc(100vh/2)] oui-z-0 oui-h-screen",
|
|
1855
2304
|
style: {
|
|
1856
2305
|
background: "conic-gradient(from -41deg at 40.63% 50.41%, rgba(242, 98, 181, 0.00) 125.17920970916748deg, rgba(95, 197, 255, 0.20) 193.4119462966919deg, rgba(255, 172, 137, 0.20) 216.0206937789917deg, rgba(129, 85, 255, 0.20) 236.0708713531494deg, rgba(120, 157, 255, 0.20) 259.95326042175293deg, rgba(159, 115, 241, 0.00) 311.0780096054077deg)",
|
|
1857
2306
|
filter: "blur(50px)"
|
|
1858
2307
|
}
|
|
1859
2308
|
}
|
|
1860
|
-
), /* @__PURE__ */
|
|
1861
|
-
"div",
|
|
1862
|
-
{
|
|
1863
|
-
className: cn(
|
|
1864
|
-
"oui-font-semibold oui-text-base-contrast-80 ",
|
|
1865
|
-
"oui-text-[20px] oui-py-2",
|
|
1866
|
-
"md:oui-text-base md:oui-py-0"
|
|
1867
|
-
)
|
|
1868
|
-
},
|
|
1869
|
-
isConnected ? t("connector.privy.myWallet") : t("connector.connectWallet")
|
|
1870
|
-
), /* @__PURE__ */ React12.createElement(
|
|
2309
|
+
), /* @__PURE__ */ React19.createElement("div", { className: "oui-relative oui-z-10" }, /* @__PURE__ */ React19.createElement("div", { className: "oui-mb-4 oui-flex oui-items-center oui-justify-between md:oui-mb-5" }, renderHeader(), /* @__PURE__ */ React19.createElement(
|
|
1871
2310
|
CloseIcon,
|
|
1872
2311
|
{
|
|
1873
|
-
className: "oui-cursor-pointer oui-text-base-contrast-20
|
|
2312
|
+
className: "oui-size-5 oui-cursor-pointer oui-text-base-contrast-20 hover:oui-text-base-contrast-80",
|
|
1874
2313
|
onClick: () => props.onChangeOpen(false)
|
|
1875
2314
|
}
|
|
1876
|
-
)), isConnected ? /* @__PURE__ */
|
|
2315
|
+
)), isConnected ? /* @__PURE__ */ React19.createElement(MyWallet, null) : /* @__PURE__ */ React19.createElement(RenderConnector, null)), !isConnected && termsOfUse && /* @__PURE__ */ React19.createElement("div", { className: "oui-relative oui-z-10 oui-text-center oui-text-2xs oui-font-semibold oui-text-base-contrast-80" }, /* @__PURE__ */ React19.createElement(
|
|
1877
2316
|
Trans,
|
|
1878
2317
|
{
|
|
1879
2318
|
i18nKey: "connector.privy.termsOfUse",
|
|
1880
2319
|
components: [
|
|
1881
|
-
/* @__PURE__ */
|
|
2320
|
+
/* @__PURE__ */ React19.createElement(
|
|
1882
2321
|
"a",
|
|
1883
2322
|
{
|
|
2323
|
+
key: "termsOfUse",
|
|
1884
2324
|
href: termsOfUse,
|
|
1885
|
-
className: "oui-cursor-pointer oui-
|
|
1886
|
-
target: "_blank"
|
|
2325
|
+
className: "oui-cursor-pointer oui-text-primary oui-underline",
|
|
2326
|
+
target: "_blank",
|
|
2327
|
+
rel: "noreferrer"
|
|
1887
2328
|
}
|
|
1888
2329
|
)
|
|
1889
2330
|
]
|
|
@@ -1892,11 +2333,11 @@ function ConnectDrawer(props) {
|
|
|
1892
2333
|
}
|
|
1893
2334
|
function UserCenter(props) {
|
|
1894
2335
|
const { accountState: state } = props;
|
|
1895
|
-
return /* @__PURE__ */
|
|
2336
|
+
return /* @__PURE__ */ React19.createElement(RenderUserCenter, { state, disabledConnect: props.disabledConnect });
|
|
1896
2337
|
}
|
|
1897
2338
|
var MwebUserCenter = (props) => {
|
|
1898
2339
|
const { state } = props;
|
|
1899
|
-
return /* @__PURE__ */
|
|
2340
|
+
return /* @__PURE__ */ React19.createElement(RenderUserCenter, { state, disabledConnect: props.disabledConnect });
|
|
1900
2341
|
};
|
|
1901
2342
|
var RenderUserCenter = (props) => {
|
|
1902
2343
|
const { state } = props;
|
|
@@ -1904,9 +2345,17 @@ var RenderUserCenter = (props) => {
|
|
|
1904
2345
|
const { isMobile } = useScreen();
|
|
1905
2346
|
const { connect, wallet } = useWalletConnector();
|
|
1906
2347
|
const { linkedAccount } = usePrivyWallet();
|
|
2348
|
+
const { state: accountState, account } = useAccount();
|
|
2349
|
+
const { connectedChain } = useWalletConnector();
|
|
1907
2350
|
const disabled = state.validating || props.disabledConnect;
|
|
2351
|
+
const userAddress = useMemo(() => {
|
|
2352
|
+
if (connectedChain?.id && ABSTRACT_CHAIN_ID_MAP.has(parseInt(connectedChain?.id))) {
|
|
2353
|
+
return account.getAdditionalInfo()?.AGWAddress;
|
|
2354
|
+
}
|
|
2355
|
+
return account.address;
|
|
2356
|
+
}, [account, connectedChain, accountState]);
|
|
1908
2357
|
if (state.status === AccountStatusEnum.EnableTradingWithoutConnected) {
|
|
1909
|
-
return /* @__PURE__ */
|
|
2358
|
+
return /* @__PURE__ */ React19.createElement(
|
|
1910
2359
|
Button,
|
|
1911
2360
|
{
|
|
1912
2361
|
size: "md",
|
|
@@ -1915,18 +2364,21 @@ var RenderUserCenter = (props) => {
|
|
|
1915
2364
|
"data-testid": "oui-testid-nav-bar-address-btn",
|
|
1916
2365
|
className: "oui-flex oui-items-center oui-justify-center oui-gap-2"
|
|
1917
2366
|
},
|
|
1918
|
-
/* @__PURE__ */
|
|
2367
|
+
/* @__PURE__ */ React19.createElement(Text.formatted, { rule: "address", className: "oui-text-[rgba(0,0,0,.88)]" }, formatAddress(userAddress))
|
|
1919
2368
|
);
|
|
1920
2369
|
}
|
|
1921
2370
|
if (state.status <= AccountStatusEnum.NotConnected || disabled) {
|
|
1922
|
-
return /* @__PURE__ */
|
|
2371
|
+
return /* @__PURE__ */ React19.createElement(
|
|
1923
2372
|
Button,
|
|
1924
2373
|
{
|
|
1925
2374
|
"data-testid": "oui-testid-nav-bar-connectWallet-btn",
|
|
1926
2375
|
size: "md",
|
|
1927
2376
|
variant: disabled ? void 0 : "gradient",
|
|
1928
2377
|
angle: 45,
|
|
1929
|
-
className:
|
|
2378
|
+
className: cn(
|
|
2379
|
+
"wallet-connect-button",
|
|
2380
|
+
isMobile && "oui-font-semibold oui-px-2"
|
|
2381
|
+
),
|
|
1930
2382
|
loading: state.validating,
|
|
1931
2383
|
disabled,
|
|
1932
2384
|
onClick: () => {
|
|
@@ -1941,42 +2393,42 @@ var RenderUserCenter = (props) => {
|
|
|
1941
2393
|
return;
|
|
1942
2394
|
}
|
|
1943
2395
|
if (isMobile) {
|
|
1944
|
-
return /* @__PURE__ */
|
|
2396
|
+
return /* @__PURE__ */ React19.createElement(
|
|
1945
2397
|
AuthGuard,
|
|
1946
2398
|
{
|
|
1947
2399
|
buttonProps: {
|
|
1948
|
-
size: "
|
|
2400
|
+
size: "md"
|
|
1949
2401
|
}
|
|
1950
2402
|
},
|
|
1951
|
-
/* @__PURE__ */
|
|
2403
|
+
/* @__PURE__ */ React19.createElement("div", { onClick: () => connect() }, /* @__PURE__ */ React19.createElement(
|
|
1952
2404
|
Button,
|
|
1953
2405
|
{
|
|
1954
|
-
size: "
|
|
2406
|
+
size: "md",
|
|
1955
2407
|
variant: "gradient",
|
|
1956
2408
|
angle: 45,
|
|
1957
2409
|
"data-testid": "oui-testid-nav-bar-address-btn",
|
|
1958
|
-
className: "oui-flex oui-items-center oui-justify-center oui-gap-
|
|
2410
|
+
className: "oui-px-2 oui-flex oui-items-center oui-justify-center oui-gap-1"
|
|
1959
2411
|
},
|
|
1960
|
-
linkedAccount && /* @__PURE__ */
|
|
2412
|
+
linkedAccount && /* @__PURE__ */ React19.createElement(
|
|
1961
2413
|
RenderPrivyTypeIcon,
|
|
1962
2414
|
{
|
|
1963
2415
|
type: linkedAccount.type,
|
|
1964
|
-
size:
|
|
2416
|
+
size: 14,
|
|
1965
2417
|
black: true
|
|
1966
2418
|
}
|
|
1967
2419
|
),
|
|
1968
|
-
/* @__PURE__ */
|
|
2420
|
+
/* @__PURE__ */ React19.createElement(
|
|
1969
2421
|
Text.formatted,
|
|
1970
2422
|
{
|
|
1971
2423
|
rule: "address",
|
|
1972
|
-
className: "oui-text-[rgba(0,0,0,.88)]"
|
|
2424
|
+
className: "oui-text-[rgba(0,0,0,.88)] oui-font-semibold"
|
|
1973
2425
|
},
|
|
1974
|
-
formatAddress(
|
|
2426
|
+
formatAddress(userAddress)
|
|
1975
2427
|
)
|
|
1976
2428
|
))
|
|
1977
2429
|
);
|
|
1978
2430
|
}
|
|
1979
|
-
return /* @__PURE__ */
|
|
2431
|
+
return /* @__PURE__ */ React19.createElement("div", { onClick: () => connect() }, /* @__PURE__ */ React19.createElement(
|
|
1980
2432
|
Button,
|
|
1981
2433
|
{
|
|
1982
2434
|
size: "md",
|
|
@@ -1985,7 +2437,7 @@ var RenderUserCenter = (props) => {
|
|
|
1985
2437
|
"data-testid": "oui-testid-nav-bar-address-btn",
|
|
1986
2438
|
className: "oui-flex oui-items-center oui-justify-center oui-gap-2"
|
|
1987
2439
|
},
|
|
1988
|
-
linkedAccount && /* @__PURE__ */
|
|
2440
|
+
linkedAccount && /* @__PURE__ */ React19.createElement(
|
|
1989
2441
|
RenderPrivyTypeIcon,
|
|
1990
2442
|
{
|
|
1991
2443
|
type: linkedAccount.type,
|
|
@@ -1993,7 +2445,7 @@ var RenderUserCenter = (props) => {
|
|
|
1993
2445
|
black: true
|
|
1994
2446
|
}
|
|
1995
2447
|
),
|
|
1996
|
-
/* @__PURE__ */
|
|
2448
|
+
/* @__PURE__ */ React19.createElement(Text.formatted, { rule: "address", className: "oui-text-[rgba(0,0,0,.88)]" }, formatAddress(userAddress))
|
|
1997
2449
|
));
|
|
1998
2450
|
};
|
|
1999
2451
|
installExtension({
|
|
@@ -2001,25 +2453,25 @@ installExtension({
|
|
|
2001
2453
|
scope: ["*"],
|
|
2002
2454
|
positions: [ExtensionPositionEnum.AccountMenu]
|
|
2003
2455
|
})((props) => {
|
|
2004
|
-
return /* @__PURE__ */
|
|
2456
|
+
return /* @__PURE__ */ React19.createElement(UserCenter, { ...props });
|
|
2005
2457
|
});
|
|
2006
2458
|
installExtension({
|
|
2007
2459
|
name: "mobile-account-menu-privy",
|
|
2008
2460
|
scope: ["*"],
|
|
2009
2461
|
positions: [ExtensionPositionEnum.MobileAccountMenu]
|
|
2010
2462
|
})((props) => {
|
|
2011
|
-
return /* @__PURE__ */
|
|
2463
|
+
return /* @__PURE__ */ React19.createElement(MwebUserCenter, { ...props });
|
|
2012
2464
|
});
|
|
2013
2465
|
|
|
2014
2466
|
// src/main.tsx
|
|
2015
2467
|
function Main(props) {
|
|
2016
2468
|
const { wallet, connectedChain, setChain, namespace } = useWallet2();
|
|
2017
|
-
const { openConnectDrawer, setOpenConnectDrawer,
|
|
2469
|
+
const { openConnectDrawer, setOpenConnectDrawer, setTargetWalletType } = useWalletConnectorPrivy();
|
|
2018
2470
|
const connect = (props2) => {
|
|
2019
2471
|
if (props2 && props2.autoSelect) {
|
|
2020
2472
|
return Promise.resolve([]);
|
|
2021
2473
|
}
|
|
2022
|
-
|
|
2474
|
+
setTargetWalletType(void 0);
|
|
2023
2475
|
return new Promise((resolve, reject) => {
|
|
2024
2476
|
setOpenConnectDrawer(true);
|
|
2025
2477
|
resolve([]);
|
|
@@ -2042,14 +2494,30 @@ function Main(props) {
|
|
|
2042
2494
|
}),
|
|
2043
2495
|
[connect, setChain, connectedChain, wallet, namespace]
|
|
2044
2496
|
);
|
|
2045
|
-
return /* @__PURE__ */
|
|
2497
|
+
return /* @__PURE__ */ React19.createElement(WalletConnectorContext.Provider, { value }, /* @__PURE__ */ React19.createElement(
|
|
2046
2498
|
ConnectDrawer,
|
|
2047
2499
|
{
|
|
2048
2500
|
open: openConnectDrawer,
|
|
2049
|
-
onChangeOpen: setOpenConnectDrawer
|
|
2501
|
+
onChangeOpen: setOpenConnectDrawer,
|
|
2502
|
+
headerProps: props.headerProps
|
|
2050
2503
|
}
|
|
2051
2504
|
), props.children);
|
|
2052
2505
|
}
|
|
2506
|
+
var InitAbstractProvider = (props) => {
|
|
2507
|
+
const { network } = useWalletConnectorPrivy();
|
|
2508
|
+
const chain = useMemo(() => {
|
|
2509
|
+
if (network === "mainnet" /* mainnet */) {
|
|
2510
|
+
return abstract;
|
|
2511
|
+
}
|
|
2512
|
+
return abstractTestnet;
|
|
2513
|
+
}, [network]);
|
|
2514
|
+
return /* @__PURE__ */ React19.createElement(AbstractWalletProvider$1, { chain }, props.children);
|
|
2515
|
+
};
|
|
2516
|
+
|
|
2517
|
+
// src/providers/abstractWallet/index.tsx
|
|
2518
|
+
function AbstractWallet({ children }) {
|
|
2519
|
+
return /* @__PURE__ */ React19.createElement(InitAbstractProvider, null, /* @__PURE__ */ React19.createElement(AbstractWalletProvider, null, children));
|
|
2520
|
+
}
|
|
2053
2521
|
function InitPrivyProvider({
|
|
2054
2522
|
privyConfig,
|
|
2055
2523
|
initChains,
|
|
@@ -2061,7 +2529,11 @@ function InitPrivyProvider({
|
|
|
2061
2529
|
const config = useMemo(() => {
|
|
2062
2530
|
const chains = initChains;
|
|
2063
2531
|
return {
|
|
2064
|
-
loginMethods: privyConfig.config?.loginMethods || [
|
|
2532
|
+
loginMethods: privyConfig.config?.loginMethods || [
|
|
2533
|
+
"email",
|
|
2534
|
+
"google",
|
|
2535
|
+
"twitter"
|
|
2536
|
+
],
|
|
2065
2537
|
appearance: {
|
|
2066
2538
|
...privyConfig.config?.appearance,
|
|
2067
2539
|
walletChainType: "ethereum-and-solana"
|
|
@@ -2081,7 +2553,19 @@ function InitPrivyProvider({
|
|
|
2081
2553
|
if (!initChains.length) {
|
|
2082
2554
|
return;
|
|
2083
2555
|
}
|
|
2084
|
-
return /* @__PURE__ */
|
|
2556
|
+
return /* @__PURE__ */ React19.createElement(PrivyProvider, { appId: privyConfig.appid, config }, children);
|
|
2557
|
+
}
|
|
2558
|
+
|
|
2559
|
+
// src/providers/privy/index.tsx
|
|
2560
|
+
function PrivyWallet(props) {
|
|
2561
|
+
return /* @__PURE__ */ React19.createElement(
|
|
2562
|
+
InitPrivyProvider,
|
|
2563
|
+
{
|
|
2564
|
+
privyConfig: props.privyConfig,
|
|
2565
|
+
initChains: props.initChains
|
|
2566
|
+
},
|
|
2567
|
+
/* @__PURE__ */ React19.createElement(PrivyWalletProvider, null, props.children)
|
|
2568
|
+
);
|
|
2085
2569
|
}
|
|
2086
2570
|
function InitSolanaProvider({
|
|
2087
2571
|
mainnetRpc,
|
|
@@ -2109,7 +2593,19 @@ function InitSolanaProvider({
|
|
|
2109
2593
|
network: network === "mainnet" ? WalletAdapterNetwork.Mainnet : WalletAdapterNetwork.Devnet
|
|
2110
2594
|
});
|
|
2111
2595
|
}, [network, mainnetRpc, devnetRpc, setSolanaInfo]);
|
|
2112
|
-
return /* @__PURE__ */
|
|
2596
|
+
return /* @__PURE__ */ React19.createElement(WalletProvider, { wallets, onError }, children);
|
|
2597
|
+
}
|
|
2598
|
+
|
|
2599
|
+
// src/providers/solana/index.tsx
|
|
2600
|
+
function SolanaWallet(props) {
|
|
2601
|
+
return /* @__PURE__ */ React19.createElement(
|
|
2602
|
+
InitSolanaProvider,
|
|
2603
|
+
{
|
|
2604
|
+
...props.solanaConfig ?? { wallets: [], onError: () => {
|
|
2605
|
+
} }
|
|
2606
|
+
},
|
|
2607
|
+
/* @__PURE__ */ React19.createElement(SolanaWalletProvider, null, props.children)
|
|
2608
|
+
);
|
|
2113
2609
|
}
|
|
2114
2610
|
function InitWagmiProvider({
|
|
2115
2611
|
children,
|
|
@@ -2136,7 +2632,19 @@ function InitWagmiProvider({
|
|
|
2136
2632
|
)
|
|
2137
2633
|
})
|
|
2138
2634
|
);
|
|
2139
|
-
return /* @__PURE__ */
|
|
2635
|
+
return /* @__PURE__ */ React19.createElement(WagmiProvider, { config, initialState }, /* @__PURE__ */ React19.createElement(QueryClientProvider, { client: queryClient }, children));
|
|
2636
|
+
}
|
|
2637
|
+
|
|
2638
|
+
// src/providers/wagmi/index.tsx
|
|
2639
|
+
function WagmiWallet(props) {
|
|
2640
|
+
return /* @__PURE__ */ React19.createElement(
|
|
2641
|
+
InitWagmiProvider,
|
|
2642
|
+
{
|
|
2643
|
+
wagmiConfig: props.wagmiConfig ?? {},
|
|
2644
|
+
initChains: props.initChains
|
|
2645
|
+
},
|
|
2646
|
+
/* @__PURE__ */ React19.createElement(WagmiWalletProvider, null, props.children)
|
|
2647
|
+
);
|
|
2140
2648
|
}
|
|
2141
2649
|
|
|
2142
2650
|
// src/provider.tsx
|
|
@@ -2166,7 +2674,7 @@ var processChainInfo = (chainInfo) => chainInfo.map(
|
|
|
2166
2674
|
}
|
|
2167
2675
|
})
|
|
2168
2676
|
) || [];
|
|
2169
|
-
var
|
|
2677
|
+
var WalletConnectorPrivyContext = createContext({
|
|
2170
2678
|
initChains: [mainnet],
|
|
2171
2679
|
mainnetChains: [],
|
|
2172
2680
|
testnetChains: [],
|
|
@@ -2174,8 +2682,8 @@ var walletConnectorPrivyContext = createContext({
|
|
|
2174
2682
|
openConnectDrawer: false,
|
|
2175
2683
|
setOpenConnectDrawer: () => {
|
|
2176
2684
|
},
|
|
2177
|
-
|
|
2178
|
-
|
|
2685
|
+
targetWalletType: void 0,
|
|
2686
|
+
setTargetWalletType: () => {
|
|
2179
2687
|
},
|
|
2180
2688
|
network: "mainnet" /* mainnet */,
|
|
2181
2689
|
setNetwork: () => {
|
|
@@ -2185,31 +2693,38 @@ var walletConnectorPrivyContext = createContext({
|
|
|
2185
2693
|
},
|
|
2186
2694
|
termsOfUse: "",
|
|
2187
2695
|
walletChainType: "EVM_SOL" /* EVM_SOL */,
|
|
2696
|
+
walletChainTypeConfig: {
|
|
2697
|
+
hasEvm: true,
|
|
2698
|
+
hasSol: true,
|
|
2699
|
+
hasAbstract: false
|
|
2700
|
+
},
|
|
2188
2701
|
connectorWalletType: {
|
|
2189
2702
|
disableWagmi: false,
|
|
2190
2703
|
disablePrivy: false,
|
|
2191
|
-
disableSolana: false
|
|
2704
|
+
disableSolana: false,
|
|
2705
|
+
disableAGW: false
|
|
2192
2706
|
}
|
|
2193
2707
|
});
|
|
2194
|
-
var useWalletConnectorPrivy = () => useContext(
|
|
2708
|
+
var useWalletConnectorPrivy = () => useContext(WalletConnectorPrivyContext);
|
|
2195
2709
|
function WalletConnectorPrivyProvider(props) {
|
|
2196
2710
|
const [walletChainType, setWalletChainType] = useState(
|
|
2197
2711
|
"EVM_SOL" /* EVM_SOL */
|
|
2198
2712
|
);
|
|
2199
|
-
const [termsOfUse] = useState(props.termsOfUse);
|
|
2713
|
+
const [termsOfUse] = useState(props.termsOfUse || "");
|
|
2200
2714
|
const [network, setNetwork] = useState(props.network);
|
|
2201
2715
|
const [initChains, setInitChains] = useState([]);
|
|
2202
2716
|
const [mainnetChains, setMainnetChains] = useState([]);
|
|
2203
2717
|
const [testnetChains, setTestnetChains] = useState([]);
|
|
2204
2718
|
const initRef = useRef(false);
|
|
2205
2719
|
const [openConnectDrawer, setOpenConnectDrawer] = useState(false);
|
|
2206
|
-
const [
|
|
2720
|
+
const [targetWalletType, setTargetWalletType] = useState();
|
|
2207
2721
|
const [solanaInfo, setSolanaInfo] = useState(null);
|
|
2208
2722
|
const connectorWalletType = useMemo(() => {
|
|
2209
|
-
|
|
2723
|
+
const type = {
|
|
2210
2724
|
disableWagmi: false,
|
|
2211
2725
|
disablePrivy: false,
|
|
2212
|
-
disableSolana: false
|
|
2726
|
+
disableSolana: false,
|
|
2727
|
+
disableAGW: false
|
|
2213
2728
|
};
|
|
2214
2729
|
if (!props.privyConfig) {
|
|
2215
2730
|
type.disablePrivy = true;
|
|
@@ -2220,8 +2735,28 @@ function WalletConnectorPrivyProvider(props) {
|
|
|
2220
2735
|
if (!props.solanaConfig) {
|
|
2221
2736
|
type.disableSolana = true;
|
|
2222
2737
|
}
|
|
2738
|
+
if (!props.abstractConfig) {
|
|
2739
|
+
type.disableAGW = true;
|
|
2740
|
+
}
|
|
2223
2741
|
return type;
|
|
2224
2742
|
}, [props.privyConfig, props.wagmiConfig, props.solanaConfig]);
|
|
2743
|
+
const walletChainTypeConfig = useMemo(() => {
|
|
2744
|
+
const chainTypeObj = {
|
|
2745
|
+
hasEvm: false,
|
|
2746
|
+
hasSol: false,
|
|
2747
|
+
hasAbstract: false
|
|
2748
|
+
};
|
|
2749
|
+
initChains.forEach((chain) => {
|
|
2750
|
+
if (SolanaChains$1.has(chain.id)) {
|
|
2751
|
+
chainTypeObj.hasSol = true;
|
|
2752
|
+
} else if (AbstractChains.has(chain.id)) {
|
|
2753
|
+
chainTypeObj.hasAbstract = true;
|
|
2754
|
+
} else {
|
|
2755
|
+
chainTypeObj.hasEvm = true;
|
|
2756
|
+
}
|
|
2757
|
+
});
|
|
2758
|
+
return chainTypeObj;
|
|
2759
|
+
}, [initChains]);
|
|
2225
2760
|
const fetchAllChains = async () => {
|
|
2226
2761
|
let testChainsList = [];
|
|
2227
2762
|
let mainnetChainsList = [];
|
|
@@ -2230,6 +2765,7 @@ function WalletConnectorPrivyProvider(props) {
|
|
|
2230
2765
|
"https://testnet-api-evm.orderly.org/v1/public/chain_info"
|
|
2231
2766
|
);
|
|
2232
2767
|
testChainsList = testChainInfoRes.data.rows;
|
|
2768
|
+
testChainsList.push(AbstractTestnetChainInfo);
|
|
2233
2769
|
} catch (error) {
|
|
2234
2770
|
testChainsList = [ArbitrumSepoliaChainInfo, SolanaDevnetChainInfo];
|
|
2235
2771
|
}
|
|
@@ -2260,11 +2796,14 @@ function WalletConnectorPrivyProvider(props) {
|
|
|
2260
2796
|
setInitChains([...testChains, ...mainnetChains2]);
|
|
2261
2797
|
const chainTypeObj = {
|
|
2262
2798
|
hasEvm: false,
|
|
2263
|
-
hasSol: false
|
|
2799
|
+
hasSol: false,
|
|
2800
|
+
hasAbstract: false
|
|
2264
2801
|
};
|
|
2265
2802
|
[...testChains, ...mainnetChains2].forEach((chain) => {
|
|
2266
2803
|
if (SolanaChains$1.has(chain.id)) {
|
|
2267
2804
|
chainTypeObj.hasSol = true;
|
|
2805
|
+
} else if (AbstractChains.has(chain.id)) {
|
|
2806
|
+
chainTypeObj.hasAbstract = true;
|
|
2268
2807
|
} else {
|
|
2269
2808
|
chainTypeObj.hasEvm = true;
|
|
2270
2809
|
}
|
|
@@ -2278,9 +2817,9 @@ function WalletConnectorPrivyProvider(props) {
|
|
|
2278
2817
|
setWalletChainType("onlySOL" /* onlySOL */);
|
|
2279
2818
|
}
|
|
2280
2819
|
};
|
|
2281
|
-
if (connectorWalletType.disablePrivy && connectorWalletType.disableWagmi && connectorWalletType.disableSolana) {
|
|
2820
|
+
if (connectorWalletType.disablePrivy && connectorWalletType.disableWagmi && connectorWalletType.disableSolana && connectorWalletType.disableAGW) {
|
|
2282
2821
|
throw new Error(
|
|
2283
|
-
"Privy, Wagmi,
|
|
2822
|
+
"Privy, Wagmi, Solana, Abstract are all disabled. Please enable at least one of them."
|
|
2284
2823
|
);
|
|
2285
2824
|
}
|
|
2286
2825
|
const getChainsByNetwork = (network2) => {
|
|
@@ -2294,15 +2833,16 @@ function WalletConnectorPrivyProvider(props) {
|
|
|
2294
2833
|
getChainsByNetwork,
|
|
2295
2834
|
openConnectDrawer,
|
|
2296
2835
|
setOpenConnectDrawer,
|
|
2297
|
-
|
|
2298
|
-
|
|
2836
|
+
targetWalletType,
|
|
2837
|
+
setTargetWalletType,
|
|
2299
2838
|
network,
|
|
2300
2839
|
setNetwork,
|
|
2301
2840
|
solanaInfo,
|
|
2302
2841
|
setSolanaInfo,
|
|
2303
2842
|
termsOfUse,
|
|
2304
2843
|
walletChainType,
|
|
2305
|
-
connectorWalletType
|
|
2844
|
+
connectorWalletType,
|
|
2845
|
+
walletChainTypeConfig
|
|
2306
2846
|
}),
|
|
2307
2847
|
[
|
|
2308
2848
|
initChains,
|
|
@@ -2311,15 +2851,16 @@ function WalletConnectorPrivyProvider(props) {
|
|
|
2311
2851
|
getChainsByNetwork,
|
|
2312
2852
|
openConnectDrawer,
|
|
2313
2853
|
setOpenConnectDrawer,
|
|
2314
|
-
|
|
2315
|
-
|
|
2854
|
+
targetWalletType,
|
|
2855
|
+
setTargetWalletType,
|
|
2316
2856
|
network,
|
|
2317
2857
|
setNetwork,
|
|
2318
2858
|
solanaInfo,
|
|
2319
2859
|
setSolanaInfo,
|
|
2320
2860
|
termsOfUse,
|
|
2321
2861
|
walletChainType,
|
|
2322
|
-
connectorWalletType
|
|
2862
|
+
connectorWalletType,
|
|
2863
|
+
walletChainTypeConfig
|
|
2323
2864
|
]
|
|
2324
2865
|
);
|
|
2325
2866
|
useEffect(() => {
|
|
@@ -2332,33 +2873,12 @@ function WalletConnectorPrivyProvider(props) {
|
|
|
2332
2873
|
if (!initRef.current) {
|
|
2333
2874
|
return null;
|
|
2334
2875
|
}
|
|
2335
|
-
return /* @__PURE__ */
|
|
2336
|
-
InitPrivyProvider,
|
|
2337
|
-
{
|
|
2338
|
-
privyConfig: props.privyConfig,
|
|
2339
|
-
initChains
|
|
2340
|
-
},
|
|
2341
|
-
/* @__PURE__ */ React12.createElement(
|
|
2342
|
-
InitWagmiProvider,
|
|
2343
|
-
{
|
|
2344
|
-
wagmiConfig: props.wagmiConfig ?? {},
|
|
2345
|
-
initChains
|
|
2346
|
-
},
|
|
2347
|
-
/* @__PURE__ */ React12.createElement(
|
|
2348
|
-
InitSolanaProvider,
|
|
2349
|
-
{
|
|
2350
|
-
...props.solanaConfig ?? { wallets: [], onError: () => {
|
|
2351
|
-
} }
|
|
2352
|
-
},
|
|
2353
|
-
/* @__PURE__ */ React12.createElement(PrivyWalletProvider, null, /* @__PURE__ */ React12.createElement(WagmiWalletProvider, null, /* @__PURE__ */ React12.createElement(SolanaWalletProvider, null, /* @__PURE__ */ React12.createElement(Main, null, props.children))))
|
|
2354
|
-
)
|
|
2355
|
-
)
|
|
2356
|
-
)));
|
|
2876
|
+
return /* @__PURE__ */ React19.createElement(WalletConnectorPrivyContext.Provider, { value }, /* @__PURE__ */ React19.createElement(TooltipProvider, { delayDuration: 300 }, /* @__PURE__ */ React19.createElement(PrivyWallet, { privyConfig: props.privyConfig, initChains }, /* @__PURE__ */ React19.createElement(WagmiWallet, { wagmiConfig: props.wagmiConfig, initChains }, /* @__PURE__ */ React19.createElement(SolanaWallet, { solanaConfig: props.solanaConfig }, /* @__PURE__ */ React19.createElement(AbstractWallet, null, /* @__PURE__ */ React19.createElement(Main, { headerProps: props.headerProps }, props.children)))))));
|
|
2357
2877
|
}
|
|
2358
2878
|
var viem = viemExport;
|
|
2359
2879
|
var wagmiConnectors = WagmiConnectorsExport;
|
|
2360
2880
|
var wagmi = WagmiExport;
|
|
2361
2881
|
|
|
2362
|
-
export { MwebUserCenter, Network, SolanaChains, SolanaChainsMap, UserCenter, WalletChainTypeEnum, WalletConnectorPrivyProvider, WalletType, viem, wagmi, wagmiConnectors };
|
|
2882
|
+
export { AbstractChainsMap, MwebUserCenter, Network, SolanaChains, SolanaChainsMap, UserCenter, WalletChainTypeEnum, WalletConnectType, WalletConnectorPrivyProvider, WalletType, viem, wagmi, wagmiConnectors };
|
|
2363
2883
|
//# sourceMappingURL=out.js.map
|
|
2364
2884
|
//# sourceMappingURL=index.mjs.map
|