@aurum-sdk/core 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.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,8 +13,7 @@
13
13
 
14
14
 
15
15
 
16
-
17
- var _chunkAFVK5GA5js = require('./chunk-AFVK5GA5.js');
16
+ var _chunkFRA6K6V4js = require('./chunk-FRA6K6V4.js');
18
17
 
19
18
  // src/AurumCore.ts
20
19
  var _viem = require('viem');
@@ -46,20 +45,20 @@ var _react = require('react');
46
45
  var _jsxruntime = require('react/jsx-runtime');
47
46
  var ModalShell = ({ onClose, brandConfig }) => {
48
47
  const [isOpen, setIsOpen] = _react.useState.call(void 0, true);
49
- const { currentPage } = _chunkAFVK5GA5js.useNavigation.call(void 0, );
48
+ const { currentPage } = _chunkFRA6K6V4js.useNavigation.call(void 0, );
50
49
  const handleClose = () => {
51
50
  setIsOpen(false);
52
51
  onClose();
53
52
  };
54
53
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
55
- _chunkAFVK5GA5js.Modal,
54
+ _chunkFRA6K6V4js.Modal,
56
55
  {
57
56
  isOpen,
58
57
  closeOnOverlayClick: true,
59
58
  onCloseComplete: handleClose,
60
59
  brandConfig,
61
60
  transitionKey: currentPage,
62
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkAFVK5GA5js.ConnectPages, {})
61
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkFRA6K6V4js.ConnectPages, {})
63
62
  }
64
63
  );
65
64
  };
@@ -71,7 +70,7 @@ var _client = require('react-dom/client');
71
70
  function createShadowRoot(container, brandConfig) {
72
71
  const shadowRoot = container.attachShadow({ mode: "open" });
73
72
  shadowRoot.innerHTML = `
74
- <style>${_chunkAFVK5GA5js.generateCompleteStyles.call(void 0, brandConfig)}</style>
73
+ <style>${_chunkFRA6K6V4js.generateCompleteStyles.call(void 0, brandConfig)}</style>
75
74
  <div class="aurum-modal-root"></div>
76
75
  `;
77
76
  return shadowRoot.querySelector(".aurum-modal-root");
@@ -101,7 +100,6 @@ function createModalContainer(id, brandConfig) {
101
100
  }
102
101
 
103
102
  // src/components/ConnectModal/renderConnectModal.tsx
104
- var _types = require('@aurum-sdk/types');
105
103
 
106
104
  var CONTAINER_ID = "aurum-modal-container";
107
105
  function renderConnectModal({
@@ -109,11 +107,7 @@ function renderConnectModal({
109
107
  brandConfig
110
108
  }) {
111
109
  return new Promise((resolve, reject) => {
112
- let sortedWallets = _chunkAFVK5GA5js.sortWallets.call(void 0, displayedWallets, { filterHidden: false });
113
- const hasAppKit = sortedWallets.some((w) => w.id === _types.WalletId.AppKit);
114
- if (_chunkAFVK5GA5js.isMobile.call(void 0, ) && !hasAppKit) {
115
- sortedWallets = sortedWallets.filter((w) => w.id !== _types.WalletId.WalletConnect);
116
- }
110
+ const sortedWallets = _chunkFRA6K6V4js.sortWallets.call(void 0, displayedWallets, { filterHidden: false });
117
111
  const { root, cleanup } = createModalContainer(CONTAINER_ID, brandConfig);
118
112
  const onConnect = (result) => {
119
113
  cleanup();
@@ -124,275 +118,14 @@ function renderConnectModal({
124
118
  reject(new Error("User rejected request"));
125
119
  };
126
120
  root.render(
127
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkAFVK5GA5js.ThemeContainer, { theme: brandConfig.theme, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkAFVK5GA5js.ConnectUIProviders, { onConnect, displayedWallets: sortedWallets, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ModalShell, { onClose, brandConfig }) }) })
121
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkFRA6K6V4js.ThemeContainer, { theme: brandConfig.theme, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkFRA6K6V4js.ConnectUIProviders, { onConnect, displayedWallets: sortedWallets, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ModalShell, { onClose, brandConfig }) }) })
128
122
  );
129
123
  });
130
124
  }
131
125
 
132
- // src/wallet-adapters/AppKitAdapter.ts
133
- var _logos = require('@aurum-sdk/logos');
134
-
135
- var AppKitAdapter = class {
136
- constructor(config) {
137
- this.id = _types.WalletId.AppKit;
138
- this.name = _types.WalletName.AppKit;
139
- this.icon = _nullishCoalesce(_logos.getLogoDataUri.call(void 0, _types.WalletId.AppKit, "brand"), () => ( ""));
140
- this.hide = true;
141
- this.downloadUrl = null;
142
- this.wcDeepLinkUrl = null;
143
- this.modal = null;
144
- this.wagmiAdapter = null;
145
- this.provider = null;
146
- this.address = null;
147
- this.accountsChangedCallback = null;
148
- this.unsubscribeFunctions = [];
149
- this.initPromise = null;
150
- this.config = {
151
- projectId: config.projectId,
152
- appName: config.appName,
153
- modalZIndex: config.modalZIndex,
154
- theme: config.theme
155
- };
156
- }
157
- async ensureInitialized() {
158
- if (this.modal) return;
159
- if (!this.initPromise) {
160
- this.initPromise = this.initializeAppKit();
161
- }
162
- await this.initPromise;
163
- }
164
- async initializeAppKit() {
165
- if (typeof window === "undefined") return;
166
- const [{ createAppKit }, { WagmiAdapter }, { mainnet: mainnet2 }] = await Promise.all([
167
- Promise.resolve().then(() => _interopRequireWildcard(require("@reown/appkit"))),
168
- Promise.resolve().then(() => _interopRequireWildcard(require("@reown/appkit-adapter-wagmi"))),
169
- Promise.resolve().then(() => _interopRequireWildcard(require("@reown/appkit/networks")))
170
- ]);
171
- const networks = [mainnet2];
172
- this.wagmiAdapter = new WagmiAdapter({
173
- projectId: this.config.projectId,
174
- networks,
175
- ssr: true
176
- });
177
- this.modal = createAppKit({
178
- adapters: [this.wagmiAdapter],
179
- networks,
180
- projectId: this.config.projectId,
181
- metadata: {
182
- name: this.config.appName,
183
- description: this.config.appName,
184
- url: window.location.origin,
185
- icons: []
186
- },
187
- allowUnsupportedChain: true,
188
- themeMode: this.config.theme,
189
- themeVariables: {
190
- "--apkt-z-index": this.config.modalZIndex + 1
191
- }
192
- });
193
- this.setupEventListeners();
194
- }
195
- setupEventListeners() {
196
- if (!this.modal) return;
197
- const unsubscribeProviders = this.modal.subscribeProviders((state) => {
198
- const eip155Provider = state["eip155"];
199
- this.provider = eip155Provider || null;
200
- if (!eip155Provider) {
201
- this.address = null;
202
- }
203
- });
204
- this.unsubscribeFunctions.push(unsubscribeProviders);
205
- }
206
- syncAddressFromWagmi() {
207
- if (!_optionalChain([this, 'access', _21 => _21.wagmiAdapter, 'optionalAccess', _22 => _22.wagmiConfig])) return;
208
- const { state } = this.wagmiAdapter.wagmiConfig;
209
- if (state.current && state.connections) {
210
- const connection = state.connections.get(state.current);
211
- if (_optionalChain([connection, 'optionalAccess', _23 => _23.accounts, 'optionalAccess', _24 => _24[0]])) {
212
- this.address = connection.accounts[0];
213
- }
214
- }
215
- }
216
- async syncProviderFromModal() {
217
- if (!this.modal) return;
218
- try {
219
- const getProvidersFn = this.modal.getProviders;
220
- if (typeof getProvidersFn === "function") {
221
- const providers = getProvidersFn.call(this.modal);
222
- const eip155Provider = _optionalChain([providers, 'optionalAccess', _25 => _25["eip155"]]);
223
- if (eip155Provider) {
224
- this.provider = eip155Provider;
225
- return;
226
- }
227
- }
228
- if (_optionalChain([this, 'access', _26 => _26.wagmiAdapter, 'optionalAccess', _27 => _27.wagmiConfig])) {
229
- const { state } = this.wagmiAdapter.wagmiConfig;
230
- if (state.current && state.connections) {
231
- const connection = state.connections.get(state.current);
232
- const connector = _optionalChain([connection, 'optionalAccess', _28 => _28.connector]);
233
- if (connector && typeof connector.getProvider === "function") {
234
- try {
235
- const provider = await connector.getProvider();
236
- if (provider) {
237
- this.provider = provider;
238
- }
239
- } catch (error) {
240
- _chunkAFVK5GA5js.sentryLogger.warn("Failed to get provider from wagmi connector", { error });
241
- }
242
- }
243
- }
244
- }
245
- } catch (error) {
246
- _chunkAFVK5GA5js.sentryLogger.warn("Failed to get provider from AppKit", { error });
247
- }
248
- }
249
- isInstalled() {
250
- return true;
251
- }
252
- async connect() {
253
- if (!this.config.projectId) {
254
- throw _chunkAFVK5GA5js.createConfigError.call(void 0, "AppKit");
255
- }
256
- await this.ensureInitialized();
257
- if (!this.modal) {
258
- _chunkAFVK5GA5js.sentryLogger.error("AppKit is not available");
259
- throw new Error("AppKit is not available");
260
- }
261
- const existingAddress = this.modal.getAddress();
262
- if (this.modal.getIsConnectedState() && existingAddress) {
263
- await this.syncProviderFromModal();
264
- if (this.provider) {
265
- this.address = existingAddress;
266
- return {
267
- address: existingAddress,
268
- provider: this.provider,
269
- walletId: this.id
270
- };
271
- }
272
- await this.disconnect();
273
- }
274
- this.modal.open({ view: "AllWallets" });
275
- return await this.waitForConnection();
276
- }
277
- waitForConnection(timeout = 6e4) {
278
- return new Promise((resolve, reject) => {
279
- const startTime = Date.now();
280
- let unsubscribeState = null;
281
- let isResolved = false;
282
- const cleanup = () => {
283
- _optionalChain([unsubscribeState, 'optionalCall', _29 => _29()]);
284
- };
285
- const checkConnection = async () => {
286
- if (isResolved) return true;
287
- this.syncAddressFromWagmi();
288
- if (this.address && !this.provider) {
289
- await this.syncProviderFromModal();
290
- }
291
- if (this.provider && this.address) {
292
- try {
293
- const accounts = await this.provider.request({ method: "eth_accounts" });
294
- if (accounts && accounts.length > 0) {
295
- isResolved = true;
296
- cleanup();
297
- _optionalChain([this, 'access', _30 => _30.modal, 'optionalAccess', _31 => _31.close, 'call', _32 => _32()]);
298
- resolve({
299
- address: this.address,
300
- provider: this.provider,
301
- walletId: this.id
302
- });
303
- return true;
304
- }
305
- return false;
306
- } catch (e) {
307
- return false;
308
- }
309
- }
310
- return false;
311
- };
312
- unsubscribeState = this.modal.subscribeState(async (state) => {
313
- if (await checkConnection()) return;
314
- if (state.open === false && !this.address && !isResolved) {
315
- cleanup();
316
- reject(new Error("Connection rejected by user"));
317
- }
318
- });
319
- const pollTimeout = async () => {
320
- if (await checkConnection()) return;
321
- if (Date.now() - startTime > timeout) {
322
- cleanup();
323
- reject(new Error("Connection timeout"));
324
- return;
325
- }
326
- setTimeout(pollTimeout, 500);
327
- };
328
- pollTimeout();
329
- });
330
- }
331
- async tryRestoreConnection() {
332
- await this.ensureInitialized();
333
- if (!this.modal || !this.wagmiAdapter) return null;
334
- try {
335
- await new Promise((resolve) => setTimeout(resolve, 1e3));
336
- const wagmiConfig = this.wagmiAdapter.wagmiConfig;
337
- if (_optionalChain([wagmiConfig, 'optionalAccess', _33 => _33.state, 'optionalAccess', _34 => _34.current]) && wagmiConfig.state.connections) {
338
- const connection = wagmiConfig.state.connections.get(wagmiConfig.state.current);
339
- if (_optionalChain([connection, 'optionalAccess', _35 => _35.accounts, 'optionalAccess', _36 => _36[0]])) {
340
- this.address = connection.accounts[0];
341
- if (this.provider && this.address) {
342
- return {
343
- address: this.address,
344
- provider: this.provider,
345
- walletId: this.id
346
- };
347
- }
348
- }
349
- }
350
- return null;
351
- } catch (e2) {
352
- return null;
353
- }
354
- }
355
- async disconnect() {
356
- if (!this.modal) {
357
- this.address = null;
358
- this.provider = null;
359
- return;
360
- }
361
- await this.modal.disconnect("eip155");
362
- const timeout = Date.now() + 2e3;
363
- while (Date.now() < timeout && (this.modal.getIsConnectedState() || this.modal.getAddress())) {
364
- await new Promise((r) => setTimeout(r, 100));
365
- }
366
- this.address = null;
367
- this.provider = null;
368
- }
369
- getProvider() {
370
- return this.provider;
371
- }
372
- onAccountsChanged(callback) {
373
- if (!_optionalChain([this, 'access', _37 => _37.provider, 'optionalAccess', _38 => _38.on])) return;
374
- if (this.accountsChangedCallback) {
375
- _optionalChain([this, 'access', _39 => _39.provider, 'access', _40 => _40.removeListener, 'optionalCall', _41 => _41("accountsChanged", this.accountsChangedCallback)]);
376
- }
377
- this.accountsChangedCallback = (accounts) => {
378
- this.address = accounts[0] || null;
379
- callback(accounts);
380
- };
381
- this.provider.on("accountsChanged", this.accountsChangedCallback);
382
- }
383
- removeListeners() {
384
- if (_optionalChain([this, 'access', _42 => _42.provider, 'optionalAccess', _43 => _43.removeListener]) && this.accountsChangedCallback) {
385
- this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
386
- this.accountsChangedCallback = null;
387
- }
388
- this.unsubscribeFunctions.forEach((unsub) => unsub());
389
- this.unsubscribeFunctions = [];
390
- }
391
- };
392
-
393
126
  // src/wallet-adapters/RabbyAdapter.ts
