@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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
3
 
4
4
 
@@ -13,10 +13,7 @@
13
13
 
14
14
 
15
15
 
16
-
17
-
18
-
19
- var _chunkNKWY4I4Ljs = require('./chunk-NKWY4I4L.js');
16
+ var _chunkK6PG2PDFjs = require('./chunk-K6PG2PDF.js');
20
17
 
21
18
  // src/AurumCore.ts
22
19
  var _viem = require('viem');
@@ -48,20 +45,20 @@ var _react = require('react');
48
45
  var _jsxruntime = require('react/jsx-runtime');
49
46
  var ModalShell = ({ onClose, brandConfig }) => {
50
47
  const [isOpen, setIsOpen] = _react.useState.call(void 0, true);
51
- const { currentPage } = _chunkNKWY4I4Ljs.useNavigation.call(void 0, );
48
+ const { currentPage } = _chunkK6PG2PDFjs.useNavigation.call(void 0, );
52
49
  const handleClose = () => {
53
50
  setIsOpen(false);
54
51
  onClose();
55
52
  };
56
53
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
57
- _chunkNKWY4I4Ljs.Modal,
54
+ _chunkK6PG2PDFjs.Modal,
58
55
  {
59
56
  isOpen,
60
57
  closeOnOverlayClick: true,
61
58
  onCloseComplete: handleClose,
62
59
  brandConfig,
63
60
  transitionKey: currentPage,
64
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkNKWY4I4Ljs.ConnectPages, {})
61
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkK6PG2PDFjs.ConnectPages, {})
65
62
  }
66
63
  );
67
64
  };
@@ -73,7 +70,7 @@ var _client = require('react-dom/client');
73
70
  function createShadowRoot(container, brandConfig) {
74
71
  const shadowRoot = container.attachShadow({ mode: "open" });
75
72
  shadowRoot.innerHTML = `
76
- <style>${_chunkNKWY4I4Ljs.generateCompleteStyles.call(void 0, brandConfig)}</style>
73
+ <style>${_chunkK6PG2PDFjs.generateCompleteStyles.call(void 0, brandConfig)}</style>
77
74
  <div class="aurum-modal-root"></div>
78
75
  `;
79
76
  return shadowRoot.querySelector(".aurum-modal-root");
@@ -103,7 +100,6 @@ function createModalContainer(id, brandConfig) {
103
100
  }
104
101
 
105
102
  // src/components/ConnectModal/renderConnectModal.tsx
106
- var _types = require('@aurum-sdk/types');
107
103
 
108
104
  var CONTAINER_ID = "aurum-modal-container";
109
105
  function renderConnectModal({
@@ -111,11 +107,7 @@ function renderConnectModal({
111
107
  brandConfig
112
108
  }) {
113
109
  return new Promise((resolve, reject) => {
114
- let sortedWallets = _chunkNKWY4I4Ljs.sortWallets.call(void 0, displayedWallets, { filterHidden: false });
115
- const hasAppKit = sortedWallets.some((w) => w instanceof _chunkNKWY4I4Ljs.AppKitAdapter);
116
- if (_chunkNKWY4I4Ljs.isMobile.call(void 0, ) && !hasAppKit) {
117
- sortedWallets = sortedWallets.filter((w) => w.id !== _types.WalletId.WalletConnect);
118
- }
110
+ const sortedWallets = _chunkK6PG2PDFjs.sortWallets.call(void 0, displayedWallets, { filterHidden: false });
119
111
  const { root, cleanup } = createModalContainer(CONTAINER_ID, brandConfig);
120
112
  const onConnect = (result) => {
121
113
  cleanup();
@@ -126,14 +118,14 @@ function renderConnectModal({
126
118
  reject(new Error("User rejected request"));
127
119
  };
128
120
  root.render(
129
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkNKWY4I4Ljs.ThemeContainer, { theme: brandConfig.theme, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkNKWY4I4Ljs.ConnectUIProviders, { onConnect, displayedWallets: sortedWallets, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ModalShell, { onClose, brandConfig }) }) })
121
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkK6PG2PDFjs.ThemeContainer, { theme: brandConfig.theme, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkK6PG2PDFjs.ConnectUIProviders, { onConnect, displayedWallets: sortedWallets, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ModalShell, { onClose, brandConfig }) }) })
130
122
  );
131
123
  });
132
124
  }
133
125
 
134
126
  // src/wallet-adapters/RabbyAdapter.ts
135
127
  var _logos = require('@aurum-sdk/logos');
136
-
128
+ var _types = require('@aurum-sdk/types');
137
129
  var RABBY_RDNS = "io.rabby";
