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