@aurum-sdk/core 0.2.0 → 0.2.2-canary.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/{chunk-NKWY4I4L.js → chunk-K6PG2PDF.js} +166 -604
- package/dist/chunk-K6PG2PDF.js.map +1 -0
- package/dist/{chunk-NRC534B3.mjs → chunk-THE7QLMS.mjs} +198 -636
- package/dist/chunk-THE7QLMS.mjs.map +1 -0
- package/dist/index.d.mts +4 -7
- package/dist/index.d.ts +4 -7
- package/dist/index.js +762 -352
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +709 -299
- package/dist/index.mjs.map +1 -1
- package/dist/widgets.d.mts +3 -0
- package/dist/widgets.d.ts +3 -0
- package/dist/widgets.js +13 -21
- package/dist/widgets.js.map +1 -1
- package/dist/widgets.mjs +3 -11
- package/dist/widgets.mjs.map +1 -1
- package/package.json +3 -5
- package/dist/chunk-NKWY4I4L.js.map +0 -1
- package/dist/chunk-NRC534B3.mjs.map +0 -1
|
@@ -91,8 +91,7 @@ var WALLET_PRIORITY = [
|
|
|
91
91
|
WalletId.WalletConnect,
|
|
92
92
|
WalletId.Brave,
|
|
93
93
|
WalletId.Rabby,
|
|
94
|
-
WalletId.CoinbaseWallet
|
|
95
|
-
WalletId.Ledger
|
|
94
|
+
WalletId.CoinbaseWallet
|
|
96
95
|
];
|
|
97
96
|
function sortWallets(wallets, options = {}) {
|
|
98
97
|
const { filterHidden = true } = options;
|
|
@@ -119,335 +118,6 @@ function sortWallets(wallets, options = {}) {
|
|
|
119
118
|
return result;
|
|
120
119
|
}
|
|
121
120
|
|
|
122
|
-
// src/services/sentry.ts
|
|
123
|
-
import * as Sentry from "@sentry/browser";
|
|
124
|
-
var initialized = false;
|
|
125
|
-
var telemetryEnabled = true;
|
|
126
|
-
function getEnvironment() {
|
|
127
|
-
if (typeof window !== "undefined") {
|
|
128
|
-
const hostname = window.location.hostname;
|
|
129
|
-
if (hostname === "localhost" || hostname === "127.0.0.1") {
|
|
130
|
-
return "development";
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return "production";
|
|
134
|
-
}
|
|
135
|
-
function initSentry(enabled = true) {
|
|
136
|
-
telemetryEnabled = enabled;
|
|
137
|
-
if (initialized || !telemetryEnabled || false) return;
|
|
138
|
-
initialized = true;
|
|
139
|
-
Sentry.init({
|
|
140
|
-
dsn: "https://0bb16fd7057ac7b45ae0ab416cdbea8b@o4505953815494656.ingest.us.sentry.io/4509747448184832",
|
|
141
|
-
environment: getEnvironment(),
|
|
142
|
-
release: `@aurum-sdk/core@${"0.2.0"}`,
|
|
143
|
-
sendDefaultPii: false,
|
|
144
|
-
enableLogs: true
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
function getUrl() {
|
|
148
|
-
if (typeof window !== "undefined") {
|
|
149
|
-
return window.location.href;
|
|
150
|
-
}
|
|
151
|
-
return void 0;
|
|
152
|
-
}
|
|
153
|
-
var sentryLogger = {
|
|
154
|
-
info: (message, attributes) => {
|
|
155
|
-
if (telemetryEnabled) Sentry.logger.info(message, { url: getUrl(), ...attributes });
|
|
156
|
-
},
|
|
157
|
-
warn: (message, attributes) => {
|
|
158
|
-
if (telemetryEnabled) Sentry.logger.warn(message, { url: getUrl(), ...attributes });
|
|
159
|
-
},
|
|
160
|
-
error: (message, attributes) => {
|
|
161
|
-
if (telemetryEnabled) Sentry.logger.error(message, { url: getUrl(), ...attributes });
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
// src/wallet-adapters/AppKitAdapter.ts
|
|
166
|
-
import { getLogoDataUri } from "@aurum-sdk/logos";
|
|
167
|
-
import { WalletId as WalletId2, WalletName } from "@aurum-sdk/types";
|
|
168
|
-
|
|
169
|
-
// src/utils/isConfigError.ts
|
|
170
|
-
var isConfigError = (error) => {
|
|
171
|
-
const name = error?.name;
|
|
172
|
-
return name === "ConfigError";
|
|
173
|
-
};
|
|
174
|
-
var createConfigError = (adapterName) => {
|
|
175
|
-
const error = new Error(`Missing required project ID for ${adapterName}`);
|
|
176
|
-
error.name = "ConfigError";
|
|
177
|
-
return error;
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
// src/wallet-adapters/AppKitAdapter.ts
|
|
181
|
-
var AppKitAdapter = class {
|
|
182
|
-
constructor(config) {
|
|
183
|
-
this.id = WalletId2.WalletConnect;
|
|
184
|
-
this.name = WalletName.WalletConnect;
|
|
185
|
-
this.icon = getLogoDataUri(WalletId2.WalletConnect, "brand") ?? "";
|
|
186
|
-
this.hide = true;
|
|
187
|
-
this.downloadUrl = null;
|
|
188
|
-
this.wcDeepLinkUrl = null;
|
|
189
|
-
this.modal = null;
|
|
190
|
-
this.wagmiAdapter = null;
|
|
191
|
-
this.provider = null;
|
|
192
|
-
this.address = null;
|
|
193
|
-
this.accountsChangedCallback = null;
|
|
194
|
-
this.unsubscribeFunctions = [];
|
|
195
|
-
this.initPromise = null;
|
|
196
|
-
this.config = {
|
|
197
|
-
projectId: config.projectId,
|
|
198
|
-
appName: config.appName,
|
|
199
|
-
modalZIndex: config.modalZIndex,
|
|
200
|
-
theme: config.theme
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
async ensureInitialized() {
|
|
204
|
-
if (this.modal) return;
|
|
205
|
-
if (!this.initPromise) {
|
|
206
|
-
this.initPromise = this.initializeAppKit();
|
|
207
|
-
}
|
|
208
|
-
await this.initPromise;
|
|
209
|
-
}
|
|
210
|
-
async initializeAppKit() {
|
|
211
|
-
if (typeof window === "undefined") return;
|
|
212
|
-
const [{ createAppKit }, { WagmiAdapter }, { mainnet }] = await Promise.all([
|
|
213
|
-
import("@reown/appkit"),
|
|
214
|
-
import("@reown/appkit-adapter-wagmi"),
|
|
215
|
-
import("@reown/appkit/networks")
|
|
216
|
-
]);
|
|
217
|
-
const networks = [mainnet];
|
|
218
|
-
this.wagmiAdapter = new WagmiAdapter({
|
|
219
|
-
projectId: this.config.projectId,
|
|
220
|
-
networks,
|
|
221
|
-
ssr: true
|
|
222
|
-
});
|
|
223
|
-
this.modal = createAppKit({
|
|
224
|
-
adapters: [this.wagmiAdapter],
|
|
225
|
-
networks,
|
|
226
|
-
projectId: this.config.projectId,
|
|
227
|
-
metadata: {
|
|
228
|
-
name: this.config.appName,
|
|
229
|
-
description: this.config.appName,
|
|
230
|
-
url: window.location.origin,
|
|
231
|
-
icons: []
|
|
232
|
-
},
|
|
233
|
-
allowUnsupportedChain: true,
|
|
234
|
-
themeMode: this.config.theme,
|
|
235
|
-
themeVariables: {
|
|
236
|
-
"--apkt-z-index": this.config.modalZIndex + 1
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
this.setupEventListeners();
|
|
240
|
-
}
|
|
241
|
-
setupEventListeners() {
|
|
242
|
-
if (!this.modal) return;
|
|
243
|
-
const unsubscribeProviders = this.modal.subscribeProviders((state) => {
|
|
244
|
-
const eip155Provider = state["eip155"];
|
|
245
|
-
this.provider = eip155Provider || null;
|
|
246
|
-
if (!eip155Provider) {
|
|
247
|
-
this.address = null;
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
this.unsubscribeFunctions.push(unsubscribeProviders);
|
|
251
|
-
}
|
|
252
|
-
syncAddressFromWagmi() {
|
|
253
|
-
if (!this.wagmiAdapter?.wagmiConfig) return;
|
|
254
|
-
const { state } = this.wagmiAdapter.wagmiConfig;
|
|
255
|
-
if (state.current && state.connections) {
|
|
256
|
-
const connection = state.connections.get(state.current);
|
|
257
|
-
if (connection?.accounts?.[0]) {
|
|
258
|
-
this.address = connection.accounts[0];
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
async syncProviderFromModal() {
|
|
263
|
-
if (!this.modal) return;
|
|
264
|
-
try {
|
|
265
|
-
const getProvidersFn = this.modal.getProviders;
|
|
266
|
-
if (typeof getProvidersFn === "function") {
|
|
267
|
-
const providers = getProvidersFn.call(this.modal);
|
|
268
|
-
const eip155Provider = providers?.["eip155"];
|
|
269
|
-
if (eip155Provider) {
|
|
270
|
-
this.provider = eip155Provider;
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
if (this.wagmiAdapter?.wagmiConfig) {
|
|
275
|
-
const { state } = this.wagmiAdapter.wagmiConfig;
|
|
276
|
-
if (state.current && state.connections) {
|
|
277
|
-
const connection = state.connections.get(state.current);
|
|
278
|
-
const connector = connection?.connector;
|
|
279
|
-
if (connector && typeof connector.getProvider === "function") {
|
|
280
|
-
try {
|
|
281
|
-
const provider = await connector.getProvider();
|
|
282
|
-
if (provider) {
|
|
283
|
-
this.provider = provider;
|
|
284
|
-
}
|
|
285
|
-
} catch (error) {
|
|
286
|
-
sentryLogger.warn("Failed to get provider from wagmi connector", { error });
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
} catch (error) {
|
|
292
|
-
sentryLogger.warn("Failed to get provider from WalletConnect modal", { error });
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
isInstalled() {
|
|
296
|
-
return true;
|
|
297
|
-
}
|
|
298
|
-
async connect() {
|
|
299
|
-
if (!this.config.projectId) {
|
|
300
|
-
throw createConfigError("WalletConnect");
|
|
301
|
-
}
|
|
302
|
-
await this.ensureInitialized();
|
|
303
|
-
if (!this.modal) {
|
|
304
|
-
sentryLogger.error("WalletConnect modal is not available");
|
|
305
|
-
throw new Error("WalletConnect modal is not available");
|
|
306
|
-
}
|
|
307
|
-
const existingAddress = this.modal.getAddress();
|
|
308
|
-
if (this.modal.getIsConnectedState() && existingAddress) {
|
|
309
|
-
await this.syncProviderFromModal();
|
|
310
|
-
if (this.provider) {
|
|
311
|
-
this.address = existingAddress;
|
|
312
|
-
return {
|
|
313
|
-
address: existingAddress,
|
|
314
|
-
provider: this.provider,
|
|
315
|
-
walletId: this.id
|
|
316
|
-
};
|
|
317
|
-
}
|
|
318
|
-
await this.disconnect();
|
|
319
|
-
}
|
|
320
|
-
this.modal.open({ view: "AllWallets" });
|
|
321
|
-
return await this.waitForConnection();
|
|
322
|
-
}
|
|
323
|
-
waitForConnection(timeout = 6e4) {
|
|
324
|
-
return new Promise((resolve, reject) => {
|
|
325
|
-
const startTime = Date.now();
|
|
326
|
-
let unsubscribeState = null;
|
|
327
|
-
let isResolved = false;
|
|
328
|
-
const cleanup = () => {
|
|
329
|
-
unsubscribeState?.();
|
|
330
|
-
};
|
|
331
|
-
const checkConnection = async () => {
|
|
332
|
-
if (isResolved) return true;
|
|
333
|
-
this.syncAddressFromWagmi();
|
|
334
|
-
if (this.address && !this.provider) {
|
|
335
|
-
await this.syncProviderFromModal();
|
|
336
|
-
}
|
|
337
|
-
if (this.provider && this.address) {
|
|
338
|
-
try {
|
|
339
|
-
const accounts = await this.provider.request({ method: "eth_accounts" });
|
|
340
|
-
if (accounts && accounts.length > 0) {
|
|
341
|
-
isResolved = true;
|
|
342
|
-
cleanup();
|
|
343
|
-
this.modal?.close();
|
|
344
|
-
resolve({
|
|
345
|
-
address: this.address,
|
|
346
|
-
provider: this.provider,
|
|
347
|
-
walletId: this.id
|
|
348
|
-
});
|
|
349
|
-
return true;
|
|
350
|
-
}
|
|
351
|
-
return false;
|
|
352
|
-
} catch {
|
|
353
|
-
return false;
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
return false;
|
|
357
|
-
};
|
|
358
|
-
unsubscribeState = this.modal.subscribeState(async (state) => {
|
|
359
|
-
if (await checkConnection()) return;
|
|
360
|
-
if (state.open === false && !this.address && !isResolved) {
|
|
361
|
-
cleanup();
|
|
362
|
-
reject(new Error("Connection rejected by user"));
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
|
-
const pollTimeout = async () => {
|
|
366
|
-
if (await checkConnection()) return;
|
|
367
|
-
if (Date.now() - startTime > timeout) {
|
|
368
|
-
cleanup();
|
|
369
|
-
reject(new Error("Connection timeout"));
|
|
370
|
-
return;
|
|
371
|
-
}
|
|
372
|
-
setTimeout(pollTimeout, 500);
|
|
373
|
-
};
|
|
374
|
-
pollTimeout();
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
async tryRestoreConnection() {
|
|
378
|
-
await this.ensureInitialized();
|
|
379
|
-
if (!this.modal || !this.wagmiAdapter) return null;
|
|
380
|
-
try {
|
|
381
|
-
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
382
|
-
const wagmiConfig = this.wagmiAdapter.wagmiConfig;
|
|
383
|
-
if (wagmiConfig?.state?.current && wagmiConfig.state.connections) {
|
|
384
|
-
const connection = wagmiConfig.state.connections.get(wagmiConfig.state.current);
|
|
385
|
-
if (connection?.accounts?.[0]) {
|
|
386
|
-
this.address = connection.accounts[0];
|
|
387
|
-
if (this.provider && this.address) {
|
|
388
|
-
return {
|
|
389
|
-
address: this.address,
|
|
390
|
-
provider: this.provider,
|
|
391
|
-
walletId: this.id
|
|
392
|
-
};
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
return null;
|
|
397
|
-
} catch {
|
|
398
|
-
return null;
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
async disconnect() {
|
|
402
|
-
if (!this.modal) {
|
|
403
|
-
this.address = null;
|
|
404
|
-
this.provider = null;
|
|
405
|
-
return;
|
|
406
|
-
}
|
|
407
|
-
await this.modal.disconnect("eip155");
|
|
408
|
-
const timeout = Date.now() + 2e3;
|
|
409
|
-
while (Date.now() < timeout && (this.modal.getIsConnectedState() || this.modal.getAddress())) {
|
|
410
|
-
await new Promise((r) => setTimeout(r, 100));
|
|
411
|
-
}
|
|
412
|
-
this.address = null;
|
|
413
|
-
this.provider = null;
|
|
414
|
-
}
|
|
415
|
-
getProvider() {
|
|
416
|
-
return this.provider;
|
|
417
|
-
}
|
|
418
|
-
onAccountsChanged(callback) {
|
|
419
|
-
if (!this.provider?.on) return;
|
|
420
|
-
if (this.accountsChangedCallback) {
|
|
421
|
-
this.provider.removeListener?.("accountsChanged", this.accountsChangedCallback);
|
|
422
|
-
}
|
|
423
|
-
this.accountsChangedCallback = (accounts) => {
|
|
424
|
-
this.address = accounts[0] || null;
|
|
425
|
-
callback(accounts);
|
|
426
|
-
};
|
|
427
|
-
this.provider.on("accountsChanged", this.accountsChangedCallback);
|
|
428
|
-
}
|
|
429
|
-
removeListeners() {
|
|
430
|
-
if (this.provider?.removeListener && this.accountsChangedCallback) {
|
|
431
|
-
this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
|
|
432
|
-
this.accountsChangedCallback = null;
|
|
433
|
-
}
|
|
434
|
-
this.unsubscribeFunctions.forEach((unsub) => unsub());
|
|
435
|
-
this.unsubscribeFunctions = [];
|
|
436
|
-
}
|
|
437
|
-
};
|
|
438
|
-
/** Internal identifier for distinguishing from WalletConnectAdapter */
|
|
439
|
-
AppKitAdapter.INTERNAL_ID = "appkit-modal";
|
|
440
|
-
|
|
441
|
-
// src/utils/platform/isMobile.ts
|
|
442
|
-
import MobileDetect from "mobile-detect";
|
|
443
|
-
function isMobile() {
|
|
444
|
-
if (typeof window === "undefined" || typeof navigator === "undefined") {
|
|
445
|
-
return false;
|
|
446
|
-
}
|
|
447
|
-
const md = new MobileDetect(window.navigator.userAgent);
|
|
448
|
-
return md.mobile() !== null || md.tablet() !== null;
|
|
449
|
-
}
|
|
450
|
-
|
|
451
121
|
// src/contexts/NavigationContext.tsx
|
|
452
122
|
import { createContext as createContext2, useContext as useContext2, useState } from "react";
|
|
453
123
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
@@ -1054,6 +724,62 @@ import { useEffect as useEffect4, useState as useState7 } from "react";
|
|
|
1054
724
|
|
|
1055
725
|
// src/contexts/EmailAuthContext.tsx
|
|
1056
726
|
import { createContext as createContext3, useContext as useContext3, useState as useState6 } from "react";
|
|
727
|
+
|
|
728
|
+
// src/services/sentry.ts
|
|
729
|
+
import * as Sentry from "@sentry/browser";
|
|
730
|
+
var initialized = false;
|
|
731
|
+
var telemetryEnabled = true;
|
|
732
|
+
function getEnvironment() {
|
|
733
|
+
if (typeof window !== "undefined") {
|
|
734
|
+
const hostname = window.location.hostname;
|
|
735
|
+
if (hostname === "localhost" || hostname === "127.0.0.1") {
|
|
736
|
+
return "development";
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
return "production";
|
|
740
|
+
}
|
|
741
|
+
function initSentry(enabled = true) {
|
|
742
|
+
telemetryEnabled = enabled;
|
|
743
|
+
if (initialized || !telemetryEnabled || false) return;
|
|
744
|
+
initialized = true;
|
|
745
|
+
Sentry.init({
|
|
746
|
+
dsn: "https://0bb16fd7057ac7b45ae0ab416cdbea8b@o4505953815494656.ingest.us.sentry.io/4509747448184832",
|
|
747
|
+
environment: getEnvironment(),
|
|
748
|
+
release: `@aurum-sdk/core@${"0.2.2-canary.0"}`,
|
|
749
|
+
sendDefaultPii: false,
|
|
750
|
+
enableLogs: true
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
function getUrl() {
|
|
754
|
+
if (typeof window !== "undefined") {
|
|
755
|
+
return window.location.href;
|
|
756
|
+
}
|
|
757
|
+
return void 0;
|
|
758
|
+
}
|
|
759
|
+
var sentryLogger = {
|
|
760
|
+
info: (message, attributes) => {
|
|
761
|
+
if (telemetryEnabled) Sentry.logger.info(message, { url: getUrl(), ...attributes });
|
|
762
|
+
},
|
|
763
|
+
warn: (message, attributes) => {
|
|
764
|
+
if (telemetryEnabled) Sentry.logger.warn(message, { url: getUrl(), ...attributes });
|
|
765
|
+
},
|
|
766
|
+
error: (message, attributes) => {
|
|
767
|
+
if (telemetryEnabled) Sentry.logger.error(message, { url: getUrl(), ...attributes });
|
|
768
|
+
}
|
|
769
|
+
};
|
|
770
|
+
|
|
771
|
+
// src/utils/isConfigError.ts
|
|
772
|
+
var isConfigError = (error) => {
|
|
773
|
+
const name = error?.name;
|
|
774
|
+
return name === "ConfigError";
|
|
775
|
+
};
|
|
776
|
+
var createConfigError = (adapterName) => {
|
|
777
|
+
const error = new Error(`Missing required project ID for ${adapterName}`);
|
|
778
|
+
error.name = "ConfigError";
|
|
779
|
+
return error;
|
|
780
|
+
};
|
|
781
|
+
|
|
782
|
+
// src/contexts/EmailAuthContext.tsx
|
|
1057
783
|
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
1058
784
|
var EmailAuthContext = createContext3(null);
|
|
1059
785
|
var useEmailAuth = () => {
|
|
@@ -1313,7 +1039,7 @@ var WalletButtonLabel = ({ type }) => {
|
|
|
1313
1039
|
};
|
|
1314
1040
|
|
|
1315
1041
|
// src/components/WalletButton/WalletButton.tsx
|
|
1316
|
-
import { WalletId as
|
|
1042
|
+
import { WalletId as WalletId2 } from "@aurum-sdk/types";
|
|
1317
1043
|
import { jsx as jsx23, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1318
1044
|
var WalletButton = ({
|
|
1319
1045
|
wallet,
|
|
@@ -1334,7 +1060,7 @@ var WalletButton = ({
|
|
|
1334
1060
|
/* @__PURE__ */ jsx23(WalletLogoWrapper, { id: wallet.id, size: iconSize, sizeSlot: "sm" }),
|
|
1335
1061
|
/* @__PURE__ */ jsx23(Text, { weight: "semibold", size: "md", children: wallet.name })
|
|
1336
1062
|
] }),
|
|
1337
|
-
wallet.id ===
|
|
1063
|
+
wallet.id === WalletId2.WalletConnect && !isLastUsed ? /* @__PURE__ */ jsx23(QrCode, { color: "var(--color-foreground)", size: 18 }) : /* @__PURE__ */ jsx23(WalletButtonLabel, { type: label })
|
|
1338
1064
|
] })
|
|
1339
1065
|
},
|
|
1340
1066
|
wallet.id
|
|
@@ -1435,12 +1161,12 @@ var WalletListStacked = ({ wallets, hasEmailAuth }) => {
|
|
|
1435
1161
|
};
|
|
1436
1162
|
|
|
1437
1163
|
// src/components/ConnectModal/SelectWallet.tsx
|
|
1438
|
-
import { WalletId as
|
|
1164
|
+
import { WalletId as WalletId3 } from "@aurum-sdk/types";
|
|
1439
1165
|
import { Fragment as Fragment3, jsx as jsx26, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1440
1166
|
var SelectWalletPage = () => {
|
|
1441
1167
|
const { displayedWallets } = useConnectModal();
|
|
1442
1168
|
const { onDismiss, brandConfig } = useWidgetContext();
|
|
1443
|
-
const hasEmailAuth = displayedWallets.some((wallet) => wallet.id ===
|
|
1169
|
+
const hasEmailAuth = displayedWallets.some((wallet) => wallet.id === WalletId3.Email);
|
|
1444
1170
|
const sortedWallets = useMemo3(() => sortWallets(displayedWallets), [displayedWallets]);
|
|
1445
1171
|
const isGridLayout = brandConfig.walletLayout === "grid";
|
|
1446
1172
|
return /* @__PURE__ */ jsxs11(Fragment3, { children: [
|
|
@@ -1569,13 +1295,17 @@ var ConnectionIconsRow = ({
|
|
|
1569
1295
|
|
|
1570
1296
|
// src/components/ConnectModal/ConnectionStatus/ConnectionStatusBase.tsx
|
|
1571
1297
|
import { Fragment as Fragment4, jsx as jsx30, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1298
|
+
var ERROR_CODE = {
|
|
1299
|
+
USER_REJECTED: 4001,
|
|
1300
|
+
REQUEST_PENDING: -32002
|
|
1301
|
+
};
|
|
1572
1302
|
var ConnectionStatusBase = ({
|
|
1573
1303
|
title,
|
|
1574
1304
|
pendingHeaderText,
|
|
1575
1305
|
pendingSubContent,
|
|
1576
1306
|
extraContent
|
|
1577
1307
|
}) => {
|
|
1578
|
-
const { selectedWallet, error, success, goBackToHome, retryConnection } = useConnectModal();
|
|
1308
|
+
const { selectedWallet, error, errorCode, success, goBackToHome, retryConnection } = useConnectModal();
|
|
1579
1309
|
const { onDismiss, brandConfig } = useWidgetContext();
|
|
1580
1310
|
const [shouldShake, setShouldShake] = useState8(false);
|
|
1581
1311
|
useEffect5(() => {
|
|
@@ -1592,12 +1322,15 @@ var ConnectionStatusBase = ({
|
|
|
1592
1322
|
}
|
|
1593
1323
|
const getHeaderVariant = () => {
|
|
1594
1324
|
if (success) return "success";
|
|
1595
|
-
if (error) return "error";
|
|
1325
|
+
if (error && errorCode !== ERROR_CODE.REQUEST_PENDING) return "error";
|
|
1596
1326
|
return "primary";
|
|
1597
1327
|
};
|
|
1598
1328
|
const getHeaderText = () => {
|
|
1599
1329
|
if (success) return "";
|
|
1600
|
-
if (error)
|
|
1330
|
+
if (error) {
|
|
1331
|
+
if (errorCode === ERROR_CODE.REQUEST_PENDING) return "Request Pending";
|
|
1332
|
+
return "Request Rejected";
|
|
1333
|
+
}
|
|
1601
1334
|
return pendingHeaderText;
|
|
1602
1335
|
};
|
|
1603
1336
|
const renderSubContent = () => {
|
|
@@ -1605,6 +1338,13 @@ var ConnectionStatusBase = ({
|
|
|
1605
1338
|
return /* @__PURE__ */ jsx30("div", { className: "success-icon-large", children: /* @__PURE__ */ jsx30(CircleCheck, { color: "var(--aurum-primary-color)", size: 46 }) });
|
|
1606
1339
|
}
|
|
1607
1340
|
if (error) {
|
|
1341
|
+
if (errorCode === ERROR_CODE.REQUEST_PENDING) {
|
|
1342
|
+
return /* @__PURE__ */ jsxs14(Text, { align: "center", size: "sm", variant: "secondary", children: [
|
|
1343
|
+
"Check your wallet for a ",
|
|
1344
|
+
"\n",
|
|
1345
|
+
"pending connection request"
|
|
1346
|
+
] });
|
|
1347
|
+
}
|
|
1608
1348
|
return /* @__PURE__ */ jsxs14(Text, { align: "center", size: "sm", variant: "secondary", children: [
|
|
1609
1349
|
"Please try again or select a ",
|
|
1610
1350
|
"\n",
|
|
@@ -1648,23 +1388,25 @@ var ConnectionStatusBase = ({
|
|
|
1648
1388
|
};
|
|
1649
1389
|
|
|
1650
1390
|
// src/components/ConnectModal/ConnectionStatus/Desktop.tsx
|
|
1651
|
-
import {
|
|
1652
|
-
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
1391
|
+
import { jsx as jsx31, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1653
1392
|
var ConnectionStatusPage = () => {
|
|
1654
1393
|
const { selectedWallet } = useConnectModal();
|
|
1655
1394
|
return /* @__PURE__ */ jsx31(
|
|
1656
1395
|
ConnectionStatusBase,
|
|
1657
1396
|
{
|
|
1658
1397
|
pendingHeaderText: `Approve in ${selectedWallet?.name}`,
|
|
1659
|
-
pendingSubContent: /* @__PURE__ */
|
|
1660
|
-
|
|
1398
|
+
pendingSubContent: /* @__PURE__ */ jsxs15(Text, { align: "center", size: "sm", variant: "secondary", children: [
|
|
1399
|
+
"Please check your wallet to",
|
|
1400
|
+
"\n",
|
|
1401
|
+
"approve the connection"
|
|
1402
|
+
] })
|
|
1661
1403
|
}
|
|
1662
1404
|
);
|
|
1663
1405
|
};
|
|
1664
1406
|
|
|
1665
1407
|
// src/components/ConnectModal/ConnectionStatus/Mobile.tsx
|
|
1666
1408
|
import { useState as useState9, useEffect as useEffect6 } from "react";
|
|
1667
|
-
import { jsx as jsx32, jsxs as
|
|
1409
|
+
import { jsx as jsx32, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
1668
1410
|
var ConnectionStatusMobilePage = () => {
|
|
1669
1411
|
const { selectedWallet, error, success, retryConnection } = useConnectModal();
|
|
1670
1412
|
const [showLaunchButton, setShowLaunchButton] = useState9(false);
|
|
@@ -1677,7 +1419,7 @@ var ConnectionStatusMobilePage = () => {
|
|
|
1677
1419
|
{
|
|
1678
1420
|
title: selectedWallet?.name,
|
|
1679
1421
|
pendingHeaderText: `Opening ${selectedWallet?.name}`,
|
|
1680
|
-
pendingSubContent: /* @__PURE__ */
|
|
1422
|
+
pendingSubContent: /* @__PURE__ */ jsxs16(Text, { size: "sm", variant: "secondary", align: "center", style: { maxWidth: "18.75rem" }, children: [
|
|
1681
1423
|
"If ",
|
|
1682
1424
|
selectedWallet?.name,
|
|
1683
1425
|
" doesn't open automatically, click the button below"
|
|
@@ -1688,28 +1430,27 @@ var ConnectionStatusMobilePage = () => {
|
|
|
1688
1430
|
};
|
|
1689
1431
|
|
|
1690
1432
|
// src/components/ConnectModal/QRCodePage.tsx
|
|
1691
|
-
import { useEffect as
|
|
1433
|
+
import { useEffect as useEffect7, useState as useState10 } from "react";
|
|
1692
1434
|
|
|
1693
1435
|
// src/components/QRCodeDisplay/QRCodeDisplay.tsx
|
|
1694
|
-
import { useRef as useRef4, useEffect as useEffect7 } from "react";
|
|
1695
1436
|
import { QRCode } from "react-qrcode-logo";
|
|
1696
1437
|
|
|
1697
1438
|
// src/utils/generateQrCodeWalletLogo.tsx
|
|
1698
|
-
import { getLogoDataUri
|
|
1699
|
-
import { WalletId as
|
|
1439
|
+
import { getLogoDataUri } from "@aurum-sdk/logos";
|
|
1440
|
+
import { WalletId as WalletId4 } from "@aurum-sdk/types";
|
|
1700
1441
|
var generateQrCodeWalletLogo = (walletAdapter) => {
|
|
1701
|
-
if (walletAdapter
|
|
1442
|
+
if (walletAdapter?.icon) {
|
|
1702
1443
|
return walletAdapter.icon;
|
|
1703
1444
|
}
|
|
1704
|
-
return
|
|
1445
|
+
return getLogoDataUri(WalletId4.WalletConnect) ?? "";
|
|
1705
1446
|
};
|
|
1706
1447
|
|
|
1707
1448
|
// src/components/QRCodeDisplay/QREye.tsx
|
|
1708
|
-
import { jsx as jsx33, jsxs as
|
|
1449
|
+
import { jsx as jsx33, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
1709
1450
|
var QREye = ({ x, y, eyeSize, eyeRadius, dotSize, fillColor, bgColor }) => {
|
|
1710
1451
|
const padding = dotSize * 0.8;
|
|
1711
1452
|
const centerRadius = (eyeSize - 4 * padding) / 2 * 1.1;
|
|
1712
|
-
return /* @__PURE__ */
|
|
1453
|
+
return /* @__PURE__ */ jsxs17("g", { children: [
|
|
1713
1454
|
/* @__PURE__ */ jsx33(
|
|
1714
1455
|
"rect",
|
|
1715
1456
|
{
|
|
@@ -1783,7 +1524,7 @@ var generateSkeletonDots = ({
|
|
|
1783
1524
|
};
|
|
1784
1525
|
|
|
1785
1526
|
// src/components/QRCodeDisplay/QRCodeSkeleton.tsx
|
|
1786
|
-
import { jsx as jsx35, jsxs as
|
|
1527
|
+
import { jsx as jsx35, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
1787
1528
|
var QRCodeSkeleton = ({ size = 128 }) => {
|
|
1788
1529
|
const { brandConfig } = useWidgetContext();
|
|
1789
1530
|
const { selectedWallet } = useConnectModal();
|
|
@@ -1794,7 +1535,7 @@ var QRCodeSkeleton = ({ size = 128 }) => {
|
|
|
1794
1535
|
const dotSize = size / 40;
|
|
1795
1536
|
const eyeSize = 32;
|
|
1796
1537
|
const gridSize = 40;
|
|
1797
|
-
return /* @__PURE__ */ jsx35("div", { className: "qr-skeleton-container", style: { height: size }, children: /* @__PURE__ */
|
|
1538
|
+
return /* @__PURE__ */ jsx35("div", { className: "qr-skeleton-container", style: { height: size }, children: /* @__PURE__ */ jsxs18("svg", { width: size, height: size, className: "qr-skeleton-svg", children: [
|
|
1798
1539
|
/* @__PURE__ */ jsx35("rect", { width: size, height: size, fill: bgColor }),
|
|
1799
1540
|
generateSkeletonDots({ logoSize, dotSize, eyeSize, gridSize, fillColor }),
|
|
1800
1541
|
/* @__PURE__ */ jsx35(
|
|
@@ -1860,26 +1601,15 @@ var QRCodeSkeleton = ({ size = 128 }) => {
|
|
|
1860
1601
|
};
|
|
1861
1602
|
|
|
1862
1603
|
// src/components/QRCodeDisplay/QRCodeDisplay.tsx
|
|
1863
|
-
import {
|
|
1604
|
+
import { WalletId as WalletId5 } from "@aurum-sdk/types";
|
|
1605
|
+
import { jsx as jsx36, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
1864
1606
|
var QRCodeDisplay = ({ uri, size = 256 }) => {
|
|
1865
1607
|
const { brandConfig } = useWidgetContext();
|
|
1866
|
-
const { selectedWallet, displayedWallets,
|
|
1608
|
+
const { selectedWallet, displayedWallets, openWalletConnectModal } = useConnectModal();
|
|
1867
1609
|
const qrCodeDisplayColor = brandConfig.theme === "light" ? "#000000" : "#6b7280";
|
|
1868
1610
|
const bgColor = brandConfig.theme === "light" ? "#ffffff" : "#121212";
|
|
1869
|
-
const
|
|
1870
|
-
|
|
1871
|
-
if (selectedWallet && !(selectedWallet instanceof AppKitAdapter)) {
|
|
1872
|
-
logoWalletRef.current = selectedWallet;
|
|
1873
|
-
}
|
|
1874
|
-
}, [selectedWallet]);
|
|
1875
|
-
const logoWallet = logoWalletRef.current || selectedWallet;
|
|
1876
|
-
const appKitAdapter = displayedWallets.find((w) => w instanceof AppKitAdapter);
|
|
1877
|
-
const handleAppKitConnect = async () => {
|
|
1878
|
-
if (appKitAdapter) {
|
|
1879
|
-
connectWallet(appKitAdapter);
|
|
1880
|
-
}
|
|
1881
|
-
};
|
|
1882
|
-
return /* @__PURE__ */ jsx36(Column, { align: "center", gap: 16, children: /* @__PURE__ */ jsxs18(Column, { align: "center", gap: 4, children: [
|
|
1611
|
+
const wcAdapter = displayedWallets.find(({ id }) => id === WalletId5.WalletConnect);
|
|
1612
|
+
return /* @__PURE__ */ jsx36(Column, { align: "center", gap: 16, children: /* @__PURE__ */ jsxs19(Column, { align: "center", gap: 4, children: [
|
|
1883
1613
|
/* @__PURE__ */ jsx36(
|
|
1884
1614
|
"div",
|
|
1885
1615
|
{
|
|
@@ -1896,7 +1626,7 @@ var QRCodeDisplay = ({ uri, size = 256 }) => {
|
|
|
1896
1626
|
quietZone: 0,
|
|
1897
1627
|
bgColor,
|
|
1898
1628
|
fgColor: qrCodeDisplayColor,
|
|
1899
|
-
logoImage: generateQrCodeWalletLogo(
|
|
1629
|
+
logoImage: generateQrCodeWalletLogo(selectedWallet || void 0),
|
|
1900
1630
|
logoWidth: size * 0.2,
|
|
1901
1631
|
logoHeight: size * 0.2,
|
|
1902
1632
|
removeQrCodeBehindLogo: true,
|
|
@@ -1907,14 +1637,14 @@ var QRCodeDisplay = ({ uri, size = 256 }) => {
|
|
|
1907
1637
|
)
|
|
1908
1638
|
}
|
|
1909
1639
|
),
|
|
1910
|
-
/* @__PURE__ */
|
|
1640
|
+
/* @__PURE__ */ jsxs19(Row, { justify: wcAdapter?.openModal ? "space-between" : "center", style: { width: "100%" }, children: [
|
|
1911
1641
|
/* @__PURE__ */ jsx36(CopyButton, { text: uri || "", disabled: !uri, variant: "secondary", label: "Copy URI" }),
|
|
1912
|
-
|
|
1642
|
+
wcAdapter?.openModal && /* @__PURE__ */ jsx36(
|
|
1913
1643
|
Button,
|
|
1914
1644
|
{
|
|
1915
1645
|
variant: "text",
|
|
1916
1646
|
size: "sm",
|
|
1917
|
-
onClick:
|
|
1647
|
+
onClick: openWalletConnectModal,
|
|
1918
1648
|
style: { color: "var(--color-foreground-muted)", fontWeight: "500" },
|
|
1919
1649
|
children: "Open Modal"
|
|
1920
1650
|
}
|
|
@@ -1925,25 +1655,18 @@ var QRCodeDisplay = ({ uri, size = 256 }) => {
|
|
|
1925
1655
|
|
|
1926
1656
|
// src/components/ConnectModal/QRCodePage.tsx
|
|
1927
1657
|
import { ChevronLeft as ChevronLeft2, X as X4, SquareArrowOutUpRight, CircleCheck as CircleCheck2 } from "lucide-react";
|
|
1928
|
-
import { WalletName
|
|
1929
|
-
import { Fragment as Fragment5, jsx as jsx37, jsxs as
|
|
1658
|
+
import { WalletName } from "@aurum-sdk/types";
|
|
1659
|
+
import { Fragment as Fragment5, jsx as jsx37, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
1930
1660
|
var QRCodePage = () => {
|
|
1931
1661
|
const { onDismiss } = useWidgetContext();
|
|
1932
1662
|
const { navigateTo } = useNavigation();
|
|
1933
1663
|
const { selectedWallet, error, configError, retryConnection, qrSuccess } = useConnectModal();
|
|
1934
1664
|
const [connectionUri, setConnectionUri] = useState10(null);
|
|
1935
|
-
const originalWalletRef = useRef5(null);
|
|
1936
|
-
useEffect8(() => {
|
|
1937
|
-
if (selectedWallet && !(selectedWallet instanceof AppKitAdapter)) {
|
|
1938
|
-
originalWalletRef.current = selectedWallet;
|
|
1939
|
-
}
|
|
1940
|
-
}, [selectedWallet]);
|
|
1941
|
-
const displayWallet = originalWalletRef.current || selectedWallet;
|
|
1942
1665
|
const goBackToHome = () => {
|
|
1943
1666
|
navigateTo(PAGE_IDS.SELECT_WALLET);
|
|
1944
1667
|
};
|
|
1945
|
-
const title =
|
|
1946
|
-
|
|
1668
|
+
const title = selectedWallet?.name === WalletName.WalletConnect ? "Scan QR code" : `Scan with ${selectedWallet?.name} app`;
|
|
1669
|
+
useEffect7(() => {
|
|
1947
1670
|
const handleWalletConnectURI = (event) => {
|
|
1948
1671
|
setConnectionUri(event.detail.uri);
|
|
1949
1672
|
};
|
|
@@ -1952,7 +1675,7 @@ var QRCodePage = () => {
|
|
|
1952
1675
|
window.removeEventListener("walletconnect:uri", handleWalletConnectURI);
|
|
1953
1676
|
};
|
|
1954
1677
|
}, []);
|
|
1955
|
-
|
|
1678
|
+
useEffect7(() => {
|
|
1956
1679
|
if (error && !configError) {
|
|
1957
1680
|
setConnectionUri(null);
|
|
1958
1681
|
retryConnection();
|
|
@@ -1961,7 +1684,7 @@ var QRCodePage = () => {
|
|
|
1961
1684
|
if (!selectedWallet) {
|
|
1962
1685
|
return null;
|
|
1963
1686
|
}
|
|
1964
|
-
return /* @__PURE__ */
|
|
1687
|
+
return /* @__PURE__ */ jsxs20(Fragment5, { children: [
|
|
1965
1688
|
/* @__PURE__ */ jsx37(
|
|
1966
1689
|
ModalHeader,
|
|
1967
1690
|
{
|
|
@@ -1970,21 +1693,21 @@ var QRCodePage = () => {
|
|
|
1970
1693
|
rightAction: qrSuccess ? null : /* @__PURE__ */ jsx37(Button, { size: "sm", variant: "close", onClick: onDismiss, "aria-label": "Close", children: /* @__PURE__ */ jsx37(X4, { size: 20, color: "var(--color-foreground-muted)" }) })
|
|
1971
1694
|
}
|
|
1972
1695
|
),
|
|
1973
|
-
qrSuccess ? /* @__PURE__ */ jsx37(Column, { align: "center", style: { height: "8rem" }, children: /* @__PURE__ */ jsx37(CircleCheck2, { color: "var(--aurum-primary-color)", size: 46 }) }) : /* @__PURE__ */
|
|
1696
|
+
qrSuccess ? /* @__PURE__ */ jsx37(Column, { align: "center", style: { height: "8rem" }, children: /* @__PURE__ */ jsx37(CircleCheck2, { color: "var(--aurum-primary-color)", size: 46 }) }) : /* @__PURE__ */ jsxs20(Fragment5, { children: [
|
|
1974
1697
|
/* @__PURE__ */ jsx37(Column, { align: "center", gap: 24, children: /* @__PURE__ */ jsx37(QRCodeDisplay, { uri: error ? null : connectionUri }) }),
|
|
1975
|
-
|
|
1698
|
+
selectedWallet?.downloadUrl && /* @__PURE__ */ jsxs20(Fragment5, { children: [
|
|
1976
1699
|
/* @__PURE__ */ jsx37(Spacer, { size: 15 }),
|
|
1977
|
-
/* @__PURE__ */
|
|
1700
|
+
/* @__PURE__ */ jsxs20(
|
|
1978
1701
|
Button,
|
|
1979
1702
|
{
|
|
1980
1703
|
variant: "tertiary",
|
|
1981
1704
|
expand: true,
|
|
1982
|
-
onClick: () => window.open(
|
|
1705
|
+
onClick: () => window.open(selectedWallet.downloadUrl ?? "", "_blank", "noopener,noreferrer"),
|
|
1983
1706
|
children: [
|
|
1984
1707
|
/* @__PURE__ */ jsx37(SquareArrowOutUpRight, { size: 16, color: "var(--color-foreground-muted)" }),
|
|
1985
|
-
/* @__PURE__ */
|
|
1708
|
+
/* @__PURE__ */ jsxs20(Text, { size: "sm", weight: "semibold", variant: "secondary", children: [
|
|
1986
1709
|
"Download ",
|
|
1987
|
-
|
|
1710
|
+
selectedWallet.name
|
|
1988
1711
|
] })
|
|
1989
1712
|
]
|
|
1990
1713
|
}
|
|
@@ -1997,7 +1720,7 @@ var QRCodePage = () => {
|
|
|
1997
1720
|
// src/components/ConnectModal/AllWallets.tsx
|
|
1998
1721
|
import { useMemo as useMemo4 } from "react";
|
|
1999
1722
|
import { X as X5, ChevronLeft as ChevronLeft3 } from "lucide-react";
|
|
2000
|
-
import { Fragment as Fragment6, jsx as jsx38, jsxs as
|
|
1723
|
+
import { Fragment as Fragment6, jsx as jsx38, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
2001
1724
|
var AllWalletsPage = () => {
|
|
2002
1725
|
const { onDismiss } = useWidgetContext();
|
|
2003
1726
|
const { navigateTo } = useNavigation();
|
|
@@ -2007,7 +1730,7 @@ var AllWalletsPage = () => {
|
|
|
2007
1730
|
const goBackToSelectWallet = () => {
|
|
2008
1731
|
navigateTo(PAGE_IDS.SELECT_WALLET);
|
|
2009
1732
|
};
|
|
2010
|
-
return /* @__PURE__ */
|
|
1733
|
+
return /* @__PURE__ */ jsxs21(Fragment6, { children: [
|
|
2011
1734
|
/* @__PURE__ */ jsx38(
|
|
2012
1735
|
ModalHeader,
|
|
2013
1736
|
{
|
|
@@ -2032,7 +1755,7 @@ var AllWalletsPage = () => {
|
|
|
2032
1755
|
|
|
2033
1756
|
// src/components/ConnectModal/DownloadWalletPage.tsx
|
|
2034
1757
|
import { X as X6, SquareArrowOutUpRight as SquareArrowOutUpRight2, ChevronLeft as ChevronLeft4 } from "lucide-react";
|
|
2035
|
-
import { Fragment as Fragment7, jsx as jsx39, jsxs as
|
|
1758
|
+
import { Fragment as Fragment7, jsx as jsx39, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
2036
1759
|
var DownloadWalletPage = () => {
|
|
2037
1760
|
const { selectedWallet, goBackToHome } = useConnectModal();
|
|
2038
1761
|
const { onDismiss } = useWidgetContext();
|
|
@@ -2045,7 +1768,7 @@ var DownloadWalletPage = () => {
|
|
|
2045
1768
|
window.open(downloadUrl, "_blank", "noopener,noreferrer");
|
|
2046
1769
|
}
|
|
2047
1770
|
};
|
|
2048
|
-
return /* @__PURE__ */
|
|
1771
|
+
return /* @__PURE__ */ jsxs22(Fragment7, { children: [
|
|
2049
1772
|
/* @__PURE__ */ jsx39(
|
|
2050
1773
|
ModalHeader,
|
|
2051
1774
|
{
|
|
@@ -2054,21 +1777,21 @@ var DownloadWalletPage = () => {
|
|
|
2054
1777
|
title: `Install ${selectedWallet.name}`
|
|
2055
1778
|
}
|
|
2056
1779
|
),
|
|
2057
|
-
/* @__PURE__ */
|
|
1780
|
+
/* @__PURE__ */ jsxs22(Column, { align: "center", gap: 24, justify: "center", children: [
|
|
2058
1781
|
/* @__PURE__ */ jsx39(WalletLogoWrapper, { id: selectedWallet.id, size: 64, sizeSlot: "lg", title: selectedWallet.name }),
|
|
2059
|
-
/* @__PURE__ */
|
|
2060
|
-
/* @__PURE__ */
|
|
1782
|
+
/* @__PURE__ */ jsxs22(Column, { align: "center", gap: 12, children: [
|
|
1783
|
+
/* @__PURE__ */ jsxs22(Text, { size: "lg", weight: "semibold", align: "center", children: [
|
|
2061
1784
|
"Install ",
|
|
2062
1785
|
selectedWallet.name
|
|
2063
1786
|
] }),
|
|
2064
|
-
/* @__PURE__ */
|
|
1787
|
+
/* @__PURE__ */ jsxs22(Text, { size: "md", variant: "secondary", align: "center", style: { maxWidth: "20rem" }, children: [
|
|
2065
1788
|
selectedWallet.name,
|
|
2066
1789
|
" not installed. Please download then try again."
|
|
2067
1790
|
] })
|
|
2068
1791
|
] }),
|
|
2069
|
-
downloadUrl && /* @__PURE__ */ jsx39(Fragment7, { children: /* @__PURE__ */
|
|
1792
|
+
downloadUrl && /* @__PURE__ */ jsx39(Fragment7, { children: /* @__PURE__ */ jsxs22(Button, { variant: "tertiary", onClick: handleDownload, expand: true, children: [
|
|
2070
1793
|
/* @__PURE__ */ jsx39(SquareArrowOutUpRight2, { size: 16, color: "var(--color-foreground-muted)" }),
|
|
2071
|
-
/* @__PURE__ */
|
|
1794
|
+
/* @__PURE__ */ jsxs22(Text, { size: "sm", weight: "semibold", variant: "secondary", children: [
|
|
2072
1795
|
"Download ",
|
|
2073
1796
|
selectedWallet.name
|
|
2074
1797
|
] })
|
|
@@ -2105,7 +1828,7 @@ var emailHighlightStyles = {
|
|
|
2105
1828
|
};
|
|
2106
1829
|
|
|
2107
1830
|
// src/components/ConnectModal/EmailVerifyOtp/useCountdown.ts
|
|
2108
|
-
import { useState as useState11, useEffect as
|
|
1831
|
+
import { useState as useState11, useEffect as useEffect8 } from "react";
|
|
2109
1832
|
var useCountdown = () => {
|
|
2110
1833
|
const [countdown, setCountdown] = useState11(0);
|
|
2111
1834
|
const [canResend, setCanResend] = useState11(true);
|
|
@@ -2113,7 +1836,7 @@ var useCountdown = () => {
|
|
|
2113
1836
|
setCanResend(false);
|
|
2114
1837
|
setCountdown(seconds);
|
|
2115
1838
|
};
|
|
2116
|
-
|
|
1839
|
+
useEffect8(() => {
|
|
2117
1840
|
if (countdown <= 0) return;
|
|
2118
1841
|
const timer = setTimeout(() => {
|
|
2119
1842
|
const newCountdown = countdown - 1;
|
|
@@ -2128,7 +1851,7 @@ var useCountdown = () => {
|
|
|
2128
1851
|
};
|
|
2129
1852
|
|
|
2130
1853
|
// src/components/ConnectModal/EmailVerifyOtp/useOtpInputs.ts
|
|
2131
|
-
import { useState as useState12, useRef as
|
|
1854
|
+
import { useState as useState12, useRef as useRef4, useEffect as useEffect9 } from "react";
|
|
2132
1855
|
var useOtpInputs = ({
|
|
2133
1856
|
emailAuthState,
|
|
2134
1857
|
error,
|
|
@@ -2138,7 +1861,7 @@ var useOtpInputs = ({
|
|
|
2138
1861
|
}) => {
|
|
2139
1862
|
const [otp, setOtp] = useState12(Array(OTP_LENGTH).fill(""));
|
|
2140
1863
|
const [focusedIndex, setFocusedIndex] = useState12(0);
|
|
2141
|
-
const inputRefs =
|
|
1864
|
+
const inputRefs = useRef4([]);
|
|
2142
1865
|
const isOtpComplete = otp.every((digit) => digit !== "");
|
|
2143
1866
|
const handleInputChange = (index, value) => {
|
|
2144
1867
|
if (error) clearError();
|
|
@@ -2167,25 +1890,25 @@ var useOtpInputs = ({
|
|
|
2167
1890
|
inputRefs.current[nextEmptyIndex]?.focus();
|
|
2168
1891
|
}
|
|
2169
1892
|
};
|
|
2170
|
-
|
|
1893
|
+
useEffect9(() => {
|
|
2171
1894
|
if (isOtpComplete && otp.join("").length === OTP_LENGTH) {
|
|
2172
1895
|
onComplete(otp.join(""));
|
|
2173
1896
|
}
|
|
2174
1897
|
}, [otp]);
|
|
2175
|
-
|
|
1898
|
+
useEffect9(() => {
|
|
2176
1899
|
inputRefs.current[0]?.focus();
|
|
2177
1900
|
const timer = setTimeout(() => {
|
|
2178
1901
|
inputRefs.current[0]?.focus();
|
|
2179
1902
|
}, 100);
|
|
2180
1903
|
return () => clearTimeout(timer);
|
|
2181
1904
|
}, []);
|
|
2182
|
-
|
|
1905
|
+
useEffect9(() => {
|
|
2183
1906
|
if (error) {
|
|
2184
1907
|
setOtp(Array(OTP_LENGTH).fill(""));
|
|
2185
1908
|
inputRefs.current[0]?.focus();
|
|
2186
1909
|
}
|
|
2187
1910
|
}, [error]);
|
|
2188
|
-
|
|
1911
|
+
useEffect9(() => {
|
|
2189
1912
|
if (isVerifying) {
|
|
2190
1913
|
setFocusedIndex(0);
|
|
2191
1914
|
}
|
|
@@ -2203,7 +1926,7 @@ var useOtpInputs = ({
|
|
|
2203
1926
|
};
|
|
2204
1927
|
|
|
2205
1928
|
// src/components/ConnectModal/EmailVerifyOtp/EmailVerifyOtp.tsx
|
|
2206
|
-
import { jsx as jsx40, jsxs as
|
|
1929
|
+
import { jsx as jsx40, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
2207
1930
|
var EmailVerifyOTP = () => {
|
|
2208
1931
|
const { onDismiss } = useWidgetContext();
|
|
2209
1932
|
const { goBackToHome } = useConnectModal();
|
|
@@ -2233,7 +1956,7 @@ var EmailVerifyOTP = () => {
|
|
|
2233
1956
|
setOtp(Array(OTP_LENGTH).fill(""));
|
|
2234
1957
|
inputRefs.current[0]?.focus();
|
|
2235
1958
|
};
|
|
2236
|
-
return /* @__PURE__ */
|
|
1959
|
+
return /* @__PURE__ */ jsxs23("div", { children: [
|
|
2237
1960
|
/* @__PURE__ */ jsx40(
|
|
2238
1961
|
ModalHeader,
|
|
2239
1962
|
{
|
|
@@ -2242,15 +1965,15 @@ var EmailVerifyOTP = () => {
|
|
|
2242
1965
|
title: "Verify Email"
|
|
2243
1966
|
}
|
|
2244
1967
|
),
|
|
2245
|
-
/* @__PURE__ */
|
|
2246
|
-
/* @__PURE__ */
|
|
1968
|
+
/* @__PURE__ */ jsxs23(Column, { gap: 24, children: [
|
|
1969
|
+
/* @__PURE__ */ jsxs23(Text, { align: "center", variant: "secondary", children: [
|
|
2247
1970
|
"Enter the 6-digit code sent to",
|
|
2248
1971
|
/* @__PURE__ */ jsx40("br", {}),
|
|
2249
1972
|
" ",
|
|
2250
1973
|
/* @__PURE__ */ jsx40("span", { style: emailHighlightStyles, children: emailAuthState.email })
|
|
2251
1974
|
] }),
|
|
2252
|
-
/* @__PURE__ */
|
|
2253
|
-
/* @__PURE__ */
|
|
1975
|
+
/* @__PURE__ */ jsxs23(Column, { align: "center", gap: 12, children: [
|
|
1976
|
+
/* @__PURE__ */ jsxs23("div", { style: { position: "relative", height: "3rem" }, children: [
|
|
2254
1977
|
/* @__PURE__ */ jsx40(
|
|
2255
1978
|
Row,
|
|
2256
1979
|
{
|
|
@@ -2296,7 +2019,7 @@ var EmailVerifyOTP = () => {
|
|
|
2296
2019
|
}
|
|
2297
2020
|
)
|
|
2298
2021
|
] }),
|
|
2299
|
-
!isSuccess && /* @__PURE__ */ jsx40(Column, { align: "center", justify: "center", children: /* @__PURE__ */ jsx40(Row, { align: "center", justify: "center", style: { minHeight: "2rem" }, children: canResend ? /* @__PURE__ */
|
|
2022
|
+
!isSuccess && /* @__PURE__ */ jsx40(Column, { align: "center", justify: "center", children: /* @__PURE__ */ jsx40(Row, { align: "center", justify: "center", style: { minHeight: "2rem" }, children: canResend ? /* @__PURE__ */ jsxs23(Row, { align: "baseline", gap: 2, children: [
|
|
2300
2023
|
/* @__PURE__ */ jsx40(Text, { size: "sm", variant: "secondary", children: "Didn't receive the code?" }),
|
|
2301
2024
|
/* @__PURE__ */ jsx40(
|
|
2302
2025
|
Button,
|
|
@@ -2309,7 +2032,7 @@ var EmailVerifyOTP = () => {
|
|
|
2309
2032
|
children: "Resend"
|
|
2310
2033
|
}
|
|
2311
2034
|
)
|
|
2312
|
-
] }) : /* @__PURE__ */
|
|
2035
|
+
] }) : /* @__PURE__ */ jsxs23(Row, { align: "center", gap: 4, children: [
|
|
2313
2036
|
/* @__PURE__ */ jsx40(Text, { size: "sm", variant: "secondary", children: "Email re-sent" }),
|
|
2314
2037
|
/* @__PURE__ */ jsx40(Check, { size: 14, color: "var(--color-foreground-muted)" })
|
|
2315
2038
|
] }) }) })
|
|
@@ -2319,11 +2042,11 @@ var EmailVerifyOTP = () => {
|
|
|
2319
2042
|
|
|
2320
2043
|
// src/components/ConnectModal/ConfigErrorPage.tsx
|
|
2321
2044
|
import { X as X8, AlertTriangle, ChevronLeft as ChevronLeft6 } from "lucide-react";
|
|
2322
|
-
import { Fragment as Fragment8, jsx as jsx41, jsxs as
|
|
2045
|
+
import { Fragment as Fragment8, jsx as jsx41, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
2323
2046
|
var ConfigErrorPage = () => {
|
|
2324
2047
|
const { onDismiss } = useWidgetContext();
|
|
2325
2048
|
const { goBackToHome } = useConnectModal();
|
|
2326
|
-
return /* @__PURE__ */
|
|
2049
|
+
return /* @__PURE__ */ jsxs24(Fragment8, { children: [
|
|
2327
2050
|
/* @__PURE__ */ jsx41(
|
|
2328
2051
|
ModalHeader,
|
|
2329
2052
|
{
|
|
@@ -2332,7 +2055,7 @@ var ConfigErrorPage = () => {
|
|
|
2332
2055
|
title: "Error"
|
|
2333
2056
|
}
|
|
2334
2057
|
),
|
|
2335
|
-
/* @__PURE__ */
|
|
2058
|
+
/* @__PURE__ */ jsxs24(Column, { align: "center", gap: 24, justify: "center", children: [
|
|
2336
2059
|
/* @__PURE__ */ jsx41(
|
|
2337
2060
|
"div",
|
|
2338
2061
|
{
|
|
@@ -2348,7 +2071,7 @@ var ConfigErrorPage = () => {
|
|
|
2348
2071
|
children: /* @__PURE__ */ jsx41(AlertTriangle, { size: 32, color: "white" })
|
|
2349
2072
|
}
|
|
2350
2073
|
),
|
|
2351
|
-
/* @__PURE__ */
|
|
2074
|
+
/* @__PURE__ */ jsxs24(Column, { align: "center", gap: 12, children: [
|
|
2352
2075
|
/* @__PURE__ */ jsx41(Text, { size: "lg", weight: "semibold", align: "center", children: "Configuration Error" }),
|
|
2353
2076
|
/* @__PURE__ */ jsx41(Text, { size: "md", variant: "secondary", align: "center", style: { maxWidth: "20rem" }, children: "Missing required project ID" })
|
|
2354
2077
|
] }),
|
|
@@ -2380,6 +2103,16 @@ var PAGE_COMPONENTS = {
|
|
|
2380
2103
|
[PAGE_IDS.CONFIG_ERROR]: /* @__PURE__ */ jsx42(ConfigErrorPage, {})
|
|
2381
2104
|
};
|
|
2382
2105
|
|
|
2106
|
+
// src/utils/platform/isMobile.ts
|
|
2107
|
+
import MobileDetect from "mobile-detect";
|
|
2108
|
+
function isMobile() {
|
|
2109
|
+
if (typeof window === "undefined" || typeof navigator === "undefined") {
|
|
2110
|
+
return false;
|
|
2111
|
+
}
|
|
2112
|
+
const md = new MobileDetect(window.navigator.userAgent);
|
|
2113
|
+
return md.mobile() !== null || md.tablet() !== null;
|
|
2114
|
+
}
|
|
2115
|
+
|
|
2383
2116
|
// src/utils/walletConnectDeepLink.ts
|
|
2384
2117
|
var clearExistingDeepLinkListeners = () => {
|
|
2385
2118
|
const existingListeners = window.__aurumDeepLinkListeners ?? [];
|
|
@@ -2422,198 +2155,8 @@ var registerGlobalCleanup = (cleanupFn) => {
|
|
|
2422
2155
|
return cleanup;
|
|
2423
2156
|
};
|
|
2424
2157
|
|
|
2425
|
-
// src/wallet-adapters/WalletConnectAdapter.ts
|
|
2426
|
-
import { getLogoDataUri as getLogoDataUri3 } from "@aurum-sdk/logos";
|
|
2427
|
-
import { WalletId as WalletId7, WalletName as WalletName3 } from "@aurum-sdk/types";
|
|
2428
|
-
var WalletConnectAdapter = class {
|
|
2429
|
-
constructor(config) {
|
|
2430
|
-
this.id = WalletId7.WalletConnect;
|
|
2431
|
-
this.name = WalletName3.WalletConnect;
|
|
2432
|
-
this.icon = getLogoDataUri3(WalletId7.WalletConnect, "brand") ?? "";
|
|
2433
|
-
this.hide = false;
|
|
2434
|
-
this.downloadUrl = null;
|
|
2435
|
-
this.wcDeepLinkUrl = null;
|
|
2436
|
-
this.provider = null;
|
|
2437
|
-
this.connectionUri = null;
|
|
2438
|
-
this.accountsChangedCallback = null;
|
|
2439
|
-
this.initPromise = null;
|
|
2440
|
-
this.config = {
|
|
2441
|
-
projectId: config.projectId,
|
|
2442
|
-
appName: config.appName
|
|
2443
|
-
};
|
|
2444
|
-
}
|
|
2445
|
-
async ensureInitialized() {
|
|
2446
|
-
if (this.provider) return;
|
|
2447
|
-
if (!this.initPromise) {
|
|
2448
|
-
this.initPromise = this.initializeProvider();
|
|
2449
|
-
}
|
|
2450
|
-
await this.initPromise;
|
|
2451
|
-
}
|
|
2452
|
-
async initializeProvider() {
|
|
2453
|
-
if (typeof window === "undefined") return;
|
|
2454
|
-
const { EthereumProvider } = await import("@walletconnect/ethereum-provider");
|
|
2455
|
-
this.provider = await EthereumProvider.init({
|
|
2456
|
-
projectId: this.config.projectId ?? "",
|
|
2457
|
-
optionalChains: [1],
|
|
2458
|
-
showQrModal: false,
|
|
2459
|
-
metadata: {
|
|
2460
|
-
name: this.config.appName,
|
|
2461
|
-
description: this.config.appName,
|
|
2462
|
-
url: window.location.origin,
|
|
2463
|
-
icons: []
|
|
2464
|
-
}
|
|
2465
|
-
});
|
|
2466
|
-
this.provider.on("display_uri", (uri) => {
|
|
2467
|
-
this.connectionUri = uri;
|
|
2468
|
-
if (typeof window !== "undefined") {
|
|
2469
|
-
window.dispatchEvent(new CustomEvent("walletconnect:uri", { detail: { uri } }));
|
|
2470
|
-
}
|
|
2471
|
-
});
|
|
2472
|
-
this.provider.on("connect", (session) => {
|
|
2473
|
-
if (typeof window !== "undefined") {
|
|
2474
|
-
window.dispatchEvent(new CustomEvent("walletconnect:connect", { detail: { session } }));
|
|
2475
|
-
}
|
|
2476
|
-
});
|
|
2477
|
-
this.provider.on("disconnect", () => {
|
|
2478
|
-
this.connectionUri = null;
|
|
2479
|
-
});
|
|
2480
|
-
this.provider.on("session_delete", () => {
|
|
2481
|
-
if (typeof window !== "undefined") {
|
|
2482
|
-
window.dispatchEvent(new CustomEvent("walletconnect:disconnect"));
|
|
2483
|
-
}
|
|
2484
|
-
});
|
|
2485
|
-
}
|
|
2486
|
-
isInstalled() {
|
|
2487
|
-
return true;
|
|
2488
|
-
}
|
|
2489
|
-
async connect() {
|
|
2490
|
-
if (!this.config.projectId) {
|
|
2491
|
-
throw createConfigError("WalletConnect");
|
|
2492
|
-
}
|
|
2493
|
-
try {
|
|
2494
|
-
await this.ensureInitialized();
|
|
2495
|
-
if (!this.provider) {
|
|
2496
|
-
sentryLogger.error("connect: WalletConnect is not available");
|
|
2497
|
-
throw new Error("WalletConnect is not available");
|
|
2498
|
-
}
|
|
2499
|
-
const accounts = await this.provider.enable();
|
|
2500
|
-
if (!accounts || accounts.length === 0 || !accounts[0]) {
|
|
2501
|
-
sentryLogger.error("connect: No accounts returned from WalletConnect");
|
|
2502
|
-
throw new Error("No accounts returned from WalletConnect");
|
|
2503
|
-
}
|
|
2504
|
-
return {
|
|
2505
|
-
address: accounts[0],
|
|
2506
|
-
provider: this.provider,
|
|
2507
|
-
walletId: this.id
|
|
2508
|
-
};
|
|
2509
|
-
} catch {
|
|
2510
|
-
this.connectionUri = null;
|
|
2511
|
-
throw new Error("Failed to connect to WalletConnect");
|
|
2512
|
-
}
|
|
2513
|
-
}
|
|
2514
|
-
getConnectionUri() {
|
|
2515
|
-
return this.connectionUri;
|
|
2516
|
-
}
|
|
2517
|
-
/**
|
|
2518
|
-
* Starts a WalletConnect session for headless/custom QR code flows.
|
|
2519
|
-
* Returns the URI immediately and a function to wait for the connection.
|
|
2520
|
-
*/
|
|
2521
|
-
async startSession(timeout = 1e4) {
|
|
2522
|
-
if (!this.config.projectId) {
|
|
2523
|
-
throw new Error("WalletConnect projectId is required");
|
|
2524
|
-
}
|
|
2525
|
-
await this.ensureInitialized();
|
|
2526
|
-
if (!this.provider) {
|
|
2527
|
-
sentryLogger.error("startSession: WalletConnect is not available");
|
|
2528
|
-
throw new Error("WalletConnect is not available");
|
|
2529
|
-
}
|
|
2530
|
-
this.connectionUri = null;
|
|
2531
|
-
const uriPromise = new Promise((resolve, reject) => {
|
|
2532
|
-
const timeoutId = setTimeout(() => {
|
|
2533
|
-
reject(new Error("Timeout waiting for WalletConnect URI"));
|
|
2534
|
-
}, timeout);
|
|
2535
|
-
this.provider.once("display_uri", (uri2) => {
|
|
2536
|
-
clearTimeout(timeoutId);
|
|
2537
|
-
this.connectionUri = uri2;
|
|
2538
|
-
resolve(uri2);
|
|
2539
|
-
});
|
|
2540
|
-
});
|
|
2541
|
-
const connectionPromise = (async () => {
|
|
2542
|
-
const accounts = await this.provider.enable();
|
|
2543
|
-
if (!accounts || accounts.length === 0 || !accounts[0]) {
|
|
2544
|
-
sentryLogger.error("startSession: No accounts returned from WalletConnect");
|
|
2545
|
-
throw new Error("No accounts returned from WalletConnect");
|
|
2546
|
-
}
|
|
2547
|
-
return {
|
|
2548
|
-
address: accounts[0],
|
|
2549
|
-
provider: this.provider,
|
|
2550
|
-
walletId: this.id
|
|
2551
|
-
};
|
|
2552
|
-
})();
|
|
2553
|
-
const uri = await uriPromise;
|
|
2554
|
-
return {
|
|
2555
|
-
uri,
|
|
2556
|
-
waitForConnection: async () => {
|
|
2557
|
-
try {
|
|
2558
|
-
return await connectionPromise;
|
|
2559
|
-
} catch {
|
|
2560
|
-
this.connectionUri = null;
|
|
2561
|
-
throw new Error("Failed to connect via WalletConnect");
|
|
2562
|
-
}
|
|
2563
|
-
}
|
|
2564
|
-
};
|
|
2565
|
-
}
|
|
2566
|
-
async tryRestoreConnection() {
|
|
2567
|
-
try {
|
|
2568
|
-
await this.ensureInitialized();
|
|
2569
|
-
if (!this.provider) {
|
|
2570
|
-
return null;
|
|
2571
|
-
}
|
|
2572
|
-
const accounts = this.provider.accounts;
|
|
2573
|
-
if (!accounts || accounts.length === 0 || !accounts[0]) {
|
|
2574
|
-
return null;
|
|
2575
|
-
}
|
|
2576
|
-
return {
|
|
2577
|
-
address: accounts[0],
|
|
2578
|
-
provider: this.provider,
|
|
2579
|
-
walletId: this.id
|
|
2580
|
-
};
|
|
2581
|
-
} catch {
|
|
2582
|
-
return null;
|
|
2583
|
-
}
|
|
2584
|
-
}
|
|
2585
|
-
async disconnect() {
|
|
2586
|
-
try {
|
|
2587
|
-
if (this.provider) {
|
|
2588
|
-
await this.provider.disconnect();
|
|
2589
|
-
}
|
|
2590
|
-
} finally {
|
|
2591
|
-
this.connectionUri = null;
|
|
2592
|
-
this.provider = null;
|
|
2593
|
-
this.initPromise = null;
|
|
2594
|
-
}
|
|
2595
|
-
}
|
|
2596
|
-
getProvider() {
|
|
2597
|
-
return this.provider;
|
|
2598
|
-
}
|
|
2599
|
-
// Called by Aurum when user connects wallet
|
|
2600
|
-
// Passes Aurum.ts --> syncStateFromAccountsChanged() to handle the provider accounts changed event
|
|
2601
|
-
onAccountsChanged(callback) {
|
|
2602
|
-
if (!this.provider?.on) return;
|
|
2603
|
-
if (this.accountsChangedCallback) {
|
|
2604
|
-
this.provider.removeListener?.("accountsChanged", this.accountsChangedCallback);
|
|
2605
|
-
}
|
|
2606
|
-
this.accountsChangedCallback = callback;
|
|
2607
|
-
this.provider.on("accountsChanged", this.accountsChangedCallback);
|
|
2608
|
-
}
|
|
2609
|
-
removeListeners() {
|
|
2610
|
-
if (!this.provider?.removeListener || !this.accountsChangedCallback) return;
|
|
2611
|
-
this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
|
|
2612
|
-
this.accountsChangedCallback = null;
|
|
2613
|
-
}
|
|
2614
|
-
};
|
|
2615
|
-
|
|
2616
2158
|
// src/hooks/useConnectSelectedWallet.tsx
|
|
2159
|
+
import { WalletId as WalletId6 } from "@aurum-sdk/types";
|
|
2617
2160
|
var useConnectSelectedWallet = () => {
|
|
2618
2161
|
const { navigateTo } = useNavigation();
|
|
2619
2162
|
const connectInstalledWallet = async ({ adapter, onConnect, setSuccess }) => {
|
|
@@ -2633,7 +2176,7 @@ var useConnectSelectedWallet = () => {
|
|
|
2633
2176
|
}
|
|
2634
2177
|
};
|
|
2635
2178
|
const connectUninstalledWalletQRCode = async ({ displayedWallets, onConnect, setSuccess }) => {
|
|
2636
|
-
const walletConnectAdapter = displayedWallets?.find((
|
|
2179
|
+
const walletConnectAdapter = displayedWallets?.find(({ id }) => id === WalletId6.WalletConnect);
|
|
2637
2180
|
if (!walletConnectAdapter) {
|
|
2638
2181
|
sentryLogger.error("connectUninstalledWalletQRCode: WalletConnect adapter not found");
|
|
2639
2182
|
throw new Error("WalletConnect adapter not found");
|
|
@@ -2659,7 +2202,7 @@ var useConnectSelectedWallet = () => {
|
|
|
2659
2202
|
onConnect,
|
|
2660
2203
|
setSuccess
|
|
2661
2204
|
}) => {
|
|
2662
|
-
const walletConnectAdapter = displayedWallets?.find((
|
|
2205
|
+
const walletConnectAdapter = displayedWallets?.find(({ id }) => id === WalletId6.WalletConnect);
|
|
2663
2206
|
if (!walletConnectAdapter) {
|
|
2664
2207
|
sentryLogger.error("connectWithMobileDeepLink: WalletConnect adapter not found");
|
|
2665
2208
|
throw new Error("WalletConnect adapter not found");
|
|
@@ -2691,13 +2234,20 @@ var useConnectSelectedWallet = () => {
|
|
|
2691
2234
|
throw error;
|
|
2692
2235
|
}
|
|
2693
2236
|
};
|
|
2694
|
-
const
|
|
2237
|
+
const connectWalletConnectModal = async ({ adapter, onConnect, setSuccess }) => {
|
|
2695
2238
|
try {
|
|
2696
|
-
|
|
2239
|
+
if (!adapter.openModal) {
|
|
2240
|
+
throw new Error("Adapter does not support openModal");
|
|
2241
|
+
}
|
|
2242
|
+
const { address, provider } = await adapter.openModal();
|
|
2697
2243
|
setSuccess?.(true);
|
|
2698
|
-
|
|
2244
|
+
if (isMobile()) {
|
|
2699
2245
|
onConnect({ walletId: adapter.id, address, provider });
|
|
2700
|
-
}
|
|
2246
|
+
} else {
|
|
2247
|
+
setTimeout(() => {
|
|
2248
|
+
onConnect({ walletId: adapter.id, address, provider });
|
|
2249
|
+
}, 1e3);
|
|
2250
|
+
}
|
|
2701
2251
|
} catch (error) {
|
|
2702
2252
|
if (isConfigError(error)) {
|
|
2703
2253
|
navigateTo(PAGE_IDS.CONFIG_ERROR);
|
|
@@ -2711,7 +2261,7 @@ var useConnectSelectedWallet = () => {
|
|
|
2711
2261
|
return {
|
|
2712
2262
|
// Both mobile and desktop
|
|
2713
2263
|
connectInstalledWallet,
|
|
2714
|
-
|
|
2264
|
+
connectWalletConnectModal,
|
|
2715
2265
|
redirectToDownloadPage,
|
|
2716
2266
|
// Desktop only
|
|
2717
2267
|
connectUninstalledWalletQRCode,
|
|
@@ -2721,7 +2271,7 @@ var useConnectSelectedWallet = () => {
|
|
|
2721
2271
|
};
|
|
2722
2272
|
|
|
2723
2273
|
// src/contexts/ConnectModalContext.tsx
|
|
2724
|
-
import { WalletId as
|
|
2274
|
+
import { WalletId as WalletId7 } from "@aurum-sdk/types";
|
|
2725
2275
|
import { jsx as jsx43 } from "react/jsx-runtime";
|
|
2726
2276
|
var ConnectModalContext = createContext4(null);
|
|
2727
2277
|
var useConnectModal = () => {
|
|
@@ -2738,9 +2288,10 @@ var ConnectModalProvider = ({ children, displayedWallets, onConnect }) => {
|
|
|
2738
2288
|
connectInstalledWallet,
|
|
2739
2289
|
connectWithMobileDeepLink,
|
|
2740
2290
|
connectUninstalledWalletQRCode,
|
|
2741
|
-
|
|
2291
|
+
connectWalletConnectModal
|
|
2742
2292
|
} = useConnectSelectedWallet();
|
|
2743
2293
|
const [error, setError] = useState13(false);
|
|
2294
|
+
const [errorCode, setErrorCode] = useState13(null);
|
|
2744
2295
|
const [configError, setConfigError] = useState13(false);
|
|
2745
2296
|
const [success, setSuccess] = useState13(false);
|
|
2746
2297
|
const [qrSuccess, setQrSuccess] = useState13(false);
|
|
@@ -2748,6 +2299,7 @@ var ConnectModalProvider = ({ children, displayedWallets, onConnect }) => {
|
|
|
2748
2299
|
const connectWallet = async (wallet) => {
|
|
2749
2300
|
try {
|
|
2750
2301
|
setError(false);
|
|
2302
|
+
setErrorCode(null);
|
|
2751
2303
|
setConfigError(false);
|
|
2752
2304
|
setSuccess(false);
|
|
2753
2305
|
setQrSuccess(false);
|
|
@@ -2756,12 +2308,10 @@ var ConnectModalProvider = ({ children, displayedWallets, onConnect }) => {
|
|
|
2756
2308
|
const isDesktop = !isOnMobile;
|
|
2757
2309
|
const hasDeepLink = Boolean(wallet.wcDeepLinkUrl);
|
|
2758
2310
|
if (isDesktop) {
|
|
2759
|
-
if (wallet instanceof AppKitAdapter)
|
|
2760
|
-
return await connectAppKit({ adapter: wallet, onConnect, setSuccess: setQrSuccess });
|
|
2761
2311
|
if (!wallet.isInstalled() && !hasDeepLink) {
|
|
2762
2312
|
return await redirectToDownloadPage();
|
|
2763
2313
|
}
|
|
2764
|
-
if (wallet.id ===
|
|
2314
|
+
if (wallet.id === WalletId7.WalletConnect || !wallet.isInstalled())
|
|
2765
2315
|
return await connectUninstalledWalletQRCode({
|
|
2766
2316
|
adapter: wallet,
|
|
2767
2317
|
displayedWallets,
|
|
@@ -2771,13 +2321,13 @@ var ConnectModalProvider = ({ children, displayedWallets, onConnect }) => {
|
|
|
2771
2321
|
return await connectInstalledWallet({ adapter: wallet, onConnect, setSuccess });
|
|
2772
2322
|
}
|
|
2773
2323
|
if (isOnMobile) {
|
|
2774
|
-
if (wallet.id ===
|
|
2775
|
-
const
|
|
2776
|
-
if (!
|
|
2777
|
-
sentryLogger.error("WalletConnect
|
|
2778
|
-
throw new Error("WalletConnect
|
|
2324
|
+
if (wallet.id === WalletId7.WalletConnect) {
|
|
2325
|
+
const wcAdapter = displayedWallets?.find(({ id }) => id === WalletId7.WalletConnect);
|
|
2326
|
+
if (!wcAdapter) {
|
|
2327
|
+
sentryLogger.error("WalletConnect adapter not found");
|
|
2328
|
+
throw new Error("WalletConnect adapter not found");
|
|
2779
2329
|
}
|
|
2780
|
-
return await
|
|
2330
|
+
return await connectWalletConnectModal({ adapter: wcAdapter, onConnect, setSuccess: setQrSuccess });
|
|
2781
2331
|
}
|
|
2782
2332
|
if (wallet.isInstalled()) return await connectInstalledWallet({ adapter: wallet, onConnect, setSuccess });
|
|
2783
2333
|
if (hasDeepLink) {
|
|
@@ -2787,6 +2337,7 @@ var ConnectModalProvider = ({ children, displayedWallets, onConnect }) => {
|
|
|
2787
2337
|
}
|
|
2788
2338
|
} catch (err) {
|
|
2789
2339
|
setError(true);
|
|
2340
|
+
setErrorCode(err?.code ?? null);
|
|
2790
2341
|
if (isConfigError(err)) {
|
|
2791
2342
|
setConfigError(true);
|
|
2792
2343
|
}
|
|
@@ -2795,16 +2346,29 @@ var ConnectModalProvider = ({ children, displayedWallets, onConnect }) => {
|
|
|
2795
2346
|
const retryConnection = () => {
|
|
2796
2347
|
if (selectedWallet) connectWallet(selectedWallet);
|
|
2797
2348
|
};
|
|
2349
|
+
const openWalletConnectModal = async () => {
|
|
2350
|
+
const wcAdapter = displayedWallets?.find(({ id }) => id === WalletId7.WalletConnect);
|
|
2351
|
+
if (!wcAdapter) {
|
|
2352
|
+
sentryLogger.error("WalletConnect adapter not found");
|
|
2353
|
+
return;
|
|
2354
|
+
}
|
|
2355
|
+
try {
|
|
2356
|
+
await connectWalletConnectModal({ adapter: wcAdapter, onConnect, setSuccess: setQrSuccess });
|
|
2357
|
+
} catch {
|
|
2358
|
+
}
|
|
2359
|
+
};
|
|
2798
2360
|
const goBackToHome = () => {
|
|
2799
2361
|
navigateTo(PAGE_IDS.SELECT_WALLET);
|
|
2800
2362
|
setSelectedWallet(null);
|
|
2801
2363
|
setError(false);
|
|
2364
|
+
setErrorCode(null);
|
|
2802
2365
|
setConfigError(false);
|
|
2803
2366
|
setSuccess(false);
|
|
2804
2367
|
setQrSuccess(false);
|
|
2805
2368
|
};
|
|
2806
2369
|
const contextValue = {
|
|
2807
2370
|
error,
|
|
2371
|
+
errorCode,
|
|
2808
2372
|
configError,
|
|
2809
2373
|
success,
|
|
2810
2374
|
qrSuccess,
|
|
@@ -2812,6 +2376,7 @@ var ConnectModalProvider = ({ children, displayedWallets, onConnect }) => {
|
|
|
2812
2376
|
displayedWallets,
|
|
2813
2377
|
goBackToHome,
|
|
2814
2378
|
connectWallet,
|
|
2379
|
+
openWalletConnectModal,
|
|
2815
2380
|
retryConnection,
|
|
2816
2381
|
setSelectedWallet,
|
|
2817
2382
|
setSuccess,
|
|
@@ -2883,11 +2448,8 @@ export {
|
|
|
2883
2448
|
initSentry,
|
|
2884
2449
|
sentryLogger,
|
|
2885
2450
|
createConfigError,
|
|
2886
|
-
AppKitAdapter,
|
|
2887
|
-
isMobile,
|
|
2888
|
-
WalletConnectAdapter,
|
|
2889
2451
|
ConnectUIProviders,
|
|
2890
2452
|
ConnectPages,
|
|
2891
2453
|
generateCompleteStyles
|
|
2892
2454
|
};
|
|
2893
|
-
//# sourceMappingURL=chunk-
|
|
2455
|
+
//# sourceMappingURL=chunk-THE7QLMS.mjs.map
|