394
-
395
-
127
+ var _logos = require('@aurum-sdk/logos');
128
+ var _types = require('@aurum-sdk/types');
396
129
  var RABBY_RDNS = "io.rabby";
397
130
  var RabbyAdapter = class {
398
131
  constructor() {
@@ -444,43 +177,39 @@ var RabbyAdapter = class {
444
177
  */
445
178
  detectLegacyProvider() {
446
179
  const ethereum = window.ethereum;
447
- if (_optionalChain([ethereum, 'optionalAccess', _44 => _44.isRabby])) {
180
+ if (_optionalChain([ethereum, 'optionalAccess', _21 => _21.isRabby])) {
448
181
  return ethereum;
449
182
  }
450
183
  return null;
451
184
  }
452
185
  isInstalled() {
453
- return Boolean(this.provider);
186
+ return Boolean(_nullishCoalesce(this.provider, () => ( this.detectLegacyProvider())));
454
187
  }
455
188
  async connect() {
456
189
  if (!this.provider && this.providerPromise) {
457
190
  await this.providerPromise;
458
191
  }
459
192
  if (!this.provider) {
460
- _chunkAFVK5GA5js.sentryLogger.error("Rabby is not available");
193
+ _chunkFRA6K6V4js.sentryLogger.error("Rabby is not available");
461
194
  throw new Error("Rabby is not available");
462
195
  }
463
- try {
464
- await this.provider.request({
465
- method: "wallet_requestPermissions",
466
- params: [{ eth_accounts: {} }]
467
- });
468
- const accounts = await this.provider.request({
469
- method: "eth_requestAccounts",
470
- params: []
471
- });
472
- if (!accounts || accounts.length === 0 || !accounts[0]) {
473
- _chunkAFVK5GA5js.sentryLogger.error("No accounts returned from Rabby");
474
- throw new Error("No accounts returned from Rabby");
475
- }
476
- return {
477
- address: accounts[0],
478
- provider: this.provider,
479
- walletId: this.id
480
- };
481
- } catch (e3) {
482
- 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
+ _chunkFRA6K6V4js.sentryLogger.error("No accounts returned from Rabby");
206
+ throw new Error("No accounts returned from Rabby");
483
207
  }
208
+ return {
209
+ address: accounts[0],
210
+ provider: this.provider,
211
+ walletId: this.id
212
+ };
484
213
  }
485
214
  async tryRestoreConnection() {
486
215
  if (!this.provider && this.providerPromise) {
@@ -502,7 +231,7 @@ var RabbyAdapter = class {
502
231
  provider: this.provider,
503
232
  walletId: this.id
504
233
  };
505
- } catch (e4) {
234
+ } catch (e) {
506
235
  return null;
507
236
  }
508
237
  }
@@ -514,15 +243,15 @@ var RabbyAdapter = class {
514
243
  // Called by Aurum when user connects wallet
515
244
  // Passes Aurum.ts --> syncStateFromAccountsChanged() to handle the provider accounts changed event
516
245
  onAccountsChanged(callback) {
517
- if (!_optionalChain([this, 'access', _45 => _45.provider, 'optionalAccess', _46 => _46.on])) return;
246
+ if (!_optionalChain([this, 'access', _22 => _22.provider, 'optionalAccess', _23 => _23.on])) return;
518
247
  if (this.accountsChangedCallback) {
519
- _optionalChain([this, 'access', _47 => _47.provider, 'access', _48 => _48.removeListener, 'optionalCall', _49 => _49("accountsChanged", this.accountsChangedCallback)]);
248
+ _optionalChain([this, 'access', _24 => _24.provider, 'access', _25 => _25.removeListener, 'optionalCall', _26 => _26("accountsChanged", this.accountsChangedCallback)]);
520
249
  }
521
250
  this.accountsChangedCallback = callback;
522
251
  this.provider.on("accountsChanged", this.accountsChangedCallback);
523
252
  }
524
253
  removeListeners() {
525
- if (!_optionalChain([this, 'access', _50 => _50.provider, 'optionalAccess', _51 => _51.removeListener]) || !this.accountsChangedCallback) return;
254
+ if (!_optionalChain([this, 'access', _27 => _27.provider, 'optionalAccess', _28 => _28.removeListener]) || !this.accountsChangedCallback) return;
526
255
  this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
527
256
  this.accountsChangedCallback = null;
528
257
  }
@@ -594,43 +323,39 @@ var BraveAdapter = class {
594
323
  */
595
324
  detectLegacyProvider() {
596
325
  const ethereum = window.ethereum;
597
- if (_optionalChain([ethereum, 'optionalAccess', _52 => _52.isBraveWallet])) {
326
+ if (_optionalChain([ethereum, 'optionalAccess', _29 => _29.isBraveWallet])) {
598
327
  return ethereum;
599
328
  }
600
329
  return null;
601
330
  }
602
331
  isInstalled() {
603
- return Boolean(this.provider);
332
+ return Boolean(_nullishCoalesce(this.provider, () => ( this.detectLegacyProvider())));
604
333
  }
605
334
  async connect() {
606
335
  if (!this.provider && this.providerPromise) {
607
336
  await this.providerPromise;
608
337
  }
609
338
  if (!this.provider) {
610
- _chunkAFVK5GA5js.sentryLogger.error("Brave Wallet is not available");
339
+ _chunkFRA6K6V4js.sentryLogger.error("Brave Wallet is not available");
611
340
  throw new Error("Brave Wallet is not available");
612
341
  }
613
- try {
614
- await this.provider.request({
615
- method: "wallet_requestPermissions",
616
- params: [{ eth_accounts: {} }]
617
- });
618
- const accounts = await this.provider.request({
619
- method: "eth_requestAccounts",
620
- params: []
621
- });
622
- if (!accounts || accounts.length === 0 || !accounts[0]) {
623
- _chunkAFVK5GA5js.sentryLogger.error("No accounts returned from Brave Wallet");
624
- throw new Error("No accounts returned from Brave Wallet");
625
- }
626
- return {
627
- address: accounts[0],
628
- provider: this.provider,
629
- walletId: this.id
630
- };
631
- } catch (e5) {
632
- 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
+ _chunkFRA6K6V4js.sentryLogger.error("No accounts returned from Brave Wallet");
352
+ throw new Error("No accounts returned from Brave Wallet");
633
353
  }
354
+ return {
355
+ address: accounts[0],
356
+ provider: this.provider,
357
+ walletId: this.id
358
+ };
634
359
  }
635
360
  async tryRestoreConnection() {
636
361
  if (!this.provider && this.providerPromise) {
@@ -652,7 +377,7 @@ var BraveAdapter = class {
652
377
  provider: this.provider,
653
378
  walletId: this.id
654
379
  };
655
- } catch (e6) {
380
+ } catch (e2) {
656
381
  return null;
657
382
  }
658
383
  }
@@ -664,132 +389,15 @@ var BraveAdapter = class {
664
389
  // Called by Aurum when user connects wallet
665
390
  // Passes Aurum.ts --> syncStateFromAccountsChanged() to handle the provider accounts changed event
666
391
  onAccountsChanged(callback) {
667
- if (!_optionalChain([this, 'access', _53 => _53.provider, 'optionalAccess', _54 => _54.on])) return;
392
+ if (!_optionalChain([this, 'access', _30 => _30.provider, 'optionalAccess', _31 => _31.on])) return;
668
393
  if (this.accountsChangedCallback) {
669
- _optionalChain([this, 'access', _55 => _55.provider, 'access', _56 => _56.removeListener, 'optionalCall', _57 => _57("accountsChanged", this.accountsChangedCallback)]);
394
+ _optionalChain([this, 'access', _32 => _32.provider, 'access', _33 => _33.removeListener, 'optionalCall', _34 => _34("accountsChanged", this.accountsChangedCallback)]);
670
395
  }
671
396
  this.accountsChangedCallback = callback;
672
397
  this.provider.on("accountsChanged", this.accountsChangedCallback);
673
398
  }
674
399
  removeListeners() {
675
- if (!_optionalChain([this, 'access', _58 => _58.provider, 'optionalAccess', _59 => _59.removeListener]) || !this.accountsChangedCallback) return;
676
- this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
677
- this.accountsChangedCallback = null;
678
- }
679
- };
680
-
681
- // src/wallet-adapters/LedgerAdapter.ts
682
-
683
-
684
- var _connectkitloader = require('@ledgerhq/connect-kit-loader');
685
- var _chains = require('viem/chains');
686
- var LedgerAdapter = class {
687
- constructor(config) {
688
- this.id = _types.WalletId.Ledger;
689
- this.name = _types.WalletName.Ledger;
690
- this.icon = _nullishCoalesce(_logos.getLogoDataUri.call(void 0, _types.WalletId.Ledger, "brand"), () => ( ""));
691
- this.hide = false;
692
- this.downloadUrl = "https://www.ledger.com/ledger-live";
693
- this.wcDeepLinkUrl = "ledgerlive://wc?uri=";
694
- this.provider = null;
695
- this.accountsChangedCallback = null;
696
- this.walletConnectProjectId = _optionalChain([config, 'optionalAccess', _60 => _60.walletConnectProjectId]);
697
- }
698
- isInstalled() {
699
- return true;
700
- }
701
- async connect() {
702
- try {
703
- if (!this.walletConnectProjectId) {
704
- throw _chunkAFVK5GA5js.createConfigError.call(void 0, "Ledger");
705
- }
706
- const { loadConnectKit } = await Promise.resolve().then(() => _interopRequireWildcard(require("@ledgerhq/connect-kit-loader")));
707
- const connectKit = await loadConnectKit();
708
- connectKit.enableDebugLogs();
709
- connectKit.checkSupport({
710
- providerType: _connectkitloader.SupportedProviders.Ethereum,
711
- chainId: 1,
712
- walletConnectVersion: 2,
713
- projectId: this.walletConnectProjectId,
714
- rpc: { 1: _chains.mainnet.rpcUrls.default.http[0] }
715
- });
716
- this.provider = await connectKit.getProvider();
717
- if (!this.provider) {
718
- _chunkAFVK5GA5js.sentryLogger.error("Failed to get Ledger provider");
719
- throw new Error("Failed to get Ledger provider");
720
- }
721
- const accounts = await this.provider.request({
722
- method: "eth_requestAccounts",
723
- params: []
724
- });
725
- if (!accounts || accounts.length === 0 || !accounts[0]) {
726
- _chunkAFVK5GA5js.sentryLogger.error("No accounts returned from Ledger");
727
- throw new Error("No accounts returned from Ledger");
728
- }
729
- return {
730
- address: accounts[0],
731
- provider: this.provider,
732
- walletId: this.id
733
- };
734
- } catch (e7) {
735
- throw new Error("Failed to connect to Ledger");
736
- }
737
- }
738
- async tryRestoreConnection() {
739
- try {
740
- const { loadConnectKit } = await Promise.resolve().then(() => _interopRequireWildcard(require("@ledgerhq/connect-kit-loader")));
741
- const connectKit = await loadConnectKit();
742
- connectKit.checkSupport({
743
- providerType: _connectkitloader.SupportedProviders.Ethereum,
744
- chainId: 1,
745
- walletConnectVersion: 2,
746
- projectId: this.walletConnectProjectId,
747
- rpc: { 1: _chains.mainnet.rpcUrls.default.http[0] }
748
- });
749
- this.provider = await connectKit.getProvider();
750
- if (!this.provider) {
751
- return null;
752
- }
753
- const accounts = await this.provider.request({
754
- method: "eth_accounts",
755
- params: []
756
- });
757
- if (!accounts || accounts.length === 0 || !accounts[0]) {
758
- return null;
759
- }
760
- return {
761
- address: accounts[0],
762
- provider: this.provider,
763
- walletId: this.id
764
- };
765
- } catch (e8) {
766
- return null;
767
- }
768
- }
769
- async disconnect() {
770
- try {
771
- const provider = this.provider;
772
- if (_optionalChain([provider, 'optionalAccess', _61 => _61.disconnect])) {
773
- await provider.disconnect();
774
- }
775
- this.provider = null;
776
- } catch (error) {
777
- _chunkAFVK5GA5js.sentryLogger.warn("Failed to disconnect from Ledger", { error });
778
- }
779
- }
780
- getProvider() {
781
- return this.provider;
782
- }
783
- onAccountsChanged(callback) {
784
- if (!_optionalChain([this, 'access', _62 => _62.provider, 'optionalAccess', _63 => _63.on])) return;
785
- if (this.accountsChangedCallback) {
786
- _optionalChain([this, 'access', _64 => _64.provider, 'access', _65 => _65.removeListener, 'optionalCall', _66 => _66("accountsChanged", this.accountsChangedCallback)]);
787
- }
788
- this.accountsChangedCallback = callback;
789
- this.provider.on("accountsChanged", this.accountsChangedCallback);
790
- }
791
- removeListeners() {
792
- if (!_optionalChain([this, 'access', _67 => _67.provider, 'optionalAccess', _68 => _68.removeListener]) || !this.accountsChangedCallback) return;
400
+ if (!_optionalChain([this, 'access', _35 => _35.provider, 'optionalAccess', _36 => _36.removeListener]) || !this.accountsChangedCallback) return;
793
401
  this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
794
402
  this.accountsChangedCallback = null;
795
403
  }
@@ -850,47 +458,43 @@ var PhantomAdapter = class {
850
458
  */
851
459
  detectLegacyProvider() {
852
460
  const phantom = window.phantom;
853
- if (_optionalChain([phantom, 'optionalAccess', _69 => _69.ethereum, 'optionalAccess', _70 => _70.isPhantom])) {
461
+ if (_optionalChain([phantom, 'optionalAccess', _37 => _37.ethereum, 'optionalAccess', _38 => _38.isPhantom])) {
854
462
  return phantom.ethereum;
855
463
  }
856
464
  const ethereum = window.ethereum;
857
- if (_optionalChain([ethereum, 'optionalAccess', _71 => _71.isPhantom])) {
465
+ if (_optionalChain([ethereum, 'optionalAccess', _39 => _39.isPhantom])) {
858
466
  return ethereum;
859
467
  }
860
468
  return null;
861
469
  }
862
470
  isInstalled() {
863
- return Boolean(this.provider);
471
+ return Boolean(_nullishCoalesce(this.provider, () => ( this.detectLegacyProvider())));
864
472
  }
865
473
  async connect() {
866
474
  if (!this.provider && this.providerPromise) {
867
475
  await this.providerPromise;
868
476
  }
869
477
  if (!this.provider) {
870
- _chunkAFVK5GA5js.sentryLogger.error("Phantom is not available");
478
+ _chunkFRA6K6V4js.sentryLogger.error("Phantom is not available");
871
479
  throw new Error("Phantom is not available");
872
480
  }
873
- try {
874
- await this.provider.request({
875
- method: "wallet_requestPermissions",
876
- params: [{ eth_accounts: {} }]
877
- });
878
- const accounts = await this.provider.request({
879
- method: "eth_requestAccounts",
880
- params: []
881
- });
882
- if (!accounts || accounts.length === 0 || !accounts[0]) {
883
- _chunkAFVK5GA5js.sentryLogger.error("No accounts returned from Phantom");
884
- throw new Error("No accounts returned from Phantom");
885
- }
886
- return {
887
- address: accounts[0],
888
- provider: this.provider,
889
- walletId: this.id
890
- };
891
- } catch (e9) {
892
- 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
+ _chunkFRA6K6V4js.sentryLogger.error("No accounts returned from Phantom");
491
+ throw new Error("No accounts returned from Phantom");
893
492
  }
493
+ return {
494
+ address: accounts[0],
495
+ provider: this.provider,
496
+ walletId: this.id
497
+ };
894
498
  }
895
499
  async tryRestoreConnection() {
896
500
  if (!this.provider && this.providerPromise) {
@@ -912,7 +516,7 @@ var PhantomAdapter = class {
912
516
  provider: this.provider,
913
517
  walletId: this.id
914
518
  };
915
- } catch (e10) {
519
+ } catch (e3) {
916
520
  return null;
917
521
  }
918
522
  }
@@ -924,15 +528,15 @@ var PhantomAdapter = class {
924
528
  // Called by Aurum when user connects wallet
925
529
  // Passes Aurum.ts --> syncStateFromAccountsChanged() to handle the provider accounts changed event
926
530
  onAccountsChanged(callback) {
927
- if (!_optionalChain([this, 'access', _72 => _72.provider, 'optionalAccess', _73 => _73.on])) return;
531
+ if (!_optionalChain([this, 'access', _40 => _40.provider, 'optionalAccess', _41 => _41.on])) return;
928
532
  if (this.accountsChangedCallback) {
929
- _optionalChain([this, 'access', _74 => _74.provider, 'access', _75 => _75.removeListener, 'optionalCall', _76 => _76("accountsChanged", this.accountsChangedCallback)]);
533
+ _optionalChain([this, 'access', _42 => _42.provider, 'access', _43 => _43.removeListener, 'optionalCall', _44 => _44("accountsChanged", this.accountsChangedCallback)]);
930
534
  }
931
535
  this.accountsChangedCallback = callback;
932
536
  this.provider.on("accountsChanged", this.accountsChangedCallback);
933
537
  }
934
538
  removeListeners() {
935
- if (!_optionalChain([this, 'access', _77 => _77.provider, 'optionalAccess', _78 => _78.removeListener]) || !this.accountsChangedCallback) return;
539
+ if (!_optionalChain([this, 'access', _45 => _45.provider, 'optionalAccess', _46 => _46.removeListener]) || !this.accountsChangedCallback) return;
936
540
  this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
937
541
  this.accountsChangedCallback = null;
938
542
  }
@@ -943,7 +547,7 @@ var _walletsdk = require('@coinbase/wallet-sdk');
943
547
 
944
548
 
945
549
  var CoinbaseWalletAdapter = class {
946
- constructor({ appName, appLogoUrl }) {
550
+ constructor({ appName, appLogoUrl, telemetry }) {
947
551
  this.id = _types.WalletId.CoinbaseWallet;
948
552
  this.name = _types.WalletName.CoinbaseWallet;
949
553
  this.icon = _nullishCoalesce(_logos.getLogoDataUri.call(void 0, _types.WalletId.CoinbaseWallet, "brand"), () => ( ""));
@@ -952,18 +556,26 @@ var CoinbaseWalletAdapter = class {
952
556
  this.wcDeepLinkUrl = "cbwallet://wc?uri=";
953
557
  this.provider = null;
954
558
  this.accountsChangedCallback = null;
955
- this.provider = this.detectProvider({ appName, appLogoUrl });
559
+ this.provider = this.detectProvider({ appName, appLogoUrl, telemetry: _nullishCoalesce(telemetry, () => ( false)) });
956
560
  }
957
- detectProvider({ appName, appLogoUrl }) {
561
+ detectProvider({
562
+ appName,
563
+ appLogoUrl,
564
+ telemetry
565
+ }) {
958
566
  if (typeof window === "undefined") return null;
959
567
  try {
960
568
  const coinbaseSdk = _walletsdk.createCoinbaseWalletSDK.call(void 0, {
961
569
  appName,
962
- appLogoUrl
570
+ appLogoUrl,
571
+ preference: {
572
+ options: "all",
573
+ telemetry
574
+ }
963
575
  });
964
576
  return coinbaseSdk.getProvider();
965
577
  } catch (error) {
966
- _chunkAFVK5GA5js.sentryLogger.warn("Failed to initialize Coinbase Wallet provider", { error });
578
+ _chunkFRA6K6V4js.sentryLogger.warn("Failed to initialize Coinbase Wallet provider", { error });
967
579
  return null;
968
580
  }
969
581
  }
@@ -972,26 +584,22 @@ var CoinbaseWalletAdapter = class {
972
584
  }
973
585
  async connect() {
974
586
  if (!this.isInstalled() || !this.provider) {
975
- _chunkAFVK5GA5js.sentryLogger.error("Coinbase Wallet is not available");
587
+ _chunkFRA6K6V4js.sentryLogger.error("Coinbase Wallet is not available");
976
588
  throw new Error("Coinbase Wallet is not available");
977
589
  }
978
- try {
979
- const accounts = await this.provider.request({
980
- method: "eth_requestAccounts",
981
- params: []
982
- });
983
- if (!accounts || accounts.length === 0 || !accounts[0]) {
984
- _chunkAFVK5GA5js.sentryLogger.error("No accounts returned from Coinbase Wallet");
985
- throw new Error("No accounts returned from Coinbase Wallet");
986
- }
987
- return {
988
- address: accounts[0],
989
- provider: this.provider,
990
- walletId: this.id
991
- };
992
- } catch (e11) {
993
- 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
+ _chunkFRA6K6V4js.sentryLogger.error("No accounts returned from Coinbase Wallet");
596
+ throw new Error("No accounts returned from Coinbase Wallet");
994
597
  }
598
+ return {
599
+ address: accounts[0],
600
+ provider: this.provider,
601
+ walletId: this.id
602
+ };
995
603
  }
996
604
  async tryRestoreConnection() {
997
605
  if (!this.isInstalled() || !this.provider) {
@@ -1010,19 +618,19 @@ var CoinbaseWalletAdapter = class {
1010
618
  provider: this.provider,
1011
619
  walletId: this.id
1012
620
  };
1013
- } catch (e12) {
621
+ } catch (e4) {
1014
622
  return null;
1015
623
  }
1016
624
  }
1017
625
  async disconnect() {
1018
626
  try {
1019
- if (_optionalChain([this, 'access', _79 => _79.provider, 'optionalAccess', _80 => _80.close])) {
627
+ if (_optionalChain([this, 'access', _47 => _47.provider, 'optionalAccess', _48 => _48.close])) {
1020
628
  await this.provider.close();
1021
- } else if (_optionalChain([this, 'access', _81 => _81.provider, 'optionalAccess', _82 => _82.disconnect])) {
629
+ } else if (_optionalChain([this, 'access', _49 => _49.provider, 'optionalAccess', _50 => _50.disconnect])) {
1022
630
  await this.provider.disconnect();
1023
631
  }
1024
632
  } catch (error) {
1025
- _chunkAFVK5GA5js.sentryLogger.warn("Error disconnecting from Coinbase Wallet", { error });
633
+ _chunkFRA6K6V4js.sentryLogger.warn("Error disconnecting from Coinbase Wallet", { error });
1026
634
  } finally {
1027
635
  this.clearLocalStorage();
1028
636
  }
@@ -1046,15 +654,15 @@ var CoinbaseWalletAdapter = class {
1046
654
  // Called by Aurum when user connects wallet
1047
655
  // Passes Aurum.ts --> syncStateFromAccountsChanged() to handle the provider accounts changed event
1048
656
  onAccountsChanged(callback) {
1049
- if (!_optionalChain([this, 'access', _83 => _83.provider, 'optionalAccess', _84 => _84.on])) return;
657
+ if (!_optionalChain([this, 'access', _51 => _51.provider, 'optionalAccess', _52 => _52.on])) return;
1050
658
  if (this.accountsChangedCallback) {
1051
- _optionalChain([this, 'access', _85 => _85.provider, 'access', _86 => _86.removeListener, 'optionalCall', _87 => _87("accountsChanged", this.accountsChangedCallback)]);
659
+ _optionalChain([this, 'access', _53 => _53.provider, 'access', _54 => _54.removeListener, 'optionalCall', _55 => _55("accountsChanged", this.accountsChangedCallback)]);
1052
660
  }
1053
661
  this.accountsChangedCallback = callback;
1054
662
  this.provider.on("accountsChanged", this.accountsChangedCallback);
1055
663
  }
1056
664
  removeListeners() {
1057
- if (!_optionalChain([this, 'access', _88 => _88.provider, 'optionalAccess', _89 => _89.removeListener]) || !this.accountsChangedCallback) return;
665
+ if (!_optionalChain([this, 'access', _56 => _56.provider, 'optionalAccess', _57 => _57.removeListener]) || !this.accountsChangedCallback) return;
1058
666
  this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
1059
667
  this.accountsChangedCallback = null;
1060
668
  }
@@ -1116,47 +724,43 @@ var MetaMaskAdapter = class {
1116
724
  detectLegacyProvider() {
1117
725
  const ethereum = window.ethereum;
1118
726
  if (!ethereum) return null;
1119
- if (_optionalChain([ethereum, 'access', _90 => _90.providers, 'optionalAccess', _91 => _91.length])) {
727
+ if (_optionalChain([ethereum, 'access', _58 => _58.providers, 'optionalAccess', _59 => _59.length])) {
1120
728
  const metaMaskProvider = ethereum.providers.find((p) => p.isMetaMask && !p.isBraveWallet);
1121
729
  if (metaMaskProvider) return metaMaskProvider;
1122
730
  }
1123
731
  if (ethereum.isMetaMask && !ethereum.isBraveWallet) {
1124
732
  return ethereum;
1125
733
  }
1126
- return null;
1127
- }
1128
- isInstalled() {
1129
- return Boolean(this.provider);
1130
- }
1131
- async connect() {
1132
- if (!this.provider && this.providerPromise) {
1133
- await this.providerPromise;
1134
- }
1135
- if (!this.provider) {
1136
- _chunkAFVK5GA5js.sentryLogger.error("MetaMask is not available");
1137
- throw new Error("MetaMask is not available");
1138
- }
1139
- try {
1140
- await this.provider.request({
1141
- method: "wallet_requestPermissions",
1142
- params: [{ eth_accounts: {} }]
1143
- });
1144
- const accounts = await this.provider.request({
1145
- method: "eth_requestAccounts",
1146
- params: []
1147
- });
1148
- if (!accounts || accounts.length === 0 || !accounts[0]) {
1149
- _chunkAFVK5GA5js.sentryLogger.error("No accounts returned from MetaMask");
1150
- throw new Error("No accounts returned from MetaMask");
1151
- }
1152
- return {
1153
- address: accounts[0],
1154
- provider: this.provider,
1155
- walletId: this.id
1156
- };
1157
- } catch (e13) {
1158
- throw new Error("Failed to connect to MetaMask");
734
+ return null;
735
+ }
736
+ isInstalled() {
737
+ return Boolean(_nullishCoalesce(this.provider, () => ( this.detectLegacyProvider())));
738
+ }
739
+ async connect() {
740
+ if (!this.provider && this.providerPromise) {
741
+ await this.providerPromise;
742
+ }
743
+ if (!this.provider) {
744
+ _chunkFRA6K6V4js.sentryLogger.error("MetaMask is not available");
745
+ throw new Error("MetaMask is not available");
746
+ }
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
+ _chunkFRA6K6V4js.sentryLogger.error("No accounts returned from MetaMask");
757
+ throw new Error("No accounts returned from MetaMask");
1159
758
  }
759
+ return {
760
+ address: accounts[0],
761
+ provider: this.provider,
762
+ walletId: this.id
763
+ };
1160
764
  }
1161
765
  async tryRestoreConnection() {
1162
766
  if (!this.provider && this.providerPromise) {
@@ -1178,7 +782,7 @@ var MetaMaskAdapter = class {
1178
782
  provider: this.provider,
1179
783
  walletId: this.id
1180
784
  };
1181
- } catch (e14) {
785
+ } catch (e5) {
1182
786
  return null;
1183
787
  }
1184
788
  }
@@ -1190,15 +794,15 @@ var MetaMaskAdapter = class {
1190
794
  // Called by Aurum when user connects wallet
1191
795
  // Passes Aurum.ts --> syncStateFromAccountsChanged() to handle the provider accounts changed event
1192
796
  onAccountsChanged(callback) {
1193
- if (!_optionalChain([this, 'access', _92 => _92.provider, 'optionalAccess', _93 => _93.on])) return;
797
+ if (!_optionalChain([this, 'access', _60 => _60.provider, 'optionalAccess', _61 => _61.on])) return;
1194
798
  if (this.accountsChangedCallback) {
1195
- _optionalChain([this, 'access', _94 => _94.provider, 'access', _95 => _95.removeListener, 'optionalCall', _96 => _96("accountsChanged", this.accountsChangedCallback)]);
799
+ _optionalChain([this, 'access', _62 => _62.provider, 'access', _63 => _63.removeListener, 'optionalCall', _64 => _64("accountsChanged", this.accountsChangedCallback)]);
1196
800
  }
1197
801
  this.accountsChangedCallback = callback;
1198
802
  this.provider.on("accountsChanged", this.accountsChangedCallback);
1199
803
  }
1200
804
  removeListeners() {
1201
- if (!_optionalChain([this, 'access', _97 => _97.provider, 'optionalAccess', _98 => _98.removeListener]) || !this.accountsChangedCallback) return;
805
+ if (!_optionalChain([this, 'access', _65 => _65.provider, 'optionalAccess', _66 => _66.removeListener]) || !this.accountsChangedCallback) return;
1202
806
  this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
1203
807
  this.accountsChangedCallback = null;
1204
808
  }
@@ -1207,6 +811,98 @@ var MetaMaskAdapter = class {
1207
811
  // src/wallet-adapters/WalletConnectAdapter.ts
1208
812
 
1209
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
+ }
1210
906
  var WalletConnectAdapter = class {
1211
907
  constructor(config) {
1212
908
  this.id = _types.WalletId.WalletConnect;
@@ -1215,122 +911,233 @@ var WalletConnectAdapter = class {
1215
911
  this.hide = false;
1216
912
  this.downloadUrl = null;
1217
913
  this.wcDeepLinkUrl = null;
914
+ this.modal = null;
915
+ this.wagmiAdapter = null;
916
+ this.universalProvider = null;
1218
917
  this.provider = null;
918
+ this.address = null;
1219
919
  this.connectionUri = null;
1220
920
  this.accountsChangedCallback = null;
921
+ this.chainChangedCallback = null;
922
+ this.disconnectCallback = null;
923
+ this.sessionUpdateHandler = null;
924
+ this.unsubscribeFunctions = [];
1221
925
  this.initPromise = null;
1222
- this.config = {
1223
- projectId: config.projectId,
1224
- appName: config.appName
1225
- };
926
+ this.lastKnownAccounts = [];
927
+ this.lastKnownChainId = null;
928
+ this.config = config;
1226
929
  }
1227
930
  async ensureInitialized() {
1228
- if (this.provider) return;
931
+ if (this.modal) return;
1229
932
  if (!this.initPromise) {
1230
- this.initPromise = this.initializeProvider();
933
+ this.initPromise = this.initializeAppKit();
1231
934
  }
1232
935
  await this.initPromise;
1233
936
  }
1234
- async initializeProvider() {
937
+ async initializeAppKit() {
1235
938
  if (typeof window === "undefined") return;
1236
- const { EthereumProvider } = await Promise.resolve().then(() => _interopRequireWildcard(require("@walletconnect/ethereum-provider")));
1237
- this.provider = await EthereumProvider.init({
1238
- projectId: _nullishCoalesce(this.config.projectId, () => ( "")),
1239
- optionalChains: [1],
1240
- showQrModal: false,
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,
1241
954
  metadata: {
1242
955
  name: this.config.appName,
1243
956
  description: this.config.appName,
1244
957
  url: window.location.origin,
1245
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))
1246
967
  }
1247
968
  });
1248
- this.provider.on("display_uri", (uri) => {
1249
- this.connectionUri = uri;
1250
- if (typeof window !== "undefined") {
1251
- window.dispatchEvent(new CustomEvent("walletconnect:uri", { detail: { uri } }));
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;
1252
979
  }
1253
980
  });
1254
- this.provider.on("connect", (session) => {
1255
- if (typeof window !== "undefined") {
1256
- window.dispatchEvent(new CustomEvent("walletconnect:connect", { detail: { session } }));
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];
1257
1021
  }
1258
- });
1259
- this.provider.on("disconnect", () => {
1260
- this.connectionUri = null;
1261
- });
1262
- this.provider.on("session_delete", () => {
1263
- if (typeof window !== "undefined") {
1264
- window.dispatchEvent(new CustomEvent("walletconnect:disconnect"));
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
+ }
1265
1035
  }
1266
- });
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
+ _chunkFRA6K6V4js.sentryLogger.warn("Failed to get provider from wagmi connector", { error });
1049
+ }
1050
+ }
1051
+ }
1052
+ }
1053
+ } catch (error) {
1054
+ _chunkFRA6K6V4js.sentryLogger.warn("Failed to get provider from WalletConnect", { error });
1055
+ }
1267
1056
  }
1268
1057
  isInstalled() {
1269
1058
  return true;
1270
1059
  }
1271
- async connect() {
1272
- if (!this.config.projectId) {
1273
- throw _chunkAFVK5GA5js.createConfigError.call(void 0, "WalletConnect");
1274
- }
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;
1275
1069
  try {
1276
- await this.ensureInitialized();
1277
- if (!this.provider) {
1278
- _chunkAFVK5GA5js.sentryLogger.error("connect: WalletConnect is not available");
1279
- throw new Error("WalletConnect is not available");
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();
1280
1074
  }
1281
- const accounts = await this.provider.enable();
1282
- if (!accounts || accounts.length === 0 || !accounts[0]) {
1283
- _chunkAFVK5GA5js.sentryLogger.error("connect: No accounts returned from WalletConnect");
1284
- throw new Error("No accounts returned from WalletConnect");
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) {
1285
1081
  }
1286
- return {
1287
- address: accounts[0],
1288
- provider: this.provider,
1289
- walletId: this.id
1290
- };
1291
- } catch (e15) {
1292
- this.connectionUri = null;
1293
- throw new Error("Failed to connect to WalletConnect");
1294
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;
1295
1091
  }
1296
- getConnectionUri() {
1297
- return this.connectionUri;
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 _chunkFRA6K6V4js.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
+ }
1298
1114
  }
1299
1115
  /**
1300
1116
  * Starts a WalletConnect session for headless/custom QR code flows.
1301
1117
  * Returns the URI immediately and a function to wait for the connection.
1302
1118
  */
1303
1119
  async startSession(timeout = 1e4) {
1304
- if (!this.config.projectId) {
1305
- throw new Error("WalletConnect projectId is required");
1306
- }
1120
+ if (!this.config.projectId) throw new Error("WalletConnect projectId is required");
1307
1121
  await this.ensureInitialized();
1308
- if (!this.provider) {
1309
- _chunkAFVK5GA5js.sentryLogger.error("startSession: WalletConnect is not available");
1310
- throw new Error("WalletConnect is not available");
1311
- }
1312
- this.connectionUri = null;
1122
+ if (!this.universalProvider) throw new Error("WalletConnect is not available");
1123
+ await this.resetConnectionState();
1313
1124
  const uriPromise = new Promise((resolve, reject) => {
1314
- const timeoutId = setTimeout(() => {
1315
- reject(new Error("Timeout waiting for WalletConnect URI"));
1316
- }, timeout);
1317
- this.provider.once("display_uri", (uri2) => {
1125
+ const timeoutId = setTimeout(() => reject(new Error("Timeout waiting for WalletConnect URI")), timeout);
1126
+ this.universalProvider.once("display_uri", (uri2) => {
1318
1127
  clearTimeout(timeoutId);
1319
1128
  this.connectionUri = uri2;
1320
1129
  resolve(uri2);
1321
1130
  });
1322
1131
  });
1323
1132
  const connectionPromise = (async () => {
1324
- const accounts = await this.provider.enable();
1325
- if (!accounts || accounts.length === 0 || !accounts[0]) {
1326
- _chunkAFVK5GA5js.sentryLogger.error("startSession: No accounts returned from WalletConnect");
1327
- throw new Error("No accounts returned from WalletConnect");
1328
- }
1329
- return {
1330
- address: accounts[0],
1331
- provider: this.provider,
1332
- walletId: this.id
1333
- };
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 };
1334
1141
  })();
1335
1142
  const uri = await uriPromise;
1336
1143
  return {
@@ -1338,60 +1145,190 @@ var WalletConnectAdapter = class {
1338
1145
  waitForConnection: async () => {
1339
1146
  try {
1340
1147
  return await connectionPromise;
1341
- } catch (e16) {
1148
+ } catch (error) {
1342
1149
  this.connectionUri = null;
1343
- throw new Error("Failed to connect via WalletConnect");
1150
+ throw error;
1344
1151
  }
1345
1152
  }
1346
1153
  };
1347
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 _chunkFRA6K6V4js.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
+ }
1348
1212
  async tryRestoreConnection() {
1213
+ await this.ensureInitialized();
1214
+ if (!this.wagmiAdapter) return null;
1349
1215
  try {
1350
- await this.ensureInitialized();
1351
- if (!this.provider) {
1352
- return null;
1353
- }
1354
- const accounts = this.provider.accounts;
1355
- if (!accounts || accounts.length === 0 || !accounts[0]) {
1356
- return null;
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 };
1357
1225
  }
1358
- return {
1359
- address: accounts[0],
1360
- provider: this.provider,
1361
- walletId: this.id
1362
- };
1363
- } catch (e17) {
1226
+ return null;
1227
+ } catch (e10) {
1364
1228
  return null;
1365
1229
  }
1366
1230
  }
1367
1231
  async disconnect() {
1368
- try {
1369
- if (this.provider) {
1370
- await this.provider.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));
1371
1237
  }
1372
- } finally {
1373
- this.connectionUri = null;
1374
- this.provider = null;
1375
- this.initPromise = null;
1376
1238
  }
1239
+ this.address = null;
1240
+ this.provider = null;
1241
+ this.connectionUri = null;
1242
+ this.lastKnownAccounts = [];
1243
+ this.lastKnownChainId = null;
1377
1244
  }
1378
1245
  getProvider() {
1379
1246
  return this.provider;
1380
1247
  }
1381
- // Called by Aurum when user connects wallet
1382
- // Passes Aurum.ts --> syncStateFromAccountsChanged() to handle the provider accounts changed event
1383
1248
  onAccountsChanged(callback) {
1384
- if (!_optionalChain([this, 'access', _99 => _99.provider, 'optionalAccess', _100 => _100.on])) return;
1385
- if (this.accountsChangedCallback) {
1386
- _optionalChain([this, 'access', _101 => _101.provider, 'access', _102 => _102.removeListener, 'optionalCall', _103 => _103("accountsChanged", this.accountsChangedCallback)]);
1249
+ if (this.accountsChangedCallback && _optionalChain([this, 'access', _104 => _104.provider, 'optionalAccess', _105 => _105.removeListener])) {
1250
+ this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
1387
1251
  }
1388
- this.accountsChangedCallback = callback;
1389
- this.provider.on("accountsChanged", this.accountsChangedCallback);
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()]));
1390
1313
  }
1391
1314
  removeListeners() {
1392
- if (!_optionalChain([this, 'access', _104 => _104.provider, 'optionalAccess', _105 => _105.removeListener]) || !this.accountsChangedCallback) return;
1393
- this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
1394
- this.accountsChangedCallback = null;
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;
1395
1332
  }
1396
1333
  };
1397
1334
 
@@ -1409,7 +1346,8 @@ var _EmailAdapter = class _EmailAdapter {
1409
1346
  this.provider = null;
1410
1347
  this.initPromise = null;
1411
1348
  this.publicClientCache = /* @__PURE__ */ new Map();
1412
- this.projectId = _optionalChain([config, 'optionalAccess', _106 => _106.projectId]) || "";
1349
+ this.projectId = _optionalChain([config, 'optionalAccess', _135 => _135.projectId]) || "";
1350
+ this.telemetry = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _136 => _136.telemetry]), () => ( false));
1413
1351
  }
1414
1352
  async ensureInitialized() {
1415
1353
  if (this.provider) return;
@@ -1423,21 +1361,16 @@ var _EmailAdapter = class _EmailAdapter {
1423
1361
  }
1424
1362
  async emailAuthStart(email) {
1425
1363
  if (!this.projectId) {
1426
- throw _chunkAFVK5GA5js.createConfigError.call(void 0, "Email");
1364
+ throw _chunkFRA6K6V4js.createConfigError.call(void 0, "Email");
1427
1365
  }
1428
1366
  await this.ensureInitialized();
1429
1367
  if (!this.provider) {
1430
- _chunkAFVK5GA5js.sentryLogger.error("Email is not available");
1368
+ _chunkFRA6K6V4js.sentryLogger.error("Email is not available");
1431
1369
  throw new Error("Email is not available");
1432
1370
  }
1433
- try {
1434
- const { signInWithEmail } = await Promise.resolve().then(() => _interopRequireWildcard(require("@coinbase/cdp-core")));
1435
- const authResult = await signInWithEmail({ email });
1436
- return authResult;
1437
- } catch (error) {
1438
- _chunkAFVK5GA5js.sentryLogger.error("Failed to start email authentication", { error });
1439
- throw error;
1440
- }
1371
+ const { signInWithEmail } = await Promise.resolve().then(() => _interopRequireWildcard(require("@coinbase/cdp-core")));
1372
+ const authResult = await signInWithEmail({ email });
1373
+ return authResult;
1441
1374
  }
1442
1375
  async emailAuthVerify(flowId, otp) {
1443
1376
  if (!flowId || !otp) {
@@ -1445,14 +1378,14 @@ var _EmailAdapter = class _EmailAdapter {
1445
1378
  }
1446
1379
  await this.ensureInitialized();
1447
1380
  if (!this.provider) {
1448
- _chunkAFVK5GA5js.sentryLogger.error("Email provider not initialized");
1381
+ _chunkFRA6K6V4js.sentryLogger.error("Email provider not initialized");
1449
1382
  throw new Error("Email provider not initialized");
1450
1383
  }
1451
1384
  const { verifyEmailOTP } = await Promise.resolve().then(() => _interopRequireWildcard(require("@coinbase/cdp-core")));
1452
1385
  return verifyEmailOTP({ flowId, otp });
1453
1386
  }
1454
1387
  async connect() {
1455
- _chunkAFVK5GA5js.sentryLogger.error("EmailAdapter.connect() is not implemented");
1388
+ _chunkFRA6K6V4js.sentryLogger.error("EmailAdapter.connect() is not implemented");
1456
1389
  throw new Error("EmailAdapter.connect() is not implemented");
1457
1390
  }
1458
1391
  async tryRestoreConnection() {
@@ -1473,7 +1406,7 @@ var _EmailAdapter = class _EmailAdapter {
1473
1406
  provider: this.provider,
1474
1407
  walletId: this.id
1475
1408
  };
1476
- } catch (e18) {
1409
+ } catch (e11) {
1477
1410
  return null;
1478
1411
  }
1479
1412
  }
@@ -1482,7 +1415,7 @@ var _EmailAdapter = class _EmailAdapter {
1482
1415
  await this.ensureInitialized();
1483
1416
  const { signOut } = await Promise.resolve().then(() => _interopRequireWildcard(require("@coinbase/cdp-core")));
1484
1417
  await signOut();
1485
- } catch (e19) {
1418
+ } catch (e12) {
1486
1419
  }
1487
1420
  }
1488
1421
  getProvider() {
@@ -1531,7 +1464,8 @@ var _EmailAdapter = class _EmailAdapter {
1531
1464
  projectId: this.projectId,
1532
1465
  ethereum: {
1533
1466
  createOnLogin: "eoa"
1534
- }
1467
+ },
1468
+ disableAnalytics: !this.telemetry
1535
1469
  });
1536
1470
  this.provider = await this.createProvider();
1537
1471
  }
@@ -1556,15 +1490,15 @@ var _EmailAdapter = class _EmailAdapter {
1556
1490
  try {
1557
1491
  return await base.request(args);
1558
1492
  } catch (err) {
1559
- const msg = String(_optionalChain([err, 'optionalAccess', _107 => _107.message]) || "");
1560
- const isUnsupported = msg.includes("not supported") || msg.includes("Unsupported") || _optionalChain([err, 'optionalAccess', _108 => _108.code]) === -32601;
1493
+ const msg = String(_optionalChain([err, 'optionalAccess', _137 => _137.message]) || "");
1494
+ const isUnsupported = msg.includes("not supported") || msg.includes("Unsupported") || _optionalChain([err, 'optionalAccess', _138 => _138.code]) === -32601;
1561
1495
  if (isUnsupported) {
1562
1496
  let chainId;
1563
1497
  try {
1564
1498
  const chainIdHex = await base.request({ method: "eth_chainId", params: [] });
1565
1499
  chainId = parseInt(chainIdHex, 16);
1566
- } catch (e20) {
1567
- _chunkAFVK5GA5js.sentryLogger.error("Failed to get chainId for fallback request");
1500
+ } catch (e13) {
1501
+ _chunkFRA6K6V4js.sentryLogger.error("Failed to get chainId for fallback request");
1568
1502
  throw new Error("Failed to get chainId for fallback request");
1569
1503
  }
1570
1504
  const publicClient = await getPublicClient(chainId);
@@ -1579,7 +1513,7 @@ var _EmailAdapter = class _EmailAdapter {
1579
1513
  };
1580
1514
  return wrapped;
1581
1515
  } catch (error) {
1582
- _chunkAFVK5GA5js.sentryLogger.error("Failed to initialize Email provider", { error });
1516
+ _chunkFRA6K6V4js.sentryLogger.error("Failed to initialize Email provider", { error });
1583
1517
  return null;
1584
1518
  }
1585
1519
  }
@@ -1601,18 +1535,23 @@ function createWalletAdapters({
1601
1535
  appName,
1602
1536
  appLogoUrl,
1603
1537
  modalZIndex,
1604
- theme
1538
+ theme,
1539
+ telemetry
1605
1540
  }) {
1606
1541
  return [
1607
- new EmailAdapter({ projectId: _optionalChain([walletsConfig, 'optionalAccess', _109 => _109.embedded, 'optionalAccess', _110 => _110.projectId]) }),
1542
+ new EmailAdapter({ projectId: _optionalChain([walletsConfig, 'optionalAccess', _139 => _139.embedded, 'optionalAccess', _140 => _140.projectId]), telemetry }),
1608
1543
  new MetaMaskAdapter(),
1609
- new WalletConnectAdapter({ projectId: _optionalChain([walletsConfig, 'optionalAccess', _111 => _111.walletConnect, 'optionalAccess', _112 => _112.projectId]), appName }),
1610
- new CoinbaseWalletAdapter({ appName, appLogoUrl }),
1544
+ new WalletConnectAdapter({
1545
+ projectId: _optionalChain([walletsConfig, 'optionalAccess', _141 => _141.walletConnect, 'optionalAccess', _142 => _142.projectId]),
1546
+ appName,
1547
+ modalZIndex,
1548
+ theme,
1549
+ telemetry
1550
+ }),
1551
+ new CoinbaseWalletAdapter({ appName, appLogoUrl, telemetry }),
1611
1552
  new PhantomAdapter(),
1612
1553
  new RabbyAdapter(),
1613
- new BraveAdapter(),
1614
- new LedgerAdapter({ walletConnectProjectId: _optionalChain([walletsConfig, 'optionalAccess', _113 => _113.walletConnect, 'optionalAccess', _114 => _114.projectId]) }),
1615
- new AppKitAdapter({ projectId: _optionalChain([walletsConfig, 'optionalAccess', _115 => _115.walletConnect, 'optionalAccess', _116 => _116.projectId]), appName, modalZIndex, theme })
1554
+ new BraveAdapter()
1616
1555
  ];
1617
1556
  }
1618
1557
 
@@ -1620,6 +1559,26 @@ function createWalletAdapters({
1620
1559
 
1621
1560
 
1622
1561
  // src/providers/RpcProvider.ts
1562
+ var ProviderRpcError = class extends Error {
1563
+ constructor(code, message, data) {
1564
+ super(message);
1565
+ this.name = "ProviderRpcError";
1566
+ this.code = code;
1567
+ this.data = data;
1568
+ }
1569
+ };
1570
+ var ProviderErrorCode = {
1571
+ USER_REJECTED: 4001,
1572
+ // User rejected the request
1573
+ UNAUTHORIZED: 4100,
1574
+ // The requested account/method has not been authorized
1575
+ UNSUPPORTED_METHOD: 4200,
1576
+ // The provider does not support the requested method
1577
+ DISCONNECTED: 4900,
1578
+ // The provider is disconnected from all chains
1579
+ CHAIN_DISCONNECTED: 4901
1580
+ // The provider is not connected to the requested chain
1581
+ };
1623
1582
  var RpcProvider = class {
1624
1583
  constructor(handleConnect) {
1625
1584
  this.isConnected = false;
@@ -1641,7 +1600,10 @@ var RpcProvider = class {
1641
1600
  const address = await this.handleConnect();
1642
1601
  return [address];
1643
1602
  } else {
1644
- throw new Error("No wallet connection available. Please use aurum.connect() instead.");
1603
+ throw new ProviderRpcError(
1604
+ ProviderErrorCode.DISCONNECTED,
1605
+ "No wallet connection available. Please use aurum.connect() instead."
1606
+ );
1645
1607
  }
1646
1608
  // Chain/network information
1647
1609
  case "eth_chainId":
@@ -1650,8 +1612,9 @@ var RpcProvider = class {
1650
1612
  return this.networkVersion;
1651
1613
  // Default case for rest of methods
1652
1614
  default:
1653
- throw new Error(
1654
- `Method ${method} requires an active connection to a JSON-RPC provider. Please connect a wallet.`
1615
+ throw new ProviderRpcError(
1616
+ ProviderErrorCode.DISCONNECTED,
1617
+ `Method ${method} requires an active wallet connection. Please connect a wallet first.`
1655
1618
  );
1656
1619
  }
1657
1620
  }
@@ -1679,15 +1642,16 @@ var _AurumCore = class _AurumCore {
1679
1642
  return _AurumCore.instance;
1680
1643
  }
1681
1644
  const telemetryEnabled = config.telemetry !== false;
1682
- _chunkAFVK5GA5js.initSentry.call(void 0, telemetryEnabled);
1645
+ _chunkFRA6K6V4js.initSentry.call(void 0, telemetryEnabled);
1683
1646
  this.brandConfig = this.resolveBrandConfig(config);
1684
- this.excludedWallets = new Set(_nullishCoalesce(_optionalChain([config, 'access', _117 => _117.wallets, 'optionalAccess', _118 => _118.exclude]), () => ( [])));
1647
+ this.excludedWallets = new Set(_nullishCoalesce(_optionalChain([config, 'access', _143 => _143.wallets, 'optionalAccess', _144 => _144.exclude]), () => ( [])));
1685
1648
  this.wallets = createWalletAdapters({
1686
1649
  walletsConfig: config.wallets,
1687
1650
  appName: this.brandConfig.appName,
1688
1651
  appLogoUrl: this.brandConfig.logo,
1689
1652
  modalZIndex: this.brandConfig.modalZIndex,
1690
- theme: this.brandConfig.theme
1653
+ theme: this.brandConfig.theme,
1654
+ telemetry: telemetryEnabled
1691
1655
  });
1692
1656
  this.skeletonProvider = new RpcProvider(() => this.connect());
1693
1657
  this.currentProvider = this.skeletonProvider;
@@ -1698,7 +1662,7 @@ var _AurumCore = class _AurumCore {
1698
1662
  async whenReady() {
1699
1663
  try {
1700
1664
  await this.readyPromise;
1701
- } catch (e21) {
1665
+ } catch (e14) {
1702
1666
  this.resetConnectionState();
1703
1667
  this.ready = true;
1704
1668
  }
@@ -1717,10 +1681,7 @@ var _AurumCore = class _AurumCore {
1717
1681
  if (walletId === "email") {
1718
1682
  throw new Error("Use emailAuthStart() and emailAuthVerify() for email wallet connections");
1719
1683
  }
1720
- if (walletId === "walletconnect") {
1721
- throw new Error("Use getWalletConnectSession() for WalletConnect connections");
1722
- }
1723
- if (_optionalChain([this, 'access', _119 => _119.userInfo, 'optionalAccess', _120 => _120.publicAddress]) && _optionalChain([this, 'access', _121 => _121.connectedWalletAdapter, 'optionalAccess', _122 => _122.getProvider, 'call', _123 => _123()])) {
1684
+ if (_optionalChain([this, 'access', _145 => _145.userInfo, 'optionalAccess', _146 => _146.publicAddress]) && _optionalChain([this, 'access', _147 => _147.connectedWalletAdapter, 'optionalAccess', _148 => _148.getProvider, 'call', _149 => _149()])) {
1724
1685
  if (!walletId || this.userInfo.walletId === walletId) {
1725
1686
  return this.userInfo.publicAddress;
1726
1687
  }
@@ -1736,27 +1697,31 @@ var _AurumCore = class _AurumCore {
1736
1697
  if (!adapter) {
1737
1698
  throw new Error(`${walletId} is not configured`);
1738
1699
  }
1739
- if (!adapter.isInstalled()) {
1740
- throw new Error(`${adapter.name} is not installed`);
1700
+ if (walletId === _types.WalletId.WalletConnect && adapter.openModal) {
1701
+ result = await adapter.openModal();
1702
+ } else {
1703
+ if (!adapter.isInstalled()) {
1704
+ throw new Error(`${adapter.name} is not installed`);
1705
+ }
1706
+ result = await adapter.connect();
1741
1707
  }
1742
- result = await adapter.connect();
1743
1708
  } else {
1744
1709
  const displayedWallets = this.wallets.filter((w) => !this.excludedWallets.has(w.id));
1745
1710
  const modalResult = await renderConnectModal({ displayedWallets, brandConfig: this.brandConfig });
1746
1711
  if (!modalResult) {
1747
- _chunkAFVK5GA5js.sentryLogger.error("Missing modal result");
1712
+ _chunkFRA6K6V4js.sentryLogger.error("Missing modal result");
1748
1713
  throw new Error("Missing modal result");
1749
1714
  }
1750
1715
  adapter = this.wallets.find((w) => w.id === modalResult.walletId) || null;
1751
1716
  if (!adapter) {
1752
- _chunkAFVK5GA5js.sentryLogger.error(`Selected wallet adapter not found: ${modalResult.walletId}`);
1717
+ _chunkFRA6K6V4js.sentryLogger.error(`Selected wallet adapter not found: ${modalResult.walletId}`);
1753
1718
  throw new Error("Selected wallet adapter not found");
1754
1719
  }
1755
1720
  result = modalResult;
1756
1721
  }
1757
1722
  const provider = _nullishCoalesce(result.provider, () => ( adapter.getProvider()));
1758
1723
  if (!provider) {
1759
- _chunkAFVK5GA5js.sentryLogger.error(`Error fetching provider on login: ${adapter.id}`);
1724
+ _chunkFRA6K6V4js.sentryLogger.error(`Error fetching provider on login: ${adapter.id}`);
1760
1725
  throw new Error("Error fetching provider. Please try again.");
1761
1726
  }
1762
1727
  const checksumAdr = _viem.checksumAddress.call(void 0, result.address);
@@ -1773,7 +1738,7 @@ var _AurumCore = class _AurumCore {
1773
1738
  const chainId = await provider.request({ method: "eth_chainId" });
1774
1739
  this.emitConnect(chainId);
1775
1740
  this.emitAccountsChanged([checksumAdr]);
1776
- _chunkAFVK5GA5js.sentryLogger.info(`Wallet connected: ${adapter.id} (${walletId ? "headless" : "modal"})`);
1741
+ _chunkFRA6K6V4js.sentryLogger.info(`Wallet connected: ${adapter.id} (${walletId ? "headless" : "modal"})`);
1777
1742
  return checksumAdr;
1778
1743
  }
1779
1744
  async disconnect() {
@@ -1793,7 +1758,7 @@ var _AurumCore = class _AurumCore {
1793
1758
  async isConnected() {
1794
1759
  await this.whenReady();
1795
1760
  return Boolean(
1796
- _optionalChain([this, 'access', _124 => _124.userInfo, 'optionalAccess', _125 => _125.publicAddress]) && _optionalChain([this, 'access', _126 => _126.userInfo, 'optionalAccess', _127 => _127.walletName]) && _optionalChain([this, 'access', _128 => _128.connectedWalletAdapter, 'optionalAccess', _129 => _129.getProvider, 'call', _130 => _130()])
1761
+ _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()])
1797
1762
  );
1798
1763
  }
1799
1764
  async handleWidgetConnection(result) {
@@ -1802,7 +1767,7 @@ var _AurumCore = class _AurumCore {
1802
1767
  if (!adapter) throw new Error("Selected wallet adapter not found");
1803
1768
  const provider = _nullishCoalesce(result.provider, () => ( adapter.getProvider()));
1804
1769
  if (!provider) {
1805
- _chunkAFVK5GA5js.sentryLogger.error(`Error fetching provider on widget login: ${_optionalChain([result, 'optionalAccess', _131 => _131.walletId])}`);
1770
+ _chunkFRA6K6V4js.sentryLogger.error(`Error fetching provider on widget login: ${_optionalChain([result, 'optionalAccess', _157 => _157.walletId])}`);
1806
1771
  throw new Error("Error fetching provider. Please try again.");
1807
1772
  }
1808
1773
  const checksumAdr = _viem.checksumAddress.call(void 0, result.address);
@@ -1819,7 +1784,7 @@ var _AurumCore = class _AurumCore {
1819
1784
  const chainId = await provider.request({ method: "eth_chainId" });
1820
1785
  this.emitConnect(chainId);
1821
1786
  this.emitAccountsChanged([checksumAdr]);
1822
- _chunkAFVK5GA5js.sentryLogger.info(`Wallet connected: ${adapter.id} (widget)`);
1787
+ _chunkFRA6K6V4js.sentryLogger.info(`Wallet connected: ${adapter.id} (widget)`);
1823
1788
  return this.userInfo;
1824
1789
  }
1825
1790
  async getChainId() {
@@ -1838,7 +1803,7 @@ var _AurumCore = class _AurumCore {
1838
1803
  }
1839
1804
  }
1840
1805
  updateBrandConfig(newConfig) {
1841
- const defaultTheme = _chunkAFVK5GA5js.getDefaultThemeConfig.call(void 0, _nullishCoalesce(newConfig.theme, () => ( this.brandConfig.theme)));
1806
+ const defaultTheme = _chunkFRA6K6V4js.getDefaultThemeConfig.call(void 0, _nullishCoalesce(newConfig.theme, () => ( this.brandConfig.theme)));
1842
1807
  this.brandConfig = {
1843
1808
  logo: "logo" in newConfig ? _nullishCoalesce(newConfig.logo, () => ( defaultTheme.logo)) : this.brandConfig.logo,
1844
1809
  theme: "theme" in newConfig ? _nullishCoalesce(newConfig.theme, () => ( defaultTheme.theme)) : this.brandConfig.theme,
@@ -1850,6 +1815,10 @@ var _AurumCore = class _AurumCore {
1850
1815
  font: "font" in newConfig ? _nullishCoalesce(newConfig.font, () => ( defaultTheme.font)) : this.brandConfig.font,
1851
1816
  walletLayout: "walletLayout" in newConfig ? _nullishCoalesce(newConfig.walletLayout, () => ( defaultTheme.walletLayout)) : this.brandConfig.walletLayout
1852
1817
  };
1818
+ if ("theme" in newConfig && this.brandConfig.theme) {
1819
+ const wcAdapter = this.wallets.find((w) => w.id === _types.WalletId.WalletConnect);
1820
+ _optionalChain([wcAdapter, 'optionalAccess', _158 => _158.updateTheme, 'call', _159 => _159(this.brandConfig.theme)]);
1821
+ }
1853
1822
  }
1854
1823
  updateWalletsConfig(newConfig) {
1855
1824
  if (newConfig.exclude !== void 0) {
@@ -1885,13 +1854,13 @@ var _AurumCore = class _AurumCore {
1885
1854
  const verifyResult = await emailAdapter.emailAuthVerify(flowId, otp);
1886
1855
  const provider = emailAdapter.getProvider();
1887
1856
  if (!provider) {
1888
- _chunkAFVK5GA5js.sentryLogger.error("Failed to get provider after email verification");
1857
+ _chunkFRA6K6V4js.sentryLogger.error("Failed to get provider after email verification");
1889
1858
  throw new Error("Failed to get provider after email verification");
1890
1859
  }
1891
- const address = _optionalChain([verifyResult, 'access', _132 => _132.user, 'optionalAccess', _133 => _133.evmAccounts, 'optionalAccess', _134 => _134[0]]);
1892
- const email = _optionalChain([verifyResult, 'access', _135 => _135.user, 'optionalAccess', _136 => _136.authenticationMethods, 'optionalAccess', _137 => _137.email, 'optionalAccess', _138 => _138.email]);
1860
+ const address = _optionalChain([verifyResult, 'access', _160 => _160.user, 'optionalAccess', _161 => _161.evmAccounts, 'optionalAccess', _162 => _162[0]]);
1861
+ const email = _optionalChain([verifyResult, 'access', _163 => _163.user, 'optionalAccess', _164 => _164.authenticationMethods, 'optionalAccess', _165 => _165.email, 'optionalAccess', _166 => _166.email]);
1893
1862
  if (!address || !email) {
1894
- _chunkAFVK5GA5js.sentryLogger.error("Address or email not found after email verification");
1863
+ _chunkFRA6K6V4js.sentryLogger.error("Address or email not found after email verification");
1895
1864
  throw new Error("Address or email not found after email verification");
1896
1865
  }
1897
1866
  const checksumAdr = _viem.checksumAddress.call(void 0, address);
@@ -1908,7 +1877,7 @@ var _AurumCore = class _AurumCore {
1908
1877
  const chainId = await provider.request({ method: "eth_chainId" });
1909
1878
  this.emitConnect(chainId);
1910
1879
  this.emitAccountsChanged([checksumAdr]);
1911
- _chunkAFVK5GA5js.sentryLogger.info(`Wallet connected: ${emailAdapter.id} (headless)`);
1880
+ _chunkFRA6K6V4js.sentryLogger.info(`Wallet connected: ${emailAdapter.id} (headless)`);
1912
1881
  return { address: checksumAdr, email: _nullishCoalesce(email, () => ( "")), isNewUser: _nullishCoalesce(verifyResult.isNewUser, () => ( false)) };
1913
1882
  }
1914
1883
  /**
@@ -1928,7 +1897,7 @@ var _AurumCore = class _AurumCore {
1928
1897
  const result = await session.waitForConnection();
1929
1898
  const provider = _nullishCoalesce(result.provider, () => ( wcAdapter.getProvider()));
1930
1899
  if (!provider) {
1931
- _chunkAFVK5GA5js.sentryLogger.error("Failed to get provider after WalletConnect connection");
1900
+ _chunkFRA6K6V4js.sentryLogger.error("Failed to get provider after WalletConnect connection");
1932
1901
  throw new Error("Failed to get provider after WalletConnect connection");
1933
1902
  }
1934
1903
  const checksumAdr = _viem.checksumAddress.call(void 0, result.address);
@@ -1944,7 +1913,7 @@ var _AurumCore = class _AurumCore {
1944
1913
  const chainId = await provider.request({ method: "eth_chainId" });
1945
1914
  this.emitConnect(chainId);
1946
1915
  this.emitAccountsChanged([checksumAdr]);
1947
- _chunkAFVK5GA5js.sentryLogger.info(`Wallet connected: ${wcAdapter.id} (headless)`);
1916
+ _chunkFRA6K6V4js.sentryLogger.info(`Wallet connected: ${wcAdapter.id} (headless)`);
1948
1917
  return checksumAdr;
1949
1918
  }
1950
1919
  };
@@ -1960,15 +1929,15 @@ var _AurumCore = class _AurumCore {
1960
1929
  }
1961
1930
  this.eventListeners.get(event).add(callback);
1962
1931
  if (!_AurumCore.MANAGED_EVENTS.includes(event)) {
1963
- _optionalChain([this, 'access', _139 => _139.currentProvider, 'access', _140 => _140.on, 'optionalCall', _141 => _141(event, callback)]);
1932
+ _optionalChain([this, 'access', _167 => _167.currentProvider, 'access', _168 => _168.on, 'optionalCall', _169 => _169(event, callback)]);
1964
1933
  }
1965
1934
  };
1966
1935
  }
1967
1936
  if (prop === "removeListener") {
1968
1937
  return (event, callback) => {
1969
- _optionalChain([this, 'access', _142 => _142.eventListeners, 'access', _143 => _143.get, 'call', _144 => _144(event), 'optionalAccess', _145 => _145.delete, 'call', _146 => _146(callback)]);
1938
+ _optionalChain([this, 'access', _170 => _170.eventListeners, 'access', _171 => _171.get, 'call', _172 => _172(event), 'optionalAccess', _173 => _173.delete, 'call', _174 => _174(callback)]);
1970
1939
  if (!_AurumCore.MANAGED_EVENTS.includes(event)) {
1971
- _optionalChain([this, 'access', _147 => _147.currentProvider, 'access', _148 => _148.removeListener, 'optionalCall', _149 => _149(event, callback)]);
1940
+ _optionalChain([this, 'access', _175 => _175.currentProvider, 'access', _176 => _176.removeListener, 'optionalCall', _177 => _177(event, callback)]);
1972
1941
  }
1973
1942
  };
1974
1943
  }
@@ -1993,7 +1962,7 @@ var _AurumCore = class _AurumCore {
1993
1962
  this.eventListeners.forEach((callbacks, event) => {
1994
1963
  if (!_AurumCore.MANAGED_EVENTS.includes(event)) {
1995
1964
  callbacks.forEach((callback) => {
1996
- _optionalChain([newProvider, 'access', _150 => _150.on, 'optionalCall', _151 => _151(event, callback)]);
1965
+ _optionalChain([newProvider, 'access', _178 => _178.on, 'optionalCall', _179 => _179(event, callback)]);
1997
1966
  });
1998
1967
  }
1999
1968
  });
@@ -2001,7 +1970,7 @@ var _AurumCore = class _AurumCore {
2001
1970
  /* BRAND & THEME METHODS */
2002
1971
  resolveBrandConfig(config) {
2003
1972
  const { brand = {} } = config || {};
2004
- const themeConfig = _chunkAFVK5GA5js.getDefaultThemeConfig.call(void 0, brand.theme || _chunkAFVK5GA5js.DEFAULT_THEME);
1973
+ const themeConfig = _chunkFRA6K6V4js.getDefaultThemeConfig.call(void 0, brand.theme || _chunkFRA6K6V4js.DEFAULT_THEME);
2005
1974
  return {
2006
1975
  logo: _nullishCoalesce(brand.logo, () => ( themeConfig.logo)),
2007
1976
  theme: _nullishCoalesce(brand.theme, () => ( themeConfig.theme)),
@@ -2016,8 +1985,8 @@ var _AurumCore = class _AurumCore {
2016
1985
  }
2017
1986
  async tryRestoreConnection() {
2018
1987
  try {
2019
- await _chunkAFVK5GA5js.waitForStoreHydration.call(void 0, );
2020
- const store = _chunkAFVK5GA5js.useAurumStore.getState();
1988
+ await _chunkFRA6K6V4js.waitForStoreHydration.call(void 0, );
1989
+ const store = _chunkFRA6K6V4js.useAurumStore.getState();
2021
1990
  if (!store.isConnected || !store.walletId || !store.address || !store.walletName) {
2022
1991
  return;
2023
1992
  }
@@ -2040,14 +2009,14 @@ var _AurumCore = class _AurumCore {
2040
2009
  email: _nullishCoalesce(store.email, () => ( void 0))
2041
2010
  };
2042
2011
  this.setInternalAccountChangeListener(persistedAdapter);
2043
- } catch (e22) {
2012
+ } catch (e15) {
2044
2013
  this.resetConnectionState();
2045
2014
  } finally {
2046
2015
  this.ready = true;
2047
2016
  }
2048
2017
  }
2049
2018
  persistConnectionState(adapter, address, email) {
2050
- _chunkAFVK5GA5js.useAurumStore.getState().setConnection(adapter.id, _viem.checksumAddress.call(void 0, address), adapter.name, email);
2019
+ _chunkFRA6K6V4js.useAurumStore.getState().setConnection(adapter.id, _viem.checksumAddress.call(void 0, address), adapter.name, email);
2051
2020
  }
2052
2021
  /* INTERNAL LISTENER METHODS */
2053
2022
  setInternalAccountChangeListener(adapter) {
@@ -2061,14 +2030,14 @@ var _AurumCore = class _AurumCore {
2061
2030
  }
2062
2031
  async syncStateFromAccountsChanged(accounts) {
2063
2032
  if (!accounts.length || !accounts[0]) return;
2064
- const prevAccount = _optionalChain([this, 'access', _152 => _152.userInfo, 'optionalAccess', _153 => _153.publicAddress]);
2033
+ const prevAccount = _optionalChain([this, 'access', _180 => _180.userInfo, 'optionalAccess', _181 => _181.publicAddress]);
2065
2034
  const newAccount = _viem.checksumAddress.call(void 0, accounts[0]);
2066
2035
  if (newAccount !== prevAccount) {
2067
2036
  this.userInfo = {
2068
2037
  publicAddress: newAccount,
2069
- walletName: _optionalChain([this, 'access', _154 => _154.userInfo, 'optionalAccess', _155 => _155.walletName]),
2070
- walletId: _optionalChain([this, 'access', _156 => _156.userInfo, 'optionalAccess', _157 => _157.walletId]),
2071
- email: _optionalChain([this, 'access', _158 => _158.userInfo, 'optionalAccess', _159 => _159.email])
2038
+ walletName: _optionalChain([this, 'access', _182 => _182.userInfo, 'optionalAccess', _183 => _183.walletName]),
2039
+ walletId: _optionalChain([this, 'access', _184 => _184.userInfo, 'optionalAccess', _185 => _185.walletId]),
2040
+ email: _optionalChain([this, 'access', _186 => _186.userInfo, 'optionalAccess', _187 => _187.email])
2072
2041
  };
2073
2042
  if (this.connectedWalletAdapter) {
2074
2043
  this.persistConnectionState(this.connectedWalletAdapter, newAccount, this.userInfo.email);
@@ -2127,7 +2096,7 @@ var _AurumCore = class _AurumCore {
2127
2096
  }
2128
2097
  }
2129
2098
  async addChain(chain) {
2130
- if (!_optionalChain([chain, 'optionalAccess', _160 => _160.id]) || !_optionalChain([chain, 'optionalAccess', _161 => _161.name]) || !_optionalChain([chain, 'optionalAccess', _162 => _162.nativeCurrency]) || !_optionalChain([chain, 'optionalAccess', _163 => _163.rpcUrls, 'optionalAccess', _164 => _164.default, 'optionalAccess', _165 => _165.http])) {
2099
+ 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])) {
2131
2100
  throw new Error("Invalid chain configuration: missing required properties");
2132
2101
  }
2133
2102
  await this.rpcProvider.request({
@@ -2145,7 +2114,7 @@ var _AurumCore = class _AurumCore {
2145
2114
  }
2146
2115
  /* REST */
2147
2116
  resetConnectionState() {
2148
- _chunkAFVK5GA5js.useAurumStore.getState().clearConnection();
2117
+ _chunkFRA6K6V4js.useAurumStore.getState().clearConnection();
2149
2118
  this.connectedWalletAdapter = null;
2150
2119
  this.updateProvider(this.skeletonProvider);
2151
2120
  this.userInfo = void 0;
@@ -2359,7 +2328,7 @@ var Aurum = class {
2359
2328
  * import { WalletId } from '@aurum-sdk/types';
2360
2329
  *
2361
2330
  * aurum.updateWalletsConfig({
2362
- * exclude: [WalletId.Email, WalletId.AppKit],
2331
+ * exclude: [WalletId.Email, WalletId.WalletConnect],
2363
2332
  * });
2364
2333
  * ```
2365
2334
  */