138
130
  var RabbyAdapter = class {
139
131
  constructor() {
@@ -191,37 +183,33 @@ var RabbyAdapter = class {
191
183
  return null;
192
184
  }
193
185
  isInstalled() {
194
- return Boolean(this.provider);
186
+ return Boolean(_nullishCoalesce(this.provider, () => ( this.detectLegacyProvider())));
195
187
  }
196
188
  async connect() {
197
189
  if (!this.provider && this.providerPromise) {
198
190
  await this.providerPromise;
199
191
  }
200
192
  if (!this.provider) {
201
- _chunkNKWY4I4Ljs.sentryLogger.error("Rabby is not available");
193
+ _chunkK6PG2PDFjs.sentryLogger.error("Rabby is not available");
202
194
  throw new Error("Rabby is not available");
203
195
  }
204
- try {
205
- await this.provider.request({
206
- method: "wallet_requestPermissions",
207
- params: [{ eth_accounts: {} }]
208
- });
209
- const accounts = await this.provider.request({
210
- method: "eth_requestAccounts",
211
- params: []
212
- });
213
- if (!accounts || accounts.length === 0 || !accounts[0]) {
214
- _chunkNKWY4I4Ljs.sentryLogger.error("No accounts returned from Rabby");
215
- throw new Error("No accounts returned from Rabby");
216
- }
217
- return {
218
- address: accounts[0],
219
- provider: this.provider,
220
- walletId: this.id
221
- };
222
- } catch (e) {
223
- throw new Error("Failed to connect to Rabby");
196
+ await this.provider.request({
197
+ method: "wallet_requestPermissions",
198
+ params: [{ eth_accounts: {} }]
199
+ });
200
+ const accounts = await this.provider.request({
201
+ method: "eth_requestAccounts",
202
+ params: []
203
+ });
204
+ if (!accounts || accounts.length === 0 || !accounts[0]) {
205
+ _chunkK6PG2PDFjs.sentryLogger.error("No accounts returned from Rabby");
206
+ throw new Error("No accounts returned from Rabby");
224
207
  }
208
+ return {
209
+ address: accounts[0],
210
+ provider: this.provider,
211
+ walletId: this.id
212
+ };
225
213
  }
226
214
  async tryRestoreConnection() {
227
215
  if (!this.provider && this.providerPromise) {
@@ -243,7 +231,7 @@ var RabbyAdapter = class {
243
231
  provider: this.provider,
244
232
  walletId: this.id
245
233
  };
246
- } catch (e2) {
234
+ } catch (e) {
247
235
  return null;
248
236
  }
249
237
  }
@@ -341,37 +329,33 @@ var BraveAdapter = class {
341
329
  return null;
342
330
  }
343
331
  isInstalled() {
344
- return Boolean(this.provider);
332
+ return Boolean(_nullishCoalesce(this.provider, () => ( this.detectLegacyProvider())));
345
333
  }
346
334
  async connect() {
347
335
  if (!this.provider && this.providerPromise) {
348
336
  await this.providerPromise;
349
337
  }
350
338
  if (!this.provider) {
351
- _chunkNKWY4I4Ljs.sentryLogger.error("Brave Wallet is not available");
339
+ _chunkK6PG2PDFjs.sentryLogger.error("Brave Wallet is not available");
352
340
  throw new Error("Brave Wallet is not available");
353
341
  }
354
- try {
355
- await this.provider.request({
356
- method: "wallet_requestPermissions",
357
- params: [{ eth_accounts: {} }]
358
- });
359
- const accounts = await this.provider.request({
360
- method: "eth_requestAccounts",
361
- params: []
362
- });
363
- if (!accounts || accounts.length === 0 || !accounts[0]) {
364
- _chunkNKWY4I4Ljs.sentryLogger.error("No accounts returned from Brave Wallet");
365
- throw new Error("No accounts returned from Brave Wallet");
366
- }
367
- return {
368
- address: accounts[0],
369
- provider: this.provider,
370
- walletId: this.id
371
- };
372
- } catch (e3) {
373
- throw new Error("Failed to connect to Brave Wallet");
342
+ await this.provider.request({
343
+ method: "wallet_requestPermissions",
344
+ params: [{ eth_accounts: {} }]
345
+ });
346
+ const accounts = await this.provider.request({
347
+ method: "eth_requestAccounts",
348
+ params: []
349
+ });
350
+ if (!accounts || accounts.length === 0 || !accounts[0]) {
351
+ _chunkK6PG2PDFjs.sentryLogger.error("No accounts returned from Brave Wallet");
352
+ throw new Error("No accounts returned from Brave Wallet");
374
353
  }
354
+ return {
355
+ address: accounts[0],
356
+ provider: this.provider,
357
+ walletId: this.id
358
+ };
375
359
  }
376
360
  async tryRestoreConnection() {
377
361
  if (!this.provider && this.providerPromise) {
@@ -393,7 +377,7 @@ var BraveAdapter = class {
393
377
  provider: this.provider,
394
378
  walletId: this.id
395
379
  };
396
- } catch (e4) {
380
+ } catch (e2) {
397
381
  return null;
398
382
  }
399
383
  }
@@ -419,123 +403,6 @@ var BraveAdapter = class {
419
403
  }
420
404
  };
421
405
 
422
- // src/wallet-adapters/LedgerAdapter.ts
423
-
424
-
425
- var _connectkitloader = require('@ledgerhq/connect-kit-loader');
426
- var _chains = require('viem/chains');
427
- var LedgerAdapter = class {
428
- constructor(config) {
429
- this.id = _types.WalletId.Ledger;
430
- this.name = _types.WalletName.Ledger;
431
- this.icon = _nullishCoalesce(_logos.getLogoDataUri.call(void 0, _types.WalletId.Ledger, "brand"), () => ( ""));
432
- this.hide = false;
433
- this.downloadUrl = "https://www.ledger.com/ledger-live";
434
- this.wcDeepLinkUrl = "ledgerlive://wc?uri=";
435
- this.provider = null;
436
- this.accountsChangedCallback = null;
437
- this.walletConnectProjectId = _optionalChain([config, 'optionalAccess', _37 => _37.walletConnectProjectId]);
438
- }
439
- isInstalled() {
440
- return true;
441
- }
442
- async connect() {
443
- try {
444
- if (!this.walletConnectProjectId) {
445
- throw _chunkNKWY4I4Ljs.createConfigError.call(void 0, "Ledger");
446
- }
447
- const { loadConnectKit } = await Promise.resolve().then(() => _interopRequireWildcard(require("@ledgerhq/connect-kit-loader")));
448
- const connectKit = await loadConnectKit();
449
- connectKit.enableDebugLogs();
450
- connectKit.checkSupport({
451
- providerType: _connectkitloader.SupportedProviders.Ethereum,
452
- chainId: 1,
453
- walletConnectVersion: 2,
454
- projectId: this.walletConnectProjectId,
455
- rpc: { 1: _chains.mainnet.rpcUrls.default.http[0] }
456
- });
457
- this.provider = await connectKit.getProvider();
458
- if (!this.provider) {
459
- _chunkNKWY4I4Ljs.sentryLogger.error("Failed to get Ledger provider");
460
- throw new Error("Failed to get Ledger provider");
461
- }
462
- const accounts = await this.provider.request({
463
- method: "eth_requestAccounts",
464
- params: []
465
- });
466
- if (!accounts || accounts.length === 0 || !accounts[0]) {
467
- _chunkNKWY4I4Ljs.sentryLogger.error("No accounts returned from Ledger");
468
- throw new Error("No accounts returned from Ledger");
469
- }
470
- return {
471
- address: accounts[0],
472
- provider: this.provider,
473
- walletId: this.id
474
- };
475
- } catch (e5) {
476
- throw new Error("Failed to connect to Ledger");
477
- }
478
- }
479
- async tryRestoreConnection() {
480
- try {
481
- const { loadConnectKit } = await Promise.resolve().then(() => _interopRequireWildcard(require("@ledgerhq/connect-kit-loader")));
482
- const connectKit = await loadConnectKit();
483
- connectKit.checkSupport({
484
- providerType: _connectkitloader.SupportedProviders.Ethereum,
485
- chainId: 1,
486
- walletConnectVersion: 2,
487
- projectId: this.walletConnectProjectId,
488
- rpc: { 1: _chains.mainnet.rpcUrls.default.http[0] }
489
- });
490
- this.provider = await connectKit.getProvider();
491
- if (!this.provider) {
492
- return null;
493
- }
494
- const accounts = await this.provider.request({
495
- method: "eth_accounts",
496
- params: []
497
- });
498
- if (!accounts || accounts.length === 0 || !accounts[0]) {
499
- return null;
500
- }
501
- return {
502
- address: accounts[0],
503
- provider: this.provider,
504
- walletId: this.id
505
- };
506
- } catch (e6) {
507
- return null;
508
- }
509
- }
510
- async disconnect() {
511
- try {
512
- const provider = this.provider;
513
- if (_optionalChain([provider, 'optionalAccess', _38 => _38.disconnect])) {
514
- await provider.disconnect();
515
- }
516
- this.provider = null;
517
- } catch (error) {
518
- _chunkNKWY4I4Ljs.sentryLogger.warn("Failed to disconnect from Ledger", { error });
519
- }
520
- }
521
- getProvider() {
522
- return this.provider;
523
- }
524
- onAccountsChanged(callback) {
525
- if (!_optionalChain([this, 'access', _39 => _39.provider, 'optionalAccess', _40 => _40.on])) return;
526
- if (this.accountsChangedCallback) {
527
- _optionalChain([this, 'access', _41 => _41.provider, 'access', _42 => _42.removeListener, 'optionalCall', _43 => _43("accountsChanged", this.accountsChangedCallback)]);
528
- }
529
- this.accountsChangedCallback = callback;
530
- this.provider.on("accountsChanged", this.accountsChangedCallback);
531
- }
532
- removeListeners() {
533
- if (!_optionalChain([this, 'access', _44 => _44.provider, 'optionalAccess', _45 => _45.removeListener]) || !this.accountsChangedCallback) return;
534
- this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
535
- this.accountsChangedCallback = null;
536
- }
537
- };
538
-
539
406
  // src/wallet-adapters/PhantomAdapter.ts
540
407
 
541
408
 
@@ -591,47 +458,43 @@ var PhantomAdapter = class {
591
458
  */
592
459
  detectLegacyProvider() {
593
460
  const phantom = window.phantom;
594
- if (_optionalChain([phantom, 'optionalAccess', _46 => _46.ethereum, 'optionalAccess', _47 => _47.isPhantom])) {
461
+ if (_optionalChain([phantom, 'optionalAccess', _37 => _37.ethereum, 'optionalAccess', _38 => _38.isPhantom])) {
595
462
  return phantom.ethereum;
596
463
  }
597
464
  const ethereum = window.ethereum;
598
- if (_optionalChain([ethereum, 'optionalAccess', _48 => _48.isPhantom])) {
465
+ if (_optionalChain([ethereum, 'optionalAccess', _39 => _39.isPhantom])) {
599
466
  return ethereum;
600
467
  }
601
468
  return null;
602
469
  }
603
470
  isInstalled() {
604
- return Boolean(this.provider);
471
+ return Boolean(_nullishCoalesce(this.provider, () => ( this.detectLegacyProvider())));
605
472
  }
606
473
  async connect() {
607
474
  if (!this.provider && this.providerPromise) {
608
475
  await this.providerPromise;
609
476
  }
610
477
  if (!this.provider) {
611
- _chunkNKWY4I4Ljs.sentryLogger.error("Phantom is not available");
478
+ _chunkK6PG2PDFjs.sentryLogger.error("Phantom is not available");
612
479
  throw new Error("Phantom is not available");
613
480
  }
614
- try {
615
- await this.provider.request({
616
- method: "wallet_requestPermissions",
617
- params: [{ eth_accounts: {} }]
618
- });
619
- const accounts = await this.provider.request({
620
- method: "eth_requestAccounts",
621
- params: []
622
- });
623
- if (!accounts || accounts.length === 0 || !accounts[0]) {
624
- _chunkNKWY4I4Ljs.sentryLogger.error("No accounts returned from Phantom");
625
- throw new Error("No accounts returned from Phantom");
626
- }
627
- return {
628
- address: accounts[0],
629
- provider: this.provider,
630
- walletId: this.id
631
- };
632
- } catch (e7) {
633
- throw new Error("Failed to connect to Phantom");
481
+ await this.provider.request({
482
+ method: "wallet_requestPermissions",
483
+ params: [{ eth_accounts: {} }]
484
+ });
485
+ const accounts = await this.provider.request({
486
+ method: "eth_requestAccounts",
487
+ params: []
488
+ });
489
+ if (!accounts || accounts.length === 0 || !accounts[0]) {
490
+ _chunkK6PG2PDFjs.sentryLogger.error("No accounts returned from Phantom");
491
+ throw new Error("No accounts returned from Phantom");
634
492
  }
493
+ return {
494
+ address: accounts[0],
495
+ provider: this.provider,
496
+ walletId: this.id
497
+ };
635
498
  }
636
499
  async tryRestoreConnection() {
637
500
  if (!this.provider && this.providerPromise) {
@@ -653,7 +516,7 @@ var PhantomAdapter = class {
653
516
  provider: this.provider,
654
517
  walletId: this.id
655
518
  };
656
- } catch (e8) {
519
+ } catch (e3) {
657
520
  return null;
658
521
  }
659
522
  }
@@ -665,15 +528,15 @@ var PhantomAdapter = class {
665
528
  // Called by Aurum when user connects wallet
666
529
  // Passes Aurum.ts --> syncStateFromAccountsChanged() to handle the provider accounts changed event
667
530
  onAccountsChanged(callback) {
668
- if (!_optionalChain([this, 'access', _49 => _49.provider, 'optionalAccess', _50 => _50.on])) return;
531
+ if (!_optionalChain([this, 'access', _40 => _40.provider, 'optionalAccess', _41 => _41.on])) return;
669
532
  if (this.accountsChangedCallback) {
670
- _optionalChain([this, 'access', _51 => _51.provider, 'access', _52 => _52.removeListener, 'optionalCall', _53 => _53("accountsChanged", this.accountsChangedCallback)]);
533
+ _optionalChain([this, 'access', _42 => _42.provider, 'access', _43 => _43.removeListener, 'optionalCall', _44 => _44("accountsChanged", this.accountsChangedCallback)]);
671
534
  }
672
535
  this.accountsChangedCallback = callback;
673
536
  this.provider.on("accountsChanged", this.accountsChangedCallback);
674
537
  }
675
538
  removeListeners() {
676
- if (!_optionalChain([this, 'access', _54 => _54.provider, 'optionalAccess', _55 => _55.removeListener]) || !this.accountsChangedCallback) return;
539
+ if (!_optionalChain([this, 'access', _45 => _45.provider, 'optionalAccess', _46 => _46.removeListener]) || !this.accountsChangedCallback) return;
677
540
  this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
678
541
  this.accountsChangedCallback = null;
679
542
  }
@@ -684,7 +547,7 @@ var _walletsdk = require('@coinbase/wallet-sdk');
684
547
 
685
548
 
686
549
  var CoinbaseWalletAdapter = class {
687
- constructor({ appName, appLogoUrl }) {
550
+ constructor({ appName, appLogoUrl, telemetry }) {
688
551
  this.id = _types.WalletId.CoinbaseWallet;
689
552
  this.name = _types.WalletName.CoinbaseWallet;
690
553
  this.icon = _nullishCoalesce(_logos.getLogoDataUri.call(void 0, _types.WalletId.CoinbaseWallet, "brand"), () => ( ""));
@@ -693,18 +556,26 @@ var CoinbaseWalletAdapter = class {
693
556
  this.wcDeepLinkUrl = "cbwallet://wc?uri=";
694
557
  this.provider = null;
695
558
  this.accountsChangedCallback = null;
696
- this.provider = this.detectProvider({ appName, appLogoUrl });
559
+ this.provider = this.detectProvider({ appName, appLogoUrl, telemetry: _nullishCoalesce(telemetry, () => ( false)) });
697
560
  }
698
- detectProvider({ appName, appLogoUrl }) {
561
+ detectProvider({
562
+ appName,
563
+ appLogoUrl,
564
+ telemetry
565
+ }) {
699
566
  if (typeof window === "undefined") return null;
700
567
  try {
701
568
  const coinbaseSdk = _walletsdk.createCoinbaseWalletSDK.call(void 0, {
702
569
  appName,
703
- appLogoUrl
570
+ appLogoUrl,
571
+ preference: {
572
+ options: "all",
573
+ telemetry
574
+ }
704
575
  });
705
576
  return coinbaseSdk.getProvider();
706
577
  } catch (error) {
707
- _chunkNKWY4I4Ljs.sentryLogger.warn("Failed to initialize Coinbase Wallet provider", { error });
578
+ _chunkK6PG2PDFjs.sentryLogger.warn("Failed to initialize Coinbase Wallet provider", { error });
708
579
  return null;
709
580
  }
710
581
  }
@@ -713,26 +584,22 @@ var CoinbaseWalletAdapter = class {
713
584
  }
714
585
  async connect() {
715
586
  if (!this.isInstalled() || !this.provider) {
716
- _chunkNKWY4I4Ljs.sentryLogger.error("Coinbase Wallet is not available");
587
+ _chunkK6PG2PDFjs.sentryLogger.error("Coinbase Wallet is not available");
717
588
  throw new Error("Coinbase Wallet is not available");
718
589
  }
719
- try {
720
- const accounts = await this.provider.request({
721
- method: "eth_requestAccounts",
722
- params: []
723
- });
724
- if (!accounts || accounts.length === 0 || !accounts[0]) {
725
- _chunkNKWY4I4Ljs.sentryLogger.error("No accounts returned from Coinbase Wallet");
726
- throw new Error("No accounts returned from Coinbase Wallet");
727
- }
728
- return {
729
- address: accounts[0],
730
- provider: this.provider,
731
- walletId: this.id
732
- };
733
- } catch (e9) {
734
- throw new Error("Failed to connect to Coinbase Wallet");
590
+ const accounts = await this.provider.request({
591
+ method: "eth_requestAccounts",
592
+ params: []
593
+ });
594
+ if (!accounts || accounts.length === 0 || !accounts[0]) {
595
+ _chunkK6PG2PDFjs.sentryLogger.error("No accounts returned from Coinbase Wallet");
596
+ throw new Error("No accounts returned from Coinbase Wallet");
735
597
  }
598
+ return {
599
+ address: accounts[0],
600
+ provider: this.provider,
601
+ walletId: this.id
602
+ };
736
603
  }
737
604
  async tryRestoreConnection() {
738
605
  if (!this.isInstalled() || !this.provider) {
@@ -751,19 +618,19 @@ var CoinbaseWalletAdapter = class {
751
618
  provider: this.provider,
752
619
  walletId: this.id
753
620
  };
754
- } catch (e10) {
621
+ } catch (e4) {
755
622
  return null;
756
623
  }
757
624
  }
758
625
  async disconnect() {
759
626
  try {
760
- if (_optionalChain([this, 'access', _56 => _56.provider, 'optionalAccess', _57 => _57.close])) {
627
+ if (_optionalChain([this, 'access', _47 => _47.provider, 'optionalAccess', _48 => _48.close])) {
761
628
  await this.provider.close();
762
- } else if (_optionalChain([this, 'access', _58 => _58.provider, 'optionalAccess', _59 => _59.disconnect])) {
629
+ } else if (_optionalChain([this, 'access', _49 => _49.provider, 'optionalAccess', _50 => _50.disconnect])) {
763
630
  await this.provider.disconnect();
764
631
  }
765
632
  } catch (error) {
766
- _chunkNKWY4I4Ljs.sentryLogger.warn("Error disconnecting from Coinbase Wallet", { error });
633
+ _chunkK6PG2PDFjs.sentryLogger.warn("Error disconnecting from Coinbase Wallet", { error });
767
634
  } finally {
768
635
  this.clearLocalStorage();
769
636
  }
@@ -787,15 +654,15 @@ var CoinbaseWalletAdapter = class {
787
654
  // Called by Aurum when user connects wallet
788
655
  // Passes Aurum.ts --> syncStateFromAccountsChanged() to handle the provider accounts changed event
789
656
  onAccountsChanged(callback) {
790
- if (!_optionalChain([this, 'access', _60 => _60.provider, 'optionalAccess', _61 => _61.on])) return;
657
+ if (!_optionalChain([this, 'access', _51 => _51.provider, 'optionalAccess', _52 => _52.on])) return;
791
658
  if (this.accountsChangedCallback) {
792
- _optionalChain([this, 'access', _62 => _62.provider, 'access', _63 => _63.removeListener, 'optionalCall', _64 => _64("accountsChanged", this.accountsChangedCallback)]);
659
+ _optionalChain([this, 'access', _53 => _53.provider, 'access', _54 => _54.removeListener, 'optionalCall', _55 => _55("accountsChanged", this.accountsChangedCallback)]);
793
660
  }
794
661
  this.accountsChangedCallback = callback;
795
662
  this.provider.on("accountsChanged", this.accountsChangedCallback);
796
663
  }
797
664
  removeListeners() {
798
- if (!_optionalChain([this, 'access', _65 => _65.provider, 'optionalAccess', _66 => _66.removeListener]) || !this.accountsChangedCallback) return;
665
+ if (!_optionalChain([this, 'access', _56 => _56.provider, 'optionalAccess', _57 => _57.removeListener]) || !this.accountsChangedCallback) return;
799
666
  this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
800
667
  this.accountsChangedCallback = null;
801
668
  }
@@ -857,7 +724,7 @@ var MetaMaskAdapter = class {
857
724
  detectLegacyProvider() {
858
725
  const ethereum = window.ethereum;
859
726
  if (!ethereum) return null;
860
- if (_optionalChain([ethereum, 'access', _67 => _67.providers, 'optionalAccess', _68 => _68.length])) {
727
+ if (_optionalChain([ethereum, 'access', _58 => _58.providers, 'optionalAccess', _59 => _59.length])) {
861
728
  const metaMaskProvider = ethereum.providers.find((p) => p.isMetaMask && !p.isBraveWallet);
862
729
  if (metaMaskProvider) return metaMaskProvider;
863
730
  }
@@ -867,37 +734,33 @@ var MetaMaskAdapter = class {
867
734
  return null;
868
735
  }
869
736
  isInstalled() {
870
- return Boolean(this.provider);
737
+ return Boolean(_nullishCoalesce(this.provider, () => ( this.detectLegacyProvider())));
871
738
  }
872
739
  async connect() {
873
740
  if (!this.provider && this.providerPromise) {
874
741
  await this.providerPromise;
875
742
  }
876
743
  if (!this.provider) {
877
- _chunkNKWY4I4Ljs.sentryLogger.error("MetaMask is not available");
744
+ _chunkK6PG2PDFjs.sentryLogger.error("MetaMask is not available");
878
745
  throw new Error("MetaMask is not available");
879
746
  }
880
- try {
881
- await this.provider.request({
882
- method: "wallet_requestPermissions",
883
- params: [{ eth_accounts: {} }]
884
- });
885
- const accounts = await this.provider.request({
886
- method: "eth_requestAccounts",
887
- params: []
888
- });
889
- if (!accounts || accounts.length === 0 || !accounts[0]) {
890
- _chunkNKWY4I4Ljs.sentryLogger.error("No accounts returned from MetaMask");
891
- throw new Error("No accounts returned from MetaMask");
892
- }
893
- return {
894
- address: accounts[0],
895
- provider: this.provider,
896
- walletId: this.id
897
- };
898
- } catch (e11) {
899
- throw new Error("Failed to connect to MetaMask");
747
+ await this.provider.request({
748
+ method: "wallet_requestPermissions",
749
+ params: [{ eth_accounts: {} }]
750
+ });
751
+ const accounts = await this.provider.request({
752
+ method: "eth_requestAccounts",
753
+ params: []
754
+ });
755
+ if (!accounts || accounts.length === 0 || !accounts[0]) {
756
+ _chunkK6PG2PDFjs.sentryLogger.error("No accounts returned from MetaMask");
757
+ throw new Error("No accounts returned from MetaMask");
900
758
  }
759
+ return {
760
+ address: accounts[0],
761
+ provider: this.provider,
762
+ walletId: this.id
763
+ };
901
764
  }
902
765
  async tryRestoreConnection() {
903
766
  if (!this.provider && this.providerPromise) {
@@ -919,7 +782,7 @@ var MetaMaskAdapter = class {
919
782
  provider: this.provider,
920
783
  walletId: this.id
921
784
  };
922
- } catch (e12) {
785
+ } catch (e5) {
923
786
  return null;
924
787
  }
925
788
  }
@@ -931,20 +794,544 @@ var MetaMaskAdapter = class {
931
794
  // Called by Aurum when user connects wallet
932
795
  // Passes Aurum.ts --> syncStateFromAccountsChanged() to handle the provider accounts changed event
933
796
  onAccountsChanged(callback) {
934
- if (!_optionalChain([this, 'access', _69 => _69.provider, 'optionalAccess', _70 => _70.on])) return;
797
+ if (!_optionalChain([this, 'access', _60 => _60.provider, 'optionalAccess', _61 => _61.on])) return;
935
798
  if (this.accountsChangedCallback) {
936
- _optionalChain([this, 'access', _71 => _71.provider, 'access', _72 => _72.removeListener, 'optionalCall', _73 => _73("accountsChanged", this.accountsChangedCallback)]);
799
+ _optionalChain([this, 'access', _62 => _62.provider, 'access', _63 => _63.removeListener, 'optionalCall', _64 => _64("accountsChanged", this.accountsChangedCallback)]);
937
800
  }
938
801
  this.accountsChangedCallback = callback;
939
802
  this.provider.on("accountsChanged", this.accountsChangedCallback);
940
803
  }
941
804
  removeListeners() {
942
- if (!_optionalChain([this, 'access', _74 => _74.provider, 'optionalAccess', _75 => _75.removeListener]) || !this.accountsChangedCallback) return;
805
+ if (!_optionalChain([this, 'access', _65 => _65.provider, 'optionalAccess', _66 => _66.removeListener]) || !this.accountsChangedCallback) return;
943
806
  this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
944
807
  this.accountsChangedCallback = null;
945
808
  }
946
809
  };
947
810
 
811
+ // src/wallet-adapters/WalletConnectAdapter.ts
812
+
813
+
814
+
815
+ // src/constants/adapters.ts
816
+ var WALLETCONNECT_NAMESPACE = {
817
+ eip155: {
818
+ methods: [
819
+ // Transaction methods
820
+ "eth_sendTransaction",
821
+ "eth_signTransaction",
822
+ "eth_sendRawTransaction",
823
+ // Signing methods
824
+ "eth_sign",
825
+ "personal_sign",
826
+ "eth_signTypedData",
827
+ "eth_signTypedData_v3",
828
+ "eth_signTypedData_v4",
829
+ // Account methods
830
+ "eth_accounts",
831
+ "eth_requestAccounts",
832
+ // Chain management
833
+ "wallet_switchEthereumChain",
834
+ "wallet_addEthereumChain",
835
+ // Permissions (EIP-2255)
836
+ "wallet_requestPermissions",
837
+ "wallet_getPermissions"
838
+ ],
839
+ chains: [
840
+ // Ethereum
841
+ "eip155:1",
842
+ // Mainnet
843
+ "eip155:11155111",
844
+ // Sepolia
845
+ // Base
846
+ "eip155:8453",
847
+ // Mainnet
848
+ "eip155:84532",
849
+ // Sepolia
850
+ // Optimism
851
+ "eip155:10",
852
+ // Mainnet
853
+ "eip155:11155420",
854
+ // Sepolia
855
+ // Arbitrum
856
+ "eip155:42161",
857
+ // Mainnet
858
+ "eip155:421614",
859
+ // Sepolia
860
+ // BNB Chain
861
+ "eip155:56",
862
+ // Mainnet
863
+ "eip155:97",
864
+ // Testnet
865
+ // Polygon
866
+ "eip155:137",
867
+ // Mainnet
868
+ "eip155:80002",
869
+ // Amoy
870
+ // Fantom
871
+ "eip155:250",
872
+ // Mainnet
873
+ "eip155:4002",
874
+ // Testnet
875
+ // Linea
876
+ "eip155:59144",
877
+ // Mainnet
878
+ "eip155:59141",
879
+ // Sepolia
880
+ // Gnosis
881
+ "eip155:100",
882
+ // Mainnet
883
+ "eip155:10200",
884
+ // Chiado
885
+ // Polygon zkEVM
886
+ "eip155:1101",
887
+ // Mainnet
888
+ "eip155:2442",
889
+ // Cardona
890
+ // Avalanche C-Chain
891
+ "eip155:43114",
892
+ // Mainnet
893
+ "eip155:43113"
894
+ // Fuji
895
+ ],
896
+ events: ["chainChanged", "accountsChanged"]
897
+ }
898
+ };
899
+
900
+ // src/wallet-adapters/WalletConnectAdapter.ts
901
+ function extractAddressFromSession(namespaces) {
902
+ const accounts = _optionalChain([namespaces, 'optionalAccess', _67 => _67.eip155, 'optionalAccess', _68 => _68.accounts]) || [];
903
+ const firstAccount = accounts[0];
904
+ return _nullishCoalesce(_optionalChain([firstAccount, 'optionalAccess', _69 => _69.split, 'call', _70 => _70(":"), 'access', _71 => _71[2]]), () => ( null));
905
+ }
906
+ var WalletConnectAdapter = class {
907
+ constructor(config) {
908
+ this.id = _types.WalletId.WalletConnect;
909
+ this.name = _types.WalletName.WalletConnect;
910
+ this.icon = _nullishCoalesce(_logos.getLogoDataUri.call(void 0, _types.WalletId.WalletConnect, "brand"), () => ( ""));
911
+ this.hide = false;
912
+ this.downloadUrl = null;
913
+ this.wcDeepLinkUrl = null;
914
+ this.modal = null;
915
+ this.wagmiAdapter = null;
916
+ this.universalProvider = null;
917
+ this.provider = null;
918
+ this.address = null;
919
+ this.connectionUri = null;
920
+ this.accountsChangedCallback = null;
921
+ this.chainChangedCallback = null;
922
+ this.disconnectCallback = null;
923
+ this.sessionUpdateHandler = null;
924
+ this.unsubscribeFunctions = [];
925
+ this.initPromise = null;
926
+ this.lastKnownAccounts = [];
927
+ this.lastKnownChainId = null;
928
+ this.config = config;
929
+ }
930
+ async ensureInitialized() {
931
+ if (this.modal) return;
932
+ if (!this.initPromise) {
933
+ this.initPromise = this.initializeAppKit();
934
+ }
935
+ await this.initPromise;
936
+ }
937
+ async initializeAppKit() {
938
+ if (typeof window === "undefined") return;
939
+ const [{ createAppKit }, { WagmiAdapter }, { mainnet }] = await Promise.all([
940
+ Promise.resolve().then(() => _interopRequireWildcard(require("@reown/appkit"))),
941
+ Promise.resolve().then(() => _interopRequireWildcard(require("@reown/appkit-adapter-wagmi"))),
942
+ Promise.resolve().then(() => _interopRequireWildcard(require("@reown/appkit/networks")))
943
+ ]);
944
+ const networks = [mainnet];
945
+ this.wagmiAdapter = new WagmiAdapter({
946
+ projectId: this.config.projectId,
947
+ networks,
948
+ ssr: true
949
+ });
950
+ this.modal = createAppKit({
951
+ adapters: [this.wagmiAdapter],
952
+ networks,
953
+ projectId: this.config.projectId,
954
+ metadata: {
955
+ name: this.config.appName,
956
+ description: this.config.appName,
957
+ url: window.location.origin,
958
+ icons: []
959
+ },
960
+ allowUnsupportedChain: true,
961
+ themeMode: this.config.theme,
962
+ themeVariables: {
963
+ "--apkt-z-index": this.config.modalZIndex + 1
964
+ },
965
+ features: {
966
+ analytics: _nullishCoalesce(this.config.telemetry, () => ( false))
967
+ }
968
+ });
969
+ this.universalProvider = await _asyncNullishCoalesce(await this.modal.getUniversalProvider(), async () => ( null));
970
+ this.setupEventListeners();
971
+ }
972
+ setupEventListeners() {
973
+ if (!this.modal) return;
974
+ const unsubscribeProviders = this.modal.subscribeProviders((state) => {
975
+ const eip155Provider = state["eip155"];
976
+ this.provider = eip155Provider || null;
977
+ if (!eip155Provider) {
978
+ this.address = null;
979
+ }
980
+ });
981
+ this.unsubscribeFunctions.push(unsubscribeProviders);
982
+ if (this.universalProvider) {
983
+ this.universalProvider.on("display_uri", (uri) => {
984
+ this.connectionUri = uri;
985
+ if (typeof window !== "undefined") {
986
+ window.dispatchEvent(new CustomEvent("walletconnect:uri", { detail: { uri } }));
987
+ }
988
+ });
989
+ this.universalProvider.on("session_delete", () => {
990
+ this.handleRemoteDisconnect();
991
+ });
992
+ this.universalProvider.on("session_expire", () => {
993
+ this.handleRemoteDisconnect();
994
+ });
995
+ }
996
+ }
997
+ /** Called when user disconnects from the wallet side (mobile app) */
998
+ handleRemoteDisconnect() {
999
+ this.connectionUri = null;
1000
+ this.address = null;
1001
+ this.provider = null;
1002
+ this.lastKnownAccounts = [];
1003
+ this.lastKnownChainId = null;
1004
+ if (this.accountsChangedCallback) {
1005
+ this.accountsChangedCallback([]);
1006
+ }
1007
+ if (this.disconnectCallback) {
1008
+ this.disconnectCallback();
1009
+ }
1010
+ if (typeof window !== "undefined") {
1011
+ window.dispatchEvent(new CustomEvent("walletconnect:disconnect"));
1012
+ }
1013
+ }
1014
+ syncAddressFromWagmi() {
1015
+ if (!_optionalChain([this, 'access', _72 => _72.wagmiAdapter, 'optionalAccess', _73 => _73.wagmiConfig])) return;
1016
+ const { state } = this.wagmiAdapter.wagmiConfig;
1017
+ if (state.current && state.connections) {
1018
+ const connection = state.connections.get(state.current);
1019
+ if (_optionalChain([connection, 'optionalAccess', _74 => _74.accounts, 'optionalAccess', _75 => _75[0]])) {
1020
+ this.address = connection.accounts[0];
1021
+ }
1022
+ }
1023
+ }
1024
+ async syncProviderFromModal() {
1025
+ if (!this.modal) return;
1026
+ try {
1027
+ const getProvidersFn = this.modal.getProviders;
1028
+ if (typeof getProvidersFn === "function") {
1029
+ const providers = getProvidersFn.call(this.modal);
1030
+ const eip155Provider = _optionalChain([providers, 'optionalAccess', _76 => _76["eip155"]]);
1031
+ if (eip155Provider) {
1032
+ this.provider = eip155Provider;
1033
+ return;
1034
+ }
1035
+ }
1036
+ if (_optionalChain([this, 'access', _77 => _77.wagmiAdapter, 'optionalAccess', _78 => _78.wagmiConfig])) {
1037
+ const { state } = this.wagmiAdapter.wagmiConfig;
1038
+ if (state.current && state.connections) {
1039
+ const connection = state.connections.get(state.current);
1040
+ const connector = _optionalChain([connection, 'optionalAccess', _79 => _79.connector]);
1041
+ if (connector && typeof connector.getProvider === "function") {
1042
+ try {
1043
+ const provider = await connector.getProvider();
1044
+ if (provider) {
1045
+ this.provider = provider;
1046
+ }
1047
+ } catch (error) {
1048
+ _chunkK6PG2PDFjs.sentryLogger.warn("Failed to get provider from wagmi connector", { error });
1049
+ }
1050
+ }
1051
+ }
1052
+ }
1053
+ } catch (error) {
1054
+ _chunkK6PG2PDFjs.sentryLogger.warn("Failed to get provider from WalletConnect", { error });
1055
+ }
1056
+ }
1057
+ isInstalled() {
1058
+ return true;
1059
+ }
1060
+ getConnectionUri() {
1061
+ return this.connectionUri;
1062
+ }
1063
+ /** Resets connection state for a fresh connection flow */
1064
+ async resetConnectionState() {
1065
+ this.connectionUri = null;
1066
+ this.address = null;
1067
+ this.lastKnownAccounts = [];
1068
+ this.lastKnownChainId = null;
1069
+ try {
1070
+ const { state } = _optionalChain([this, 'access', _80 => _80.wagmiAdapter, 'optionalAccess', _81 => _81.wagmiConfig]) || {};
1071
+ const connection = _optionalChain([state, 'optionalAccess', _82 => _82.current]) && _optionalChain([state, 'access', _83 => _83.connections, 'optionalAccess', _84 => _84.get, 'call', _85 => _85(state.current)]);
1072
+ if (connection && typeof connection !== "string" && _optionalChain([connection, 'access', _86 => _86.connector, 'optionalAccess', _87 => _87.disconnect])) {
1073
+ await connection.connector.disconnect();
1074
+ }
1075
+ } catch (e6) {
1076
+ }
1077
+ if (_optionalChain([this, 'access', _88 => _88.modal, 'optionalAccess', _89 => _89.getIsConnectedState, 'call', _90 => _90()])) {
1078
+ try {
1079
+ await this.modal.disconnect("eip155");
1080
+ } catch (e7) {
1081
+ }
1082
+ }
1083
+ if (_optionalChain([this, 'access', _91 => _91.universalProvider, 'optionalAccess', _92 => _92.session])) {
1084
+ try {
1085
+ await this.universalProvider.disconnect();
1086
+ } catch (e8) {
1087
+ }
1088
+ }
1089
+ await new Promise((r) => setTimeout(r, 200));
1090
+ this.provider = null;
1091
+ }
1092
+ /**
1093
+ * Connects via WalletConnect QR code flow.
1094
+ * Emits walletconnect:uri event for QR code display.
1095
+ */
1096
+ async connect() {
1097
+ if (!this.config.projectId) throw _chunkK6PG2PDFjs.createConfigError.call(void 0, "WalletConnect");
1098
+ await this.ensureInitialized();
1099
+ if (!this.universalProvider) throw new Error("WalletConnect is not available");
1100
+ await this.resetConnectionState();
1101
+ try {
1102
+ const session = await this.universalProvider.connect({ namespaces: WALLETCONNECT_NAMESPACE });
1103
+ if (!session) throw new Error("Failed to establish WalletConnect session");
1104
+ const address = extractAddressFromSession(session.namespaces);
1105
+ if (!address) throw new Error("No accounts returned from WalletConnect");
1106
+ this.provider = this.universalProvider;
1107
+ this.address = address;
1108
+ this.lastKnownAccounts = [address];
1109
+ return { address, provider: this.provider, walletId: this.id };
1110
+ } catch (error) {
1111
+ this.connectionUri = null;
1112
+ throw error;
1113
+ }
1114
+ }
1115
+ /**
1116
+ * Starts a WalletConnect session for headless/custom QR code flows.
1117
+ * Returns the URI immediately and a function to wait for the connection.
1118
+ */
1119
+ async startSession(timeout = 1e4) {
1120
+ if (!this.config.projectId) throw new Error("WalletConnect projectId is required");
1121
+ await this.ensureInitialized();
1122
+ if (!this.universalProvider) throw new Error("WalletConnect is not available");
1123
+ await this.resetConnectionState();
1124
+ const uriPromise = new Promise((resolve, reject) => {
1125
+ const timeoutId = setTimeout(() => reject(new Error("Timeout waiting for WalletConnect URI")), timeout);
1126
+ this.universalProvider.once("display_uri", (uri2) => {
1127
+ clearTimeout(timeoutId);
1128
+ this.connectionUri = uri2;
1129
+ resolve(uri2);
1130
+ });
1131
+ });
1132
+ const connectionPromise = (async () => {
1133
+ const session = await this.universalProvider.connect({ namespaces: WALLETCONNECT_NAMESPACE });
1134
+ if (!session) throw new Error("Failed to establish WalletConnect session");
1135
+ const address = extractAddressFromSession(session.namespaces);
1136
+ if (!address) throw new Error("No accounts returned from WalletConnect");
1137
+ this.provider = this.universalProvider;
1138
+ this.address = address;
1139
+ this.lastKnownAccounts = [address];
1140
+ return { address, provider: this.provider, walletId: this.id };
1141
+ })();
1142
+ const uri = await uriPromise;
1143
+ return {
1144
+ uri,
1145
+ waitForConnection: async () => {
1146
+ try {
1147
+ return await connectionPromise;
1148
+ } catch (error) {
1149
+ this.connectionUri = null;
1150
+ throw error;
1151
+ }
1152
+ }
1153
+ };
1154
+ }
1155
+ /**
1156
+ * Opens the AppKit modal for wallet selection.
1157
+ * Used on mobile and when user clicks "Open Modal" button.
1158
+ */
1159
+ async openModal() {
1160
+ if (!this.config.projectId) throw _chunkK6PG2PDFjs.createConfigError.call(void 0, "WalletConnect");
1161
+ await this.ensureInitialized();
1162
+ if (!this.modal) throw new Error("AppKit is not available");
1163
+ await this.resetConnectionState();
1164
+ this.modal.open({ view: "AllWallets" });
1165
+ return this.waitForModalConnection();
1166
+ }
1167
+ waitForModalConnection(timeout = 6e4) {
1168
+ return new Promise((resolve, reject) => {
1169
+ const startTime = Date.now();
1170
+ let unsubscribe = null;
1171
+ let resolved = false;
1172
+ const cleanup = () => _optionalChain([unsubscribe, 'optionalCall', _93 => _93()]);
1173
+ const checkConnection = async () => {
1174
+ if (resolved) return true;
1175
+ this.syncAddressFromWagmi();
1176
+ if (this.address && !this.provider) await this.syncProviderFromModal();
1177
+ if (this.provider && this.address) {
1178
+ try {
1179
+ const accounts = await this.provider.request({ method: "eth_accounts" });
1180
+ if (_optionalChain([accounts, 'optionalAccess', _94 => _94.length])) {
1181
+ resolved = true;
1182
+ cleanup();
1183
+ _optionalChain([this, 'access', _95 => _95.modal, 'optionalAccess', _96 => _96.close, 'call', _97 => _97()]);
1184
+ this.lastKnownAccounts = accounts;
1185
+ resolve({ address: this.address, provider: this.provider, walletId: this.id });
1186
+ return true;
1187
+ }
1188
+ } catch (e9) {
1189
+ }
1190
+ }
1191
+ return false;
1192
+ };
1193
+ unsubscribe = this.modal.subscribeState(async (state) => {
1194
+ if (await checkConnection()) return;
1195
+ if (!state.open && !this.address && !resolved) {
1196
+ cleanup();
1197
+ reject(new Error("Connection rejected by user"));
1198
+ }
1199
+ });
1200
+ const poll = async () => {
1201
+ if (await checkConnection()) return;
1202
+ if (Date.now() - startTime > timeout) {
1203
+ cleanup();
1204
+ reject(new Error("Connection timeout"));
1205
+ return;
1206
+ }
1207
+ setTimeout(poll, 500);
1208
+ };
1209
+ poll();
1210
+ });
1211
+ }
1212
+ async tryRestoreConnection() {
1213
+ await this.ensureInitialized();
1214
+ if (!this.wagmiAdapter) return null;
1215
+ try {
1216
+ await new Promise((r) => setTimeout(r, 1e3));
1217
+ const { state } = this.wagmiAdapter.wagmiConfig || {};
1218
+ const connection = _optionalChain([state, 'optionalAccess', _98 => _98.current]) && _optionalChain([state, 'access', _99 => _99.connections, 'optionalAccess', _100 => _100.get, 'call', _101 => _101(state.current)]);
1219
+ if (!connection || typeof connection === "string") return null;
1220
+ const address = _optionalChain([connection, 'access', _102 => _102.accounts, 'optionalAccess', _103 => _103[0]]);
1221
+ if (address && this.provider) {
1222
+ this.address = address;
1223
+ this.lastKnownAccounts = [...connection.accounts || []];
1224
+ return { address, provider: this.provider, walletId: this.id };
1225
+ }
1226
+ return null;
1227
+ } catch (e10) {
1228
+ return null;
1229
+ }
1230
+ }
1231
+ async disconnect() {
1232
+ if (this.modal) {
1233
+ await this.modal.disconnect("eip155");
1234
+ const deadline = Date.now() + 2e3;
1235
+ while (Date.now() < deadline && (this.modal.getIsConnectedState() || this.modal.getAddress())) {
1236
+ await new Promise((r) => setTimeout(r, 100));
1237
+ }
1238
+ }
1239
+ this.address = null;
1240
+ this.provider = null;
1241
+ this.connectionUri = null;
1242
+ this.lastKnownAccounts = [];
1243
+ this.lastKnownChainId = null;
1244
+ }
1245
+ getProvider() {
1246
+ return this.provider;
1247
+ }
1248
+ onAccountsChanged(callback) {
1249
+ if (this.accountsChangedCallback && _optionalChain([this, 'access', _104 => _104.provider, 'optionalAccess', _105 => _105.removeListener])) {
1250
+ this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
1251
+ }
1252
+ if (this.sessionUpdateHandler && _optionalChain([this, 'access', _106 => _106.universalProvider, 'optionalAccess', _107 => _107.removeListener])) {
1253
+ this.universalProvider.removeListener("session_update", this.sessionUpdateHandler);
1254
+ }
1255
+ if (!this.lastKnownAccounts.length && this.address) this.lastKnownAccounts = [this.address];
1256
+ this.accountsChangedCallback = (accounts) => {
1257
+ this.address = accounts[0] || null;
1258
+ this.lastKnownAccounts = accounts;
1259
+ callback(accounts);
1260
+ };
1261
+ if (_optionalChain([this, 'access', _108 => _108.provider, 'optionalAccess', _109 => _109.on])) {
1262
+ this.provider.on("accountsChanged", this.accountsChangedCallback);
1263
+ }
1264
+ if (_optionalChain([this, 'access', _110 => _110.universalProvider, 'optionalAccess', _111 => _111.on])) {
1265
+ this.sessionUpdateHandler = (args) => {
1266
+ const accounts = this.extractAccountsFromNamespaces(_optionalChain([args, 'optionalAccess', _112 => _112.params, 'optionalAccess', _113 => _113.namespaces]));
1267
+ if (accounts.length && this.hasAccountsChanged(accounts)) {
1268
+ this.lastKnownAccounts = accounts;
1269
+ this.address = accounts[0];
1270
+ callback(accounts);
1271
+ }
1272
+ };
1273
+ this.universalProvider.on("session_update", this.sessionUpdateHandler);
1274
+ }
1275
+ }
1276
+ onChainChanged(callback) {
1277
+ if (!_optionalChain([this, 'access', _114 => _114.provider, 'optionalAccess', _115 => _115.on])) return;
1278
+ if (this.chainChangedCallback) _optionalChain([this, 'access', _116 => _116.provider, 'access', _117 => _117.removeListener, 'optionalCall', _118 => _118("chainChanged", this.chainChangedCallback)]);
1279
+ this.chainChangedCallback = (chainId) => {
1280
+ const normalized = typeof chainId === "string" ? chainId : `0x${Number(chainId).toString(16)}`;
1281
+ if (normalized !== this.lastKnownChainId) {
1282
+ this.lastKnownChainId = normalized;
1283
+ callback(normalized);
1284
+ }
1285
+ };
1286
+ this.provider.on("chainChanged", this.chainChangedCallback);
1287
+ }
1288
+ /** Called when remote wallet disconnects (user disconnects from mobile app) */
1289
+ onDisconnect(callback) {
1290
+ this.disconnectCallback = callback;
1291
+ }
1292
+ /** Updates the AppKit modal theme */
1293
+ updateTheme(theme) {
1294
+ this.config.theme = theme;
1295
+ if (this.modal && typeof this.modal.setThemeMode === "function") {
1296
+ this.modal.setThemeMode(theme);
1297
+ }
1298
+ }
1299
+ extractAccountsFromNamespaces(namespaces) {
1300
+ if (!namespaces) return [];
1301
+ const accounts = [];
1302
+ Object.values(namespaces).forEach((ns) => {
1303
+ _optionalChain([ns, 'optionalAccess', _119 => _119.accounts, 'optionalAccess', _120 => _120.forEach, 'call', _121 => _121((account) => {
1304
+ const address = account.split(":")[2];
1305
+ if (address) accounts.push(address);
1306
+ })]);
1307
+ });
1308
+ return [...new Set(accounts)];
1309
+ }
1310
+ hasAccountsChanged(newAccounts) {
1311
+ if (newAccounts.length !== this.lastKnownAccounts.length) return true;
1312
+ return newAccounts.some((acc, i) => acc.toLowerCase() !== _optionalChain([this, 'access', _122 => _122.lastKnownAccounts, 'access', _123 => _123[i], 'optionalAccess', _124 => _124.toLowerCase, 'call', _125 => _125()]));
1313
+ }
1314
+ removeListeners() {
1315
+ if (this.accountsChangedCallback) {
1316
+ _optionalChain([this, 'access', _126 => _126.provider, 'optionalAccess', _127 => _127.removeListener, 'optionalCall', _128 => _128("accountsChanged", this.accountsChangedCallback)]);
1317
+ this.accountsChangedCallback = null;
1318
+ }
1319
+ if (this.chainChangedCallback) {
1320
+ _optionalChain([this, 'access', _129 => _129.provider, 'optionalAccess', _130 => _130.removeListener, 'optionalCall', _131 => _131("chainChanged", this.chainChangedCallback)]);
1321
+ this.chainChangedCallback = null;
1322
+ }
1323
+ if (this.sessionUpdateHandler) {
1324
+ _optionalChain([this, 'access', _132 => _132.universalProvider, 'optionalAccess', _133 => _133.removeListener, 'optionalCall', _134 => _134("session_update", this.sessionUpdateHandler)]);
1325
+ this.sessionUpdateHandler = null;
1326
+ }
1327
+ this.disconnectCallback = null;
1328
+ this.unsubscribeFunctions.forEach((unsub) => unsub());
1329
+ this.unsubscribeFunctions = [];
1330
+ this.lastKnownAccounts = [];
1331
+ this.lastKnownChainId = null;
1332
+ }
1333
+ };
1334
+
948
1335
  // src/wallet-adapters/EmailAdapter.ts
949
1336
 
950
1337
 
@@ -959,7 +1346,8 @@ var _EmailAdapter = class _EmailAdapter {
959
1346
  this.provider = null;
960
1347
  this.initPromise = null;
961
1348
  this.publicClientCache = /* @__PURE__ */ new Map();
962
- this.projectId = _optionalChain([config, 'optionalAccess', _76 => _76.projectId]) || "";
1349
+ this.projectId = _optionalChain([config, 'optionalAccess', _135 => _135.projectId]) || "";
1350
+ this.telemetry = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _136 => _136.telemetry]), () => ( false));
963
1351
  }
964
1352
  async ensureInitialized() {
965
1353
  if (this.provider) return;
@@ -973,11 +1361,11 @@ var _EmailAdapter = class _EmailAdapter {
973
1361
  }
974
1362
  async emailAuthStart(email) {
975
1363
  if (!this.projectId) {
976
- throw _chunkNKWY4I4Ljs.createConfigError.call(void 0, "Email");
1364
+ throw _chunkK6PG2PDFjs.createConfigError.call(void 0, "Email");
977
1365
  }
978
1366
  await this.ensureInitialized();
979
1367
  if (!this.provider) {
980
- _chunkNKWY4I4Ljs.sentryLogger.error("Email is not available");
1368
+ _chunkK6PG2PDFjs.sentryLogger.error("Email is not available");
981
1369
  throw new Error("Email is not available");
982
1370
  }
983
1371
  try {
@@ -985,7 +1373,7 @@ var _EmailAdapter = class _EmailAdapter {
985
1373
  const authResult = await signInWithEmail({ email });
986
1374
  return authResult;
987
1375
  } catch (error) {
988
- _chunkNKWY4I4Ljs.sentryLogger.error("Failed to start email authentication", { error });
1376
+ _chunkK6PG2PDFjs.sentryLogger.error("Failed to start email authentication", { error });
989
1377
  throw error;
990
1378
  }
991
1379
  }
@@ -995,14 +1383,14 @@ var _EmailAdapter = class _EmailAdapter {
995
1383
  }
996
1384
  await this.ensureInitialized();
997
1385
  if (!this.provider) {
998
- _chunkNKWY4I4Ljs.sentryLogger.error("Email provider not initialized");
1386
+ _chunkK6PG2PDFjs.sentryLogger.error("Email provider not initialized");
999
1387
  throw new Error("Email provider not initialized");
1000
1388
  }
1001
1389
  const { verifyEmailOTP } = await Promise.resolve().then(() => _interopRequireWildcard(require("@coinbase/cdp-core")));
1002
1390
  return verifyEmailOTP({ flowId, otp });
1003
1391
  }
1004
1392
  async connect() {
1005
- _chunkNKWY4I4Ljs.sentryLogger.error("EmailAdapter.connect() is not implemented");
1393
+ _chunkK6PG2PDFjs.sentryLogger.error("EmailAdapter.connect() is not implemented");
1006
1394
  throw new Error("EmailAdapter.connect() is not implemented");
1007
1395
  }
1008
1396
  async tryRestoreConnection() {
@@ -1023,7 +1411,7 @@ var _EmailAdapter = class _EmailAdapter {
1023
1411
  provider: this.provider,
1024
1412
  walletId: this.id
1025
1413
  };
1026
- } catch (e13) {
1414
+ } catch (e11) {
1027
1415
  return null;
1028
1416
  }
1029
1417
  }
@@ -1032,7 +1420,7 @@ var _EmailAdapter = class _EmailAdapter {
1032
1420
  await this.ensureInitialized();
1033
1421
  const { signOut } = await Promise.resolve().then(() => _interopRequireWildcard(require("@coinbase/cdp-core")));
1034
1422
  await signOut();
1035
- } catch (e14) {
1423
+ } catch (e12) {
1036
1424
  }
1037
1425
  }
1038
1426
  getProvider() {
@@ -1081,7 +1469,8 @@ var _EmailAdapter = class _EmailAdapter {
1081
1469
  projectId: this.projectId,
1082
1470
  ethereum: {
1083
1471
  createOnLogin: "eoa"
1084
- }
1472
+ },
1473
+ disableAnalytics: !this.telemetry
1085
1474
  });
1086
1475
  this.provider = await this.createProvider();
1087
1476
  }
@@ -1106,15 +1495,15 @@ var _EmailAdapter = class _EmailAdapter {
1106
1495
  try {
1107
1496
  return await base.request(args);
1108
1497
  } catch (err) {
1109
- const msg = String(_optionalChain([err, 'optionalAccess', _77 => _77.message]) || "");
1110
- const isUnsupported = msg.includes("not supported") || msg.includes("Unsupported") || _optionalChain([err, 'optionalAccess', _78 => _78.code]) === -32601;
1498
+ const msg = String(_optionalChain([err, 'optionalAccess', _137 => _137.message]) || "");
1499
+ const isUnsupported = msg.includes("not supported") || msg.includes("Unsupported") || _optionalChain([err, 'optionalAccess', _138 => _138.code]) === -32601;
1111
1500
  if (isUnsupported) {
1112
1501
  let chainId;
1113
1502
  try {
1114
1503
  const chainIdHex = await base.request({ method: "eth_chainId", params: [] });
1115
1504
  chainId = parseInt(chainIdHex, 16);
1116
- } catch (e15) {
1117
- _chunkNKWY4I4Ljs.sentryLogger.error("Failed to get chainId for fallback request");
1505
+ } catch (e13) {
1506
+ _chunkK6PG2PDFjs.sentryLogger.error("Failed to get chainId for fallback request");
1118
1507
  throw new Error("Failed to get chainId for fallback request");
1119
1508
  }
1120
1509
  const publicClient = await getPublicClient(chainId);
@@ -1129,7 +1518,7 @@ var _EmailAdapter = class _EmailAdapter {
1129
1518
  };
1130
1519
  return wrapped;
1131
1520
  } catch (error) {
1132
- _chunkNKWY4I4Ljs.sentryLogger.error("Failed to initialize Email provider", { error });
1521
+ _chunkK6PG2PDFjs.sentryLogger.error("Failed to initialize Email provider", { error });
1133
1522
  return null;
1134
1523
  }
1135
1524
  }
@@ -1151,18 +1540,23 @@ function createWalletAdapters({
1151
1540
  appName,
1152
1541
  appLogoUrl,
1153
1542
  modalZIndex,
1154
- theme
1543
+ theme,
1544
+ telemetry
1155
1545
  }) {
1156
1546
  return [
1157
- new EmailAdapter({ projectId: _optionalChain([walletsConfig, 'optionalAccess', _79 => _79.embedded, 'optionalAccess', _80 => _80.projectId]) }),
1547
+ new EmailAdapter({ projectId: _optionalChain([walletsConfig, 'optionalAccess', _139 => _139.embedded, 'optionalAccess', _140 => _140.projectId]), telemetry }),
1158
1548
  new MetaMaskAdapter(),
1159
- new (0, _chunkNKWY4I4Ljs.WalletConnectAdapter)({ projectId: _optionalChain([walletsConfig, 'optionalAccess', _81 => _81.walletConnect, 'optionalAccess', _82 => _82.projectId]), appName }),
1160
- new CoinbaseWalletAdapter({ appName, appLogoUrl }),
1549
+ new WalletConnectAdapter({
1550
+ projectId: _optionalChain([walletsConfig, 'optionalAccess', _141 => _141.walletConnect, 'optionalAccess', _142 => _142.projectId]),
1551
+ appName,
1552
+ modalZIndex,
1553
+ theme,
1554
+ telemetry
1555
+ }),
1556
+ new CoinbaseWalletAdapter({ appName, appLogoUrl, telemetry }),
1161
1557
  new PhantomAdapter(),
1162
1558
  new RabbyAdapter(),
1163
- new BraveAdapter(),
1164
- new LedgerAdapter({ walletConnectProjectId: _optionalChain([walletsConfig, 'optionalAccess', _83 => _83.walletConnect, 'optionalAccess', _84 => _84.projectId]) }),
1165
- new (0, _chunkNKWY4I4Ljs.AppKitAdapter)({ projectId: _optionalChain([walletsConfig, 'optionalAccess', _85 => _85.walletConnect, 'optionalAccess', _86 => _86.projectId]), appName, modalZIndex, theme })
1559
+ new BraveAdapter()
1166
1560
  ];
1167
1561
  }
1168
1562
 
@@ -1170,6 +1564,26 @@ function createWalletAdapters({
1170
1564
 
1171
1565
 
1172
1566
  // src/providers/RpcProvider.ts
1567
+ var ProviderRpcError = class extends Error {
1568
+ constructor(code, message, data) {
1569
+ super(message);
1570
+ this.name = "ProviderRpcError";
1571
+ this.code = code;
1572
+ this.data = data;
1573
+ }
1574
+ };
1575
+ var ProviderErrorCode = {
1576
+ USER_REJECTED: 4001,
1577
+ // User rejected the request
1578
+ UNAUTHORIZED: 4100,
1579
+ // The requested account/method has not been authorized
1580
+ UNSUPPORTED_METHOD: 4200,
1581
+ // The provider does not support the requested method
1582
+ DISCONNECTED: 4900,
1583
+ // The provider is disconnected from all chains
1584
+ CHAIN_DISCONNECTED: 4901
1585
+ // The provider is not connected to the requested chain
1586
+ };
1173
1587
  var RpcProvider = class {
1174
1588
  constructor(handleConnect) {
1175
1589
  this.isConnected = false;
@@ -1191,7 +1605,10 @@ var RpcProvider = class {
1191
1605
  const address = await this.handleConnect();
1192
1606
  return [address];
1193
1607
  } else {
1194
- throw new Error("No wallet connection available. Please use aurum.connect() instead.");
1608
+ throw new ProviderRpcError(
1609
+ ProviderErrorCode.DISCONNECTED,
1610
+ "No wallet connection available. Please use aurum.connect() instead."
1611
+ );
1195
1612
  }
1196
1613
  // Chain/network information
1197
1614
  case "eth_chainId":
@@ -1200,8 +1617,9 @@ var RpcProvider = class {
1200
1617
  return this.networkVersion;
1201
1618
  // Default case for rest of methods
1202
1619
  default:
1203
- throw new Error(
1204
- `Method ${method} requires an active connection to a JSON-RPC provider. Please connect a wallet.`
1620
+ throw new ProviderRpcError(
1621
+ ProviderErrorCode.DISCONNECTED,
1622
+ `Method ${method} requires an active wallet connection. Please connect a wallet first.`
1205
1623
  );
1206
1624
  }
1207
1625
  }
@@ -1229,15 +1647,16 @@ var _AurumCore = class _AurumCore {
1229
1647
  return _AurumCore.instance;
1230
1648
  }
1231
1649
  const telemetryEnabled = config.telemetry !== false;
1232
- _chunkNKWY4I4Ljs.initSentry.call(void 0, telemetryEnabled);
1650
+ _chunkK6PG2PDFjs.initSentry.call(void 0, telemetryEnabled);
1233
1651
  this.brandConfig = this.resolveBrandConfig(config);
1234
- this.excludedWallets = new Set(_nullishCoalesce(_optionalChain([config, 'access', _87 => _87.wallets, 'optionalAccess', _88 => _88.exclude]), () => ( [])));
1652
+ this.excludedWallets = new Set(_nullishCoalesce(_optionalChain([config, 'access', _143 => _143.wallets, 'optionalAccess', _144 => _144.exclude]), () => ( [])));
1235
1653
  this.wallets = createWalletAdapters({
1236
1654
  walletsConfig: config.wallets,
1237
1655
  appName: this.brandConfig.appName,
1238
1656
  appLogoUrl: this.brandConfig.logo,
1239
1657
  modalZIndex: this.brandConfig.modalZIndex,
1240
- theme: this.brandConfig.theme
1658
+ theme: this.brandConfig.theme,
1659
+ telemetry: telemetryEnabled
1241
1660
  });
1242
1661
  this.skeletonProvider = new RpcProvider(() => this.connect());
1243
1662
  this.currentProvider = this.skeletonProvider;
@@ -1248,7 +1667,7 @@ var _AurumCore = class _AurumCore {
1248
1667
  async whenReady() {
1249
1668
  try {
1250
1669
  await this.readyPromise;
1251
- } catch (e16) {
1670
+ } catch (e14) {
1252
1671
  this.resetConnectionState();
1253
1672
  this.ready = true;
1254
1673
  }
@@ -1267,7 +1686,7 @@ var _AurumCore = class _AurumCore {
1267
1686
  if (walletId === "email") {
1268
1687
  throw new Error("Use emailAuthStart() and emailAuthVerify() for email wallet connections");
1269
1688
  }
1270
- if (_optionalChain([this, 'access', _89 => _89.userInfo, 'optionalAccess', _90 => _90.publicAddress]) && _optionalChain([this, 'access', _91 => _91.connectedWalletAdapter, 'optionalAccess', _92 => _92.getProvider, 'call', _93 => _93()])) {
1689
+ if (_optionalChain([this, 'access', _145 => _145.userInfo, 'optionalAccess', _146 => _146.publicAddress]) && _optionalChain([this, 'access', _147 => _147.connectedWalletAdapter, 'optionalAccess', _148 => _148.getProvider, 'call', _149 => _149()])) {
1271
1690
  if (!walletId || this.userInfo.walletId === walletId) {
1272
1691
  return this.userInfo.publicAddress;
1273
1692
  }
@@ -1275,44 +1694,39 @@ var _AurumCore = class _AurumCore {
1275
1694
  }
1276
1695
  let adapter = null;
1277
1696
  let result;
1278
- if (walletId === _types.WalletId.WalletConnect) {
1279
- if (this.excludedWallets.has(walletId)) {
1280
- throw new Error(`${walletId} is excluded from wallet options`);
1281
- }
1282
- adapter = this.wallets.find((w) => w instanceof _chunkNKWY4I4Ljs.AppKitAdapter) || null;
1283
- if (!adapter) {
1284
- throw new Error("WalletConnect is not enabled");
1285
- }
1286
- result = await adapter.connect();
1287
- } else if (walletId) {
1697
+ if (walletId) {
1288
1698
  if (this.excludedWallets.has(walletId)) {
1289
1699
  throw new Error(`${walletId} is excluded from wallet options`);
1290
1700
  }
1291
1701
  adapter = this.wallets.find((w) => w.id === walletId) || null;
1292
1702
  if (!adapter) {
1293
- throw new Error(`${walletId} is not enabled`);
1703
+ throw new Error(`${walletId} is not configured`);
1294
1704
  }
1295
- if (!adapter.isInstalled()) {
1296
- throw new Error(`${adapter.name} is not installed`);
1705
+ if (walletId === _types.WalletId.WalletConnect && adapter.openModal) {
1706
+ result = await adapter.openModal();
1707
+ } else {
1708
+ if (!adapter.isInstalled()) {
1709
+ throw new Error(`${adapter.name} is not installed`);
1710
+ }
1711
+ result = await adapter.connect();
1297
1712
  }
1298
- result = await adapter.connect();
1299
1713
  } else {
1300
1714
  const displayedWallets = this.wallets.filter((w) => !this.excludedWallets.has(w.id));
1301
1715
  const modalResult = await renderConnectModal({ displayedWallets, brandConfig: this.brandConfig });
1302
1716
  if (!modalResult) {
1303
- _chunkNKWY4I4Ljs.sentryLogger.error("Missing modal result");
1717
+ _chunkK6PG2PDFjs.sentryLogger.error("Missing modal result");
1304
1718
  throw new Error("Missing modal result");
1305
1719
  }
1306
1720
  adapter = this.wallets.find((w) => w.id === modalResult.walletId) || null;
1307
1721
  if (!adapter) {
1308
- _chunkNKWY4I4Ljs.sentryLogger.error(`Selected wallet adapter not found: ${modalResult.walletId}`);
1722
+ _chunkK6PG2PDFjs.sentryLogger.error(`Selected wallet adapter not found: ${modalResult.walletId}`);
1309
1723
  throw new Error("Selected wallet adapter not found");
1310
1724
  }
1311
1725
  result = modalResult;
1312
1726
  }
1313
1727
  const provider = _nullishCoalesce(result.provider, () => ( adapter.getProvider()));
1314
1728
  if (!provider) {
1315
- _chunkNKWY4I4Ljs.sentryLogger.error(`Error fetching provider on login: ${adapter.id}`);
1729
+ _chunkK6PG2PDFjs.sentryLogger.error(`Error fetching provider on login: ${adapter.id}`);
1316
1730
  throw new Error("Error fetching provider. Please try again.");
1317
1731
  }
1318
1732
  const checksumAdr = _viem.checksumAddress.call(void 0, result.address);
@@ -1329,7 +1743,7 @@ var _AurumCore = class _AurumCore {
1329
1743
  const chainId = await provider.request({ method: "eth_chainId" });
1330
1744
  this.emitConnect(chainId);
1331
1745
  this.emitAccountsChanged([checksumAdr]);
1332
- _chunkNKWY4I4Ljs.sentryLogger.info(`Wallet connected: ${adapter.id} (${walletId ? "headless" : "modal"})`);
1746
+ _chunkK6PG2PDFjs.sentryLogger.info(`Wallet connected: ${adapter.id} (${walletId ? "headless" : "modal"})`);
1333
1747
  return checksumAdr;
1334
1748
  }
1335
1749
  async disconnect() {
@@ -1349,7 +1763,7 @@ var _AurumCore = class _AurumCore {
1349
1763
  async isConnected() {
1350
1764
  await this.whenReady();
1351
1765
  return Boolean(
1352
- _optionalChain([this, 'access', _94 => _94.userInfo, 'optionalAccess', _95 => _95.publicAddress]) && _optionalChain([this, 'access', _96 => _96.userInfo, 'optionalAccess', _97 => _97.walletName]) && _optionalChain([this, 'access', _98 => _98.connectedWalletAdapter, 'optionalAccess', _99 => _99.getProvider, 'call', _100 => _100()])
1766
+ _optionalChain([this, 'access', _150 => _150.userInfo, 'optionalAccess', _151 => _151.publicAddress]) && _optionalChain([this, 'access', _152 => _152.userInfo, 'optionalAccess', _153 => _153.walletName]) && _optionalChain([this, 'access', _154 => _154.connectedWalletAdapter, 'optionalAccess', _155 => _155.getProvider, 'call', _156 => _156()])
1353
1767
  );
1354
1768
  }
1355
1769
  async handleWidgetConnection(result) {
@@ -1358,7 +1772,7 @@ var _AurumCore = class _AurumCore {
1358
1772
  if (!adapter) throw new Error("Selected wallet adapter not found");
1359
1773
  const provider = _nullishCoalesce(result.provider, () => ( adapter.getProvider()));
1360
1774
  if (!provider) {
1361
- _chunkNKWY4I4Ljs.sentryLogger.error(`Error fetching provider on widget login: ${_optionalChain([result, 'optionalAccess', _101 => _101.walletId])}`);
1775
+ _chunkK6PG2PDFjs.sentryLogger.error(`Error fetching provider on widget login: ${_optionalChain([result, 'optionalAccess', _157 => _157.walletId])}`);
1362
1776
  throw new Error("Error fetching provider. Please try again.");
1363
1777
  }
1364
1778
  const checksumAdr = _viem.checksumAddress.call(void 0, result.address);
@@ -1375,7 +1789,7 @@ var _AurumCore = class _AurumCore {
1375
1789
  const chainId = await provider.request({ method: "eth_chainId" });
1376
1790
  this.emitConnect(chainId);
1377
1791
  this.emitAccountsChanged([checksumAdr]);
1378
- _chunkNKWY4I4Ljs.sentryLogger.info(`Wallet connected: ${adapter.id} (widget)`);
1792
+ _chunkK6PG2PDFjs.sentryLogger.info(`Wallet connected: ${adapter.id} (widget)`);
1379
1793
  return this.userInfo;
1380
1794
  }
1381
1795
  async getChainId() {
@@ -1394,7 +1808,7 @@ var _AurumCore = class _AurumCore {
1394
1808
  }
1395
1809
  }
1396
1810
  updateBrandConfig(newConfig) {
1397
- const defaultTheme = _chunkNKWY4I4Ljs.getDefaultThemeConfig.call(void 0, _nullishCoalesce(newConfig.theme, () => ( this.brandConfig.theme)));
1811
+ const defaultTheme = _chunkK6PG2PDFjs.getDefaultThemeConfig.call(void 0, _nullishCoalesce(newConfig.theme, () => ( this.brandConfig.theme)));
1398
1812
  this.brandConfig = {
1399
1813
  logo: "logo" in newConfig ? _nullishCoalesce(newConfig.logo, () => ( defaultTheme.logo)) : this.brandConfig.logo,
1400
1814
  theme: "theme" in newConfig ? _nullishCoalesce(newConfig.theme, () => ( defaultTheme.theme)) : this.brandConfig.theme,
@@ -1406,6 +1820,10 @@ var _AurumCore = class _AurumCore {
1406
1820
  font: "font" in newConfig ? _nullishCoalesce(newConfig.font, () => ( defaultTheme.font)) : this.brandConfig.font,
1407
1821
  walletLayout: "walletLayout" in newConfig ? _nullishCoalesce(newConfig.walletLayout, () => ( defaultTheme.walletLayout)) : this.brandConfig.walletLayout
1408
1822
  };
1823
+ if ("theme" in newConfig && this.brandConfig.theme) {
1824
+ const wcAdapter = this.wallets.find((w) => w.id === _types.WalletId.WalletConnect);
1825
+ _optionalChain([wcAdapter, 'optionalAccess', _158 => _158.updateTheme, 'call', _159 => _159(this.brandConfig.theme)]);
1826
+ }
1409
1827
  }
1410
1828
  updateWalletsConfig(newConfig) {
1411
1829
  if (newConfig.exclude !== void 0) {
@@ -1421,7 +1839,7 @@ var _AurumCore = class _AurumCore {
1421
1839
  await this.whenReady();
1422
1840
  const emailAdapter = this.wallets.find((w) => w.id === _types.WalletId.Email);
1423
1841
  if (!emailAdapter || !emailAdapter.emailAuthStart) {
1424
- throw new Error("Email wallet is not enabled");
1842
+ throw new Error("Email wallet is not configured");
1425
1843
  }
1426
1844
  const result = await emailAdapter.emailAuthStart(email);
1427
1845
  return { flowId: result.flowId };
@@ -1436,18 +1854,18 @@ var _AurumCore = class _AurumCore {
1436
1854
  await this.whenReady();
1437
1855
  const emailAdapter = this.wallets.find((w) => w.id === _types.WalletId.Email);
1438
1856
  if (!emailAdapter || !emailAdapter.emailAuthVerify) {
1439
- throw new Error("Email wallet is not enabled");
1857
+ throw new Error("Email wallet is not configured");
1440
1858
  }
1441
1859
  const verifyResult = await emailAdapter.emailAuthVerify(flowId, otp);
1442
1860
  const provider = emailAdapter.getProvider();
1443
1861
  if (!provider) {
1444
- _chunkNKWY4I4Ljs.sentryLogger.error("Failed to get provider after email verification");
1862
+ _chunkK6PG2PDFjs.sentryLogger.error("Failed to get provider after email verification");
1445
1863
  throw new Error("Failed to get provider after email verification");
1446
1864
  }
1447
- const address = _optionalChain([verifyResult, 'access', _102 => _102.user, 'optionalAccess', _103 => _103.evmAccounts, 'optionalAccess', _104 => _104[0]]);
1448
- const email = _optionalChain([verifyResult, 'access', _105 => _105.user, 'optionalAccess', _106 => _106.authenticationMethods, 'optionalAccess', _107 => _107.email, 'optionalAccess', _108 => _108.email]);
1865
+ const address = _optionalChain([verifyResult, 'access', _160 => _160.user, 'optionalAccess', _161 => _161.evmAccounts, 'optionalAccess', _162 => _162[0]]);
1866
+ const email = _optionalChain([verifyResult, 'access', _163 => _163.user, 'optionalAccess', _164 => _164.authenticationMethods, 'optionalAccess', _165 => _165.email, 'optionalAccess', _166 => _166.email]);
1449
1867
  if (!address || !email) {
1450
- _chunkNKWY4I4Ljs.sentryLogger.error("Address or email not found after email verification");
1868
+ _chunkK6PG2PDFjs.sentryLogger.error("Address or email not found after email verification");
1451
1869
  throw new Error("Address or email not found after email verification");
1452
1870
  }
1453
1871
  const checksumAdr = _viem.checksumAddress.call(void 0, address);
@@ -1464,7 +1882,7 @@ var _AurumCore = class _AurumCore {
1464
1882
  const chainId = await provider.request({ method: "eth_chainId" });
1465
1883
  this.emitConnect(chainId);
1466
1884
  this.emitAccountsChanged([checksumAdr]);
1467
- _chunkNKWY4I4Ljs.sentryLogger.info(`Wallet connected: ${emailAdapter.id} (headless)`);
1885
+ _chunkK6PG2PDFjs.sentryLogger.info(`Wallet connected: ${emailAdapter.id} (headless)`);
1468
1886
  return { address: checksumAdr, email: _nullishCoalesce(email, () => ( "")), isNewUser: _nullishCoalesce(verifyResult.isNewUser, () => ( false)) };
1469
1887
  }
1470
1888
  /**
@@ -1473,10 +1891,7 @@ var _AurumCore = class _AurumCore {
1473
1891
  */
1474
1892
  async getWalletConnectSession() {
1475
1893
  await this.whenReady();
1476
- if (this.excludedWallets.has(_types.WalletId.WalletConnect)) {
1477
- throw new Error("WalletConnect is excluded from wallet options");
1478
- }
1479
- const wcAdapter = this.wallets.find((w) => w instanceof _chunkNKWY4I4Ljs.WalletConnectAdapter);
1894
+ const wcAdapter = this.wallets.find((w) => w.id === _types.WalletId.WalletConnect);
1480
1895
  if (!wcAdapter) {
1481
1896
  throw new Error("WalletConnect is not enabled");
1482
1897
  }
@@ -1487,7 +1902,7 @@ var _AurumCore = class _AurumCore {
1487
1902
  const result = await session.waitForConnection();
1488
1903
  const provider = _nullishCoalesce(result.provider, () => ( wcAdapter.getProvider()));
1489
1904
  if (!provider) {
1490
- _chunkNKWY4I4Ljs.sentryLogger.error("Failed to get provider after WalletConnect connection");
1905
+ _chunkK6PG2PDFjs.sentryLogger.error("Failed to get provider after WalletConnect connection");
1491
1906
  throw new Error("Failed to get provider after WalletConnect connection");
1492
1907
  }
1493
1908
  const checksumAdr = _viem.checksumAddress.call(void 0, result.address);
@@ -1496,15 +1911,14 @@ var _AurumCore = class _AurumCore {
1496
1911
  this.userInfo = {
1497
1912
  publicAddress: checksumAdr,
1498
1913
  walletName: wcAdapter.name,
1499
- walletId: wcAdapter.id,
1500
- email: void 0
1914
+ walletId: wcAdapter.id
1501
1915
  };
1502
1916
  this.persistConnectionState(wcAdapter, checksumAdr);
1503
1917
  this.setInternalAccountChangeListener(wcAdapter);
1504
1918
  const chainId = await provider.request({ method: "eth_chainId" });
1505
1919
  this.emitConnect(chainId);
1506
1920
  this.emitAccountsChanged([checksumAdr]);
1507
- _chunkNKWY4I4Ljs.sentryLogger.info(`Wallet connected: ${wcAdapter.id} (headless)`);
1921
+ _chunkK6PG2PDFjs.sentryLogger.info(`Wallet connected: ${wcAdapter.id} (headless)`);
1508
1922
  return checksumAdr;
1509
1923
  }
1510
1924
  };
@@ -1520,15 +1934,15 @@ var _AurumCore = class _AurumCore {
1520
1934
  }
1521
1935
  this.eventListeners.get(event).add(callback);
1522
1936
  if (!_AurumCore.MANAGED_EVENTS.includes(event)) {
1523
- _optionalChain([this, 'access', _109 => _109.currentProvider, 'access', _110 => _110.on, 'optionalCall', _111 => _111(event, callback)]);
1937
+ _optionalChain([this, 'access', _167 => _167.currentProvider, 'access', _168 => _168.on, 'optionalCall', _169 => _169(event, callback)]);
1524
1938
  }
1525
1939
  };
1526
1940
  }
1527
1941
  if (prop === "removeListener") {
1528
1942
  return (event, callback) => {
1529
- _optionalChain([this, 'access', _112 => _112.eventListeners, 'access', _113 => _113.get, 'call', _114 => _114(event), 'optionalAccess', _115 => _115.delete, 'call', _116 => _116(callback)]);
1943
+ _optionalChain([this, 'access', _170 => _170.eventListeners, 'access', _171 => _171.get, 'call', _172 => _172(event), 'optionalAccess', _173 => _173.delete, 'call', _174 => _174(callback)]);
1530
1944
  if (!_AurumCore.MANAGED_EVENTS.includes(event)) {
1531
- _optionalChain([this, 'access', _117 => _117.currentProvider, 'access', _118 => _118.removeListener, 'optionalCall', _119 => _119(event, callback)]);
1945
+ _optionalChain([this, 'access', _175 => _175.currentProvider, 'access', _176 => _176.removeListener, 'optionalCall', _177 => _177(event, callback)]);
1532
1946
  }
1533
1947
  };
1534
1948
  }
@@ -1553,7 +1967,7 @@ var _AurumCore = class _AurumCore {
1553
1967
  this.eventListeners.forEach((callbacks, event) => {
1554
1968
  if (!_AurumCore.MANAGED_EVENTS.includes(event)) {
1555
1969
  callbacks.forEach((callback) => {
1556
- _optionalChain([newProvider, 'access', _120 => _120.on, 'optionalCall', _121 => _121(event, callback)]);
1970
+ _optionalChain([newProvider, 'access', _178 => _178.on, 'optionalCall', _179 => _179(event, callback)]);
1557
1971
  });
1558
1972
  }
1559
1973
  });
@@ -1561,7 +1975,7 @@ var _AurumCore = class _AurumCore {
1561
1975
  /* BRAND & THEME METHODS */
1562
1976
  resolveBrandConfig(config) {
1563
1977
  const { brand = {} } = config || {};
1564
- const themeConfig = _chunkNKWY4I4Ljs.getDefaultThemeConfig.call(void 0, brand.theme || _chunkNKWY4I4Ljs.DEFAULT_THEME);
1978
+ const themeConfig = _chunkK6PG2PDFjs.getDefaultThemeConfig.call(void 0, brand.theme || _chunkK6PG2PDFjs.DEFAULT_THEME);
1565
1979
  return {
1566
1980
  logo: _nullishCoalesce(brand.logo, () => ( themeConfig.logo)),
1567
1981
  theme: _nullishCoalesce(brand.theme, () => ( themeConfig.theme)),
@@ -1576,8 +1990,8 @@ var _AurumCore = class _AurumCore {
1576
1990
  }
1577
1991
  async tryRestoreConnection() {
1578
1992
  try {
1579
- await _chunkNKWY4I4Ljs.waitForStoreHydration.call(void 0, );
1580
- const store = _chunkNKWY4I4Ljs.useAurumStore.getState();
1993
+ await _chunkK6PG2PDFjs.waitForStoreHydration.call(void 0, );
1994
+ const store = _chunkK6PG2PDFjs.useAurumStore.getState();
1581
1995
  if (!store.isConnected || !store.walletId || !store.address || !store.walletName) {
1582
1996
  return;
1583
1997
  }
@@ -1600,14 +2014,14 @@ var _AurumCore = class _AurumCore {
1600
2014
  email: _nullishCoalesce(store.email, () => ( void 0))
1601
2015
  };
1602
2016
  this.setInternalAccountChangeListener(persistedAdapter);
1603
- } catch (e17) {
2017
+ } catch (e15) {
1604
2018
  this.resetConnectionState();
1605
2019
  } finally {
1606
2020
  this.ready = true;
1607
2021
  }
1608
2022
  }
1609
2023
  persistConnectionState(adapter, address, email) {
1610
- _chunkNKWY4I4Ljs.useAurumStore.getState().setConnection(adapter.id, _viem.checksumAddress.call(void 0, address), adapter.name, email);
2024
+ _chunkK6PG2PDFjs.useAurumStore.getState().setConnection(adapter.id, _viem.checksumAddress.call(void 0, address), adapter.name, email);
1611
2025
  }
1612
2026
  /* INTERNAL LISTENER METHODS */
1613
2027
  setInternalAccountChangeListener(adapter) {
@@ -1621,14 +2035,14 @@ var _AurumCore = class _AurumCore {
1621
2035
  }
1622
2036
  async syncStateFromAccountsChanged(accounts) {
1623
2037
  if (!accounts.length || !accounts[0]) return;
1624
- const prevAccount = _optionalChain([this, 'access', _122 => _122.userInfo, 'optionalAccess', _123 => _123.publicAddress]);
2038
+ const prevAccount = _optionalChain([this, 'access', _180 => _180.userInfo, 'optionalAccess', _181 => _181.publicAddress]);
1625
2039
  const newAccount = _viem.checksumAddress.call(void 0, accounts[0]);
1626
2040
  if (newAccount !== prevAccount) {
1627
2041
  this.userInfo = {
1628
2042
  publicAddress: newAccount,
1629
- walletName: _optionalChain([this, 'access', _124 => _124.userInfo, 'optionalAccess', _125 => _125.walletName]),
1630
- walletId: _optionalChain([this, 'access', _126 => _126.userInfo, 'optionalAccess', _127 => _127.walletId]),
1631
- email: _optionalChain([this, 'access', _128 => _128.userInfo, 'optionalAccess', _129 => _129.email])
2043
+ walletName: _optionalChain([this, 'access', _182 => _182.userInfo, 'optionalAccess', _183 => _183.walletName]),
2044
+ walletId: _optionalChain([this, 'access', _184 => _184.userInfo, 'optionalAccess', _185 => _185.walletId]),
2045
+ email: _optionalChain([this, 'access', _186 => _186.userInfo, 'optionalAccess', _187 => _187.email])
1632
2046
  };
1633
2047
  if (this.connectedWalletAdapter) {
1634
2048
  this.persistConnectionState(this.connectedWalletAdapter, newAccount, this.userInfo.email);
@@ -1687,7 +2101,7 @@ var _AurumCore = class _AurumCore {
1687
2101
  }
1688
2102
  }
1689
2103
  async addChain(chain) {
1690
- if (!_optionalChain([chain, 'optionalAccess', _130 => _130.id]) || !_optionalChain([chain, 'optionalAccess', _131 => _131.name]) || !_optionalChain([chain, 'optionalAccess', _132 => _132.nativeCurrency]) || !_optionalChain([chain, 'optionalAccess', _133 => _133.rpcUrls, 'optionalAccess', _134 => _134.default, 'optionalAccess', _135 => _135.http])) {
2104
+ if (!_optionalChain([chain, 'optionalAccess', _188 => _188.id]) || !_optionalChain([chain, 'optionalAccess', _189 => _189.name]) || !_optionalChain([chain, 'optionalAccess', _190 => _190.nativeCurrency]) || !_optionalChain([chain, 'optionalAccess', _191 => _191.rpcUrls, 'optionalAccess', _192 => _192.default, 'optionalAccess', _193 => _193.http])) {
1691
2105
  throw new Error("Invalid chain configuration: missing required properties");
1692
2106
  }
1693
2107
  await this.rpcProvider.request({
@@ -1705,7 +2119,7 @@ var _AurumCore = class _AurumCore {
1705
2119
  }
1706
2120
  /* REST */
1707
2121
  resetConnectionState() {
1708
- _chunkNKWY4I4Ljs.useAurumStore.getState().clearConnection();
2122
+ _chunkK6PG2PDFjs.useAurumStore.getState().clearConnection();
1709
2123
  this.connectedWalletAdapter = null;
1710
2124
  this.updateProvider(this.skeletonProvider);
1711
2125
  this.userInfo = void 0;
@@ -1800,8 +2214,7 @@ var Aurum = class {
1800
2214
  * Opens the wallet connection modal or connects directly to a specific wallet.
1801
2215
  *
1802
2216
  * @param walletId - Optional wallet ID for direct connection (bypasses modal).
1803
- * Cannot be 'email' (use emailAuthStart/emailAuthVerify).
1804
- * For 'walletconnect', opens the WalletConnect modal directly.
2217
+ * Cannot be 'email' or 'walletconnect' (use their dedicated methods).
1805
2218
  * @returns The connected wallet address
1806
2219
  * @throws Error if user closes the modal without connecting a wallet
1807
2220
  *
@@ -1813,9 +2226,6 @@ var Aurum = class {
1813
2226
  * // Or connect directly to a specific wallet
1814
2227
  * import { WalletId } from '@aurum-sdk/types';
1815
2228
  * const address = await aurum.connect(WalletId.MetaMask);
1816
- *
1817
- * // Open WalletConnect modal directly
1818
- * const address = await aurum.connect(WalletId.WalletConnect);
1819
2229
  * ```
1820
2230
  */
1821
2231
  async connect(walletId) {
@@ -1945,7 +2355,7 @@ var Aurum = class {
1945
2355
  *
1946
2356
  * @param email - The email address to send the OTP to
1947
2357
  * @returns Object containing flowId to use with emailAuthVerify
1948
- * @throws Error if email wallet is not enabled
2358
+ * @throws Error if email wallet is not configured
1949
2359
  *
1950
2360
  * @example
1951
2361
  * ```typescript
@@ -1981,7 +2391,7 @@ var Aurum = class {
1981
2391
  * Use this for building custom QR code UIs instead of using the built-in modal.
1982
2392
  *
1983
2393
  * @returns Object containing the URI and a function to wait for the connection
1984
- * @throws Error if WalletConnect is not enabled
2394
+ * @throws Error if WalletConnect is not configured
1985
2395
  *
1986
2396
  * @example
1987
2397
  * ```typescript