adapter-connect 0.0.2

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.mjs ADDED
@@ -0,0 +1,927 @@
1
+ // src/WhatWagmiProvider.tsx
2
+ import { WagmiProvider } from "wagmi";
3
+ import { PrivyProvider } from "@privy-io/react-auth";
4
+
5
+ // src/config.ts
6
+ import { createConfig, http, injected } from "wagmi";
7
+ import { base } from "viem/chains";
8
+ var createConnectors = () => {
9
+ return [injected()];
10
+ };
11
+ var config = createConfig({
12
+ chains: [base],
13
+ connectors: createConnectors(),
14
+ transports: {
15
+ [base.id]: http()
16
+ }
17
+ });
18
+
19
+ // src/ModalPrivyConnect.tsx
20
+ import React, { useEffect, useMemo as useMemo2 } from "react";
21
+ import { get } from "lodash";
22
+ import { createConnector } from "wagmi";
23
+ import { arbitrum, arbitrumSepolia } from "viem/chains";
24
+
25
+ // src/useWalletConnect.tsx
26
+ import { usePrivy, useWallets } from "@privy-io/react-auth";
27
+ import { useMemo } from "react";
28
+ import { useAccount, useConnect, useDisconnect } from "wagmi";
29
+
30
+ // node_modules/@wagmi/core/dist/esm/version.js
31
+ var version = "2.22.1";
32
+
33
+ // node_modules/@wagmi/core/dist/esm/utils/getVersion.js
34
+ var getVersion = () => `@wagmi/core@${version}`;
35
+
36
+ // node_modules/@wagmi/core/dist/esm/errors/base.js
37
+ var __classPrivateFieldGet = function(receiver, state, kind, f) {
38
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
39
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
40
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
41
+ };
42
+ var _BaseError_instances;
43
+ var _BaseError_walk;
44
+ var BaseError = class _BaseError extends Error {
45
+ get docsBaseUrl() {
46
+ return "https://wagmi.sh/core";
47
+ }
48
+ get version() {
49
+ return getVersion();
50
+ }
51
+ constructor(shortMessage, options = {}) {
52
+ var _a;
53
+ super();
54
+ _BaseError_instances.add(this);
55
+ Object.defineProperty(this, "details", {
56
+ enumerable: true,
57
+ configurable: true,
58
+ writable: true,
59
+ value: void 0
60
+ });
61
+ Object.defineProperty(this, "docsPath", {
62
+ enumerable: true,
63
+ configurable: true,
64
+ writable: true,
65
+ value: void 0
66
+ });
67
+ Object.defineProperty(this, "metaMessages", {
68
+ enumerable: true,
69
+ configurable: true,
70
+ writable: true,
71
+ value: void 0
72
+ });
73
+ Object.defineProperty(this, "shortMessage", {
74
+ enumerable: true,
75
+ configurable: true,
76
+ writable: true,
77
+ value: void 0
78
+ });
79
+ Object.defineProperty(this, "name", {
80
+ enumerable: true,
81
+ configurable: true,
82
+ writable: true,
83
+ value: "WagmiCoreError"
84
+ });
85
+ const details = options.cause instanceof _BaseError ? options.cause.details : ((_a = options.cause) == null ? void 0 : _a.message) ? options.cause.message : options.details;
86
+ const docsPath = options.cause instanceof _BaseError ? options.cause.docsPath || options.docsPath : options.docsPath;
87
+ this.message = [
88
+ shortMessage || "An error occurred.",
89
+ "",
90
+ ...options.metaMessages ? [...options.metaMessages, ""] : [],
91
+ ...docsPath ? [
92
+ `Docs: ${this.docsBaseUrl}${docsPath}.html${options.docsSlug ? `#${options.docsSlug}` : ""}`
93
+ ] : [],
94
+ ...details ? [`Details: ${details}`] : [],
95
+ `Version: ${this.version}`
96
+ ].join("\n");
97
+ if (options.cause)
98
+ this.cause = options.cause;
99
+ this.details = details;
100
+ this.docsPath = docsPath;
101
+ this.metaMessages = options.metaMessages;
102
+ this.shortMessage = shortMessage;
103
+ }
104
+ walk(fn) {
105
+ return __classPrivateFieldGet(this, _BaseError_instances, "m", _BaseError_walk).call(this, this, fn);
106
+ }
107
+ };
108
+ _BaseError_instances = /* @__PURE__ */ new WeakSet(), _BaseError_walk = function _BaseError_walk2(err, fn) {
109
+ if (fn == null ? void 0 : fn(err))
110
+ return err;
111
+ if (err.cause)
112
+ return __classPrivateFieldGet(this, _BaseError_instances, "m", _BaseError_walk2).call(this, err.cause, fn);
113
+ return err;
114
+ };
115
+
116
+ // node_modules/@wagmi/core/dist/esm/errors/config.js
117
+ var ChainNotConfiguredError = class extends BaseError {
118
+ constructor() {
119
+ super("Chain not configured.");
120
+ Object.defineProperty(this, "name", {
121
+ enumerable: true,
122
+ configurable: true,
123
+ writable: true,
124
+ value: "ChainNotConfiguredError"
125
+ });
126
+ }
127
+ };
128
+
129
+ // node_modules/@wagmi/core/dist/esm/errors/connector.js
130
+ var SwitchChainNotSupportedError = class extends BaseError {
131
+ constructor({ connector }) {
132
+ super(`"${connector.name}" does not support programmatic chain switching.`);
133
+ Object.defineProperty(this, "name", {
134
+ enumerable: true,
135
+ configurable: true,
136
+ writable: true,
137
+ value: "SwitchChainNotSupportedError"
138
+ });
139
+ }
140
+ };
141
+
142
+ // node_modules/@wagmi/core/dist/esm/actions/switchChain.js
143
+ async function switchChain(config2, parameters) {
144
+ var _a, _b;
145
+ const { addEthereumChainParameter, chainId } = parameters;
146
+ const connection = config2.state.connections.get((_b = (_a = parameters.connector) == null ? void 0 : _a.uid) != null ? _b : config2.state.current);
147
+ if (connection) {
148
+ const connector = connection.connector;
149
+ if (!connector.switchChain)
150
+ throw new SwitchChainNotSupportedError({ connector });
151
+ const chain2 = await connector.switchChain({
152
+ addEthereumChainParameter,
153
+ chainId
154
+ });
155
+ return chain2;
156
+ }
157
+ const chain = config2.chains.find((x) => x.id === chainId);
158
+ if (!chain)
159
+ throw new ChainNotConfiguredError();
160
+ config2.setState((x) => ({ ...x, chainId }));
161
+ return chain;
162
+ }
163
+
164
+ // node_modules/@wagmi/core/dist/esm/exports/index.js
165
+ import { custom, http as http2, webSocket } from "viem";
166
+
167
+ // src/useWalletConnect.tsx
168
+ import { base as base2 } from "viem/chains";
169
+ var useWalletConnect = () => {
170
+ const { login, authenticated, user, logout, ready } = usePrivy();
171
+ const { connectors, connect } = useConnect();
172
+ const { connectWallet } = usePrivy();
173
+ const { wallets } = useWallets();
174
+ const { disconnect: disconnectWagmiFunction } = useDisconnect();
175
+ const { address, isConnected, chainId } = useAccount();
176
+ const disconnect = async () => {
177
+ try {
178
+ disconnectWagmiFunction();
179
+ } catch (e) {
180
+ }
181
+ };
182
+ const isCorrectChain = chainId === base2.id;
183
+ const switchToArbitrum = async () => {
184
+ try {
185
+ const wallet = wallets.find((wallet2) => wallet2.address.toString() === (address == null ? void 0 : address.toString()));
186
+ wallet == null ? void 0 : wallet.switchChain(base2.id);
187
+ switchChain(config, { chainId: base2.id });
188
+ } catch (error) {
189
+ console.error("Failed to switch chain:", error);
190
+ }
191
+ };
192
+ const setActiveWallet = async (walletAddress) => {
193
+ try {
194
+ if (walletAddress) {
195
+ const wallet = wallets.find((w) => w.address.toLowerCase() === walletAddress.toLowerCase());
196
+ if (wallet) {
197
+ await wallet.switchChain(base2.id);
198
+ }
199
+ }
200
+ } catch (error) {
201
+ console.error("Failed to set active wallet:", error);
202
+ }
203
+ };
204
+ const connectorsMemo = useMemo(() => {
205
+ return connectors.filter((connector) => connector.id !== "injected");
206
+ }, [connectors]);
207
+ return {
208
+ // connectWallet,
209
+ address,
210
+ connectors: connectorsMemo,
211
+ connect,
212
+ login,
213
+ authenticated,
214
+ user,
215
+ logout,
216
+ ready,
217
+ disconnect,
218
+ isCorrectChain,
219
+ switchToArbitrum,
220
+ chainId,
221
+ connectWallet,
222
+ setActiveWallet
223
+ };
224
+ };
225
+
226
+ // src/ModalPrivyConnect.tsx
227
+ import { base as base3 } from "viem/chains";
228
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
229
+ var ModalPrivyConnect = () => {
230
+ const [isModalOpen, setIsModalOpen] = React.useState(false);
231
+ const { login, connectors, connect, connectWallet } = useWalletConnect();
232
+ const icon = useMemo2(() => {
233
+ const icons = {
234
+ "walletConnect": "https://hype.what.exchange/icons/walletconnect-icon.png",
235
+ "metaMaskSDK": "https://hype.what.exchange/icons/metamask-icon.png",
236
+ "io.metamask": "https://hype.what.exchange/icons/metamask-icon.png",
237
+ "io.privy.wallet": "https://hype.what.exchange/icons/privy-icon.png",
238
+ "phantom": "https://hype.what.exchange/icons/phantom-icon.png",
239
+ "brave": "https://hype.what.exchange/icons/brave-icon.png",
240
+ "binance": "https://hype.what.exchange/icons/binance-icon.png"
241
+ };
242
+ return icons;
243
+ }, []);
244
+ const connectorToPrivyWallet = useMemo2(() => {
245
+ const map = {
246
+ "io.metamask": "metamask",
247
+ "metaMaskSDK": "metamask",
248
+ "walletConnect": "wallet_connect"
249
+ };
250
+ return map;
251
+ }, []);
252
+ const handleConnectWallet = async (connector) => {
253
+ try {
254
+ const privyWalletName = connectorToPrivyWallet[connector.id];
255
+ if (privyWalletName && connectWallet) {
256
+ await connectWallet({ walletList: [privyWalletName] });
257
+ } else {
258
+ await connect({ connector, chainId: base3.id });
259
+ }
260
+ setIsModalOpen(false);
261
+ } catch (error) {
262
+ console.error("Failed to connect wallet:", error);
263
+ }
264
+ };
265
+ const handleConnectSpecificWallet = async (walletName) => {
266
+ var _a, _b, _c;
267
+ try {
268
+ let provider = null;
269
+ if (walletName === "brave") {
270
+ provider = window.braveEthereum;
271
+ if (!provider || !((_a = window.braveEthereum) == null ? void 0 : _a.isBraveWallet) && !((_b = window.braveEthereum) == null ? void 0 : _b._brave)) {
272
+ throw new Error("Brave Wallet is not installed. Please install it first.");
273
+ }
274
+ } else if (walletName === "binance") {
275
+ provider = (_c = window.binancew3w) == null ? void 0 : _c.ethereum;
276
+ if (!provider) {
277
+ throw new Error("Binance Wallet is not installed. Please install it first.");
278
+ return;
279
+ }
280
+ }
281
+ await provider.request({ method: "eth_requestAccounts" });
282
+ const customConnector = createConnector((config2) => ({
283
+ id: walletName,
284
+ name: walletName === "brave" ? "Brave Wallet" : "Binance Wallet",
285
+ type: "injected",
286
+ async setup() {
287
+ },
288
+ async connect(parameters) {
289
+ const accounts = await provider.request({ method: "eth_requestAccounts" });
290
+ const chainId = await provider.request({ method: "eth_chainId" });
291
+ return {
292
+ accounts: accounts.map((account) => account),
293
+ chainId: Number(chainId)
294
+ };
295
+ },
296
+ async disconnect() {
297
+ },
298
+ async getAccounts() {
299
+ const accounts = await provider.request({ method: "eth_accounts" });
300
+ return accounts.map((account) => account);
301
+ },
302
+ async getChainId() {
303
+ const chainId = await provider.request({ method: "eth_chainId" });
304
+ return Number(chainId);
305
+ },
306
+ async isAuthorized() {
307
+ try {
308
+ const accounts = await provider.request({ method: "eth_accounts" });
309
+ return accounts.length > 0;
310
+ } catch {
311
+ return false;
312
+ }
313
+ },
314
+ getProvider() {
315
+ return provider;
316
+ },
317
+ async switchChain({ chainId: targetChainId }) {
318
+ var _a2, _b2;
319
+ const hexChainId = `0x${targetChainId.toString(16)}`;
320
+ const targetChain = targetChainId === arbitrum.id ? arbitrum : arbitrumSepolia;
321
+ try {
322
+ await provider.request({
323
+ method: "wallet_switchEthereumChain",
324
+ params: [{ chainId: hexChainId }]
325
+ });
326
+ return targetChain;
327
+ } catch (switchError) {
328
+ if (switchError.code === 4902 || switchError.code === -32603) {
329
+ try {
330
+ const explorerUrl = (_b2 = (_a2 = targetChain.blockExplorers) == null ? void 0 : _a2.default) == null ? void 0 : _b2.url;
331
+ await provider.request({
332
+ method: "wallet_addEthereumChain",
333
+ params: [{
334
+ chainId: hexChainId,
335
+ chainName: targetChain.name,
336
+ nativeCurrency: {
337
+ name: targetChain.nativeCurrency.name,
338
+ symbol: targetChain.nativeCurrency.symbol,
339
+ decimals: targetChain.nativeCurrency.decimals
340
+ },
341
+ rpcUrls: targetChain.rpcUrls.default.http,
342
+ blockExplorerUrls: explorerUrl ? [explorerUrl] : void 0
343
+ }]
344
+ });
345
+ return targetChain;
346
+ } catch (addError) {
347
+ throw new Error(`Failed to add chain: ${addError}`);
348
+ }
349
+ }
350
+ if (switchError.code === 4001) {
351
+ throw new Error("User rejected the chain switch.");
352
+ }
353
+ throw switchError;
354
+ }
355
+ },
356
+ onAccountsChanged(accounts) {
357
+ if (accounts.length === 0) {
358
+ config2.emitter.emit("disconnect");
359
+ } else {
360
+ config2.emitter.emit("change", { accounts: accounts.map((account) => account) });
361
+ }
362
+ },
363
+ onChainChanged(chainId) {
364
+ const chainIdNumber = typeof chainId === "string" ? Number.parseInt(chainId, 16) : Number(chainId);
365
+ config2.emitter.emit("change", { chainId: chainIdNumber });
366
+ },
367
+ onDisconnect() {
368
+ config2.emitter.emit("disconnect");
369
+ }
370
+ }));
371
+ await connect({ connector: customConnector, chainId: base3.id });
372
+ setIsModalOpen(false);
373
+ } catch (error) {
374
+ console.error(`Failed to connect ${walletName}:`, error);
375
+ if ((error == null ? void 0 : error.code) === 4001) {
376
+ console.error("User rejected the connection request.");
377
+ } else {
378
+ console.error(`Failed to connect ${walletName}. Please try again.`);
379
+ }
380
+ }
381
+ };
382
+ const handleEmailLogin = () => {
383
+ login({
384
+ loginMethods: ["email"]
385
+ });
386
+ };
387
+ const handleGoogleLogin = () => {
388
+ login({
389
+ loginMethods: ["google"]
390
+ });
391
+ };
392
+ const handleTwitterLogin = () => {
393
+ login({
394
+ loginMethods: ["twitter"]
395
+ });
396
+ };
397
+ useEffect(() => {
398
+ window.openModalPrivyConnect = () => {
399
+ setIsModalOpen(true);
400
+ };
401
+ }, []);
402
+ if (!isModalOpen) {
403
+ return /* @__PURE__ */ jsx(Fragment, {});
404
+ }
405
+ const handleConnectWalletSolana = async (walletList) => {
406
+ setIsModalOpen(false);
407
+ };
408
+ return /* @__PURE__ */ jsx(
409
+ "div",
410
+ {
411
+ className: "fixed inset-0 oui-bg-black/80 flex items-center justify-end z-50",
412
+ onClick: () => setIsModalOpen(false),
413
+ children: /* @__PURE__ */ jsx(
414
+ "div",
415
+ {
416
+ role: "dialog",
417
+ "aria-describedby": "radix-:r2:",
418
+ "aria-labelledby": "radix-:r1:",
419
+ "data-state": "open",
420
+ className: "oui-fixed oui-z-50 oui-gap-4 oui-px-4 oui-shadow-lg oui-transition oui-ease-in-out data-[state=closed]:oui-duration-260 data-[state=open]:oui-duration-300 data-[state=open]:oui-animate-in data-[state=closed]:oui-animate-out oui-inset-y-0 oui-right-0 oui-h-auto oui-w-3/4 my-4 py-4 oui-border mr-4 data-[state=closed]:oui-slide-out-to-right data-[state=open]:oui-slide-in-from-right sm:oui-max-w-sm !oui-p-4 !oui-bg-[#131519] !oui-border !oui-border-solid oui-border-line-12 oui-border-solid !oui-bottom-[30px] oui-right-3 oui-top-[48px] !oui-h-auto oui-w-[300px] oui-overflow-hidden rounded-[16px] oui-bg-[#131519]",
421
+ tabIndex: -1,
422
+ style: { pointerEvents: "auto" },
423
+ onClick: (e) => e.stopPropagation(),
424
+ children: /* @__PURE__ */ jsxs("div", { className: "oui-h-full oui-py-0 oui-border-none oui-relative", children: [
425
+ /* @__PURE__ */ jsx(
426
+ "div",
427
+ {
428
+ className: "oui-absolute oui-inset-x-[50px] -oui-top-[calc(100vh/2)] oui-z-0 oui-h-screen",
429
+ style: {
430
+ background: "conic-gradient(from -41deg at 40.63% 50.41%, rgba(242, 98, 181, 0) 125.179deg, rgba(95, 197, 255, 0.2) 193.412deg, rgba(255, 172, 137, 0.2) 216.021deg, rgba(129, 85, 255, 0.2) 236.071deg, rgba(120, 157, 255, 0.2) 259.953deg, rgba(159, 115, 241, 0) 311.078deg)",
431
+ filter: "blur(50px)"
432
+ }
433
+ }
434
+ ),
435
+ /* @__PURE__ */ jsxs("div", { className: "oui-relative oui-z-10 oui-flex oui-h-full oui-flex-col oui-gap-4 md:oui-gap-5", children: [
436
+ /* @__PURE__ */ jsxs("div", { className: "oui-flex oui-flex-none oui-items-center oui-justify-between", children: [
437
+ /* @__PURE__ */ jsx("div", { className: "oui-font-semibold oui-text-base-contrast-80 oui-pb-2 oui-text-[20px] md:oui-py-0 md:oui-text-base", children: "Connect wallet" }),
438
+ /* @__PURE__ */ jsx(
439
+ "svg",
440
+ {
441
+ xmlns: "http://www.w3.org/2000/svg",
442
+ width: "24",
443
+ height: "24",
444
+ fill: "none",
445
+ viewBox: "0 0 24 24",
446
+ className: "oui-size-5 oui-cursor-pointer oui-text-base-contrast-20 hover:oui-text-base-contrast-80",
447
+ onClick: () => setIsModalOpen(false),
448
+ children: /* @__PURE__ */ jsx("path", { fill: "currentcolor", fillOpacity: "0.54", d: "M4.994 3.906c-.256 0-.523.086-.718.281a1.029 1.029 0 0 0 0 1.438l6.28 6.281-6.28 6.281a1.029 1.029 0 0 0 0 1.438c.39.39 1.047.39 1.437 0l6.281-6.28 6.282 6.28c.39.39 1.047.39 1.437 0 .39-.39.39-1.047 0-1.438l-6.281-6.28 6.281-6.282c.39-.39.39-1.047 0-1.438a1.013 1.013 0 0 0-.719-.28c-.256 0-.523.085-.718.28l-6.282 6.281-6.28-6.28a1.013 1.013 0 0 0-.72-.282Z" })
449
+ }
450
+ )
451
+ ] }),
452
+ /* @__PURE__ */ jsx("div", { className: "oui-relative oui-overflow-hidden oui-scroll-area-root oui-flex oui-grow oui-shrik oui-basis-auto oui-custom-scrollbar", style: { position: "relative" }, children: /* @__PURE__ */ jsx("div", { className: "oui-h-full oui-w-full oui-rounded-[inherit]", style: { overflow: "auto" }, children: /* @__PURE__ */ jsx("div", { style: { minWidth: "100%", display: "table" }, children: /* @__PURE__ */ jsxs("div", { className: "oui-flex oui-flex-col oui-gap-4 md:oui-gap-5", children: [
453
+ /* @__PURE__ */ jsxs("div", { className: "oui-box oui-flex oui-flex-col oui-items-start oui-justify-start oui-flex-nowrap oui-gap-2 oui-w-full", children: [
454
+ /* @__PURE__ */ jsx("div", { className: "oui-flex oui-items-center oui-justify-between oui-mb-3 oui-text-sm oui-font-semibold oui-text-base-contrast-80", children: "Login in" }),
455
+ /* @__PURE__ */ jsxs("div", { className: "oui-box oui-grid oui-grid-cols-1 oui-gap-2 oui-w-full", children: [
456
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(
457
+ "button",
458
+ {
459
+ onClick: handleEmailLogin,
460
+ className: "oui-flex oui-cursor-pointer oui-items-center oui-justify-center oui-gap-1 oui-rounded-[6px] oui-border oui-border-base-contrast-12 oui-px-2 oui-py-[11px] oui-border-none oui-bg-[#333948] w-full",
461
+ children: [
462
+ /* @__PURE__ */ jsx("img", { src: "https://oss.orderly.network/static/sdk/privy/email.svg", className: "oui-size-[18px]" }),
463
+ /* @__PURE__ */ jsx("div", { className: "oui-text-2xs oui-text-base-contrast", children: "Email" })
464
+ ]
465
+ }
466
+ ) }),
467
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(
468
+ "button",
469
+ {
470
+ onClick: handleGoogleLogin,
471
+ className: "oui-flex oui-cursor-pointer oui-items-center oui-justify-center oui-gap-1 oui-rounded-[6px] oui-border oui-border-base-contrast-12 oui-px-2 oui-py-[11px] oui-border-none oui-bg-[#335FFC] w-full",
472
+ children: [
473
+ /* @__PURE__ */ jsx("img", { src: "https://oss.orderly.network/static/sdk/privy/google.svg", className: "oui-size-[18px]" }),
474
+ /* @__PURE__ */ jsx("div", { className: "oui-text-2xs oui-text-base-contrast", children: "Google" })
475
+ ]
476
+ }
477
+ ) }),
478
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(
479
+ "button",
480
+ {
481
+ onClick: handleTwitterLogin,
482
+ className: "oui-flex oui-cursor-pointer oui-items-center oui-justify-center oui-gap-1 oui-rounded-[6px] oui-border oui-border-base-contrast-12 oui-px-2 oui-py-[11px] oui-border-none oui-bg-[#07080A] w-full",
483
+ children: [
484
+ /* @__PURE__ */ jsx("img", { src: "https://oss.orderly.network/static/sdk/privy/twitter.svg", className: "oui-size-[18px]" }),
485
+ /* @__PURE__ */ jsx("div", { className: "oui-text-2xs oui-text-base-contrast", children: "X / Twitter" })
486
+ ]
487
+ }
488
+ ) })
489
+ ] }),
490
+ /* @__PURE__ */ jsx("div", { className: "oui-mt-4 oui-flex oui-h-3 oui-justify-center", children: /* @__PURE__ */ jsx("img", { src: "https://oss.orderly.network/static/sdk/privy/privy-logo.png", className: "oui-h-[10px]" }) }),
491
+ /* @__PURE__ */ jsx("div", { className: "oui-mt-4 oui-h-px oui-w-full oui-bg-line md:oui-mt-5" })
492
+ ] }),
493
+ /* @__PURE__ */ jsxs("div", { className: "", children: [
494
+ /* @__PURE__ */ jsx("div", { className: "oui-mb-2 oui-text-sm oui-font-semibold oui-text-base-contrast-80", children: "EVM" }),
495
+ /* @__PURE__ */ jsxs("div", { className: "oui-grid oui-grid-cols-2 oui-gap-2", children: [
496
+ connectors.map((connector) => /* @__PURE__ */ jsxs(
497
+ "button",
498
+ {
499
+ onClick: () => handleConnectWallet(connector),
500
+ className: "oui-flex oui-flex-1 oui-cursor-pointer oui-items-center oui-justify-start oui-gap-1 oui-rounded-[6px] oui-px-2 oui-py-[11px] oui-bg-[#07080A]",
501
+ children: [
502
+ /* @__PURE__ */ jsx("div", { className: "oui-w-[18px] oui-h-[18px] oui-flex oui-items-center oui-justify-center", children: /* @__PURE__ */ jsx(
503
+ "img",
504
+ {
505
+ src: (connector.icon ? connector.icon : get(icon, connector.id, "")) || "",
506
+ className: "oui-w-[18px] oui-h-[18px]",
507
+ alt: connector.name
508
+ }
509
+ ) }),
510
+ /* @__PURE__ */ jsx("div", { className: "oui-text-2xs oui-text-base-contrast", children: connector.name })
511
+ ]
512
+ },
513
+ connector.id
514
+ )),
515
+ /* @__PURE__ */ jsxs(
516
+ "button",
517
+ {
518
+ onClick: async () => {
519
+ try {
520
+ if (connectWallet) {
521
+ await connectWallet({ walletList: ["metamask"] });
522
+ }
523
+ setIsModalOpen(false);
524
+ } catch (error) {
525
+ console.error("Failed to connect MetaMask:", error);
526
+ }
527
+ },
528
+ className: "oui-flex oui-flex-1 oui-cursor-pointer oui-items-center oui-justify-start oui-gap-1 oui-rounded-[6px] oui-px-2 oui-py-[11px] oui-bg-[#07080A]",
529
+ children: [
530
+ /* @__PURE__ */ jsx("div", { className: "oui-w-[18px] oui-h-[18px] oui-flex oui-items-center oui-justify-center", children: /* @__PURE__ */ jsx(
531
+ "img",
532
+ {
533
+ src: "https://hype.what.exchange/icons/metamask-icon.png",
534
+ className: "oui-w-[18px] oui-h-[18px]",
535
+ alt: "MetaMask"
536
+ }
537
+ ) }),
538
+ /* @__PURE__ */ jsx("div", { className: "oui-text-2xs oui-text-base-contrast", children: "MetaMask" })
539
+ ]
540
+ }
541
+ ),
542
+ /* @__PURE__ */ jsxs(
543
+ "button",
544
+ {
545
+ onClick: async () => {
546
+ try {
547
+ if (connectWallet) {
548
+ await connectWallet({ walletList: ["wallet_connect"] });
549
+ }
550
+ setIsModalOpen(false);
551
+ } catch (error) {
552
+ console.error("Failed to connect WalletConnect:", error);
553
+ }
554
+ },
555
+ className: "oui-flex oui-flex-1 oui-cursor-pointer oui-items-center oui-justify-start oui-gap-1 oui-rounded-[6px] oui-px-2 oui-py-[11px] oui-bg-[#07080A]",
556
+ children: [
557
+ /* @__PURE__ */ jsx("div", { className: "oui-w-[18px] oui-h-[18px] oui-flex oui-items-center oui-justify-center", children: /* @__PURE__ */ jsx(
558
+ "img",
559
+ {
560
+ src: "https://hype.what.exchange/icons/walletconnect-icon.png",
561
+ className: "oui-w-[18px] oui-h-[18px]",
562
+ alt: "WalletConnect"
563
+ }
564
+ ) }),
565
+ /* @__PURE__ */ jsx("div", { className: "oui-text-2xs oui-text-base-contrast", children: "WalletConnect" })
566
+ ]
567
+ }
568
+ ),
569
+ /* @__PURE__ */ jsxs(
570
+ "button",
571
+ {
572
+ onClick: () => handleConnectSpecificWallet("brave"),
573
+ className: "oui-flex oui-flex-1 oui-cursor-pointer oui-items-center oui-justify-start oui-gap-1 oui-rounded-[6px] oui-px-2 oui-py-[11px] oui-bg-[#07080A]",
574
+ children: [
575
+ /* @__PURE__ */ jsx("div", { className: "oui-w-[18px] oui-h-[18px] oui-flex oui-items-center oui-justify-center", children: /* @__PURE__ */ jsx(
576
+ "img",
577
+ {
578
+ src: "https://hype.what.exchange/icons/brave-icon.png",
579
+ className: "oui-w-[18px] oui-h-[18px]",
580
+ alt: "Brave Wallet",
581
+ onError: (e) => {
582
+ e.target.src = "https://hype.what.exchange/icons/metamask-icon.png";
583
+ }
584
+ }
585
+ ) }),
586
+ /* @__PURE__ */ jsx("div", { className: "oui-text-2xs oui-text-base-contrast", children: "Brave Wallet" })
587
+ ]
588
+ }
589
+ ),
590
+ /* @__PURE__ */ jsxs(
591
+ "button",
592
+ {
593
+ onClick: () => handleConnectSpecificWallet("binance"),
594
+ className: "oui-flex oui-flex-1 oui-cursor-pointer oui-items-center oui-justify-start oui-gap-1 oui-rounded-[6px] oui-px-2 oui-py-[11px] oui-bg-[#07080A]",
595
+ children: [
596
+ /* @__PURE__ */ jsx("div", { className: "oui-w-[18px] oui-h-[18px] oui-flex oui-items-center oui-justify-center", children: /* @__PURE__ */ jsx(
597
+ "img",
598
+ {
599
+ src: "https://hype.what.exchange/icons/binance-icon.png",
600
+ className: "oui-w-[18px] oui-h-[18px]",
601
+ alt: "Binance Wallet",
602
+ onError: (e) => {
603
+ e.target.src = "https://hype.what.exchange/icons/metamask-icon.png";
604
+ }
605
+ }
606
+ ) }),
607
+ /* @__PURE__ */ jsx("div", { className: "oui-text-2xs oui-text-base-contrast", children: "Binance Wallet" })
608
+ ]
609
+ }
610
+ )
611
+ ] })
612
+ ] })
613
+ ] }) }) }) }),
614
+ /* @__PURE__ */ jsx("div", { className: "oui-box oui-flex oui-flex-col oui-items-center oui-justify-start oui-flex-nowrap oui-gap-4", children: /* @__PURE__ */ jsxs("div", { className: "oui-flex-none oui-text-center oui-text-2xs oui-font-semibold oui-text-base-contrast-80", children: [
615
+ "By connecting your wallet, you acknowledge and agree to the",
616
+ " ",
617
+ /* @__PURE__ */ jsx("a", { href: "termsofuse", className: "oui-cursor-pointer oui-text-primary oui-underline", target: "_blank", rel: "noreferrer", children: "terms of use" }),
618
+ "."
619
+ ] }) })
620
+ ] })
621
+ ] })
622
+ }
623
+ )
624
+ }
625
+ );
626
+ };
627
+
628
+ // src/ModalPrivyWallets.tsx
629
+ import { useEffect as useEffect2, useState } from "react";
630
+
631
+ // node_modules/lucide-react/dist/esm/createLucideIcon.js
632
+ import { forwardRef as forwardRef2, createElement as createElement2 } from "react";
633
+
634
+ // node_modules/lucide-react/dist/esm/shared/src/utils.js
635
+ var toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
636
+ var toCamelCase = (string) => string.replace(
637
+ /^([A-Z])|[\s-_]+(\w)/g,
638
+ (match, p1, p2) => p2 ? p2.toUpperCase() : p1.toLowerCase()
639
+ );
640
+ var toPascalCase = (string) => {
641
+ const camelCase = toCamelCase(string);
642
+ return camelCase.charAt(0).toUpperCase() + camelCase.slice(1);
643
+ };
644
+ var mergeClasses = (...classes) => classes.filter((className, index, array) => {
645
+ return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
646
+ }).join(" ").trim();
647
+ var hasA11yProp = (props) => {
648
+ for (const prop in props) {
649
+ if (prop.startsWith("aria-") || prop === "role" || prop === "title") {
650
+ return true;
651
+ }
652
+ }
653
+ };
654
+
655
+ // node_modules/lucide-react/dist/esm/Icon.js
656
+ import { forwardRef, createElement } from "react";
657
+
658
+ // node_modules/lucide-react/dist/esm/defaultAttributes.js
659
+ var defaultAttributes = {
660
+ xmlns: "http://www.w3.org/2000/svg",
661
+ width: 24,
662
+ height: 24,
663
+ viewBox: "0 0 24 24",
664
+ fill: "none",
665
+ stroke: "currentColor",
666
+ strokeWidth: 2,
667
+ strokeLinecap: "round",
668
+ strokeLinejoin: "round"
669
+ };
670
+
671
+ // node_modules/lucide-react/dist/esm/Icon.js
672
+ var Icon = forwardRef(
673
+ ({
674
+ color = "currentColor",
675
+ size = 24,
676
+ strokeWidth = 2,
677
+ absoluteStrokeWidth,
678
+ className = "",
679
+ children,
680
+ iconNode,
681
+ ...rest
682
+ }, ref) => createElement(
683
+ "svg",
684
+ {
685
+ ref,
686
+ ...defaultAttributes,
687
+ width: size,
688
+ height: size,
689
+ stroke: color,
690
+ strokeWidth: absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size) : strokeWidth,
691
+ className: mergeClasses("lucide", className),
692
+ ...!children && !hasA11yProp(rest) && { "aria-hidden": "true" },
693
+ ...rest
694
+ },
695
+ [
696
+ ...iconNode.map(([tag, attrs]) => createElement(tag, attrs)),
697
+ ...Array.isArray(children) ? children : [children]
698
+ ]
699
+ )
700
+ );
701
+
702
+ // node_modules/lucide-react/dist/esm/createLucideIcon.js
703
+ var createLucideIcon = (iconName, iconNode) => {
704
+ const Component = forwardRef2(
705
+ ({ className, ...props }, ref) => createElement2(Icon, {
706
+ ref,
707
+ iconNode,
708
+ className: mergeClasses(
709
+ `lucide-${toKebabCase(toPascalCase(iconName))}`,
710
+ `lucide-${iconName}`,
711
+ className
712
+ ),
713
+ ...props
714
+ })
715
+ );
716
+ Component.displayName = toPascalCase(iconName);
717
+ return Component;
718
+ };
719
+
720
+ // node_modules/lucide-react/dist/esm/icons/copy.js
721
+ var __iconNode = [
722
+ ["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2", key: "17jyea" }],
723
+ ["path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2", key: "zix9uf" }]
724
+ ];
725
+ var Copy = createLucideIcon("copy", __iconNode);
726
+
727
+ // node_modules/lucide-react/dist/esm/icons/external-link.js
728
+ var __iconNode2 = [
729
+ ["path", { d: "M15 3h6v6", key: "1q9fwt" }],
730
+ ["path", { d: "M10 14 21 3", key: "gplh6r" }],
731
+ ["path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6", key: "a6xqqp" }]
732
+ ];
733
+ var ExternalLink = createLucideIcon("external-link", __iconNode2);
734
+
735
+ // node_modules/lucide-react/dist/esm/icons/x.js
736
+ var __iconNode3 = [
737
+ ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
738
+ ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
739
+ ];
740
+ var X = createLucideIcon("x", __iconNode3);
741
+
742
+ // src/ModalPrivyWallets.tsx
743
+ import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
744
+ var formatAddress = (address) => {
745
+ if (!address) return "";
746
+ return `${address.slice(0, 6)}...${address.slice(-4)}`;
747
+ };
748
+ var CopyAddress = ({ address }) => {
749
+ const [copied, setCopied] = useState(false);
750
+ const handleCopy = async () => {
751
+ try {
752
+ await navigator.clipboard.writeText(address);
753
+ setCopied(true);
754
+ setTimeout(() => setCopied(false), 2e3);
755
+ } catch (err) {
756
+ console.error("Failed to copy address:", err);
757
+ }
758
+ };
759
+ return /* @__PURE__ */ jsx2(
760
+ "button",
761
+ {
762
+ onClick: handleCopy,
763
+ className: " transition-colors duration-200 cursor-pointer",
764
+ children: copied ? "\u2713 Copied!" : /* @__PURE__ */ jsx2(Copy, { className: "w-4 h-4" })
765
+ }
766
+ );
767
+ };
768
+ var ModalPrivyWallet = () => {
769
+ const [isExpanded, setIsExpanded] = useState(true);
770
+ const { address, disconnect } = useWalletConnect();
771
+ const [isOpen, setIsOpen] = useState(false);
772
+ const [isClosing, setIsClosing] = useState(false);
773
+ const [isVisible, setIsVisible] = useState(false);
774
+ const safeAddress = address != null ? address : "";
775
+ useEffect2(() => {
776
+ window.openModalPrivyWallet = () => {
777
+ setIsOpen(true);
778
+ };
779
+ }, []);
780
+ useEffect2(() => {
781
+ if (isOpen) {
782
+ setIsVisible(false);
783
+ const t = requestAnimationFrame(() => setIsVisible(true));
784
+ return () => cancelAnimationFrame(t);
785
+ } else {
786
+ setIsVisible(false);
787
+ }
788
+ }, [isOpen]);
789
+ useEffect2(() => {
790
+ if (isOpen) {
791
+ const previous = document.body.style.overflow;
792
+ document.body.style.overflow = "hidden";
793
+ return () => {
794
+ document.body.style.overflow = previous;
795
+ };
796
+ }
797
+ }, [isOpen]);
798
+ const handleClose = () => {
799
+ if (isClosing) return;
800
+ setIsClosing(true);
801
+ setIsVisible(false);
802
+ setTimeout(() => {
803
+ setIsOpen(false);
804
+ setIsClosing(false);
805
+ }, 320);
806
+ };
807
+ const handleDisconnect = async () => {
808
+ await disconnect();
809
+ setIsOpen(false);
810
+ };
811
+ if (!isOpen) return /* @__PURE__ */ jsx2(Fragment2, {});
812
+ return /* @__PURE__ */ jsxs2(Fragment2, { children: [
813
+ /* @__PURE__ */ jsx2(
814
+ "div",
815
+ {
816
+ className: `fixed inset-0 z-40 transition-opacity duration-300 ${isClosing ? "opacity-0" : "opacity-100"} `,
817
+ style: { backgroundColor: "rgba(0,0,0,0.6)" },
818
+ onClick: handleClose
819
+ }
820
+ ),
821
+ /* @__PURE__ */ jsx2(
822
+ "div",
823
+ {
824
+ role: "dialog",
825
+ "aria-labelledby": "wallet-dialog-title",
826
+ className: "oui-fixed oui-z-50 oui-gap-4 oui-px-4 oui-shadow-lg oui-inset-y-0 oui-right-0 oui-h-auto oui-w-3/4 my-4 py-4 oui-border mr-4 sm:oui-max-w-sm !oui-p-4 !oui-bg-[#131519] !oui-border !oui-border-solid oui-border-line-12 oui-border-solid !oui-bottom-[30px] oui-right-3 oui-top-[48px] !oui-h-auto oui-w-[300px] oui-overflow-hidden rounded-[16px] oui-bg-[#131519]",
827
+ tabIndex: -1,
828
+ style: {
829
+ pointerEvents: isClosing ? "none" : "auto",
830
+ willChange: "transform, opacity",
831
+ transform: isVisible && !isClosing ? "translateX(0%)" : "translateX(100%)",
832
+ opacity: isVisible && !isClosing ? 1 : 0,
833
+ transition: "transform 300ms ease, opacity 300ms ease"
834
+ },
835
+ children: /* @__PURE__ */ jsxs2("div", { className: "oui-h-full oui-py-0 oui-border-none oui-relative", children: [
836
+ /* @__PURE__ */ jsx2(
837
+ "div",
838
+ {
839
+ className: "oui-absolute oui-inset-x-[50px] -oui-top-[calc(100vh/2)] oui-z-0 oui-h-screen",
840
+ style: {
841
+ background: "conic-gradient(from -41deg at 40.63% 50.41%, rgba(242, 98, 181, 0) 125.179deg, rgba(95, 197, 255, 0.2) 193.412deg, rgba(255, 172, 137, 0.2) 216.021deg, rgba(129, 85, 255, 0.2) 236.071deg, rgba(120, 157, 255, 0.2) 259.953deg, rgba(159, 115, 241, 0) 311.078deg)",
842
+ filter: "blur(50px)"
843
+ }
844
+ }
845
+ ),
846
+ /* @__PURE__ */ jsxs2("div", { className: "oui-relative oui-z-10 oui-flex oui-h-full oui-flex-col oui-gap-4 md:oui-gap-5", children: [
847
+ /* @__PURE__ */ jsxs2("div", { className: "oui-flex oui-flex-none oui-items-center oui-justify-between", children: [
848
+ /* @__PURE__ */ jsx2("div", { id: "wallet-dialog-title", className: "oui-font-semibold oui-text-base-contrast-80 oui-pb-2 oui-text-[20px] md:oui-py-0 md:oui-text-base", children: "My wallet" }),
849
+ /* @__PURE__ */ jsx2("button", { className: "oui-size-5 oui-cursor-pointer oui-text-base-contrast-20 hover:oui-text-base-contrast-80", onClick: handleClose, children: /* @__PURE__ */ jsx2(X, { size: 24 }) })
850
+ ] }),
851
+ /* @__PURE__ */ jsx2("div", { children: /* @__PURE__ */ jsx2("div", { className: "oui-flex oui-flex-col oui-gap-5", children: /* @__PURE__ */ jsxs2("div", { className: "oui-relative oui-h-[110px] oui-overflow-hidden oui-rounded-2xl oui-p-4 oui-bg-[#283BEE]", children: [
852
+ /* @__PURE__ */ jsx2(
853
+ "div",
854
+ {
855
+ style: {
856
+ position: "absolute",
857
+ top: 0,
858
+ right: "-20px",
859
+ background: 'url("https://oss.orderly.network/static/sdk/wallet-card-bg.png") center center / contain no-repeat',
860
+ width: 110,
861
+ height: 110,
862
+ zIndex: 0
863
+ }
864
+ }
865
+ ),
866
+ /* @__PURE__ */ jsx2("div", { className: "oui-relative oui-z-10 oui-flex oui-h-full oui-flex-col oui-justify-between", children: /* @__PURE__ */ jsxs2("div", { className: "oui-flex oui-items-center oui-justify-between", children: [
867
+ /* @__PURE__ */ jsx2("div", { className: "oui-text-sm oui-font-semibold oui-text-base-contrast", children: formatAddress(safeAddress) }),
868
+ /* @__PURE__ */ jsxs2("div", { className: "oui-flex oui-items-center oui-justify-center oui-gap-2", children: [
869
+ /* @__PURE__ */ jsx2(CopyAddress, { address: safeAddress }),
870
+ /* @__PURE__ */ jsx2("button", { className: "oui-cursor-pointer oui-text-base-contrast-80 hover:oui-text-base-contrast", onClick: handleDisconnect, children: /* @__PURE__ */ jsx2(ExternalLink, { size: 16 }) })
871
+ ] })
872
+ ] }) })
873
+ ] }) }) })
874
+ ] })
875
+ ] })
876
+ }
877
+ )
878
+ ] });
879
+ };
880
+
881
+ // src/WhatWagmiProvider.tsx
882
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
883
+ function WhatWagmiProvider({
884
+ children,
885
+ privyKey = ""
886
+ }) {
887
+ return /* @__PURE__ */ jsx3(
888
+ PrivyProvider,
889
+ {
890
+ appId: privyKey,
891
+ config: {
892
+ loginMethods: ["email", "google", "twitter", "wallet"],
893
+ appearance: {
894
+ theme: "dark",
895
+ accentColor: "#3B82F6",
896
+ walletList: ["metamask", "rainbow", "wallet_connect"],
897
+ walletChainType: "ethereum-and-solana"
898
+ }
899
+ },
900
+ children: /* @__PURE__ */ jsxs3(WagmiProvider, { config, children: [
901
+ children,
902
+ /* @__PURE__ */ jsx3(ModalPrivyConnect, {}),
903
+ /* @__PURE__ */ jsx3(ModalPrivyWallet, {})
904
+ ] })
905
+ }
906
+ );
907
+ }
908
+ export {
909
+ WhatWagmiProvider
910
+ };
911
+ /*! Bundled license information:
912
+
913
+ lucide-react/dist/esm/shared/src/utils.js:
914
+ lucide-react/dist/esm/defaultAttributes.js:
915
+ lucide-react/dist/esm/Icon.js:
916
+ lucide-react/dist/esm/createLucideIcon.js:
917
+ lucide-react/dist/esm/icons/copy.js:
918
+ lucide-react/dist/esm/icons/external-link.js:
919
+ lucide-react/dist/esm/icons/x.js:
920
+ lucide-react/dist/esm/lucide-react.js:
921
+ (**
922
+ * @license lucide-react v0.554.0 - ISC
923
+ *
924
+ * This source code is licensed under the ISC license.
925
+ * See the LICENSE file in the root directory of this source tree.
926
+ *)
927
+ */