@aurum-sdk/core 0.2.8 → 0.3.0-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/{Aurum-B0Okb4Qv.d.mts → Aurum-BoIhHFKm.d.mts} +25 -2
  2. package/dist/{Aurum-B0Okb4Qv.d.ts → Aurum-BoIhHFKm.d.ts} +25 -2
  3. package/dist/BraveAdapter-GTB4OCMH.mjs +153 -0
  4. package/dist/BraveAdapter-XGUK2CH7.js +153 -0
  5. package/dist/CoinbaseWalletAdapter-A6RMB5AG.mjs +144 -0
  6. package/dist/CoinbaseWalletAdapter-EV44SYND.js +144 -0
  7. package/dist/EmailAdapter-Q63KI6DV.js +212 -0
  8. package/dist/EmailAdapter-T5FVQLCY.mjs +212 -0
  9. package/dist/MetaMaskAdapter-KX7EJ73V.mjs +152 -0
  10. package/dist/MetaMaskAdapter-X5MUH2DT.js +152 -0
  11. package/dist/PhantomAdapter-C7PQCQHP.js +151 -0
  12. package/dist/PhantomAdapter-REAJL27H.mjs +151 -0
  13. package/dist/RabbyAdapter-4SEMVMND.mjs +146 -0
  14. package/dist/RabbyAdapter-QLBUCYWB.js +146 -0
  15. package/dist/WalletConnectAdapter-J5J3ILFG.mjs +540 -0
  16. package/dist/WalletConnectAdapter-NKQZY25A.js +540 -0
  17. package/dist/chunk-4S5E6KOY.mjs +21 -0
  18. package/dist/{chunk-K64T6WW3.js → chunk-4XQZ5JBS.js} +420 -6850
  19. package/dist/{chunk-GMFEFDGS.mjs → chunk-7WLUHQA3.mjs} +348 -6778
  20. package/dist/chunk-ALDVMRQG.js +6558 -0
  21. package/dist/chunk-D7M3K26I.mjs +6558 -0
  22. package/dist/chunk-PFK6YHOX.mjs +15 -0
  23. package/dist/chunk-QOCN4F47.js +21 -0
  24. package/dist/chunk-XVRTCAR4.js +15 -0
  25. package/dist/index.d.mts +7 -2
  26. package/dist/index.d.ts +7 -2
  27. package/dist/index.js +304 -1573
  28. package/dist/index.mjs +243 -1512
  29. package/dist/{index.web-Q2L3EMC3.mjs → index.web-NX7JZBIY.mjs} +267 -267
  30. package/dist/{index.web-V7DLWC7H.js → index.web-OPNRZHYZ.js} +267 -267
  31. package/dist/widgets.d.mts +1 -1
  32. package/dist/widgets.d.ts +1 -1
  33. package/dist/widgets.js +14 -12
  34. package/dist/widgets.mjs +3 -1
  35. package/package.json +3 -7
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(); } } 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; }
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; }
2
2
 
3
3
 
4
4
 
@@ -16,8 +16,26 @@
16
16
 
17
17
 
18
18
 
19
- var _chunkK64T6WW3js = require('./chunk-K64T6WW3.js');
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+ var _chunk4XQZ5JBSjs = require('./chunk-4XQZ5JBS.js');
20
27
  require('./chunk-4EBNC4R3.js');
28
+ require('./chunk-QOCN4F47.js');
29
+
30
+
31
+ var _chunkXVRTCAR4js = require('./chunk-XVRTCAR4.js');
32
+
33
+
34
+
35
+
36
+
37
+
38
+ var _chunkALDVMRQGjs = require('./chunk-ALDVMRQG.js');
21
39
 
22
40
 
23
41
  var _chunkQIPVNM7Tjs = require('./chunk-QIPVNM7T.js');
@@ -64,20 +82,20 @@ var _react = require('react');
64
82
  var _jsxruntime = require('react/jsx-runtime');
65
83
  var ModalShell = ({ onClose, brandConfig }) => {
66
84
  const [isOpen, setIsOpen] = _react.useState.call(void 0, true);
67
- const { currentPage } = _chunkK64T6WW3js.useNavigation.call(void 0, );
85
+ const { currentPage } = _chunk4XQZ5JBSjs.useNavigation.call(void 0, );
68
86
  const handleClose = () => {
69
87
  setIsOpen(false);
70
88
  onClose();
71
89
  };
72
90
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
73
- _chunkK64T6WW3js.Modal,
91
+ _chunk4XQZ5JBSjs.Modal,
74
92
  {
75
93
  isOpen,
76
94
  closeOnOverlayClick: true,
77
95
  onCloseComplete: handleClose,
78
96
  brandConfig,
79
97
  transitionKey: currentPage,
80
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkK64T6WW3js.ConnectPages, {})
98
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk4XQZ5JBSjs.ConnectPages, {})
81
99
  }
82
100
  );
83
101
  };
@@ -91,7 +109,7 @@ _chunkQIPVNM7Tjs.init_polyfills.call(void 0, );
91
109
  function createShadowRoot(container, brandConfig) {
92
110
  const shadowRoot = container.attachShadow({ mode: "open" });
93
111
  shadowRoot.innerHTML = `
94
- <style>${_chunkK64T6WW3js.generateCompleteStyles.call(void 0, brandConfig)}</style>
112
+ <style>${_chunk4XQZ5JBSjs.generateCompleteStyles.call(void 0, brandConfig)}</style>
95
113
  <div class="aurum-modal-root"></div>
96
114
  `;
97
115
  return shadowRoot.querySelector(".aurum-modal-root");
@@ -128,7 +146,7 @@ function renderConnectModal({
128
146
  brandConfig
129
147
  }) {
130
148
  return new Promise((resolve, reject) => {
131
- const sortedWallets = _chunkK64T6WW3js.sortWallets.call(void 0, displayedWallets, { filterHidden: false });
149
+ const sortedWallets = _chunk4XQZ5JBSjs.sortWallets.call(void 0, displayedWallets, { filterHidden: false });
132
150
  const { root, cleanup } = createModalContainer(CONTAINER_ID, brandConfig);
133
151
  const onConnect = (result) => {
134
152
  cleanup();
@@ -139,1426 +157,190 @@ function renderConnectModal({
139
157
  reject(new Error("User rejected request"));
140
158
  };
141
159
  root.render(
142
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkK64T6WW3js.ThemeContainer, { theme: brandConfig.theme, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkK64T6WW3js.ConnectUIProviders, { onConnect, displayedWallets: sortedWallets, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ModalShell, { onClose, brandConfig }) }) })
160
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk4XQZ5JBSjs.ThemeContainer, { theme: brandConfig.theme, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk4XQZ5JBSjs.ConnectUIProviders, { onConnect, displayedWallets: sortedWallets, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ModalShell, { onClose, brandConfig }) }) })
143
161
  );
144
162
  });
145
163
  }
146
164
 
147
- // src/utils/createWalletAdapters.ts
165
+ // src/utils/createWalletManifests.ts
148
166
  _chunkQIPVNM7Tjs.init_polyfills.call(void 0, );
149
167
 
150
- // src/wallet-adapters/index.ts
168
+ // src/utils/eip6963Registry.ts
151
169
  _chunkQIPVNM7Tjs.init_polyfills.call(void 0, );
