@aurum-sdk/core 0.1.5 → 0.2.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/README.md +3 -3
- package/dist/{chunk-HPH3VJRX.js → chunk-NKWY4I4L.js} +553 -99
- package/dist/chunk-NKWY4I4L.js.map +1 -0
- package/dist/{chunk-5NXCRO5Q.mjs → chunk-NRC534B3.mjs} +537 -83
- package/dist/chunk-NRC534B3.mjs.map +1 -0
- package/dist/index.d.mts +9 -5
- package/dist/index.d.ts +9 -5
- package/dist/index.js +146 -581
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +69 -504
- package/dist/index.mjs.map +1 -1
- package/dist/widgets.d.mts +2 -54
- package/dist/widgets.d.ts +2 -54
- package/dist/widgets.js +18 -21
- package/dist/widgets.js.map +1 -1
- package/dist/widgets.mjs +5 -8
- package/dist/widgets.mjs.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-5NXCRO5Q.mjs.map +0 -1
- package/dist/chunk-HPH3VJRX.js.map +0 -1
|
@@ -119,6 +119,325 @@ function sortWallets(wallets, options = {}) {
|
|
|
119
119
|
return result;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
+
// src/services/sentry.ts
|
|
123
|
+
var _browser = require('@sentry/browser'); var Sentry = _interopRequireWildcard(_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
|
+
var _logos = require('@aurum-sdk/logos');
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
// src/utils/isConfigError.ts
|
|
170
|
+
var isConfigError = (error) => {
|
|
171
|
+
const name = _optionalChain([error, 'optionalAccess', _2 => _2.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 = _types.WalletId.WalletConnect;
|
|
184
|
+
this.name = _types.WalletName.WalletConnect;
|
|
185
|
+
this.icon = _nullishCoalesce(_logos.getLogoDataUri.call(void 0, _types.WalletId.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
|
+
Promise.resolve().then(() => _interopRequireWildcard(require("@reown/appkit"))),
|
|
214
|
+
Promise.resolve().then(() => _interopRequireWildcard(require("@reown/appkit-adapter-wagmi"))),
|
|
215
|
+
Promise.resolve().then(() => _interopRequireWildcard(require("@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 (!_optionalChain([this, 'access', _3 => _3.wagmiAdapter, 'optionalAccess', _4 => _4.wagmiConfig])) return;
|
|
254
|
+
const { state } = this.wagmiAdapter.wagmiConfig;
|
|
255
|
+
if (state.current && state.connections) {
|
|
256
|
+
const connection = state.connections.get(state.current);
|
|
257
|
+
if (_optionalChain([connection, 'optionalAccess', _5 => _5.accounts, 'optionalAccess', _6 => _6[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 = _optionalChain([providers, 'optionalAccess', _7 => _7["eip155"]]);
|
|
269
|
+
if (eip155Provider) {
|
|
270
|
+
this.provider = eip155Provider;
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
if (_optionalChain([this, 'access', _8 => _8.wagmiAdapter, 'optionalAccess', _9 => _9.wagmiConfig])) {
|
|
275
|
+
const { state } = this.wagmiAdapter.wagmiConfig;
|
|
276
|
+
if (state.current && state.connections) {
|
|
277
|
+
const connection = state.connections.get(state.current);
|
|
278
|
+
const connector = _optionalChain([connection, 'optionalAccess', _10 => _10.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
|
+
_optionalChain([unsubscribeState, 'optionalCall', _11 => _11()]);
|
|
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
|
+
_optionalChain([this, 'access', _12 => _12.modal, 'optionalAccess', _13 => _13.close, 'call', _14 => _14()]);
|
|
344
|
+
resolve({
|
|
345
|
+
address: this.address,
|
|
346
|
+
provider: this.provider,
|
|
347
|
+
walletId: this.id
|
|
348
|
+
});
|
|
349
|
+
return true;
|
|
350
|
+
}
|
|
351
|
+
return false;
|
|
352
|
+
} catch (e2) {
|
|
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 (_optionalChain([wagmiConfig, 'optionalAccess', _15 => _15.state, 'optionalAccess', _16 => _16.current]) && wagmiConfig.state.connections) {
|
|
384
|
+
const connection = wagmiConfig.state.connections.get(wagmiConfig.state.current);
|
|
385
|
+
if (_optionalChain([connection, 'optionalAccess', _17 => _17.accounts, 'optionalAccess', _18 => _18[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 (e3) {
|
|
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 (!_optionalChain([this, 'access', _19 => _19.provider, 'optionalAccess', _20 => _20.on])) return;
|
|
420
|
+
if (this.accountsChangedCallback) {
|
|
421
|
+
_optionalChain([this, 'access', _21 => _21.provider, 'access', _22 => _22.removeListener, 'optionalCall', _23 => _23("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 (_optionalChain([this, 'access', _24 => _24.provider, 'optionalAccess', _25 => _25.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
|
+
|
|
122
441
|
// src/utils/platform/isMobile.ts
|
|
123
442
|
var _mobiledetect = require('mobile-detect'); var _mobiledetect2 = _interopRequireDefault(_mobiledetect);
|
|
124
443
|
function isMobile() {
|
|
@@ -334,7 +653,7 @@ var Divider = ({ children }) => {
|
|
|
334
653
|
var FOCUSABLE_SELECTOR = 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
335
654
|
function getDeepActiveElement() {
|
|
336
655
|
let active = document.activeElement;
|
|
337
|
-
while (_optionalChain([active, 'optionalAccess',
|
|
656
|
+
while (_optionalChain([active, 'optionalAccess', _26 => _26.shadowRoot, 'optionalAccess', _27 => _27.activeElement])) {
|
|
338
657
|
active = active.shadowRoot.activeElement;
|
|
339
658
|
}
|
|
340
659
|
return active;
|
|
@@ -343,7 +662,7 @@ function useFocusTrap(containerRef, { isActive, onEscape, refocusKey }) {
|
|
|
343
662
|
_react.useEffect.call(void 0, () => {
|
|
344
663
|
if (isActive && containerRef.current) {
|
|
345
664
|
const timer = setTimeout(() => {
|
|
346
|
-
_optionalChain([containerRef, 'access',
|
|
665
|
+
_optionalChain([containerRef, 'access', _28 => _28.current, 'optionalAccess', _29 => _29.focus, 'call', _30 => _30()]);
|
|
347
666
|
}, 50);
|
|
348
667
|
return () => clearTimeout(timer);
|
|
349
668
|
}
|
|
@@ -352,7 +671,7 @@ function useFocusTrap(containerRef, { isActive, onEscape, refocusKey }) {
|
|
|
352
671
|
if (!isActive) return;
|
|
353
672
|
const handleKeyDown = (e) => {
|
|
354
673
|
if (e.key === "Escape") {
|
|
355
|
-
_optionalChain([onEscape, 'optionalCall',
|
|
674
|
+
_optionalChain([onEscape, 'optionalCall', _31 => _31()]);
|
|
356
675
|
return;
|
|
357
676
|
}
|
|
358
677
|
if (e.key !== "Tab" || !containerRef.current) return;
|
|
@@ -554,7 +873,7 @@ var Modal = ({
|
|
|
554
873
|
if (animState !== "entering") return;
|
|
555
874
|
const rafId = requestAnimationFrame(() => {
|
|
556
875
|
setAnimState("open");
|
|
557
|
-
_optionalChain([dialogRef, 'access',
|
|
876
|
+
_optionalChain([dialogRef, 'access', _32 => _32.current, 'optionalAccess', _33 => _33.focus, 'call', _34 => _34()]);
|
|
558
877
|
});
|
|
559
878
|
return () => cancelAnimationFrame(rafId);
|
|
560
879
|
}, [animState]);
|
|
@@ -736,62 +1055,6 @@ var ModalHeader = ({ leftAction, rightAction, title }) => {
|
|
|
736
1055
|
// src/contexts/EmailAuthContext.tsx
|
|
737
1056
|
|
|
738
1057
|
|
|
739
|
-
// src/services/sentry.ts
|
|
740
|
-
var _browser = require('@sentry/browser'); var Sentry = _interopRequireWildcard(_browser);
|
|
741
|
-
var initialized = false;
|
|
742
|
-
var telemetryEnabled = true;
|
|
743
|
-
function getEnvironment() {
|
|
744
|
-
if (typeof window !== "undefined") {
|
|
745
|
-
const hostname = window.location.hostname;
|
|
746
|
-
if (hostname === "localhost" || hostname === "127.0.0.1") {
|
|
747
|
-
return "development";
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
return "production";
|
|
751
|
-
}
|
|
752
|
-
function initSentry(enabled = true) {
|
|
753
|
-
telemetryEnabled = enabled;
|
|
754
|
-
if (initialized || !telemetryEnabled || false) return;
|
|
755
|
-
initialized = true;
|
|
756
|
-
Sentry.init({
|
|
757
|
-
dsn: "https://0bb16fd7057ac7b45ae0ab416cdbea8b@o4505953815494656.ingest.us.sentry.io/4509747448184832",
|
|
758
|
-
environment: getEnvironment(),
|
|
759
|
-
release: `@aurum-sdk/core@${"0.1.5"}`,
|
|
760
|
-
sendDefaultPii: false,
|
|
761
|
-
enableLogs: true
|
|
762
|
-
});
|
|
763
|
-
}
|
|
764
|
-
function getUrl() {
|
|
765
|
-
if (typeof window !== "undefined") {
|
|
766
|
-
return window.location.href;
|
|
767
|
-
}
|
|
768
|
-
return void 0;
|
|
769
|
-
}
|
|
770
|
-
var sentryLogger = {
|
|
771
|
-
info: (message, attributes) => {
|
|
772
|
-
if (telemetryEnabled) Sentry.logger.info(message, { url: getUrl(), ...attributes });
|
|
773
|
-
},
|
|
774
|
-
warn: (message, attributes) => {
|
|
775
|
-
if (telemetryEnabled) Sentry.logger.warn(message, { url: getUrl(), ...attributes });
|
|
776
|
-
},
|
|
777
|
-
error: (message, attributes) => {
|
|
778
|
-
if (telemetryEnabled) Sentry.logger.error(message, { url: getUrl(), ...attributes });
|
|
779
|
-
}
|
|
780
|
-
};
|
|
781
|
-
|
|
782
|
-
// src/utils/isConfigError.ts
|
|
783
|
-
var isConfigError = (error) => {
|
|
784
|
-
const name = _optionalChain([error, 'optionalAccess', _11 => _11.name]);
|
|
785
|
-
return name === "ConfigError";
|
|
786
|
-
};
|
|
787
|
-
var createConfigError = (adapterName) => {
|
|
788
|
-
const error = new Error(`Missing required project ID for ${adapterName}`);
|
|
789
|
-
error.name = "ConfigError";
|
|
790
|
-
return error;
|
|
791
|
-
};
|
|
792
|
-
|
|
793
|
-
// src/contexts/EmailAuthContext.tsx
|
|
794
|
-
|
|
795
1058
|
var EmailAuthContext = _react.createContext.call(void 0, null);
|
|
796
1059
|
var useEmailAuth = () => {
|
|
797
1060
|
const context = _react.useContext.call(void 0, EmailAuthContext);
|
|
@@ -852,14 +1115,14 @@ var EmailAuthProvider = ({
|
|
|
852
1115
|
await attemptEmailAuth(email, emailAdapter);
|
|
853
1116
|
} catch (error2) {
|
|
854
1117
|
setEmailAuthState((prev) => ({ ...prev, step: "email" }));
|
|
855
|
-
const errorMessage = _nullishCoalesce(_optionalChain([error2, 'access',
|
|
1118
|
+
const errorMessage = _nullishCoalesce(_optionalChain([error2, 'access', _35 => _35.message, 'optionalAccess', _36 => _36.toLowerCase, 'call', _37 => _37()]), () => ( ""));
|
|
856
1119
|
const isAlreadyAuthenticated = errorMessage.includes("user is already authenticated");
|
|
857
1120
|
if (isConfigError(error2)) {
|
|
858
1121
|
navigateTo(PAGE_IDS.CONFIG_ERROR);
|
|
859
1122
|
} else if (isAlreadyAuthenticated) {
|
|
860
1123
|
try {
|
|
861
1124
|
await handleAlreadyAuthenticatedError(email, emailAdapter);
|
|
862
|
-
} catch (
|
|
1125
|
+
} catch (e4) {
|
|
863
1126
|
setError("Failed to send email verification");
|
|
864
1127
|
}
|
|
865
1128
|
} else {
|
|
@@ -889,12 +1152,12 @@ var EmailAuthProvider = ({
|
|
|
889
1152
|
setTimeout(() => {
|
|
890
1153
|
onConnect({
|
|
891
1154
|
walletId: emailAdapter.id,
|
|
892
|
-
address: _nullishCoalesce(_optionalChain([verifyResult, 'access',
|
|
1155
|
+
address: _nullishCoalesce(_optionalChain([verifyResult, 'access', _38 => _38.user, 'optionalAccess', _39 => _39.evmAccounts, 'optionalAccess', _40 => _40[0]]), () => ( "")),
|
|
893
1156
|
provider: emailAdapter.getProvider(),
|
|
894
1157
|
email: emailAuthState.email
|
|
895
1158
|
});
|
|
896
1159
|
}, 1500);
|
|
897
|
-
} catch (
|
|
1160
|
+
} catch (e5) {
|
|
898
1161
|
setError("Invalid or expired code");
|
|
899
1162
|
setEmailAuthState((prev) => ({ ...prev, step: "otp" }));
|
|
900
1163
|
}
|
|
@@ -1392,8 +1655,8 @@ var ConnectionStatusPage = () => {
|
|
|
1392
1655
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1393
1656
|
ConnectionStatusBase,
|
|
1394
1657
|
{
|
|
1395
|
-
pendingHeaderText: `Approve in ${_optionalChain([selectedWallet, 'optionalAccess',
|
|
1396
|
-
pendingSubContent: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Text, { align: "center", size: "sm", variant: "secondary", children: _optionalChain([selectedWallet, 'optionalAccess',
|
|
1658
|
+
pendingHeaderText: `Approve in ${_optionalChain([selectedWallet, 'optionalAccess', _41 => _41.name])}`,
|
|
1659
|
+
pendingSubContent: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Text, { align: "center", size: "sm", variant: "secondary", children: _optionalChain([selectedWallet, 'optionalAccess', _42 => _42.id]) === _types.WalletId.Ledger ? `Please wait for the Ledger Live modal to open` : `Please check your wallet to
|
|
1397
1660
|
approve the connection` })
|
|
1398
1661
|
}
|
|
1399
1662
|
);
|
|
@@ -1412,11 +1675,11 @@ var ConnectionStatusMobilePage = () => {
|
|
|
1412
1675
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1413
1676
|
ConnectionStatusBase,
|
|
1414
1677
|
{
|
|
1415
|
-
title: _optionalChain([selectedWallet, 'optionalAccess',
|
|
1416
|
-
pendingHeaderText: `Opening ${_optionalChain([selectedWallet, 'optionalAccess',
|
|
1678
|
+
title: _optionalChain([selectedWallet, 'optionalAccess', _43 => _43.name]),
|
|
1679
|
+
pendingHeaderText: `Opening ${_optionalChain([selectedWallet, 'optionalAccess', _44 => _44.name])}`,
|
|
1417
1680
|
pendingSubContent: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Text, { size: "sm", variant: "secondary", align: "center", style: { maxWidth: "18.75rem" }, children: [
|
|
1418
1681
|
"If ",
|
|
1419
|
-
_optionalChain([selectedWallet, 'optionalAccess',
|
|
1682
|
+
_optionalChain([selectedWallet, 'optionalAccess', _45 => _45.name]),
|
|
1420
1683
|
" doesn't open automatically, click the button below"
|
|
1421
1684
|
] }),
|
|
1422
1685
|
extraContent: showLaunchButton && !success && !error ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Button, { variant: "tertiary", size: "md", onClick: retryConnection, style: { width: "100%", marginTop: "0.5rem" }, children: "Launch App" }) : void 0
|
|
@@ -1432,10 +1695,10 @@ var ConnectionStatusMobilePage = () => {
|
|
|
1432
1695
|
var _reactqrcodelogo = require('react-qrcode-logo');
|
|
1433
1696
|
|
|
1434
1697
|
// src/utils/generateQrCodeWalletLogo.tsx
|
|
1435
|
-
|
|
1698
|
+
|
|
1436
1699
|
|
|
1437
1700
|
var generateQrCodeWalletLogo = (walletAdapter) => {
|
|
1438
|
-
if (walletAdapter && walletAdapter
|
|
1701
|
+
if (walletAdapter && !(walletAdapter instanceof AppKitAdapter) && walletAdapter.icon) {
|
|
1439
1702
|
return walletAdapter.icon;
|
|
1440
1703
|
}
|
|
1441
1704
|
return _nullishCoalesce(_logos.getLogoDataUri.call(void 0, _types.WalletId.WalletConnect), () => ( ""));
|
|
@@ -1598,7 +1861,6 @@ var QRCodeSkeleton = ({ size = 128 }) => {
|
|
|
1598
1861
|
|
|
1599
1862
|
// src/components/QRCodeDisplay/QRCodeDisplay.tsx
|
|
1600
1863
|
|
|
1601
|
-
|
|
1602
1864
|
var QRCodeDisplay = ({ uri, size = 256 }) => {
|
|
1603
1865
|
const { brandConfig } = useWidgetContext();
|
|
1604
1866
|
const { selectedWallet, displayedWallets, connectWallet } = useConnectModal();
|
|
@@ -1606,12 +1868,12 @@ var QRCodeDisplay = ({ uri, size = 256 }) => {
|
|
|
1606
1868
|
const bgColor = brandConfig.theme === "light" ? "#ffffff" : "#121212";
|
|
1607
1869
|
const logoWalletRef = _react.useRef.call(void 0, null);
|
|
1608
1870
|
_react.useEffect.call(void 0, () => {
|
|
1609
|
-
if (selectedWallet && selectedWallet
|
|
1871
|
+
if (selectedWallet && !(selectedWallet instanceof AppKitAdapter)) {
|
|
1610
1872
|
logoWalletRef.current = selectedWallet;
|
|
1611
1873
|
}
|
|
1612
1874
|
}, [selectedWallet]);
|
|
1613
1875
|
const logoWallet = logoWalletRef.current || selectedWallet;
|
|
1614
|
-
const appKitAdapter = displayedWallets.find((
|
|
1876
|
+
const appKitAdapter = displayedWallets.find((w) => w instanceof AppKitAdapter);
|
|
1615
1877
|
const handleAppKitConnect = async () => {
|
|
1616
1878
|
if (appKitAdapter) {
|
|
1617
1879
|
connectWallet(appKitAdapter);
|
|
@@ -1672,7 +1934,7 @@ var QRCodePage = () => {
|
|
|
1672
1934
|
const [connectionUri, setConnectionUri] = _react.useState.call(void 0, null);
|
|
1673
1935
|
const originalWalletRef = _react.useRef.call(void 0, null);
|
|
1674
1936
|
_react.useEffect.call(void 0, () => {
|
|
1675
|
-
if (selectedWallet && selectedWallet
|
|
1937
|
+
if (selectedWallet && !(selectedWallet instanceof AppKitAdapter)) {
|
|
1676
1938
|
originalWalletRef.current = selectedWallet;
|
|
1677
1939
|
}
|
|
1678
1940
|
}, [selectedWallet]);
|
|
@@ -1680,7 +1942,7 @@ var QRCodePage = () => {
|
|
|
1680
1942
|
const goBackToHome = () => {
|
|
1681
1943
|
navigateTo(PAGE_IDS.SELECT_WALLET);
|
|
1682
1944
|
};
|
|
1683
|
-
const title = _optionalChain([displayWallet, 'optionalAccess',
|
|
1945
|
+
const title = _optionalChain([displayWallet, 'optionalAccess', _46 => _46.name]) === _types.WalletName.WalletConnect ? "Scan QR code" : `Scan with ${_optionalChain([displayWallet, 'optionalAccess', _47 => _47.name])} app`;
|
|
1684
1946
|
_react.useEffect.call(void 0, () => {
|
|
1685
1947
|
const handleWalletConnectURI = (event) => {
|
|
1686
1948
|
setConnectionUri(event.detail.uri);
|
|
@@ -1710,7 +1972,7 @@ var QRCodePage = () => {
|
|
|
1710
1972
|
),
|
|
1711
1973
|
qrSuccess ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Column, { align: "center", style: { height: "8rem" }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CircleCheck, { color: "var(--aurum-primary-color)", size: 46 }) }) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1712
1974
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Column, { align: "center", gap: 24, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, QRCodeDisplay, { uri: error ? null : connectionUri }) }),
|
|
1713
|
-
_optionalChain([displayWallet, 'optionalAccess',
|
|
1975
|
+
_optionalChain([displayWallet, 'optionalAccess', _48 => _48.downloadUrl]) && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1714
1976
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Spacer, { size: 15 }),
|
|
1715
1977
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
1716
1978
|
Button,
|
|
@@ -1885,12 +2147,12 @@ var useOtpInputs = ({
|
|
|
1885
2147
|
newOtp[index] = value.slice(-1);
|
|
1886
2148
|
setOtp(newOtp);
|
|
1887
2149
|
if (value && index < OTP_LENGTH - 1) {
|
|
1888
|
-
_optionalChain([inputRefs, 'access',
|
|
2150
|
+
_optionalChain([inputRefs, 'access', _49 => _49.current, 'access', _50 => _50[index + 1], 'optionalAccess', _51 => _51.focus, 'call', _52 => _52()]);
|
|
1889
2151
|
}
|
|
1890
2152
|
};
|
|
1891
2153
|
const handleKeyDown = (index, e) => {
|
|
1892
2154
|
if (e.key === "Backspace" && !otp[index] && index > 0) {
|
|
1893
|
-
_optionalChain([inputRefs, 'access',
|
|
2155
|
+
_optionalChain([inputRefs, 'access', _53 => _53.current, 'access', _54 => _54[index - 1], 'optionalAccess', _55 => _55.focus, 'call', _56 => _56()]);
|
|
1894
2156
|
}
|
|
1895
2157
|
};
|
|
1896
2158
|
const handlePaste = (e) => {
|
|
@@ -1902,7 +2164,7 @@ var useOtpInputs = ({
|
|
|
1902
2164
|
setOtp(newOtp);
|
|
1903
2165
|
const nextEmptyIndex = newOtp.findIndex((digit) => !digit);
|
|
1904
2166
|
if (nextEmptyIndex !== -1) {
|
|
1905
|
-
_optionalChain([inputRefs, 'access',
|
|
2167
|
+
_optionalChain([inputRefs, 'access', _57 => _57.current, 'access', _58 => _58[nextEmptyIndex], 'optionalAccess', _59 => _59.focus, 'call', _60 => _60()]);
|
|
1906
2168
|
}
|
|
1907
2169
|
};
|
|
1908
2170
|
_react.useEffect.call(void 0, () => {
|
|
@@ -1911,16 +2173,16 @@ var useOtpInputs = ({
|
|
|
1911
2173
|
}
|
|
1912
2174
|
}, [otp]);
|
|
1913
2175
|
_react.useEffect.call(void 0, () => {
|
|
1914
|
-
_optionalChain([inputRefs, 'access',
|
|
2176
|
+
_optionalChain([inputRefs, 'access', _61 => _61.current, 'access', _62 => _62[0], 'optionalAccess', _63 => _63.focus, 'call', _64 => _64()]);
|
|
1915
2177
|
const timer = setTimeout(() => {
|
|
1916
|
-
_optionalChain([inputRefs, 'access',
|
|
2178
|
+
_optionalChain([inputRefs, 'access', _65 => _65.current, 'access', _66 => _66[0], 'optionalAccess', _67 => _67.focus, 'call', _68 => _68()]);
|
|
1917
2179
|
}, 100);
|
|
1918
2180
|
return () => clearTimeout(timer);
|
|
1919
2181
|
}, []);
|
|
1920
2182
|
_react.useEffect.call(void 0, () => {
|
|
1921
2183
|
if (error) {
|
|
1922
2184
|
setOtp(Array(OTP_LENGTH).fill(""));
|
|
1923
|
-
_optionalChain([inputRefs, 'access',
|
|
2185
|
+
_optionalChain([inputRefs, 'access', _69 => _69.current, 'access', _70 => _70[0], 'optionalAccess', _71 => _71.focus, 'call', _72 => _72()]);
|
|
1924
2186
|
}
|
|
1925
2187
|
}, [error]);
|
|
1926
2188
|
_react.useEffect.call(void 0, () => {
|
|
@@ -1969,7 +2231,7 @@ var EmailVerifyOTP = () => {
|
|
|
1969
2231
|
startCountdown(RESEND_COUNTDOWN_SECONDS);
|
|
1970
2232
|
await sendEmailOTP(emailAuthState.email);
|
|
1971
2233
|
setOtp(Array(OTP_LENGTH).fill(""));
|
|
1972
|
-
_optionalChain([inputRefs, 'access',
|
|
2234
|
+
_optionalChain([inputRefs, 'access', _73 => _73.current, 'access', _74 => _74[0], 'optionalAccess', _75 => _75.focus, 'call', _76 => _76()]);
|
|
1973
2235
|
};
|
|
1974
2236
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
1975
2237
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -2156,19 +2418,209 @@ var registerGlobalCleanup = (cleanupFn) => {
|
|
|
2156
2418
|
if (index > -1) cleanupList.splice(index, 1);
|
|
2157
2419
|
cleanupFn();
|
|
2158
2420
|
};
|
|
2159
|
-
_optionalChain([window, 'access',
|
|
2421
|
+
_optionalChain([window, 'access', _77 => _77.__aurumDeepLinkListeners, 'optionalAccess', _78 => _78.push, 'call', _79 => _79(cleanup)]);
|
|
2160
2422
|
return cleanup;
|
|
2161
2423
|
};
|
|
2162
2424
|
|
|
2163
|
-
// src/
|
|
2425
|
+
// src/wallet-adapters/WalletConnectAdapter.ts
|
|
2426
|
+
|
|
2427
|
+
|
|
2428
|
+
var WalletConnectAdapter = class {
|
|
2429
|
+
constructor(config) {
|
|
2430
|
+
this.id = _types.WalletId.WalletConnect;
|
|
2431
|
+
this.name = _types.WalletName.WalletConnect;
|
|
2432
|
+
this.icon = _nullishCoalesce(_logos.getLogoDataUri.call(void 0, _types.WalletId.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 Promise.resolve().then(() => _interopRequireWildcard(require("@walletconnect/ethereum-provider")));
|
|
2455
|
+
this.provider = await EthereumProvider.init({
|
|
2456
|
+
projectId: _nullishCoalesce(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 (e6) {
|
|
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 (e7) {
|
|
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 (e8) {
|
|
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 (!_optionalChain([this, 'access', _80 => _80.provider, 'optionalAccess', _81 => _81.on])) return;
|
|
2603
|
+
if (this.accountsChangedCallback) {
|
|
2604
|
+
_optionalChain([this, 'access', _82 => _82.provider, 'access', _83 => _83.removeListener, 'optionalCall', _84 => _84("accountsChanged", this.accountsChangedCallback)]);
|
|
2605
|
+
}
|
|
2606
|
+
this.accountsChangedCallback = callback;
|
|
2607
|
+
this.provider.on("accountsChanged", this.accountsChangedCallback);
|
|
2608
|
+
}
|
|
2609
|
+
removeListeners() {
|
|
2610
|
+
if (!_optionalChain([this, 'access', _85 => _85.provider, 'optionalAccess', _86 => _86.removeListener]) || !this.accountsChangedCallback) return;
|
|
2611
|
+
this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
|
|
2612
|
+
this.accountsChangedCallback = null;
|
|
2613
|
+
}
|
|
2614
|
+
};
|
|
2164
2615
|
|
|
2616
|
+
// src/hooks/useConnectSelectedWallet.tsx
|
|
2165
2617
|
var useConnectSelectedWallet = () => {
|
|
2166
2618
|
const { navigateTo } = useNavigation();
|
|
2167
2619
|
const connectInstalledWallet = async ({ adapter, onConnect, setSuccess }) => {
|
|
2168
2620
|
navigateTo(PAGE_IDS.CONNECTING);
|
|
2169
2621
|
try {
|
|
2170
2622
|
const { address, provider } = await adapter.connect();
|
|
2171
|
-
_optionalChain([setSuccess, 'optionalCall',
|
|
2623
|
+
_optionalChain([setSuccess, 'optionalCall', _87 => _87(true)]);
|
|
2172
2624
|
setTimeout(() => {
|
|
2173
2625
|
onConnect({ walletId: adapter.id, address, provider });
|
|
2174
2626
|
}, 1e3);
|
|
@@ -2181,7 +2633,7 @@ var useConnectSelectedWallet = () => {
|
|
|
2181
2633
|
}
|
|
2182
2634
|
};
|
|
2183
2635
|
const connectUninstalledWalletQRCode = async ({ displayedWallets, onConnect, setSuccess }) => {
|
|
2184
|
-
const walletConnectAdapter = _optionalChain([displayedWallets, 'optionalAccess',
|
|
2636
|
+
const walletConnectAdapter = _optionalChain([displayedWallets, 'optionalAccess', _88 => _88.find, 'call', _89 => _89((w) => w instanceof WalletConnectAdapter)]);
|
|
2185
2637
|
if (!walletConnectAdapter) {
|
|
2186
2638
|
sentryLogger.error("connectUninstalledWalletQRCode: WalletConnect adapter not found");
|
|
2187
2639
|
throw new Error("WalletConnect adapter not found");
|
|
@@ -2189,7 +2641,7 @@ var useConnectSelectedWallet = () => {
|
|
|
2189
2641
|
navigateTo(PAGE_IDS.QR_CODE);
|
|
2190
2642
|
try {
|
|
2191
2643
|
const { address, provider } = await walletConnectAdapter.connect();
|
|
2192
|
-
_optionalChain([setSuccess, 'optionalCall',
|
|
2644
|
+
_optionalChain([setSuccess, 'optionalCall', _90 => _90(true)]);
|
|
2193
2645
|
setTimeout(() => {
|
|
2194
2646
|
onConnect({ walletId: walletConnectAdapter.id, address, provider });
|
|
2195
2647
|
}, 1e3);
|
|
@@ -2207,7 +2659,7 @@ var useConnectSelectedWallet = () => {
|
|
|
2207
2659
|
onConnect,
|
|
2208
2660
|
setSuccess
|
|
2209
2661
|
}) => {
|
|
2210
|
-
const walletConnectAdapter = _optionalChain([displayedWallets, 'optionalAccess',
|
|
2662
|
+
const walletConnectAdapter = _optionalChain([displayedWallets, 'optionalAccess', _91 => _91.find, 'call', _92 => _92((w) => w instanceof WalletConnectAdapter)]);
|
|
2211
2663
|
if (!walletConnectAdapter) {
|
|
2212
2664
|
sentryLogger.error("connectWithMobileDeepLink: WalletConnect adapter not found");
|
|
2213
2665
|
throw new Error("WalletConnect adapter not found");
|
|
@@ -2226,7 +2678,7 @@ var useConnectSelectedWallet = () => {
|
|
|
2226
2678
|
if (isRejected) {
|
|
2227
2679
|
return;
|
|
2228
2680
|
}
|
|
2229
|
-
_optionalChain([setSuccess, 'optionalCall',
|
|
2681
|
+
_optionalChain([setSuccess, 'optionalCall', _93 => _93(true)]);
|
|
2230
2682
|
setTimeout(() => {
|
|
2231
2683
|
onConnect({ walletId: walletConnectAdapter.id, address, provider });
|
|
2232
2684
|
}, 1e3);
|
|
@@ -2242,7 +2694,7 @@ var useConnectSelectedWallet = () => {
|
|
|
2242
2694
|
const connectAppKit = async ({ adapter, onConnect, setSuccess }) => {
|
|
2243
2695
|
try {
|
|
2244
2696
|
const { address, provider } = await adapter.connect();
|
|
2245
|
-
_optionalChain([setSuccess, 'optionalCall',
|
|
2697
|
+
_optionalChain([setSuccess, 'optionalCall', _94 => _94(true)]);
|
|
2246
2698
|
setTimeout(() => {
|
|
2247
2699
|
onConnect({ walletId: adapter.id, address, provider });
|
|
2248
2700
|
}, 1e3);
|
|
@@ -2304,7 +2756,7 @@ var ConnectModalProvider = ({ children, displayedWallets, onConnect }) => {
|
|
|
2304
2756
|
const isDesktop = !isOnMobile;
|
|
2305
2757
|
const hasDeepLink = Boolean(wallet.wcDeepLinkUrl);
|
|
2306
2758
|
if (isDesktop) {
|
|
2307
|
-
if (wallet
|
|
2759
|
+
if (wallet instanceof AppKitAdapter)
|
|
2308
2760
|
return await connectAppKit({ adapter: wallet, onConnect, setSuccess: setQrSuccess });
|
|
2309
2761
|
if (!wallet.isInstalled() && !hasDeepLink) {
|
|
2310
2762
|
return await redirectToDownloadPage();
|
|
@@ -2319,11 +2771,11 @@ var ConnectModalProvider = ({ children, displayedWallets, onConnect }) => {
|
|
|
2319
2771
|
return await connectInstalledWallet({ adapter: wallet, onConnect, setSuccess });
|
|
2320
2772
|
}
|
|
2321
2773
|
if (isOnMobile) {
|
|
2322
|
-
if (wallet.id === _types.WalletId.WalletConnect
|
|
2323
|
-
const appkitAdapter = _optionalChain([displayedWallets, 'optionalAccess',
|
|
2774
|
+
if (wallet.id === _types.WalletId.WalletConnect) {
|
|
2775
|
+
const appkitAdapter = _optionalChain([displayedWallets, 'optionalAccess', _95 => _95.find, 'call', _96 => _96((w) => w instanceof AppKitAdapter)]);
|
|
2324
2776
|
if (!appkitAdapter) {
|
|
2325
|
-
sentryLogger.error("
|
|
2326
|
-
throw new Error("
|
|
2777
|
+
sentryLogger.error("WalletConnect modal adapter not found");
|
|
2778
|
+
throw new Error("WalletConnect modal adapter not found");
|
|
2327
2779
|
}
|
|
2328
2780
|
return await connectAppKit({ adapter: appkitAdapter, onConnect, setSuccess: setQrSuccess });
|
|
2329
2781
|
}
|
|
@@ -2435,5 +2887,7 @@ ${generateBrandCssVariables(brandConfig)}`;
|
|
|
2435
2887
|
|
|
2436
2888
|
|
|
2437
2889
|
|
|
2438
|
-
|
|
2439
|
-
|
|
2890
|
+
|
|
2891
|
+
|
|
2892
|
+
exports.useAurumStore = useAurumStore; exports.waitForStoreHydration = waitForStoreHydration; exports.useWidgetContext = useWidgetContext; exports.WidgetProvider = WidgetProvider; exports.DEFAULT_THEME = DEFAULT_THEME; exports.getDefaultThemeConfig = getDefaultThemeConfig; exports.POWERED_BY_SPACER_REM = POWERED_BY_SPACER_REM; exports.PageTransitionContainer = PageTransitionContainer; exports.PoweredBy = PoweredBy; exports.Modal = Modal; exports.Spacer = Spacer; exports.ThemeContainer = ThemeContainer; exports.useNavigation = useNavigation; exports.sortWallets = sortWallets; exports.initSentry = initSentry; exports.sentryLogger = sentryLogger; exports.createConfigError = createConfigError; exports.AppKitAdapter = AppKitAdapter; exports.isMobile = isMobile; exports.WalletConnectAdapter = WalletConnectAdapter; exports.ConnectUIProviders = ConnectUIProviders; exports.ConnectPages = ConnectPages; exports.generateCompleteStyles = generateCompleteStyles;
|
|
2893
|
+
//# sourceMappingURL=chunk-NKWY4I4L.js.map
|