152
-
153
- // src/wallet-adapters/RabbyAdapter.ts
154
- _chunkQIPVNM7Tjs.init_polyfills.call(void 0, );
155
- var RABBY_RDNS = "io.rabby";
156
- var RabbyAdapter = class {
157
- constructor() {
158
- this.id = _chunkK64T6WW3js.WalletId.Rabby;
159
- this.name = _chunkK64T6WW3js.WalletName.Rabby;
160
- this.icon = _nullishCoalesce(_chunkK64T6WW3js.getLogoDataUri.call(void 0, _chunkK64T6WW3js.WalletId.Rabby, "brand"), () => ( ""));
161
- this.hide = false;
162
- this.downloadUrl = "https://rabby.io";
163
- this.wcDeepLinkUrl = null;
164
- this.provider = null;
165
- this.accountsChangedCallback = null;
166
- this.providerPromise = null;
167
- this.providerPromise = this.discoverProvider();
168
- }
169
- /**
170
- * Uses EIP-6963 to discover the Rabby provider by its RDNS identifier.
171
- * Falls back to window.ethereum for legacy detection.
172
- */
173
- discoverProvider() {
174
- if (typeof window === "undefined") return Promise.resolve(null);
175
- return new Promise((resolve) => {
176
- let resolved = false;
177
- const onAnnouncement = (event) => {
178
- const { detail } = event;
179
- if (detail.info.rdns === RABBY_RDNS) {
180
- resolved = true;
181
- this.provider = detail.provider;
182
- window.removeEventListener("eip6963:announceProvider", onAnnouncement);
183
- resolve(detail.provider);
184
- }
185
- };
186
- window.addEventListener("eip6963:announceProvider", onAnnouncement);
187
- window.dispatchEvent(new Event("eip6963:requestProvider"));
188
- setTimeout(() => {
189
- if (!resolved) {
190
- window.removeEventListener("eip6963:announceProvider", onAnnouncement);
191
- const legacyProvider = this.detectLegacyProvider();
192
- if (legacyProvider) {
193
- this.provider = legacyProvider;
194
- }
195
- resolve(legacyProvider);
196
- }
197
- }, 100);
198
- });
199
- }
200
- /**
201
- * Fallback detection for legacy Rabby installations.
202
- * Checks window.ethereum for Rabby-specific flags.
203
- */
204
- detectLegacyProvider() {
205
- const ethereum = window.ethereum;
206
- if (_optionalChain([ethereum, 'optionalAccess', _21 => _21.isRabby])) {
207
- return ethereum;
170
+ var announced = /* @__PURE__ */ new Map();
171
+ var started = false;
172
+ function startEIP6963Discovery() {
173
+ if (started || typeof window === "undefined") return;
174
+ started = true;
175
+ window.addEventListener("eip6963:announceProvider", (event) => {
176
+ const detail = event.detail;
177
+ if (_optionalChain([detail, 'optionalAccess', _21 => _21.info, 'optionalAccess', _22 => _22.rdns])) {
178
+ announced.set(detail.info.rdns, detail.provider);
208
179
  }
209
- return null;
210
- }
211
- isInstalled() {
212
- return Boolean(_nullishCoalesce(this.provider, () => ( this.detectLegacyProvider())));
213
- }
214
- async connect() {
215
- if (!this.provider && this.providerPromise) {
216
- await this.providerPromise;
217
- }
218
- if (!this.provider) {
219
- _chunkK64T6WW3js.sentryLogger.error("Rabby is not available");
220
- throw new Error("Rabby is not available");
221
- }
222
- await this.provider.request({
223
- method: "wallet_requestPermissions",
224
- params: [{ eth_accounts: {} }]
225
- });
226
- const accounts = await this.provider.request({
227
- method: "eth_requestAccounts",
228
- params: []
229
- });
230
- if (!accounts || accounts.length === 0 || !accounts[0]) {
231
- _chunkK64T6WW3js.sentryLogger.error("No accounts returned from Rabby");
232
- throw new Error("No accounts returned from Rabby");
233
- }
234
- return {
235
- address: accounts[0],
236
- provider: this.provider,
237
- walletId: this.id
238
- };
239
- }
240
- async tryRestoreConnection() {
241
- if (!this.provider && this.providerPromise) {
242
- await this.providerPromise;
243
- }
244
- if (!this.provider) {
245
- return null;
246
- }
247
- try {
248
- const accounts = await this.provider.request({
249
- method: "eth_accounts",
250
- params: []
251
- });
252
- if (!accounts || accounts.length === 0 || !accounts[0]) {
253
- return null;
254
- }
255
- return {
256
- address: accounts[0],
257
- provider: this.provider,
258
- walletId: this.id
259
- };
260
- } catch (e) {
261
- return null;
262
- }
263
- }
264
- async disconnect() {
265
- }
266
- getProvider() {
267
- return this.provider;
268
- }
269
- // Called by Aurum when user connects wallet
270
- // Passes Aurum.ts --> syncStateFromAccountsChanged() to handle the provider accounts changed event
271
- onAccountsChanged(callback) {
272
- if (!_optionalChain([this, 'access', _22 => _22.provider, 'optionalAccess', _23 => _23.on])) return;
273
- if (this.accountsChangedCallback) {
274
- _optionalChain([this, 'access', _24 => _24.provider, 'access', _25 => _25.removeListener, 'optionalCall', _26 => _26("accountsChanged", this.accountsChangedCallback)]);
275
- }
276
- this.accountsChangedCallback = callback;
277
- this.provider.on("accountsChanged", this.accountsChangedCallback);
278
- }
279
- removeListeners() {
280
- if (!_optionalChain([this, 'access', _27 => _27.provider, 'optionalAccess', _28 => _28.removeListener]) || !this.accountsChangedCallback) return;
281
- this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
282
- this.accountsChangedCallback = null;
283
- }
284
- };
285
-
286
- // src/wallet-adapters/BraveAdapter.ts
287
- _chunkQIPVNM7Tjs.init_polyfills.call(void 0, );
288
-
289
- // src/utils/platform/isBraveBrowser.ts
290
- _chunkQIPVNM7Tjs.init_polyfills.call(void 0, );
291
- function isBraveBrowser() {
292
- if (typeof navigator === "undefined") return false;
293
- return navigator.brave !== void 0;
180
+ });
181
+ window.dispatchEvent(new Event("eip6963:requestProvider"));
182
+ }
183
+ function getAnnouncedProvider(rdns) {
184
+ return announced.get(rdns);
294
185
  }
295
186
 
296
- // src/wallet-adapters/BraveAdapter.ts
297
- var BRAVE_RDNS = "com.brave.wallet";
298
- var BraveAdapter = class {
299
- constructor() {
300
- this.id = _chunkK64T6WW3js.WalletId.Brave;
301
- this.name = _chunkK64T6WW3js.WalletName.Brave;
302
- this.icon = _nullishCoalesce(_chunkK64T6WW3js.getLogoDataUri.call(void 0, _chunkK64T6WW3js.WalletId.Brave, "brand"), () => ( ""));
303
- this.downloadUrl = "https://brave.com/download";
304
- this.wcDeepLinkUrl = null;
305
- this.provider = null;
306
- this.accountsChangedCallback = null;
307
- this.providerPromise = null;
308
- this.providerPromise = this.discoverProvider();
309
- }
310
- get hide() {
311
- if (this.provider) return false;
312
- if (isBraveBrowser()) return false;
313
- return true;
314
- }
315
- /**
316
- * Uses EIP-6963 to discover the Brave Wallet provider by its RDNS identifier.
317
- * Falls back to window.ethereum for legacy detection.
318
- */
319
- discoverProvider() {
320
- if (typeof window === "undefined") return Promise.resolve(null);
321
- return new Promise((resolve) => {
322
- let resolved = false;
323
- const onAnnouncement = (event) => {
324
- const { detail } = event;
325
- if (detail.info.rdns === BRAVE_RDNS) {
326
- resolved = true;
327
- this.provider = detail.provider;
328
- window.removeEventListener("eip6963:announceProvider", onAnnouncement);
329
- resolve(detail.provider);
330
- }
331
- };
332
- window.addEventListener("eip6963:announceProvider", onAnnouncement);
333
- window.dispatchEvent(new Event("eip6963:requestProvider"));
334
- setTimeout(() => {
335
- if (!resolved) {
336
- window.removeEventListener("eip6963:announceProvider", onAnnouncement);
337
- const legacyProvider = this.detectLegacyProvider();
338
- if (legacyProvider) {
339
- this.provider = legacyProvider;
340
- }
341
- resolve(legacyProvider);
342
- }
343
- }, 100);
344
- });
345
- }
346
- /**
347
- * Fallback detection for legacy Brave Wallet detection.
348
- * Checks window.ethereum for Brave-specific flags.
349
- */
350
- detectLegacyProvider() {
351
- const ethereum = window.ethereum;
352
- if (_optionalChain([ethereum, 'optionalAccess', _29 => _29.isBraveWallet])) {
353
- return ethereum;
354
- }
355
- return null;
356
- }
357
- isInstalled() {
358
- return Boolean(_nullishCoalesce(this.provider, () => ( this.detectLegacyProvider())));
359
- }
360
- async connect() {
361
- if (!this.provider && this.providerPromise) {
362
- await this.providerPromise;
363
- }
364
- if (!this.provider) {
365
- _chunkK64T6WW3js.sentryLogger.error("Brave Wallet is not available");
366
- throw new Error("Brave Wallet is not available");
367
- }
368
- await this.provider.request({
369
- method: "wallet_requestPermissions",
370
- params: [{ eth_accounts: {} }]
371
- });
372
- const accounts = await this.provider.request({
373
- method: "eth_requestAccounts",
374
- params: []
375
- });
376
- if (!accounts || accounts.length === 0 || !accounts[0]) {
377
- _chunkK64T6WW3js.sentryLogger.error("No accounts returned from Brave Wallet");
378
- throw new Error("No accounts returned from Brave Wallet");
379
- }
380
- return {
381
- address: accounts[0],
382
- provider: this.provider,
383
- walletId: this.id
384
- };
385
- }
386
- async tryRestoreConnection() {
387
- if (!this.provider && this.providerPromise) {
388
- await this.providerPromise;
389
- }
390
- if (!this.provider) {
391
- return null;
392
- }
393
- try {
394
- const accounts = await this.provider.request({
395
- method: "eth_accounts",
396
- params: []
397
- });
398
- if (!accounts || accounts.length === 0 || !accounts[0]) {
399
- return null;
400
- }
401
- return {
402
- address: accounts[0],
403
- provider: this.provider,
404
- walletId: this.id
405
- };
406
- } catch (e2) {
407
- return null;
408
- }
409
- }
410
- async disconnect() {
411
- }
412
- getProvider() {
413
- return this.provider;
414
- }
415
- // Called by Aurum when user connects wallet
416
- // Passes Aurum.ts --> syncStateFromAccountsChanged() to handle the provider accounts changed event
417
- onAccountsChanged(callback) {
418
- if (!_optionalChain([this, 'access', _30 => _30.provider, 'optionalAccess', _31 => _31.on])) return;
419
- if (this.accountsChangedCallback) {
420
- _optionalChain([this, 'access', _32 => _32.provider, 'access', _33 => _33.removeListener, 'optionalCall', _34 => _34("accountsChanged", this.accountsChangedCallback)]);
421
- }
422
- this.accountsChangedCallback = callback;
423
- this.provider.on("accountsChanged", this.accountsChangedCallback);
424
- }
425
- removeListeners() {
426
- if (!_optionalChain([this, 'access', _35 => _35.provider, 'optionalAccess', _36 => _36.removeListener]) || !this.accountsChangedCallback) return;
427
- this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
428
- this.accountsChangedCallback = null;
429
- }
430
- };
431
-
432
- // src/wallet-adapters/PhantomAdapter.ts
433
- _chunkQIPVNM7Tjs.init_polyfills.call(void 0, );
434
- var PHANTOM_RDNS = "app.phantom";
435
- var PhantomAdapter = class {
436
- constructor() {
437
- this.id = _chunkK64T6WW3js.WalletId.Phantom;
438
- this.name = _chunkK64T6WW3js.WalletName.Phantom;
439
- this.icon = _nullishCoalesce(_chunkK64T6WW3js.getLogoDataUri.call(void 0, _chunkK64T6WW3js.WalletId.Phantom, "brand"), () => ( ""));
440
- this.hide = false;
441
- this.downloadUrl = "https://phantom.com/download";
442
- this.wcDeepLinkUrl = "phantom://wc?uri=";
443
- this.provider = null;
444
- this.accountsChangedCallback = null;
445
- this.providerPromise = null;
446
- this.providerPromise = this.discoverProvider();
447
- }
448
- /**
449
- * Uses EIP-6963 to discover the Phantom provider by its RDNS identifier.
450
- * Falls back to window.phantom.ethereum for in-app browser support (Phantom Mobile).
451
- * This prevents other wallets from hijacking the connection.
452
- */
453
- discoverProvider() {
454
- if (typeof window === "undefined") return Promise.resolve(null);
455
- return new Promise((resolve) => {
456
- let resolved = false;
457
- const onAnnouncement = (event) => {
458
- const { detail } = event;
459
- if (detail.info.rdns === PHANTOM_RDNS) {
460
- resolved = true;
461
- this.provider = detail.provider;
462
- window.removeEventListener("eip6963:announceProvider", onAnnouncement);
463
- resolve(detail.provider);
464
- }
465
- };
466
- window.addEventListener("eip6963:announceProvider", onAnnouncement);
467
- window.dispatchEvent(new Event("eip6963:requestProvider"));
468
- setTimeout(() => {
469
- if (!resolved) {
470
- window.removeEventListener("eip6963:announceProvider", onAnnouncement);
471
- const legacyProvider = this.detectLegacyProvider();
472
- if (legacyProvider) {
473
- this.provider = legacyProvider;
474
- }
475
- resolve(legacyProvider);
476
- }
477
- }, 100);
478
- });
479
- }
480
- /**
481
- * Fallback detection for in-app browsers (Phantom Mobile) that don't support EIP-6963.
482
- * Checks window.phantom.ethereum and window.ethereum for Phantom-specific flags.
483
- */
484
- detectLegacyProvider() {
485
- const phantom = window.phantom;
486
- if (_optionalChain([phantom, 'optionalAccess', _37 => _37.ethereum, 'optionalAccess', _38 => _38.isPhantom])) {
487
- return phantom.ethereum;
488
- }
489
- const ethereum = window.ethereum;
490
- if (_optionalChain([ethereum, 'optionalAccess', _39 => _39.isPhantom])) {
491
- return ethereum;
492
- }
493
- return null;
494
- }
495
- isInstalled() {
496
- return Boolean(_nullishCoalesce(this.provider, () => ( this.detectLegacyProvider())));
497
- }
498
- async connect() {
499
- if (!this.provider && this.providerPromise) {
500
- await this.providerPromise;
501
- }
502
- if (!this.provider) {
503
- _chunkK64T6WW3js.sentryLogger.error("Phantom is not available");
504
- throw new Error("Phantom is not available");
505
- }
506
- await this.provider.request({
507
- method: "wallet_requestPermissions",
508
- params: [{ eth_accounts: {} }]
509
- });
510
- const accounts = await this.provider.request({
511
- method: "eth_requestAccounts",
512
- params: []
513
- });
514
- if (!accounts || accounts.length === 0 || !accounts[0]) {
515
- _chunkK64T6WW3js.sentryLogger.error("No accounts returned from Phantom");
516
- throw new Error("No accounts returned from Phantom");
517
- }
518
- return {
519
- address: accounts[0],
520
- provider: this.provider,
521
- walletId: this.id
522
- };
523
- }
524
- async tryRestoreConnection() {
525
- if (!this.provider && this.providerPromise) {
526
- await this.providerPromise;
527
- }
528
- if (!this.provider) {
529
- return null;
530
- }
531
- try {
532
- const accounts = await this.provider.request({
533
- method: "eth_accounts",
534
- params: []
535
- });
536
- if (!accounts || accounts.length === 0 || !accounts[0]) {
537
- return null;
538
- }
539
- return {
540
- address: accounts[0],
541
- provider: this.provider,
542
- walletId: this.id
543
- };
544
- } catch (e3) {
545
- return null;
546
- }
547
- }
548
- async disconnect() {
549
- }
550
- getProvider() {
551
- return this.provider;
552
- }
553
- // Called by Aurum when user connects wallet
554
- // Passes Aurum.ts --> syncStateFromAccountsChanged() to handle the provider accounts changed event
555
- onAccountsChanged(callback) {
556
- if (!_optionalChain([this, 'access', _40 => _40.provider, 'optionalAccess', _41 => _41.on])) return;
557
- if (this.accountsChangedCallback) {
558
- _optionalChain([this, 'access', _42 => _42.provider, 'access', _43 => _43.removeListener, 'optionalCall', _44 => _44("accountsChanged", this.accountsChangedCallback)]);
559
- }
560
- this.accountsChangedCallback = callback;
561
- this.provider.on("accountsChanged", this.accountsChangedCallback);
562
- }
563
- removeListeners() {
564
- if (!_optionalChain([this, 'access', _45 => _45.provider, 'optionalAccess', _46 => _46.removeListener]) || !this.accountsChangedCallback) return;
565
- this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
566
- this.accountsChangedCallback = null;
567
- }
568
- };
569
-
570
- // src/wallet-adapters/CoinbaseWalletAdapter.ts
571
- _chunkQIPVNM7Tjs.init_polyfills.call(void 0, );
572
- var CoinbaseWalletAdapter = class {
573
- constructor({ appName, appLogoUrl, telemetry }) {
574
- this.id = _chunkK64T6WW3js.WalletId.CoinbaseWallet;
575
- this.name = _chunkK64T6WW3js.WalletName.CoinbaseWallet;
576
- this.icon = _nullishCoalesce(_chunkK64T6WW3js.getLogoDataUri.call(void 0, _chunkK64T6WW3js.WalletId.CoinbaseWallet, "brand"), () => ( ""));
577
- this.hide = false;
578
- this.downloadUrl = "https://www.coinbase.com/wallet/downloads";
579
- this.wcDeepLinkUrl = "cbwallet://wc?uri=";
580
- this.provider = null;
581
- this.accountsChangedCallback = null;
582
- this.initPromise = null;
583
- this.config = { appName, appLogoUrl, telemetry: _nullishCoalesce(telemetry, () => ( false)) };
584
- }
585
- async ensureInitialized() {
586
- if (this.provider) return;
587
- if (!this.initPromise) {
588
- this.initPromise = this.initializeProvider();
589
- }
590
- await this.initPromise;
591
- }
592
- async initializeProvider() {
593
- if (typeof window === "undefined") return;
594
- try {
595
- const { createCoinbaseWalletSDK } = await Promise.resolve().then(() => _interopRequireWildcard(require("./dist-7I773YNF.js")));
596
- const coinbaseSdk = createCoinbaseWalletSDK({
597
- appName: this.config.appName,
598
- appLogoUrl: this.config.appLogoUrl,
599
- preference: {
600
- options: "all",
601
- telemetry: this.config.telemetry
602
- }
603
- });
604
- this.provider = coinbaseSdk.getProvider();
605
- } catch (error) {
606
- _chunkK64T6WW3js.sentryLogger.warn("Failed to initialize Coinbase Wallet provider", { error });
607
- }
608
- }
609
- isInstalled() {
610
- return true;
611
- }
612
- async connect() {
613
- await this.ensureInitialized();
614
- if (!this.provider) {
615
- _chunkK64T6WW3js.sentryLogger.error("Coinbase Wallet is not available");
616
- throw new Error("Coinbase Wallet is not available");
617
- }
618
- const accounts = await this.provider.request({
619
- method: "eth_requestAccounts",
620
- params: []
621
- });
622
- if (!accounts || accounts.length === 0 || !accounts[0]) {
623
- _chunkK64T6WW3js.sentryLogger.error("No accounts returned from Coinbase Wallet");
624
- throw new Error("No accounts returned from Coinbase Wallet");
625
- }
626
- return {
627
- address: accounts[0],
628
- provider: this.provider,
629
- walletId: this.id
630
- };
631
- }
632
- async tryRestoreConnection() {
633
- await this.ensureInitialized();
634
- if (!this.provider) {
635
- return null;
636
- }
637
- try {
638
- const accounts = await this.provider.request({
639
- method: "eth_accounts",
640
- params: []
641
- });
642
- if (!accounts || accounts.length === 0 || !accounts[0]) {
643
- return null;
644
- }
645
- return {
646
- address: accounts[0],
647
- provider: this.provider,
648
- walletId: this.id
649
- };
650
- } catch (e4) {
651
- return null;
652
- }
653
- }
654
- async disconnect() {
655
- if (!this.provider) return;
656
- try {
657
- if (this.provider.close) {
658
- await this.provider.close();
659
- } else if (this.provider.disconnect) {
660
- await this.provider.disconnect();
661
- }
662
- } catch (error) {
663
- _chunkK64T6WW3js.sentryLogger.warn("Error disconnecting from Coinbase Wallet", { error });
664
- } finally {
665
- this.clearLocalStorage();
666
- }
667
- }
668
- clearLocalStorage() {
669
- if (typeof window === "undefined" || !window.localStorage) return;
670
- const keysToRemove = [];
671
- for (let i = 0; i < localStorage.length; i++) {
672
- const key = localStorage.key(i);
673
- if (key && (key.startsWith("-walletlink") || key.startsWith("-CBWSDK") || key.startsWith("walletlink:") || key.startsWith("CBWSDK:"))) {
674
- keysToRemove.push(key);
675
- }
676
- }
677
- keysToRemove.forEach((key) => {
678
- localStorage.removeItem(key);
679
- });
680
- }
681
- getProvider() {
682
- return this.provider;
683
- }
684
- // Called by Aurum when user connects wallet
685
- // Passes Aurum.ts --> syncStateFromAccountsChanged() to handle the provider accounts changed event
686
- onAccountsChanged(callback) {
687
- if (!_optionalChain([this, 'access', _47 => _47.provider, 'optionalAccess', _48 => _48.on])) return;
688
- if (this.accountsChangedCallback) {
689
- _optionalChain([this, 'access', _49 => _49.provider, 'access', _50 => _50.removeListener, 'optionalCall', _51 => _51("accountsChanged", this.accountsChangedCallback)]);
690
- }
691
- this.accountsChangedCallback = callback;
692
- this.provider.on("accountsChanged", this.accountsChangedCallback);
693
- }
694
- removeListeners() {
695
- if (!_optionalChain([this, 'access', _52 => _52.provider, 'optionalAccess', _53 => _53.removeListener]) || !this.accountsChangedCallback) return;
696
- this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
697
- this.accountsChangedCallback = null;
698
- }
699
- };
700
-
701
- // src/wallet-adapters/MetaMaskAdapter.ts
187
+ // src/wallet-adapters/manifests.ts
702
188
  _chunkQIPVNM7Tjs.init_polyfills.call(void 0, );
703
189
  var METAMASK_RDNS = "io.metamask";
704
- var MetaMaskAdapter = class {
705
- constructor() {
706
- this.id = _chunkK64T6WW3js.WalletId.MetaMask;
707
- this.name = _chunkK64T6WW3js.WalletName.MetaMask;
708
- this.icon = _nullishCoalesce(_chunkK64T6WW3js.getLogoDataUri.call(void 0, _chunkK64T6WW3js.WalletId.MetaMask, "brand"), () => ( ""));
709
- this.hide = false;
710
- this.downloadUrl = "https://metamask.io/download";
711
- this.wcDeepLinkUrl = "metamask://wc?uri=";
712
- this.provider = null;
713
- this.accountsChangedCallback = null;
714
- this.providerPromise = null;
715
- this.providerPromise = this.discoverProvider();
716
- }
717
- /**
718
- * Uses EIP-6963 to discover the MetaMask provider by its RDNS identifier.
719
- * Falls back to window.ethereum for in-app browser support (MetaMask Mobile).
720
- * This prevents other wallets (like Rabby) from hijacking the connection.
721
- */
722
- discoverProvider() {
723
- if (typeof window === "undefined") return Promise.resolve(null);
724
- return new Promise((resolve) => {
725
- let resolved = false;
726
- const onAnnouncement = (event) => {
727
- const { detail } = event;
728
- if (detail.info.rdns === METAMASK_RDNS) {
729
- resolved = true;
730
- this.provider = detail.provider;
731
- window.removeEventListener("eip6963:announceProvider", onAnnouncement);
732
- resolve(detail.provider);
733
- }
734
- };
735
- window.addEventListener("eip6963:announceProvider", onAnnouncement);
736
- window.dispatchEvent(new Event("eip6963:requestProvider"));
737
- setTimeout(() => {
738
- if (!resolved) {
739
- window.removeEventListener("eip6963:announceProvider", onAnnouncement);
740
- const legacyProvider = this.detectLegacyProvider();
741
- if (legacyProvider) {
742
- this.provider = legacyProvider;
743
- }
744
- resolve(legacyProvider);
745
- }
746
- }, 100);
747
- });
748
- }
749
- /**
750
- * Fallback detection for in-app browsers (MetaMask Mobile) that don't support EIP-6963.
751
- * Checks window.ethereum for MetaMask-specific flags.
752
- */
753
- detectLegacyProvider() {
754
- const ethereum = window.ethereum;
755
- if (!ethereum) return null;
756
- if (_optionalChain([ethereum, 'access', _54 => _54.providers, 'optionalAccess', _55 => _55.length])) {
757
- const metaMaskProvider = ethereum.providers.find((p) => p.isMetaMask && !p.isBraveWallet);
758
- if (metaMaskProvider) return metaMaskProvider;
759
- }
760
- if (ethereum.isMetaMask && !ethereum.isBraveWallet) {
761
- return ethereum;
762
- }
763
- return null;
764
- }
765
- isInstalled() {
766
- return Boolean(_nullishCoalesce(this.provider, () => ( this.detectLegacyProvider())));
767
- }
768
- async connect() {
769
- if (!this.provider && this.providerPromise) {
770
- await this.providerPromise;
771
- }
772
- if (!this.provider) {
773
- _chunkK64T6WW3js.sentryLogger.error("MetaMask is not available");
774
- throw new Error("MetaMask is not available");
190
+ var PHANTOM_RDNS = "app.phantom";
191
+ var RABBY_RDNS = "io.rabby";
192
+ var BRAVE_RDNS = "com.brave.wallet";
193
+ function getWindowEthereum() {
194
+ if (typeof window === "undefined") return void 0;
195
+ return window.ethereum;
196
+ }
197
+ function detectMetaMask() {
198
+ if (getAnnouncedProvider(METAMASK_RDNS)) return true;
199
+ const eth = getWindowEthereum();
200
+ if (!eth) return false;
201
+ if (_optionalChain([eth, 'access', _23 => _23.providers, 'optionalAccess', _24 => _24.length])) {
202
+ return eth.providers.some((p) => p.isMetaMask && !p.isBraveWallet);
203
+ }
204
+ return Boolean(eth.isMetaMask && !eth.isBraveWallet);
205
+ }
206
+ function detectPhantom() {
207
+ if (getAnnouncedProvider(PHANTOM_RDNS)) return true;
208
+ if (typeof window === "undefined") return false;
209
+ const phantom = window.phantom;
210
+ if (_optionalChain([phantom, 'optionalAccess', _25 => _25.ethereum, 'optionalAccess', _26 => _26.isPhantom])) return true;
211
+ return Boolean(_optionalChain([getWindowEthereum, 'call', _27 => _27(), 'optionalAccess', _28 => _28.isPhantom]));
212
+ }
213
+ function detectRabby() {
214
+ if (getAnnouncedProvider(RABBY_RDNS)) return true;
215
+ return Boolean(_optionalChain([getWindowEthereum, 'call', _29 => _29(), 'optionalAccess', _30 => _30.isRabby]));
216
+ }
217
+ function detectBrave() {
218
+ if (getAnnouncedProvider(BRAVE_RDNS)) return true;
219
+ return Boolean(_optionalChain([getWindowEthereum, 'call', _31 => _31(), 'optionalAccess', _32 => _32.isBraveWallet]));
220
+ }
221
+ function createMetaMaskManifest() {
222
+ return {
223
+ id: _chunkALDVMRQGjs.WalletId.MetaMask,
224
+ name: _chunkALDVMRQGjs.WalletName.MetaMask,
225
+ icon: _nullishCoalesce(_chunkALDVMRQGjs.getLogoDataUri.call(void 0, _chunkALDVMRQGjs.WalletId.MetaMask, "brand"), () => ( "")),
226
+ hide: false,
227
+ downloadUrl: "https://metamask.io/download",
228
+ wcDeepLinkUrl: "metamask://wc?uri=",
229
+ isInstalled: detectMetaMask,
230
+ load: async () => {
231
+ const { MetaMaskAdapter } = await Promise.resolve().then(() => _interopRequireWildcard(require("./MetaMaskAdapter-X5MUH2DT.js")));
232
+ return new MetaMaskAdapter();
775
233
  }
776
- await this.provider.request({
777
- method: "wallet_requestPermissions",
778
- params: [{ eth_accounts: {} }]
779
- });
780
- const accounts = await this.provider.request({
781
- method: "eth_requestAccounts",
782
- params: []
783
- });
784
- if (!accounts || accounts.length === 0 || !accounts[0]) {
785
- _chunkK64T6WW3js.sentryLogger.error("No accounts returned from MetaMask");
786
- throw new Error("No accounts returned from MetaMask");
234
+ };
235
+ }
236
+ function createPhantomManifest() {
237
+ return {
238
+ id: _chunkALDVMRQGjs.WalletId.Phantom,
239
+ name: _chunkALDVMRQGjs.WalletName.Phantom,
240
+ icon: _nullishCoalesce(_chunkALDVMRQGjs.getLogoDataUri.call(void 0, _chunkALDVMRQGjs.WalletId.Phantom, "brand"), () => ( "")),
241
+ hide: false,
242
+ downloadUrl: "https://phantom.com/download",
243
+ wcDeepLinkUrl: "phantom://wc?uri=",
244
+ isInstalled: detectPhantom,
245
+ load: async () => {
246
+ const { PhantomAdapter } = await Promise.resolve().then(() => _interopRequireWildcard(require("./PhantomAdapter-C7PQCQHP.js")));
247
+ return new PhantomAdapter();
787
248
  }
788
- return {
789
- address: accounts[0],
790
- provider: this.provider,
791
- walletId: this.id
792
- };
793
- }
794
- async tryRestoreConnection() {
795
- if (!this.provider && this.providerPromise) {
796
- await this.providerPromise;
249
+ };
250
+ }
251
+ function createRabbyManifest() {
252
+ return {
253
+ id: _chunkALDVMRQGjs.WalletId.Rabby,
254
+ name: _chunkALDVMRQGjs.WalletName.Rabby,
255
+ icon: _nullishCoalesce(_chunkALDVMRQGjs.getLogoDataUri.call(void 0, _chunkALDVMRQGjs.WalletId.Rabby, "brand"), () => ( "")),
256
+ hide: false,
257
+ downloadUrl: "https://rabby.io",
258
+ wcDeepLinkUrl: null,
259
+ isInstalled: detectRabby,
260
+ load: async () => {
261
+ const { RabbyAdapter } = await Promise.resolve().then(() => _interopRequireWildcard(require("./RabbyAdapter-QLBUCYWB.js")));
262
+ return new RabbyAdapter();
797
263
  }
798
- if (!this.provider) {
799
- return null;
264
+ };
265
+ }
266
+ function createBraveManifest() {
267
+ return {
268
+ id: _chunkALDVMRQGjs.WalletId.Brave,
269
+ name: _chunkALDVMRQGjs.WalletName.Brave,
270
+ icon: _nullishCoalesce(_chunkALDVMRQGjs.getLogoDataUri.call(void 0, _chunkALDVMRQGjs.WalletId.Brave, "brand"), () => ( "")),
271
+ downloadUrl: "https://brave.com/download",
272
+ wcDeepLinkUrl: null,
273
+ isInstalled: detectBrave,
274
+ get hide() {
275
+ return !detectBrave() && !_chunkXVRTCAR4js.isBraveBrowser.call(void 0, );
276
+ },
277
+ load: async () => {
278
+ const { BraveAdapter } = await Promise.resolve().then(() => _interopRequireWildcard(require("./BraveAdapter-XGUK2CH7.js")));
279
+ return new BraveAdapter();
800
280
  }
801
- try {
802
- const accounts = await this.provider.request({
803
- method: "eth_accounts",
804
- params: []
281
+ };
282
+ }
283
+ function createCoinbaseWalletManifest(config) {
284
+ return {
285
+ id: _chunkALDVMRQGjs.WalletId.CoinbaseWallet,
286
+ name: _chunkALDVMRQGjs.WalletName.CoinbaseWallet,
287
+ icon: _nullishCoalesce(_chunkALDVMRQGjs.getLogoDataUri.call(void 0, _chunkALDVMRQGjs.WalletId.CoinbaseWallet, "brand"), () => ( "")),
288
+ hide: false,
289
+ downloadUrl: "https://www.coinbase.com/wallet/downloads",
290
+ wcDeepLinkUrl: "cbwallet://wc?uri=",
291
+ isInstalled: () => true,
292
+ load: async () => {
293
+ const { CoinbaseWalletAdapter } = await Promise.resolve().then(() => _interopRequireWildcard(require("./CoinbaseWalletAdapter-EV44SYND.js")));
294
+ return new CoinbaseWalletAdapter({
295
+ appName: config.appName,
296
+ appLogoUrl: config.appLogoUrl,
297
+ telemetry: config.telemetry
805
298
  });
806
- if (!accounts || accounts.length === 0 || !accounts[0]) {
807
- return null;
808
- }
809
- return {
810
- address: accounts[0],
811
- provider: this.provider,
812
- walletId: this.id
813
- };
814
- } catch (e5) {
815
- return null;
816
299
  }
817
- }
818
- async disconnect() {
819
- }
820
- getProvider() {
821
- return this.provider;
822
- }
823
- // Called by Aurum when user connects wallet
824
- // Passes Aurum.ts --> syncStateFromAccountsChanged() to handle the provider accounts changed event
825
- onAccountsChanged(callback) {
826
- if (!_optionalChain([this, 'access', _56 => _56.provider, 'optionalAccess', _57 => _57.on])) return;
827
- if (this.accountsChangedCallback) {
828
- _optionalChain([this, 'access', _58 => _58.provider, 'access', _59 => _59.removeListener, 'optionalCall', _60 => _60("accountsChanged", this.accountsChangedCallback)]);
829
- }
830
- this.accountsChangedCallback = callback;
831
- this.provider.on("accountsChanged", this.accountsChangedCallback);
832
- }
833
- removeListeners() {
834
- if (!_optionalChain([this, 'access', _61 => _61.provider, 'optionalAccess', _62 => _62.removeListener]) || !this.accountsChangedCallback) return;
835
- this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
836
- this.accountsChangedCallback = null;
837
- }
838
- };
839
-
840
- // src/wallet-adapters/WalletConnectAdapter.ts
841
- _chunkQIPVNM7Tjs.init_polyfills.call(void 0, );
842
-
843
- // src/constants/adapters.ts
844
- _chunkQIPVNM7Tjs.init_polyfills.call(void 0, );
845
- var WALLETCONNECT_NAMESPACE = {
846
- eip155: {
847
- methods: [
848
- // Transaction methods
849
- "eth_sendTransaction",
850
- "eth_signTransaction",
851
- "eth_sendRawTransaction",
852
- // Signing methods
853
- "eth_sign",
854
- "personal_sign",
855
- "eth_signTypedData",
856
- "eth_signTypedData_v3",
857
- "eth_signTypedData_v4",
858
- // Account methods
859
- "eth_accounts",
860
- "eth_requestAccounts",
861
- // Chain management
862
- "wallet_switchEthereumChain",
863
- "wallet_addEthereumChain",
864
- // Permissions (EIP-2255)
865
- "wallet_requestPermissions",
866
- "wallet_getPermissions"
867
- ],
868
- chains: [
869
- // Ethereum
870
- "eip155:1",
871
- // Mainnet
872
- "eip155:11155111",
873
- // Sepolia
874
- // Base
875
- "eip155:8453",
876
- // Mainnet
877
- "eip155:84532",
878
- // Sepolia
879
- // Optimism
880
- "eip155:10",
881
- // Mainnet
882
- "eip155:11155420",
883
- // Sepolia
884
- // Arbitrum
885
- "eip155:42161",
886
- // Mainnet
887
- "eip155:421614",
888
- // Sepolia
889
- // BNB Chain
890
- "eip155:56",
891
- // Mainnet
892
- "eip155:97",
893
- // Testnet
894
- // Polygon
895
- "eip155:137",
896
- // Mainnet
897
- "eip155:80002",
898
- // Amoy
899
- // Fantom
900
- "eip155:250",
901
- // Mainnet
902
- "eip155:4002",
903
- // Testnet
904
- // Linea
905
- "eip155:59144",
906
- // Mainnet
907
- "eip155:59141",
908
- // Sepolia
909
- // Gnosis
910
- "eip155:100",
911
- // Mainnet
912
- "eip155:10200",
913
- // Chiado
914
- // Polygon zkEVM
915
- "eip155:1101",
916
- // Mainnet
917
- "eip155:2442",
918
- // Cardona
919
- // Avalanche C-Chain
920
- "eip155:43114",
921
- // Mainnet
922
- "eip155:43113"
923
- // Fuji
924
- ],
925
- events: ["chainChanged", "accountsChanged"]
926
- }
927
- };
928
-
929
- // src/wallet-adapters/WalletConnectAdapter.ts
930
- function extractAddressFromSession(namespaces) {
931
- const accounts = _optionalChain([namespaces, 'optionalAccess', _63 => _63.eip155, 'optionalAccess', _64 => _64.accounts]) || [];
932
- const firstAccount = accounts[0];
933
- return _nullishCoalesce(_optionalChain([firstAccount, 'optionalAccess', _65 => _65.split, 'call', _66 => _66(":"), 'access', _67 => _67[2]]), () => ( null));
300
+ };
934
301
  }
935
- var WalletConnectAdapter = class {
936
- constructor(config) {
937
- this.id = _chunkK64T6WW3js.WalletId.WalletConnect;
938
- this.name = _chunkK64T6WW3js.WalletName.WalletConnect;
939
- this.icon = _nullishCoalesce(_chunkK64T6WW3js.getLogoDataUri.call(void 0, _chunkK64T6WW3js.WalletId.WalletConnect, "brand"), () => ( ""));
940
- this.hide = false;
941
- this.downloadUrl = null;
942
- this.wcDeepLinkUrl = null;
943
- this.modal = null;
944
- this.wagmiAdapter = null;
945
- this.universalProvider = null;
946
- this.provider = null;
947
- this.address = null;
948
- this.connectionUri = null;
949
- this.accountsChangedCallback = null;
950
- this.chainChangedCallback = null;
951
- this.disconnectCallback = null;
952
- this.sessionUpdateHandler = null;
953
- this.unsubscribeFunctions = [];
954
- this.initPromise = null;
955
- this.lastKnownAccounts = [];
956
- this.lastKnownChainId = null;
957
- this.config = config;
958
- }
959
- async ensureInitialized() {
960
- if (this.modal) return;
961
- if (!this.initPromise) {
962
- this.initPromise = this.initializeAppKit();
963
- }
964
- await this.initPromise;
965
- }
966
- async initializeAppKit() {
967
- if (typeof window === "undefined") return;
968
- const [{ createAppKit }, { WagmiAdapter }, { mainnet }] = await Promise.all([
969
- Promise.resolve().then(() => _interopRequireWildcard(require("@reown/appkit"))),
970
- Promise.resolve().then(() => _interopRequireWildcard(require("@reown/appkit-adapter-wagmi"))),
971
- Promise.resolve().then(() => _interopRequireWildcard(require("@reown/appkit/networks")))
972
- ]);
973
- const networks = [mainnet];
974
- this.wagmiAdapter = new WagmiAdapter({
975
- projectId: this.config.projectId,
976
- networks,
977
- ssr: true
978
- });
979
- this.modal = createAppKit({
980
- adapters: [this.wagmiAdapter],
981
- networks,
982
- projectId: this.config.projectId,
983
- metadata: {
984
- name: this.config.appName,
985
- description: this.config.appName,
986
- url: window.location.origin,
987
- icons: []
988
- },
989
- allowUnsupportedChain: true,
990
- themeMode: this.config.theme,
991
- themeVariables: {
992
- "--apkt-z-index": this.config.modalZIndex + 1
993
- },
994
- features: {
995
- analytics: _nullishCoalesce(this.config.telemetry, () => ( false))
996
- }
997
- });
998
- this.universalProvider = await _asyncNullishCoalesce(await this.modal.getUniversalProvider(), async () => ( null));
999
- this.setupEventListeners();
1000
- }
1001
- setupEventListeners() {
1002
- if (!this.modal) return;
1003
- const unsubscribeProviders = this.modal.subscribeProviders((state) => {
1004
- const eip155Provider = state["eip155"];
1005
- this.provider = eip155Provider || null;
1006
- if (!eip155Provider) {
1007
- this.address = null;
1008
- }
1009
- });
1010
- this.unsubscribeFunctions.push(unsubscribeProviders);
1011
- if (this.universalProvider) {
1012
- this.universalProvider.on("display_uri", (uri) => {
1013
- this.connectionUri = uri;
1014
- if (typeof window !== "undefined") {
1015
- window.dispatchEvent(new CustomEvent("walletconnect:uri", { detail: { uri } }));
1016
- }
1017
- });
1018
- this.universalProvider.on("session_delete", () => {
1019
- this.handleRemoteDisconnect();
302
+ function createWalletConnectManifest(config) {
303
+ return {
304
+ id: _chunkALDVMRQGjs.WalletId.WalletConnect,
305
+ name: _chunkALDVMRQGjs.WalletName.WalletConnect,
306
+ icon: _nullishCoalesce(_chunkALDVMRQGjs.getLogoDataUri.call(void 0, _chunkALDVMRQGjs.WalletId.WalletConnect, "brand"), () => ( "")),
307
+ hide: false,
308
+ downloadUrl: null,
309
+ wcDeepLinkUrl: null,
310
+ isInstalled: () => true,
311
+ load: async () => {
312
+ const { WalletConnectAdapter } = await Promise.resolve().then(() => _interopRequireWildcard(require("./WalletConnectAdapter-NKQZY25A.js")));
313
+ return new WalletConnectAdapter({
314
+ projectId: config.walletConnectProjectId,
315
+ appName: config.appName,
316
+ modalZIndex: config.modalZIndex,
317
+ theme: config.theme,
318
+ telemetry: config.telemetry
1020
319
  });
1021
- this.universalProvider.on("session_expire", () => {
1022
- this.handleRemoteDisconnect();
1023
- });
1024
- }
1025
- }
1026
- /** Called when user disconnects from the wallet side (mobile app) */
1027
- handleRemoteDisconnect() {
1028
- this.connectionUri = null;
1029
- this.address = null;
1030
- this.provider = null;
1031
- this.lastKnownAccounts = [];
1032
- this.lastKnownChainId = null;
1033
- if (this.accountsChangedCallback) {
1034
- this.accountsChangedCallback([]);
1035
- }
1036
- if (this.disconnectCallback) {
1037
- this.disconnectCallback();
1038
- }
1039
- if (typeof window !== "undefined") {
1040
- window.dispatchEvent(new CustomEvent("walletconnect:disconnect"));
1041
- }
1042
- }
1043
- syncAddressFromWagmi() {
1044
- if (!_optionalChain([this, 'access', _68 => _68.wagmiAdapter, 'optionalAccess', _69 => _69.wagmiConfig])) return;
1045
- const { state } = this.wagmiAdapter.wagmiConfig;
1046
- if (state.current && state.connections) {
1047
- const connection = state.connections.get(state.current);
1048
- if (_optionalChain([connection, 'optionalAccess', _70 => _70.accounts, 'optionalAccess', _71 => _71[0]])) {
1049
- this.address = connection.accounts[0];
1050
- }
1051
- }
1052
- }
1053
- async syncProviderFromModal() {
1054
- if (!this.modal) return;
1055
- try {
1056
- const getProvidersFn = this.modal.getProviders;
1057
- if (typeof getProvidersFn === "function") {
1058
- const providers = getProvidersFn.call(this.modal);
1059
- const eip155Provider = _optionalChain([providers, 'optionalAccess', _72 => _72["eip155"]]);
1060
- if (eip155Provider) {
1061
- this.provider = eip155Provider;
1062
- return;
1063
- }
1064
- }
1065
- if (_optionalChain([this, 'access', _73 => _73.wagmiAdapter, 'optionalAccess', _74 => _74.wagmiConfig])) {
1066
- const { state } = this.wagmiAdapter.wagmiConfig;
1067
- if (state.current && state.connections) {
1068
- const connection = state.connections.get(state.current);
1069
- const connector = _optionalChain([connection, 'optionalAccess', _75 => _75.connector]);
1070
- if (connector && typeof connector.getProvider === "function") {
1071
- try {
1072
- const provider = await connector.getProvider();
1073
- if (provider) {
1074
- this.provider = provider;
1075
- }
1076
- } catch (error) {
1077
- _chunkK64T6WW3js.sentryLogger.warn("Failed to get provider from wagmi connector", { error });
1078
- }
1079
- }
1080
- }
1081
- }
1082
- } catch (error) {
1083
- _chunkK64T6WW3js.sentryLogger.warn("Failed to get provider from WalletConnect", { error });
1084
- }
1085
- }
1086
- isInstalled() {
1087
- return true;
1088
- }
1089
- getConnectionUri() {
1090
- return this.connectionUri;
1091
- }
1092
- /** Resets connection state for a fresh connection flow */
1093
- async resetConnectionState() {
1094
- this.connectionUri = null;
1095
- this.address = null;
1096
- this.lastKnownAccounts = [];
1097
- this.lastKnownChainId = null;
1098
- try {
1099
- const { state } = _optionalChain([this, 'access', _76 => _76.wagmiAdapter, 'optionalAccess', _77 => _77.wagmiConfig]) || {};
1100
- const connection = _optionalChain([state, 'optionalAccess', _78 => _78.current]) && _optionalChain([state, 'access', _79 => _79.connections, 'optionalAccess', _80 => _80.get, 'call', _81 => _81(state.current)]);
1101
- if (connection && typeof connection !== "string" && _optionalChain([connection, 'access', _82 => _82.connector, 'optionalAccess', _83 => _83.disconnect])) {
1102
- await connection.connector.disconnect();
1103
- }
1104
- } catch (e6) {
1105
- }
1106
- if (_optionalChain([this, 'access', _84 => _84.modal, 'optionalAccess', _85 => _85.getIsConnectedState, 'call', _86 => _86()])) {
1107
- try {
1108
- await this.modal.disconnect("eip155");
1109
- } catch (e7) {
1110
- }
1111
- }
1112
- if (_optionalChain([this, 'access', _87 => _87.universalProvider, 'optionalAccess', _88 => _88.session])) {
1113
- try {
1114
- await this.universalProvider.disconnect();
1115
- } catch (e8) {
1116
- }
1117
320
  }
1118
- await new Promise((r) => setTimeout(r, 200));
1119
- this.provider = null;
1120
- }
1121
- /**
1122
- * Connects via WalletConnect QR code flow.
1123
- * Emits walletconnect:uri event for QR code display.
1124
- */
1125
- async connect() {
1126
- if (!this.config.projectId) throw _chunkK64T6WW3js.createConfigError.call(void 0, "WalletConnect");
1127
- await this.ensureInitialized();
1128
- if (!this.universalProvider) throw new Error("WalletConnect is not available");
1129
- await this.resetConnectionState();
1130
- try {
1131
- const session = await this.universalProvider.connect({ namespaces: WALLETCONNECT_NAMESPACE });
1132
- if (!session) throw new Error("Failed to establish WalletConnect session");
1133
- const address = extractAddressFromSession(session.namespaces);
1134
- if (!address) throw new Error("No accounts returned from WalletConnect");
1135
- this.provider = this.universalProvider;
1136
- this.address = address;
1137
- this.lastKnownAccounts = [address];
1138
- return { address, provider: this.provider, walletId: this.id };
1139
- } catch (error) {
1140
- this.connectionUri = null;
1141
- throw error;
1142
- }
1143
- }
1144
- /**
1145
- * Starts a WalletConnect session for headless/custom QR code flows.
1146
- * Returns the URI immediately and a function to wait for the connection.
1147
- */
1148
- async startSession(timeout = 1e4) {
1149
- if (!this.config.projectId) throw new Error("WalletConnect projectId is required");
1150
- await this.ensureInitialized();
1151
- if (!this.universalProvider) throw new Error("WalletConnect is not available");
1152
- await this.resetConnectionState();
1153
- const uriPromise = new Promise((resolve, reject) => {
1154
- const timeoutId = setTimeout(() => reject(new Error("Timeout waiting for WalletConnect URI")), timeout);
1155
- this.universalProvider.once("display_uri", (uri2) => {
1156
- clearTimeout(timeoutId);
1157
- this.connectionUri = uri2;
1158
- resolve(uri2);
1159
- });
1160
- });
1161
- const connectionPromise = (async () => {
1162
- const session = await this.universalProvider.connect({ namespaces: WALLETCONNECT_NAMESPACE });
1163
- if (!session) throw new Error("Failed to establish WalletConnect session");
1164
- const address = extractAddressFromSession(session.namespaces);
1165
- if (!address) throw new Error("No accounts returned from WalletConnect");
1166
- this.provider = this.universalProvider;
1167
- this.address = address;
1168
- this.lastKnownAccounts = [address];
1169
- return { address, provider: this.provider, walletId: this.id };
1170
- })();
1171
- const uri = await uriPromise;
1172
- return {
1173
- uri,
1174
- waitForConnection: async () => {
1175
- try {
1176
- return await connectionPromise;
1177
- } catch (error) {
1178
- this.connectionUri = null;
1179
- throw error;
1180
- }
1181
- }
1182
- };
1183
- }
1184
- /**
1185
- * Opens the AppKit modal for wallet selection.
1186
- * Used on mobile and when user clicks "Open Modal" button.
1187
- */
1188
- async openModal() {
1189
- if (!this.config.projectId) throw _chunkK64T6WW3js.createConfigError.call(void 0, "WalletConnect");
1190
- await this.ensureInitialized();
1191
- if (!this.modal) throw new Error("AppKit is not available");
1192
- await this.resetConnectionState();
1193
- this.modal.open({ view: "AllWallets" });
1194
- return this.waitForModalConnection();
1195
- }
1196
- waitForModalConnection(timeout = 6e4) {
1197
- return new Promise((resolve, reject) => {
1198
- const startTime = Date.now();
1199
- let unsubscribe = null;
1200
- let resolved = false;
1201
- const cleanup = () => _optionalChain([unsubscribe, 'optionalCall', _89 => _89()]);
1202
- const checkConnection = async () => {
1203
- if (resolved) return true;
1204
- this.syncAddressFromWagmi();
1205
- if (this.address && !this.provider) await this.syncProviderFromModal();
1206
- if (this.provider && this.address) {
1207
- try {
1208
- const accounts = await this.provider.request({ method: "eth_accounts" });
1209
- if (_optionalChain([accounts, 'optionalAccess', _90 => _90.length])) {
1210
- resolved = true;
1211
- cleanup();
1212
- _optionalChain([this, 'access', _91 => _91.modal, 'optionalAccess', _92 => _92.close, 'call', _93 => _93()]);
1213
- this.lastKnownAccounts = accounts;
1214
- resolve({ address: this.address, provider: this.provider, walletId: this.id });
1215
- return true;
1216
- }
1217
- } catch (e9) {
1218
- }
1219
- }
1220
- return false;
1221
- };
1222
- unsubscribe = this.modal.subscribeState(async (state) => {
1223
- if (await checkConnection()) return;
1224
- if (!state.open && !this.address && !resolved) {
1225
- cleanup();
1226
- reject(new Error("Connection rejected by user"));
1227
- }
321
+ };
322
+ }
323
+ function createEmailManifest(config) {
324
+ return {
325
+ id: _chunkALDVMRQGjs.WalletId.Email,
326
+ name: _chunkALDVMRQGjs.WalletName.Email,
327
+ icon: _nullishCoalesce(_chunkALDVMRQGjs.getLogoDataUri.call(void 0, _chunkALDVMRQGjs.WalletId.Email, "brand"), () => ( "")),
328
+ hide: true,
329
+ downloadUrl: null,
330
+ wcDeepLinkUrl: null,
331
+ isInstalled: () => true,
332
+ load: async () => {
333
+ const { EmailAdapter } = await Promise.resolve().then(() => _interopRequireWildcard(require("./EmailAdapter-Q63KI6DV.js")));
334
+ return new EmailAdapter({
335
+ projectId: config.embeddedProjectId,
336
+ telemetry: config.telemetry
1228
337
  });
1229
- const poll = async () => {
1230
- if (await checkConnection()) return;
1231
- if (Date.now() - startTime > timeout) {
1232
- cleanup();
1233
- reject(new Error("Connection timeout"));
1234
- return;
1235
- }
1236
- setTimeout(poll, 500);
1237
- };
1238
- poll();
1239
- });
1240
- }
1241
- async tryRestoreConnection() {
1242
- await this.ensureInitialized();
1243
- if (!this.wagmiAdapter) return null;
1244
- try {
1245
- await new Promise((r) => setTimeout(r, 1e3));
1246
- const { state } = this.wagmiAdapter.wagmiConfig || {};
1247
- const connection = _optionalChain([state, 'optionalAccess', _94 => _94.current]) && _optionalChain([state, 'access', _95 => _95.connections, 'optionalAccess', _96 => _96.get, 'call', _97 => _97(state.current)]);
1248
- if (!connection || typeof connection === "string") return null;
1249
- const address = _optionalChain([connection, 'access', _98 => _98.accounts, 'optionalAccess', _99 => _99[0]]);
1250
- if (address && this.provider) {
1251
- this.address = address;
1252
- this.lastKnownAccounts = [...connection.accounts || []];
1253
- return { address, provider: this.provider, walletId: this.id };
1254
- }
1255
- return null;
1256
- } catch (e10) {
1257
- return null;
1258
- }
1259
- }
1260
- async disconnect() {
1261
- if (this.modal) {
1262
- await this.modal.disconnect("eip155");
1263
- const deadline = Date.now() + 2e3;
1264
- while (Date.now() < deadline && (this.modal.getIsConnectedState() || this.modal.getAddress())) {
1265
- await new Promise((r) => setTimeout(r, 100));
1266
- }
1267
- }
1268
- this.address = null;
1269
- this.provider = null;
1270
- this.connectionUri = null;
1271
- this.lastKnownAccounts = [];
1272
- this.lastKnownChainId = null;
1273
- }
1274
- getProvider() {
1275
- return this.provider;
1276
- }
1277
- onAccountsChanged(callback) {
1278
- if (this.accountsChangedCallback && _optionalChain([this, 'access', _100 => _100.provider, 'optionalAccess', _101 => _101.removeListener])) {
1279
- this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
1280
338
  }
1281
- if (this.sessionUpdateHandler && _optionalChain([this, 'access', _102 => _102.universalProvider, 'optionalAccess', _103 => _103.removeListener])) {
1282
- this.universalProvider.removeListener("session_update", this.sessionUpdateHandler);
1283
- }
1284
- if (!this.lastKnownAccounts.length && this.address) this.lastKnownAccounts = [this.address];
1285
- this.accountsChangedCallback = (accounts) => {
1286
- this.address = accounts[0] || null;
1287
- this.lastKnownAccounts = accounts;
1288
- callback(accounts);
1289
- };
1290
- if (_optionalChain([this, 'access', _104 => _104.provider, 'optionalAccess', _105 => _105.on])) {
1291
- this.provider.on("accountsChanged", this.accountsChangedCallback);
1292
- }
1293
- if (_optionalChain([this, 'access', _106 => _106.universalProvider, 'optionalAccess', _107 => _107.on])) {
1294
- this.sessionUpdateHandler = (args) => {
1295
- const accounts = this.extractAccountsFromNamespaces(_optionalChain([args, 'optionalAccess', _108 => _108.params, 'optionalAccess', _109 => _109.namespaces]));
1296
- if (accounts.length && this.hasAccountsChanged(accounts)) {
1297
- this.lastKnownAccounts = accounts;
1298
- this.address = accounts[0];
1299
- callback(accounts);
1300
- }
1301
- };
1302
- this.universalProvider.on("session_update", this.sessionUpdateHandler);
1303
- }
1304
- }
1305
- onChainChanged(callback) {
1306
- if (!_optionalChain([this, 'access', _110 => _110.provider, 'optionalAccess', _111 => _111.on])) return;
1307
- if (this.chainChangedCallback) _optionalChain([this, 'access', _112 => _112.provider, 'access', _113 => _113.removeListener, 'optionalCall', _114 => _114("chainChanged", this.chainChangedCallback)]);
1308
- this.chainChangedCallback = (chainId) => {
1309
- const normalized = typeof chainId === "string" ? chainId : `0x${Number(chainId).toString(16)}`;
1310
- if (normalized !== this.lastKnownChainId) {
1311
- this.lastKnownChainId = normalized;
1312
- callback(normalized);
1313
- }
1314
- };
1315
- this.provider.on("chainChanged", this.chainChangedCallback);
1316
- }
1317
- /** Called when remote wallet disconnects (user disconnects from mobile app) */
1318
- onDisconnect(callback) {
1319
- this.disconnectCallback = callback;
1320
- }
1321
- /** Updates the AppKit modal theme */
1322
- updateTheme(theme) {
1323
- this.config.theme = theme;
1324
- if (this.modal && typeof this.modal.setThemeMode === "function") {
1325
- this.modal.setThemeMode(theme);
1326
- }
1327
- }
1328
- extractAccountsFromNamespaces(namespaces) {
1329
- if (!namespaces) return [];
1330
- const accounts = [];
1331
- Object.values(namespaces).forEach((ns) => {
1332
- _optionalChain([ns, 'optionalAccess', _115 => _115.accounts, 'optionalAccess', _116 => _116.forEach, 'call', _117 => _117((account) => {
1333
- const address = account.split(":")[2];
1334
- if (address) accounts.push(address);
1335
- })]);
1336
- });
1337
- return [...new Set(accounts)];
1338
- }
1339
- hasAccountsChanged(newAccounts) {
1340
- if (newAccounts.length !== this.lastKnownAccounts.length) return true;
1341
- return newAccounts.some((acc, i) => acc.toLowerCase() !== _optionalChain([this, 'access', _118 => _118.lastKnownAccounts, 'access', _119 => _119[i], 'optionalAccess', _120 => _120.toLowerCase, 'call', _121 => _121()]));
1342
- }
1343
- removeListeners() {
1344
- if (this.accountsChangedCallback) {
1345
- _optionalChain([this, 'access', _122 => _122.provider, 'optionalAccess', _123 => _123.removeListener, 'optionalCall', _124 => _124("accountsChanged", this.accountsChangedCallback)]);
1346
- this.accountsChangedCallback = null;
1347
- }
1348
- if (this.chainChangedCallback) {
1349
- _optionalChain([this, 'access', _125 => _125.provider, 'optionalAccess', _126 => _126.removeListener, 'optionalCall', _127 => _127("chainChanged", this.chainChangedCallback)]);
1350
- this.chainChangedCallback = null;
1351
- }
1352
- if (this.sessionUpdateHandler) {
1353
- _optionalChain([this, 'access', _128 => _128.universalProvider, 'optionalAccess', _129 => _129.removeListener, 'optionalCall', _130 => _130("session_update", this.sessionUpdateHandler)]);
1354
- this.sessionUpdateHandler = null;
1355
- }
1356
- this.disconnectCallback = null;
1357
- this.unsubscribeFunctions.forEach((unsub) => unsub());
1358
- this.unsubscribeFunctions = [];
1359
- this.lastKnownAccounts = [];
1360
- this.lastKnownChainId = null;
1361
- }
1362
- };
339
+ };
340
+ }
1363
341
 
1364
- // src/wallet-adapters/EmailAdapter.ts
1365
- _chunkQIPVNM7Tjs.init_polyfills.call(void 0, );
1366
- var _EmailAdapter = class _EmailAdapter {
1367
- constructor(config) {
1368
- this.id = _chunkK64T6WW3js.WalletId.Email;
1369
- this.name = _chunkK64T6WW3js.WalletName.Email;
1370
- this.icon = _nullishCoalesce(_chunkK64T6WW3js.getLogoDataUri.call(void 0, _chunkK64T6WW3js.WalletId.Email, "brand"), () => ( ""));
1371
- this.hide = true;
1372
- this.downloadUrl = null;
1373
- this.wcDeepLinkUrl = null;
1374
- this.provider = null;
1375
- this.initPromise = null;
1376
- this.publicClientCache = /* @__PURE__ */ new Map();
1377
- this.projectId = _optionalChain([config, 'optionalAccess', _131 => _131.projectId]) || "";
1378
- this.telemetry = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _132 => _132.telemetry]), () => ( false));
1379
- }
1380
- async ensureInitialized() {
1381
- if (this.provider) return;
1382
- if (!this.initPromise) {
1383
- this.initPromise = this.initializeProvider();
1384
- }
1385
- await this.initPromise;
1386
- }
1387
- isInstalled() {
1388
- return true;
1389
- }
1390
- async emailAuthStart(email) {
1391
- if (!this.projectId) {
1392
- throw _chunkK64T6WW3js.createConfigError.call(void 0, "Email");
1393
- }
1394
- await this.ensureInitialized();
1395
- if (!this.provider) {
1396
- _chunkK64T6WW3js.sentryLogger.error("Email is not available");
1397
- throw new Error("Email is not available");
1398
- }
1399
- const { signInWithEmail } = await Promise.resolve().then(() => _interopRequireWildcard(require("./index.web-V7DLWC7H.js")));
1400
- const authResult = await signInWithEmail({ email });
1401
- return authResult;
1402
- }
1403
- async emailAuthVerify(flowId, otp) {
1404
- if (!flowId || !otp) {
1405
- throw new Error("flowId and otp are required");
1406
- }
1407
- await this.ensureInitialized();
1408
- if (!this.provider) {
1409
- _chunkK64T6WW3js.sentryLogger.error("Email provider not initialized");
1410
- throw new Error("Email provider not initialized");
1411
- }
1412
- const { verifyEmailOTP } = await Promise.resolve().then(() => _interopRequireWildcard(require("./index.web-V7DLWC7H.js")));
1413
- return verifyEmailOTP({ flowId, otp });
1414
- }
1415
- async connect() {
1416
- _chunkK64T6WW3js.sentryLogger.error("EmailAdapter.connect() is not implemented");
1417
- throw new Error("EmailAdapter.connect() is not implemented");
1418
- }
1419
- async tryRestoreConnection() {
1420
- await this.ensureInitialized();
1421
- if (!this.provider) {
1422
- return null;
1423
- }
1424
- try {
1425
- const accounts = await this.provider.request({
1426
- method: "eth_accounts",
1427
- params: []
1428
- });
1429
- if (!accounts || accounts.length === 0 || !accounts[0]) {
1430
- return null;
1431
- }
1432
- return {
1433
- address: accounts[0],
1434
- provider: this.provider,
1435
- walletId: this.id
1436
- };
1437
- } catch (e11) {
1438
- return null;
1439
- }
1440
- }
1441
- async disconnect() {
1442
- try {
1443
- await this.ensureInitialized();
1444
- const { signOut } = await Promise.resolve().then(() => _interopRequireWildcard(require("./index.web-V7DLWC7H.js")));
1445
- await signOut();
1446
- } catch (e12) {
1447
- }
1448
- }
1449
- getProvider() {
1450
- return this.provider;
1451
- }
1452
- static async initializeChainData() {
1453
- if (this.chainIdMap !== null) return;
1454
- const [allChains, { http }] = await Promise.all([Promise.resolve().then(() => _interopRequireWildcard(require("viem/chains"))), Promise.resolve().then(() => _interopRequireWildcard(require("viem")))]);
1455
- const chains = Object.values(allChains).filter(
1456
- (chain) => typeof chain === "object" && chain !== null && "id" in chain
1457
- );
1458
- this.chainIdMap = new Map(chains.map((chain) => [chain.id, chain]));
1459
- this.viemChains = chains;
1460
- this.viemTransports = chains.reduce(
1461
- (acc, chain) => {
1462
- acc[chain.id] = http();
1463
- return acc;
1464
- },
1465
- {}
1466
- );
1467
- }
1468
- async getPublicClientForChain(chainId) {
1469
- if (this.publicClientCache.has(chainId)) {
1470
- return this.publicClientCache.get(chainId);
1471
- }
1472
- await _EmailAdapter.initializeChainData();
1473
- const viemChain = _EmailAdapter.chainIdMap.get(chainId);
1474
- if (!viemChain) {
1475
- throw new Error(`Chain ${chainId} not supported`);
1476
- }
1477
- const { createPublicClient, http } = await Promise.resolve().then(() => _interopRequireWildcard(require("viem")));
1478
- const publicClient = createPublicClient({
1479
- chain: viemChain,
1480
- transport: http()
1481
- });
1482
- this.publicClientCache.set(chainId, publicClient);
1483
- return publicClient;
1484
- }
1485
- /**
1486
- * Initializes CDP and creates the provider.
1487
- * Called by ensureInitialized() - deduplication handled via initPromise.
1488
- */
1489
- async initializeProvider() {
1490
- const { initialize } = await Promise.resolve().then(() => _interopRequireWildcard(require("./index.web-V7DLWC7H.js")));
1491
- await initialize({
1492
- projectId: this.projectId,
1493
- ethereum: {
1494
- createOnLogin: "eoa"
1495
- },
1496
- disableAnalytics: !this.telemetry
1497
- });
1498
- this.provider = await this.createProvider();
1499
- }
1500
- /**
1501
- * Special case:
1502
- * Coinbase default provider does not support generic read methods like eth_getBalance.
1503
- * Wraps the provider to send unsupported methods to a public RPC endpoint.
1504
- */
1505
- async createProvider() {
1506
- try {
1507
- await _EmailAdapter.initializeChainData();
1508
- const { createCDPEmbeddedWallet } = await Promise.resolve().then(() => _interopRequireWildcard(require("./index.web-V7DLWC7H.js")));
1509
- const wallet = createCDPEmbeddedWallet({
1510
- chains: _EmailAdapter.viemChains,
1511
- transports: _EmailAdapter.viemTransports
1512
- });
1513
- const base = wallet.provider;
1514
- const getPublicClient = this.getPublicClientForChain.bind(this);
1515
- const wrapped = {
1516
- ...base,
1517
- async request(args) {
1518
- try {
1519
- return await base.request(args);
1520
- } catch (err) {
1521
- const msg = String(_optionalChain([err, 'optionalAccess', _133 => _133.message]) || "");
1522
- const isUnsupported = msg.includes("not supported") || msg.includes("Unsupported") || _optionalChain([err, 'optionalAccess', _134 => _134.code]) === -32601;
1523
- if (isUnsupported) {
1524
- let chainId;
1525
- try {
1526
- const chainIdHex = await base.request({ method: "eth_chainId", params: [] });
1527
- chainId = parseInt(chainIdHex, 16);
1528
- } catch (e13) {
1529
- _chunkK64T6WW3js.sentryLogger.error("Failed to get chainId for fallback request");
1530
- throw new Error("Failed to get chainId for fallback request");
1531
- }
1532
- const publicClient = await getPublicClient(chainId);
1533
- return await publicClient.transport.request({
1534
- method: args.method,
1535
- params: Array.isArray(args.params) ? args.params : args.params ? [args.params] : void 0
1536
- });
1537
- }
1538
- throw err;
1539
- }
1540
- }
1541
- };
1542
- return wrapped;
1543
- } catch (error) {
1544
- _chunkK64T6WW3js.sentryLogger.error("Failed to initialize Email provider", { error });
1545
- return null;
1546
- }
1547
- }
1548
- // Email wallets don't support account switching - user must re-authenticate to change accounts
1549
- onAccountsChanged() {
1550
- }
1551
- removeListeners() {
1552
- }
1553
- };
1554
- // Static variables - computed once across all instances
1555
- _EmailAdapter.chainIdMap = null;
1556
- _EmailAdapter.viemChains = null;
1557
- _EmailAdapter.viemTransports = null;
1558
- var EmailAdapter = _EmailAdapter;
1559
-
1560
- // src/utils/createWalletAdapters.ts
1561
- function createWalletAdapters({
342
+ // src/utils/createWalletManifests.ts
343
+ function createWalletManifests({
1562
344
  walletsConfig,
1563
345
  appName,
1564
346
  appLogoUrl,
@@ -1566,20 +348,24 @@ function createWalletAdapters({
1566
348
  theme,
1567
349
  telemetry
1568
350
  }) {
351
+ startEIP6963Discovery();
352
+ const config = {
353
+ appName,
354
+ appLogoUrl,
355
+ modalZIndex,
356
+ theme,
357
+ telemetry,
358
+ embeddedProjectId: _optionalChain([walletsConfig, 'optionalAccess', _33 => _33.embedded, 'optionalAccess', _34 => _34.projectId]),
359
+ walletConnectProjectId: _optionalChain([walletsConfig, 'optionalAccess', _35 => _35.walletConnect, 'optionalAccess', _36 => _36.projectId])
360
+ };
1569
361
  return [
1570
- new EmailAdapter({ projectId: _optionalChain([walletsConfig, 'optionalAccess', _135 => _135.embedded, 'optionalAccess', _136 => _136.projectId]), telemetry }),
1571
- new MetaMaskAdapter(),
1572
- new WalletConnectAdapter({
1573
- projectId: _optionalChain([walletsConfig, 'optionalAccess', _137 => _137.walletConnect, 'optionalAccess', _138 => _138.projectId]),
1574
- appName,
1575
- modalZIndex,
1576
- theme,
1577
- telemetry
1578
- }),
1579
- new CoinbaseWalletAdapter({ appName, appLogoUrl, telemetry }),
1580
- new PhantomAdapter(),
1581
- new RabbyAdapter(),
1582
- new BraveAdapter()
362
+ createEmailManifest(config),
363
+ createMetaMaskManifest(),
364
+ createWalletConnectManifest(config),
365
+ createCoinbaseWalletManifest(config),
366
+ createPhantomManifest(),
367
+ createRabbyManifest(),
368
+ createBraveManifest()
1583
369
  ];
1584
370
  }
1585
371
 
@@ -1656,81 +442,6 @@ var RpcProvider = class {
1656
442
  }
1657
443
  };
1658
444
 
1659
- // src/errors.ts
1660
- _chunkQIPVNM7Tjs.init_polyfills.call(void 0, );
1661
- var AurumError = class extends Error {
1662
- constructor(message, cause) {
1663
- super(message);
1664
- this.name = this.constructor.name;
1665
- this.cause = cause;
1666
- Object.setPrototypeOf(this, new.target.prototype);
1667
- }
1668
- };
1669
- var UserRejectedError = class extends AurumError {
1670
- constructor() {
1671
- super(...arguments);
1672
- this.code = "USER_REJECTED";
1673
- }
1674
- };
1675
- var ChainSwitchRejectedError = class extends AurumError {
1676
- constructor() {
1677
- super(...arguments);
1678
- this.code = "CHAIN_SWITCH_REJECTED";
1679
- }
1680
- };
1681
- var WalletNotInstalledError = class extends AurumError {
1682
- constructor(walletId, cause) {
1683
- super(`${walletId} is not installed`, cause);
1684
- this.walletId = walletId;
1685
- this.code = "WALLET_NOT_INSTALLED";
1686
- }
1687
- };
1688
- var WalletNotConfiguredError = class extends AurumError {
1689
- constructor(walletId, cause) {
1690
- super(`${walletId} is not configured`, cause);
1691
- this.walletId = walletId;
1692
- this.code = "WALLET_NOT_CONFIGURED";
1693
- }
1694
- };
1695
- var WalletExcludedError = class extends AurumError {
1696
- constructor(walletId, cause) {
1697
- super(`${walletId} is excluded from wallet options`, cause);
1698
- this.walletId = walletId;
1699
- this.code = "WALLET_EXCLUDED";
1700
- }
1701
- };
1702
- var ChainNotSupportedError = class extends AurumError {
1703
- constructor() {
1704
- super(...arguments);
1705
- this.code = "CHAIN_NOT_SUPPORTED";
1706
- }
1707
- };
1708
- var InvalidConfigError = class extends AurumError {
1709
- constructor() {
1710
- super(...arguments);
1711
- this.code = "INVALID_CONFIG";
1712
- }
1713
- };
1714
- var ConnectionError = class extends AurumError {
1715
- constructor() {
1716
- super(...arguments);
1717
- this.code = "CONNECTION_FAILED";
1718
- }
1719
- };
1720
- var USER_REJECTION_REGEX = /user (rejected|denied|cancel(l?)ed)/i;
1721
- function normalizeError(err, context) {
1722
- if (err instanceof AurumError) return err;
1723
- const rawCode = _optionalChain([err, 'optionalAccess', _139 => _139.code]);
1724
- const rawMessage = _optionalChain([err, 'optionalAccess', _140 => _140.message]);
1725
- const message = typeof rawMessage === "string" ? rawMessage : "Unknown error";
1726
- const isRejectionCode = rawCode === 4001 || rawCode === "4001" || rawCode === "ACTION_REJECTED";
1727
- const isRejectionMessage = typeof rawMessage === "string" && USER_REJECTION_REGEX.test(rawMessage);
1728
- if (isRejectionCode || isRejectionMessage) {
1729
- return _optionalChain([context, 'optionalAccess', _141 => _141.operation]) === "switchChain" ? new ChainSwitchRejectedError(message, err) : new UserRejectedError(message, err);
1730
- }
1731
- return new ConnectionError(message, err);
1732
- }
1733
-
1734
445
  // src/AurumCore.ts
1735
446
  var _AurumCore = class _AurumCore {
1736
447
  constructor(config) {
@@ -1770,10 +481,10 @@ var _AurumCore = class _AurumCore {
1770
481
  }
1771
482
  _AurumCore.storedConfigJson = _AurumCore.serializeConfig(config);
1772
483
  const telemetryEnabled = config.telemetry !== false;
1773
- _chunkK64T6WW3js.initSentry.call(void 0, telemetryEnabled);
484
+ _chunkALDVMRQGjs.initSentry.call(void 0, telemetryEnabled);
1774
485
  this.brandConfig = this.resolveBrandConfig(config);
1775
- this.excludedWallets = new Set(_nullishCoalesce(_optionalChain([config, 'access', _142 => _142.wallets, 'optionalAccess', _143 => _143.exclude]), () => ( [])));
1776
- this.wallets = createWalletAdapters({
486
+ this.excludedWallets = new Set(_nullishCoalesce(_optionalChain([config, 'access', _37 => _37.wallets, 'optionalAccess', _38 => _38.exclude]), () => ( [])));
487
+ this.walletManifests = createWalletManifests({
1777
488
  walletsConfig: config.wallets,
1778
489
  appName: this.brandConfig.appName,
1779
490
  appLogoUrl: this.brandConfig.logo,
@@ -1790,14 +501,14 @@ var _AurumCore = class _AurumCore {
1790
501
  static serializeConfig(config) {
1791
502
  try {
1792
503
  return JSON.stringify(config);
1793
- } catch (e14) {
504
+ } catch (e) {
1794
505
  return null;
1795
506
  }
1796
507
  }
1797
508
  async whenReady() {
1798
509
  try {
1799
510
  await this.readyPromise;
1800
- } catch (e15) {
511
+ } catch (e2) {
1801
512
  this.resetConnectionState();
1802
513
  this.ready = true;
1803
514
  }
@@ -1806,7 +517,7 @@ var _AurumCore = class _AurumCore {
1806
517
  return this.brandConfig;
1807
518
  }
1808
519
  get walletAdapters() {
1809
- return this.wallets;
520
+ return this.walletManifests;
1810
521
  }
1811
522
  get excludedWalletIds() {
1812
523
  return this.excludedWallets;
@@ -1815,50 +526,52 @@ var _AurumCore = class _AurumCore {
1815
526
  try {
1816
527
  await this.whenReady();
1817
528
  if (walletId === "email") {
1818
- throw new InvalidConfigError("Use emailAuthStart() and emailAuthVerify() for email wallet connections");
529
+ throw new (0, _chunk4XQZ5JBSjs.InvalidConfigError)("Use emailAuthStart() and emailAuthVerify() for email wallet connections");
1819
530
  }
1820
- if (_optionalChain([this, 'access', _144 => _144.userInfo, 'optionalAccess', _145 => _145.publicAddress]) && _optionalChain([this, 'access', _146 => _146.connectedWalletAdapter, 'optionalAccess', _147 => _147.getProvider, 'call', _148 => _148()])) {
531
+ if (_optionalChain([this, 'access', _39 => _39.userInfo, 'optionalAccess', _40 => _40.publicAddress]) && _optionalChain([this, 'access', _41 => _41.connectedWalletAdapter, 'optionalAccess', _42 => _42.getProvider, 'call', _43 => _43()])) {
1821
532
  if (!walletId || this.userInfo.walletId === walletId) {
1822
533
  return this.userInfo.publicAddress;
1823
534
  }
1824
535
  await this.disconnect();
1825
536
  }
1826
- let adapter = null;
537
+ let adapter;
1827
538
  let result;
1828
539
  if (walletId) {
1829
540
  if (this.excludedWallets.has(walletId)) {
1830
- throw new WalletExcludedError(walletId);
541
+ throw new (0, _chunk4XQZ5JBSjs.WalletExcludedError)(walletId);
1831
542
  }
1832
- adapter = this.wallets.find((w) => w.id === walletId) || null;
1833
- if (!adapter) {
1834
- throw new WalletNotConfiguredError(walletId);
543
+ const manifest = this.walletManifests.find((m) => m.id === walletId);
544
+ if (!manifest) {
545
+ throw new (0, _chunk4XQZ5JBSjs.WalletNotConfiguredError)(walletId);
1835
546
  }
1836
- if (walletId === _chunkK64T6WW3js.WalletId.WalletConnect && adapter.openModal) {
547
+ adapter = await _chunk4XQZ5JBSjs.loadAdapter.call(void 0, manifest);
548
+ if (walletId === _chunkALDVMRQGjs.WalletId.WalletConnect && adapter.openModal) {
1837
549
  result = await adapter.openModal();
1838
550
  } else {
1839
- if (!adapter.isInstalled()) {
1840
- throw new WalletNotInstalledError(adapter.name);
551
+ if (!manifest.isInstalled()) {
552
+ throw new (0, _chunk4XQZ5JBSjs.WalletNotInstalledError)(adapter.name);
1841
553
  }
1842
554
  result = await adapter.connect();
1843
555
  }
1844
556
  } else {
1845
- const displayedWallets = this.wallets.filter((w) => !this.excludedWallets.has(w.id));
557
+ const displayedWallets = this.walletManifests.filter((m) => !this.excludedWallets.has(m.id));
1846
558
  const modalResult = await renderConnectModal({ displayedWallets, brandConfig: this.brandConfig });
1847
559
  if (!modalResult) {
1848
- _chunkK64T6WW3js.sentryLogger.error("Missing modal result");
1849
- throw new ConnectionError("Missing modal result");
560
+ _chunkALDVMRQGjs.sentryLogger.error("Missing modal result");
561
+ throw new (0, _chunk4XQZ5JBSjs.ConnectionError)("Missing modal result");
1850
562
  }
1851
- adapter = this.wallets.find((w) => w.id === modalResult.walletId) || null;
1852
- if (!adapter) {
1853
- _chunkK64T6WW3js.sentryLogger.error(`Selected wallet adapter not found: ${modalResult.walletId}`);
1854
- throw new ConnectionError("Selected wallet adapter not found");
563
+ const manifest = this.walletManifests.find((m) => m.id === modalResult.walletId);
564
+ if (!manifest) {
565
+ _chunkALDVMRQGjs.sentryLogger.error(`Selected wallet adapter not found: ${modalResult.walletId}`);
566
+ throw new (0, _chunk4XQZ5JBSjs.ConnectionError)("Selected wallet adapter not found");
1855
567
  }
568
+ adapter = await _chunk4XQZ5JBSjs.loadAdapter.call(void 0, manifest);
1856
569
  result = modalResult;
1857
570
  }
1858
571
  const provider = _nullishCoalesce(result.provider, () => ( adapter.getProvider()));
1859
572
  if (!provider) {
1860
- _chunkK64T6WW3js.sentryLogger.error(`Error fetching provider on login: ${adapter.id}`);
1861
- throw new ConnectionError("Error fetching provider. Please try again.");
573
+ _chunkALDVMRQGjs.sentryLogger.error(`Error fetching provider on login: ${adapter.id}`);
574
+ throw new (0, _chunk4XQZ5JBSjs.ConnectionError)("Error fetching provider. Please try again.");
1862
575
  }
1863
576
  const checksumAdr = _viem.checksumAddress.call(void 0, result.address);
1864
577
  this.connectedWalletAdapter = adapter;
@@ -1874,10 +587,10 @@ var _AurumCore = class _AurumCore {
1874
587
  const chainId = await provider.request({ method: "eth_chainId" });
1875
588
  this.emitConnect(chainId);
1876
589
  this.emitAccountsChanged([checksumAdr]);
1877
- _chunkK64T6WW3js.sentryLogger.info(`Wallet connected: ${adapter.id} (${walletId ? "headless" : "modal"})`);
590
+ _chunkALDVMRQGjs.sentryLogger.info(`Wallet connected: ${adapter.id} (${walletId ? "headless" : "modal"})`);
1878
591
  return checksumAdr;
1879
592
  } catch (err) {
1880
- throw normalizeError(err, { operation: "connect" });
593
+ throw _chunk4XQZ5JBSjs.normalizeError.call(void 0, err, { operation: "connect" });
1881
594
  }
1882
595
  }
1883
596
  async disconnect() {
@@ -1891,7 +604,7 @@ var _AurumCore = class _AurumCore {
1891
604
  this.emitDisconnect();
1892
605
  this.emitAccountsChanged([]);
1893
606
  } catch (err) {
1894
- throw normalizeError(err, { operation: "disconnect" });
607
+ throw _chunk4XQZ5JBSjs.normalizeError.call(void 0, err, { operation: "disconnect" });
1895
608
  }
1896
609
  }
1897
610
  async getUserInfo() {
@@ -1901,18 +614,19 @@ var _AurumCore = class _AurumCore {
1901
614
  async isConnected() {
1902
615
  await this.whenReady();
1903
616
  return Boolean(
1904
- _optionalChain([this, 'access', _149 => _149.userInfo, 'optionalAccess', _150 => _150.publicAddress]) && _optionalChain([this, 'access', _151 => _151.userInfo, 'optionalAccess', _152 => _152.walletName]) && _optionalChain([this, 'access', _153 => _153.connectedWalletAdapter, 'optionalAccess', _154 => _154.getProvider, 'call', _155 => _155()])
617
+ _optionalChain([this, 'access', _44 => _44.userInfo, 'optionalAccess', _45 => _45.publicAddress]) && _optionalChain([this, 'access', _46 => _46.userInfo, 'optionalAccess', _47 => _47.walletName]) && _optionalChain([this, 'access', _48 => _48.connectedWalletAdapter, 'optionalAccess', _49 => _49.getProvider, 'call', _50 => _50()])
1905
618
  );
1906
619
  }
1907
620
  async handleWidgetConnection(result) {
1908
621
  try {
1909
622
  await this.whenReady();
1910
- const adapter = this.wallets.find((w) => w.id === result.walletId) || null;
1911
- if (!adapter) throw new ConnectionError("Selected wallet adapter not found");
623
+ const manifest = this.walletManifests.find((m) => m.id === result.walletId);
624
+ if (!manifest) throw new (0, _chunk4XQZ5JBSjs.ConnectionError)("Selected wallet adapter not found");
625
+ const adapter = await _chunk4XQZ5JBSjs.loadAdapter.call(void 0, manifest);
1912
626
  const provider = _nullishCoalesce(result.provider, () => ( adapter.getProvider()));
1913
627
  if (!provider) {
1914
- _chunkK64T6WW3js.sentryLogger.error(`Error fetching provider on widget login: ${_optionalChain([result, 'optionalAccess', _156 => _156.walletId])}`);
1915
- throw new ConnectionError("Error fetching provider. Please try again.");
628
+ _chunkALDVMRQGjs.sentryLogger.error(`Error fetching provider on widget login: ${_optionalChain([result, 'optionalAccess', _51 => _51.walletId])}`);
629
+ throw new (0, _chunk4XQZ5JBSjs.ConnectionError)("Error fetching provider. Please try again.");
1916
630
  }
1917
631
  const checksumAdr = _viem.checksumAddress.call(void 0, result.address);
1918
632
  this.connectedWalletAdapter = adapter;
@@ -1928,10 +642,10 @@ var _AurumCore = class _AurumCore {
1928
642
  const chainId = await provider.request({ method: "eth_chainId" });
1929
643
  this.emitConnect(chainId);
1930
644
  this.emitAccountsChanged([checksumAdr]);
1931
- _chunkK64T6WW3js.sentryLogger.info(`Wallet connected: ${adapter.id} (widget)`);
645
+ _chunkALDVMRQGjs.sentryLogger.info(`Wallet connected: ${adapter.id} (widget)`);
1932
646
  return this.userInfo;
1933
647
  } catch (err) {
1934
- throw normalizeError(err, { operation: "connect" });
648
+ throw _chunk4XQZ5JBSjs.normalizeError.call(void 0, err, { operation: "connect" });
1935
649
  }
1936
650
  }
1937
651
  async getChainId() {
@@ -1950,11 +664,11 @@ var _AurumCore = class _AurumCore {
1950
664
  await this.handleMissingChain(hexChainId, chain);
1951
665
  }
1952
666
  } catch (err) {
1953
- throw normalizeError(err, { operation: "switchChain" });
667
+ throw _chunk4XQZ5JBSjs.normalizeError.call(void 0, err, { operation: "switchChain" });
1954
668
  }
1955
669
  }
1956
670
  updateBrandConfig(newConfig) {
1957
- const defaultTheme = _chunkK64T6WW3js.getDefaultThemeConfig.call(void 0, _nullishCoalesce(newConfig.theme, () => ( this.brandConfig.theme)));
671
+ const defaultTheme = _chunk4XQZ5JBSjs.getDefaultThemeConfig.call(void 0, _nullishCoalesce(newConfig.theme, () => ( this.brandConfig.theme)));
1958
672
  this.brandConfig = {
1959
673
  logo: "logo" in newConfig ? _nullishCoalesce(newConfig.logo, () => ( defaultTheme.logo)) : this.brandConfig.logo,
1960
674
  theme: "theme" in newConfig ? _nullishCoalesce(newConfig.theme, () => ( defaultTheme.theme)) : this.brandConfig.theme,
@@ -1967,8 +681,12 @@ var _AurumCore = class _AurumCore {
1967
681
  walletLayout: "walletLayout" in newConfig ? _nullishCoalesce(newConfig.walletLayout, () => ( defaultTheme.walletLayout)) : this.brandConfig.walletLayout
1968
682
  };
1969
683
  if ("theme" in newConfig && this.brandConfig.theme) {
1970
- const wcAdapter = this.wallets.find((w) => w.id === _chunkK64T6WW3js.WalletId.WalletConnect);
1971
- _optionalChain([wcAdapter, 'optionalAccess', _157 => _157.updateTheme, 'call', _158 => _158(this.brandConfig.theme)]);
684
+ const wcPromise = _chunk4XQZ5JBSjs.peekAdapter.call(void 0, _chunkALDVMRQGjs.WalletId.WalletConnect);
685
+ if (wcPromise) {
686
+ const theme = this.brandConfig.theme;
687
+ wcPromise.then((adapter) => adapter.updateTheme(theme)).catch(() => {
688
+ });
689
+ }
1972
690
  }
1973
691
  }
1974
692
  updateWalletsConfig(newConfig) {
@@ -1984,14 +702,18 @@ var _AurumCore = class _AurumCore {
1984
702
  async emailAuthStart(email) {
1985
703
  try {
1986
704
  await this.whenReady();
1987
- const emailAdapter = this.wallets.find((w) => w.id === _chunkK64T6WW3js.WalletId.Email);
1988
- if (!emailAdapter || !emailAdapter.emailAuthStart) {
1989
- throw new WalletNotConfiguredError("email");
705
+ const manifest = this.walletManifests.find((m) => m.id === _chunkALDVMRQGjs.WalletId.Email);
706
+ if (!manifest) {
707
+ throw new (0, _chunk4XQZ5JBSjs.WalletNotConfiguredError)("email");
708
+ }
709
+ const emailAdapter = await _chunk4XQZ5JBSjs.loadAdapter.call(void 0, manifest);
710
+ if (!emailAdapter.emailAuthStart) {
711
+ throw new (0, _chunk4XQZ5JBSjs.WalletNotConfiguredError)("email");
1990
712
  }
1991
713
  const result = await emailAdapter.emailAuthStart(email);
1992
714
  return { flowId: result.flowId };
1993
715
  } catch (err) {
1994
- throw normalizeError(err, { operation: "emailAuthStart" });
716
+ throw _chunk4XQZ5JBSjs.normalizeError.call(void 0, err, { operation: "emailAuthStart" });
1995
717
  }
1996
718
  }
1997
719
  /**
@@ -2003,21 +725,25 @@ var _AurumCore = class _AurumCore {
2003
725
  async emailAuthVerify(flowId, otp) {
2004
726
  try {
2005
727
  await this.whenReady();
2006
- const emailAdapter = this.wallets.find((w) => w.id === _chunkK64T6WW3js.WalletId.Email);
2007
- if (!emailAdapter || !emailAdapter.emailAuthVerify) {
2008
- throw new WalletNotConfiguredError("email");
728
+ const manifest = this.walletManifests.find((m) => m.id === _chunkALDVMRQGjs.WalletId.Email);
729
+ if (!manifest) {
730
+ throw new (0, _chunk4XQZ5JBSjs.WalletNotConfiguredError)("email");
731
+ }
732
+ const emailAdapter = await _chunk4XQZ5JBSjs.loadAdapter.call(void 0, manifest);
733
+ if (!emailAdapter.emailAuthVerify) {
734
+ throw new (0, _chunk4XQZ5JBSjs.WalletNotConfiguredError)("email");
2009
735
  }
2010
736
  const verifyResult = await emailAdapter.emailAuthVerify(flowId, otp);
2011
737
  const provider = emailAdapter.getProvider();
2012
738
  if (!provider) {
2013
- _chunkK64T6WW3js.sentryLogger.error("Failed to get provider after email verification");
2014
- throw new ConnectionError("Failed to get provider after email verification");
739
+ _chunkALDVMRQGjs.sentryLogger.error("Failed to get provider after email verification");
740
+ throw new (0, _chunk4XQZ5JBSjs.ConnectionError)("Failed to get provider after email verification");
2015
741
  }
2016
- const address = _optionalChain([verifyResult, 'access', _159 => _159.user, 'optionalAccess', _160 => _160.evmAccounts, 'optionalAccess', _161 => _161[0]]);
2017
- const email = _optionalChain([verifyResult, 'access', _162 => _162.user, 'optionalAccess', _163 => _163.authenticationMethods, 'optionalAccess', _164 => _164.email, 'optionalAccess', _165 => _165.email]);
742
+ const address = _optionalChain([verifyResult, 'access', _52 => _52.user, 'optionalAccess', _53 => _53.evmAccounts, 'optionalAccess', _54 => _54[0]]);
743
+ const email = _optionalChain([verifyResult, 'access', _55 => _55.user, 'optionalAccess', _56 => _56.authenticationMethods, 'optionalAccess', _57 => _57.email, 'optionalAccess', _58 => _58.email]);
2018
744
  if (!address || !email) {
2019
- _chunkK64T6WW3js.sentryLogger.error("Address or email not found after email verification");
2020
- throw new ConnectionError("Address or email not found after email verification");
745
+ _chunkALDVMRQGjs.sentryLogger.error("Address or email not found after email verification");
746
+ throw new (0, _chunk4XQZ5JBSjs.ConnectionError)("Address or email not found after email verification");
2021
747
  }
2022
748
  const checksumAdr = _viem.checksumAddress.call(void 0, address);
2023
749
  this.connectedWalletAdapter = emailAdapter;
@@ -2033,10 +759,10 @@ var _AurumCore = class _AurumCore {
2033
759
  const chainId = await provider.request({ method: "eth_chainId" });
2034
760
  this.emitConnect(chainId);
2035
761
  this.emitAccountsChanged([checksumAdr]);
2036
- _chunkK64T6WW3js.sentryLogger.info(`Wallet connected: ${emailAdapter.id} (headless)`);
762
+ _chunkALDVMRQGjs.sentryLogger.info(`Wallet connected: ${emailAdapter.id} (headless)`);
2037
763
  return { address: checksumAdr, email: _nullishCoalesce(email, () => ( "")), isNewUser: _nullishCoalesce(verifyResult.isNewUser, () => ( false)) };
2038
764
  } catch (err) {
2039
- throw normalizeError(err, { operation: "emailAuthVerify" });
765
+ throw _chunk4XQZ5JBSjs.normalizeError.call(void 0, err, { operation: "emailAuthVerify" });
2040
766
  }
2041
767
  }
2042
768
  /**
@@ -2046,10 +772,11 @@ var _AurumCore = class _AurumCore {
2046
772
  async getWalletConnectSession() {
2047
773
  try {
2048
774
  await this.whenReady();
2049
- const wcAdapter = this.wallets.find((w) => w.id === _chunkK64T6WW3js.WalletId.WalletConnect);
2050
- if (!wcAdapter) {
2051
- throw new WalletNotConfiguredError("walletconnect");
775
+ const manifest = this.walletManifests.find((m) => m.id === _chunkALDVMRQGjs.WalletId.WalletConnect);
776
+ if (!manifest) {
777
+ throw new (0, _chunk4XQZ5JBSjs.WalletNotConfiguredError)("walletconnect");
2052
778
  }
779
+ const wcAdapter = await _chunk4XQZ5JBSjs.loadAdapter.call(void 0, manifest);
2053
780
  const session = await wcAdapter.startSession();
2054
781
  return {
2055
782
  uri: session.uri,
@@ -2058,8 +785,8 @@ var _AurumCore = class _AurumCore {
2058
785
  const result = await session.waitForConnection();
2059
786
  const provider = _nullishCoalesce(result.provider, () => ( wcAdapter.getProvider()));
2060
787
  if (!provider) {
2061
- _chunkK64T6WW3js.sentryLogger.error("Failed to get provider after WalletConnect connection");
2062
- throw new ConnectionError("Failed to get provider after WalletConnect connection");
788
+ _chunkALDVMRQGjs.sentryLogger.error("Failed to get provider after WalletConnect connection");
789
+ throw new (0, _chunk4XQZ5JBSjs.ConnectionError)("Failed to get provider after WalletConnect connection");
2063
790
  }
2064
791
  const checksumAdr = _viem.checksumAddress.call(void 0, result.address);
2065
792
  this.connectedWalletAdapter = wcAdapter;
@@ -2074,15 +801,15 @@ var _AurumCore = class _AurumCore {
2074
801
  const chainId = await provider.request({ method: "eth_chainId" });
2075
802
  this.emitConnect(chainId);
2076
803
  this.emitAccountsChanged([checksumAdr]);
2077
- _chunkK64T6WW3js.sentryLogger.info(`Wallet connected: ${wcAdapter.id} (headless)`);
804
+ _chunkALDVMRQGjs.sentryLogger.info(`Wallet connected: ${wcAdapter.id} (headless)`);
2078
805
  return checksumAdr;
2079
806
  } catch (err) {
2080
- throw normalizeError(err, { operation: "connect" });
807
+ throw _chunk4XQZ5JBSjs.normalizeError.call(void 0, err, { operation: "connect" });
2081
808
  }
2082
809
  }
2083
810
  };
2084
811
  } catch (err) {
2085
- throw normalizeError(err, { operation: "connect" });
812
+ throw _chunk4XQZ5JBSjs.normalizeError.call(void 0, err, { operation: "connect" });
2086
813
  }
2087
814
  }
2088
815
  /* PROVIDER METHODS */
@@ -2096,15 +823,15 @@ var _AurumCore = class _AurumCore {
2096
823
  }
2097
824
  this.eventListeners.get(event).add(callback);
2098
825
  if (!_AurumCore.MANAGED_EVENTS.includes(event)) {
2099
- _optionalChain([this, 'access', _166 => _166.currentProvider, 'access', _167 => _167.on, 'optionalCall', _168 => _168(event, callback)]);
826
+ _optionalChain([this, 'access', _59 => _59.currentProvider, 'access', _60 => _60.on, 'optionalCall', _61 => _61(event, callback)]);
2100
827
  }
2101
828
  };
2102
829
  }
2103
830
  if (prop === "removeListener") {
2104
831
  return (event, callback) => {
2105
- _optionalChain([this, 'access', _169 => _169.eventListeners, 'access', _170 => _170.get, 'call', _171 => _171(event), 'optionalAccess', _172 => _172.delete, 'call', _173 => _173(callback)]);
832
+ _optionalChain([this, 'access', _62 => _62.eventListeners, 'access', _63 => _63.get, 'call', _64 => _64(event), 'optionalAccess', _65 => _65.delete, 'call', _66 => _66(callback)]);
2106
833
  if (!_AurumCore.MANAGED_EVENTS.includes(event)) {
2107
- _optionalChain([this, 'access', _174 => _174.currentProvider, 'access', _175 => _175.removeListener, 'optionalCall', _176 => _176(event, callback)]);
834
+ _optionalChain([this, 'access', _67 => _67.currentProvider, 'access', _68 => _68.removeListener, 'optionalCall', _69 => _69(event, callback)]);
2108
835
  }
2109
836
  };
2110
837
  }
@@ -2129,7 +856,7 @@ var _AurumCore = class _AurumCore {
2129
856
  this.eventListeners.forEach((callbacks, event) => {
2130
857
  if (!_AurumCore.MANAGED_EVENTS.includes(event)) {
2131
858
  callbacks.forEach((callback) => {
2132
- _optionalChain([newProvider, 'access', _177 => _177.on, 'optionalCall', _178 => _178(event, callback)]);
859
+ _optionalChain([newProvider, 'access', _70 => _70.on, 'optionalCall', _71 => _71(event, callback)]);
2133
860
  });
2134
861
  }
2135
862
  });
@@ -2137,7 +864,7 @@ var _AurumCore = class _AurumCore {
2137
864
  /* BRAND & THEME METHODS */
2138
865
  resolveBrandConfig(config) {
2139
866
  const { brand = {} } = config || {};
2140
- const themeConfig = _chunkK64T6WW3js.getDefaultThemeConfig.call(void 0, brand.theme || _chunkK64T6WW3js.DEFAULT_THEME);
867
+ const themeConfig = _chunk4XQZ5JBSjs.getDefaultThemeConfig.call(void 0, brand.theme || _chunk4XQZ5JBSjs.DEFAULT_THEME);
2141
868
  return {
2142
869
  logo: _nullishCoalesce(brand.logo, () => ( themeConfig.logo)),
2143
870
  theme: _nullishCoalesce(brand.theme, () => ( themeConfig.theme)),
@@ -2156,16 +883,17 @@ var _AurumCore = class _AurumCore {
2156
883
  return;
2157
884
  }
2158
885
  try {
2159
- await _chunkK64T6WW3js.waitForStoreHydration.call(void 0, );
2160
- const store = _chunkK64T6WW3js.useAurumStore.getState();
886
+ await _chunk4XQZ5JBSjs.waitForStoreHydration.call(void 0, );
887
+ const store = _chunk4XQZ5JBSjs.useAurumStore.getState();
2161
888
  if (!store.isConnected || !store.walletId || !store.address || !store.walletName) {
2162
889
  return;
2163
890
  }
2164
- const persistedAdapter = this.wallets.find((w) => w.id === store.walletId) || null;
2165
- if (!persistedAdapter || !persistedAdapter.isInstalled()) {
891
+ const manifest = this.walletManifests.find((m) => m.id === store.walletId);
892
+ if (!manifest || !manifest.isInstalled()) {
2166
893
  store.clearConnection();
2167
894
  return;
2168
895
  }
896
+ const persistedAdapter = await _chunk4XQZ5JBSjs.loadAdapter.call(void 0, manifest);
2169
897
  const connectionResult = await persistedAdapter.tryRestoreConnection();
2170
898
  if (!connectionResult || connectionResult.address.toLowerCase() !== store.address.toLowerCase()) {
2171
899
  store.clearConnection();
@@ -2180,14 +908,14 @@ var _AurumCore = class _AurumCore {
2180
908
  email: _nullishCoalesce(store.email, () => ( void 0))
2181
909
  };
2182
910
  this.setInternalAccountChangeListener(persistedAdapter);
2183
- } catch (e16) {
911
+ } catch (e3) {
2184
912
  this.resetConnectionState();
2185
913
  } finally {
2186
914
  this.ready = true;
2187
915
  }
2188
916
  }
2189
917
  persistConnectionState(adapter, address, email) {
2190
- _chunkK64T6WW3js.useAurumStore.getState().setConnection(adapter.id, _viem.checksumAddress.call(void 0, address), adapter.name, email);
918
+ _chunk4XQZ5JBSjs.useAurumStore.getState().setConnection(adapter.id, _viem.checksumAddress.call(void 0, address), adapter.name, email);
2191
919
  }
2192
920
  /* INTERNAL LISTENER METHODS */
2193
921
  setInternalAccountChangeListener(adapter) {
@@ -2201,14 +929,14 @@ var _AurumCore = class _AurumCore {
2201
929
  }
2202
930
  async syncStateFromAccountsChanged(accounts) {
2203
931
  if (!accounts.length || !accounts[0]) return;
2204
- const prevAccount = _optionalChain([this, 'access', _179 => _179.userInfo, 'optionalAccess', _180 => _180.publicAddress]);
932
+ const prevAccount = _optionalChain([this, 'access', _72 => _72.userInfo, 'optionalAccess', _73 => _73.publicAddress]);
2205
933
  const newAccount = _viem.checksumAddress.call(void 0, accounts[0]);
2206
934
  if (newAccount !== prevAccount) {
2207
935
  this.userInfo = {
2208
936
  publicAddress: newAccount,
2209
- walletName: _optionalChain([this, 'access', _181 => _181.userInfo, 'optionalAccess', _182 => _182.walletName]),
2210
- walletId: _optionalChain([this, 'access', _183 => _183.userInfo, 'optionalAccess', _184 => _184.walletId]),
2211
- email: _optionalChain([this, 'access', _185 => _185.userInfo, 'optionalAccess', _186 => _186.email])
937
+ walletName: _optionalChain([this, 'access', _74 => _74.userInfo, 'optionalAccess', _75 => _75.walletName]),
938
+ walletId: _optionalChain([this, 'access', _76 => _76.userInfo, 'optionalAccess', _77 => _77.walletId]),
939
+ email: _optionalChain([this, 'access', _78 => _78.userInfo, 'optionalAccess', _79 => _79.email])
2212
940
  };
2213
941
  if (this.connectedWalletAdapter) {
2214
942
  this.persistConnectionState(this.connectedWalletAdapter, newAccount, this.userInfo.email);
@@ -2267,8 +995,8 @@ var _AurumCore = class _AurumCore {
2267
995
  }
2268
996
  }
2269
997
  async addChain(chain) {
2270
- if (!_optionalChain([chain, 'optionalAccess', _187 => _187.id]) || !_optionalChain([chain, 'optionalAccess', _188 => _188.name]) || !_optionalChain([chain, 'optionalAccess', _189 => _189.nativeCurrency]) || !_optionalChain([chain, 'optionalAccess', _190 => _190.rpcUrls, 'optionalAccess', _191 => _191.default, 'optionalAccess', _192 => _192.http])) {
2271
- throw new InvalidConfigError("Invalid chain configuration: missing required properties");
998
+ if (!_optionalChain([chain, 'optionalAccess', _80 => _80.id]) || !_optionalChain([chain, 'optionalAccess', _81 => _81.name]) || !_optionalChain([chain, 'optionalAccess', _82 => _82.nativeCurrency]) || !_optionalChain([chain, 'optionalAccess', _83 => _83.rpcUrls, 'optionalAccess', _84 => _84.default, 'optionalAccess', _85 => _85.http])) {
999
+ throw new (0, _chunk4XQZ5JBSjs.InvalidConfigError)("Invalid chain configuration: missing required properties");
2272
1000
  }
2273
1001
  await this.rpcProvider.request({
2274
1002
  method: "wallet_addEthereumChain",
@@ -2285,7 +1013,7 @@ var _AurumCore = class _AurumCore {
2285
1013
  }
2286
1014
  /* REST */
2287
1015
  resetConnectionState() {
2288
- _chunkK64T6WW3js.useAurumStore.getState().clearConnection();
1016
+ _chunk4XQZ5JBSjs.useAurumStore.getState().clearConnection();
2289
1017
  this.connectedWalletAdapter = null;
2290
1018
  this.updateProvider(this.skeletonProvider);
2291
1019
  this.userInfo = void 0;
@@ -2377,7 +1105,9 @@ var Aurum = class {
2377
1105
  return this.core.resolvedBrandConfig;
2378
1106
  }
2379
1107
  /**
2380
- * Returns the wallet adapters configured for this instance.
1108
+ * Returns lightweight manifests for the wallets configured on this instance.
1109
+ * Each manifest exposes the metadata needed to render a wallet button (id, name,
1110
+ * icon, install state) plus a `load()` method that pulls in the heavy adapter.
2381
1111
  * @internal Used by widget components (i.e. ConnectWidget)
2382
1112
  */
2383
1113
  get walletAdapters() {
@@ -2618,5 +1348,6 @@ var Aurum = class {
2618
1348
 
2619
1349
 
2620
1350
 
2621
- exports.Aurum = Aurum; exports.AurumError = AurumError; exports.ChainNotSupportedError = ChainNotSupportedError; exports.ChainSwitchRejectedError = ChainSwitchRejectedError; exports.ConnectionError = ConnectionError; exports.InvalidConfigError = InvalidConfigError; exports.UserRejectedError = UserRejectedError; exports.WalletExcludedError = WalletExcludedError; exports.WalletNotConfiguredError = WalletNotConfiguredError; exports.WalletNotInstalledError = WalletNotInstalledError; exports.normalizeError = normalizeError;
1351
+
1352
+ exports.AdapterLoadError = _chunk4XQZ5JBSjs.AdapterLoadError; exports.Aurum = Aurum; exports.AurumError = _chunk4XQZ5JBSjs.AurumError; exports.ChainNotSupportedError = _chunk4XQZ5JBSjs.ChainNotSupportedError; exports.ChainSwitchRejectedError = _chunk4XQZ5JBSjs.ChainSwitchRejectedError; exports.ConnectionError = _chunk4XQZ5JBSjs.ConnectionError; exports.InvalidConfigError = _chunk4XQZ5JBSjs.InvalidConfigError; exports.UserRejectedError = _chunk4XQZ5JBSjs.UserRejectedError; exports.WalletExcludedError = _chunk4XQZ5JBSjs.WalletExcludedError; exports.WalletNotConfiguredError = _chunk4XQZ5JBSjs.WalletNotConfiguredError; exports.WalletNotInstalledError = _chunk4XQZ5JBSjs.WalletNotInstalledError; exports.normalizeError = _chunk4XQZ5JBSjs.normalizeError;
2622
1353
  //# sourceMappingURL=index.js.map