@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.
- package/dist/{Aurum-B0Okb4Qv.d.mts → Aurum-BoIhHFKm.d.mts} +25 -2
- package/dist/{Aurum-B0Okb4Qv.d.ts → Aurum-BoIhHFKm.d.ts} +25 -2
- package/dist/BraveAdapter-GTB4OCMH.mjs +153 -0
- package/dist/BraveAdapter-XGUK2CH7.js +153 -0
- package/dist/CoinbaseWalletAdapter-A6RMB5AG.mjs +144 -0
- package/dist/CoinbaseWalletAdapter-EV44SYND.js +144 -0
- package/dist/EmailAdapter-Q63KI6DV.js +212 -0
- package/dist/EmailAdapter-T5FVQLCY.mjs +212 -0
- package/dist/MetaMaskAdapter-KX7EJ73V.mjs +152 -0
- package/dist/MetaMaskAdapter-X5MUH2DT.js +152 -0
- package/dist/PhantomAdapter-C7PQCQHP.js +151 -0
- package/dist/PhantomAdapter-REAJL27H.mjs +151 -0
- package/dist/RabbyAdapter-4SEMVMND.mjs +146 -0
- package/dist/RabbyAdapter-QLBUCYWB.js +146 -0
- package/dist/WalletConnectAdapter-J5J3ILFG.mjs +540 -0
- package/dist/WalletConnectAdapter-NKQZY25A.js +540 -0
- package/dist/chunk-4S5E6KOY.mjs +21 -0
- package/dist/{chunk-K64T6WW3.js → chunk-4XQZ5JBS.js} +420 -6850
- package/dist/{chunk-GMFEFDGS.mjs → chunk-7WLUHQA3.mjs} +348 -6778
- package/dist/chunk-ALDVMRQG.js +6558 -0
- package/dist/chunk-D7M3K26I.mjs +6558 -0
- package/dist/chunk-PFK6YHOX.mjs +15 -0
- package/dist/chunk-QOCN4F47.js +21 -0
- package/dist/chunk-XVRTCAR4.js +15 -0
- package/dist/index.d.mts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +304 -1573
- package/dist/index.mjs +243 -1512
- package/dist/{index.web-Q2L3EMC3.mjs → index.web-NX7JZBIY.mjs} +267 -267
- package/dist/{index.web-V7DLWC7H.js → index.web-OPNRZHYZ.js} +267 -267
- package/dist/widgets.d.mts +1 -1
- package/dist/widgets.d.ts +1 -1
- package/dist/widgets.js +14 -12
- package/dist/widgets.mjs +3 -1
- package/package.json +3 -7
package/dist/index.mjs
CHANGED
|
@@ -1,23 +1,41 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AdapterLoadError,
|
|
3
|
+
AurumError,
|
|
4
|
+
ChainNotSupportedError,
|
|
5
|
+
ChainSwitchRejectedError,
|
|
2
6
|
ConnectPages,
|
|
3
7
|
ConnectUIProviders,
|
|
8
|
+
ConnectionError,
|
|
4
9
|
DEFAULT_THEME,
|
|
10
|
+
InvalidConfigError,
|
|
5
11
|
Modal,
|
|
6
12
|
ThemeContainer,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
13
|
+
UserRejectedError,
|
|
14
|
+
WalletExcludedError,
|
|
15
|
+
WalletNotConfiguredError,
|
|
16
|
+
WalletNotInstalledError,
|
|
10
17
|
generateCompleteStyles,
|
|
11
18
|
getDefaultThemeConfig,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
19
|
+
loadAdapter,
|
|
20
|
+
normalizeError,
|
|
21
|
+
peekAdapter,
|
|
15
22
|
sortWallets,
|
|
16
23
|
useAurumStore,
|
|
17
24
|
useNavigation,
|
|
18
25
|
waitForStoreHydration
|
|
19
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-7WLUHQA3.mjs";
|
|
20
27
|
import "./chunk-DRID67T7.mjs";
|
|
28
|
+
import "./chunk-4S5E6KOY.mjs";
|
|
29
|
+
import {
|
|
30
|
+
isBraveBrowser
|
|
31
|
+
} from "./chunk-PFK6YHOX.mjs";
|
|
32
|
+
import {
|
|
33
|
+
WalletId,
|
|
34
|
+
WalletName,
|
|
35
|
+
getLogoDataUri,
|
|
36
|
+
initSentry,
|
|
37
|
+
sentryLogger
|
|
38
|
+
} from "./chunk-D7M3K26I.mjs";
|
|
21
39
|
import {
|
|
22
40
|
init_polyfills
|
|
23
41
|
} from "./chunk-J6XFKNJN.mjs";
|
|
@@ -144,1421 +162,185 @@ function renderConnectModal({
|
|
|
144
162
|
});
|
|
145
163
|
}
|
|
146
164
|
|
|
147
|
-
// src/utils/
|
|
165
|
+
// src/utils/createWalletManifests.ts
|
|
148
166
|
init_polyfills();
|
|
149
167
|
|
|
150
|
-
// src/
|
|
168
|
+
// src/utils/eip6963Registry.ts
|
|
151
169
|
init_polyfills();
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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 (ethereum?.isRabby) {
|
|
207
|
-
return ethereum;
|
|
208
|
-
}
|
|
209
|
-
return null;
|
|
210
|
-
}
|
|
211
|
-
isInstalled() {
|
|
212
|
-
return Boolean(this.provider ?? this.detectLegacyProvider());
|
|
213
|
-
}
|
|
214
|
-
async connect() {
|
|
215
|
-
if (!this.provider && this.providerPromise) {
|
|
216
|
-
await this.providerPromise;
|
|
217
|
-
}
|
|
218
|
-
if (!this.provider) {
|
|
219
|
-
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
|
-
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;
|
|
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 (detail?.info?.rdns) {
|
|
178
|
+
announced.set(detail.info.rdns, detail.provider);
|
|
243
179
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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 {
|
|
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 (!this.provider?.on) return;
|
|
273
|
-
if (this.accountsChangedCallback) {
|
|
274
|
-
this.provider.removeListener?.("accountsChanged", this.accountsChangedCallback);
|
|
275
|
-
}
|
|
276
|
-
this.accountsChangedCallback = callback;
|
|
277
|
-
this.provider.on("accountsChanged", this.accountsChangedCallback);
|
|
278
|
-
}
|
|
279
|
-
removeListeners() {
|
|
280
|
-
if (!this.provider?.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
|
-
init_polyfills();
|
|
288
|
-
|
|
289
|
-
// src/utils/platform/isBraveBrowser.ts
|
|
290
|
-
init_polyfills();
|
|
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/
|
|
297
|
-
var BRAVE_RDNS = "com.brave.wallet";
|
|
298
|
-
var BraveAdapter = class {
|
|
299
|
-
constructor() {
|
|
300
|
-
this.id = WalletId.Brave;
|
|
301
|
-
this.name = WalletName.Brave;
|
|
302
|
-
this.icon = getLogoDataUri(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 (ethereum?.isBraveWallet) {
|
|
353
|
-
return ethereum;
|
|
354
|
-
}
|
|
355
|
-
return null;
|
|
356
|
-
}
|
|
357
|
-
isInstalled() {
|
|
358
|
-
return Boolean(this.provider ?? this.detectLegacyProvider());
|
|
359
|
-
}
|
|
360
|
-
async connect() {
|
|
361
|
-
if (!this.provider && this.providerPromise) {
|
|
362
|
-
await this.providerPromise;
|
|
363
|
-
}
|
|
364
|
-
if (!this.provider) {
|
|
365
|
-
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
|
-
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 {
|
|
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 (!this.provider?.on) return;
|
|
419
|
-
if (this.accountsChangedCallback) {
|
|
420
|
-
this.provider.removeListener?.("accountsChanged", this.accountsChangedCallback);
|
|
421
|
-
}
|
|
422
|
-
this.accountsChangedCallback = callback;
|
|
423
|
-
this.provider.on("accountsChanged", this.accountsChangedCallback);
|
|
424
|
-
}
|
|
425
|
-
removeListeners() {
|
|
426
|
-
if (!this.provider?.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
|
-
init_polyfills();
|
|
434
|
-
var PHANTOM_RDNS = "app.phantom";
|
|
435
|
-
var PhantomAdapter = class {
|
|
436
|
-
constructor() {
|
|
437
|
-
this.id = WalletId.Phantom;
|
|
438
|
-
this.name = WalletName.Phantom;
|
|
439
|
-
this.icon = getLogoDataUri(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 (phantom?.ethereum?.isPhantom) {
|
|
487
|
-
return phantom.ethereum;
|
|
488
|
-
}
|
|
489
|
-
const ethereum = window.ethereum;
|
|
490
|
-
if (ethereum?.isPhantom) {
|
|
491
|
-
return ethereum;
|
|
492
|
-
}
|
|
493
|
-
return null;
|
|
494
|
-
}
|
|
495
|
-
isInstalled() {
|
|
496
|
-
return Boolean(this.provider ?? this.detectLegacyProvider());
|
|
497
|
-
}
|
|
498
|
-
async connect() {
|
|
499
|
-
if (!this.provider && this.providerPromise) {
|
|
500
|
-
await this.providerPromise;
|
|
501
|
-
}
|
|
502
|
-
if (!this.provider) {
|
|
503
|
-
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
|
-
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 {
|
|
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 (!this.provider?.on) return;
|
|
557
|
-
if (this.accountsChangedCallback) {
|
|
558
|
-
this.provider.removeListener?.("accountsChanged", this.accountsChangedCallback);
|
|
559
|
-
}
|
|
560
|
-
this.accountsChangedCallback = callback;
|
|
561
|
-
this.provider.on("accountsChanged", this.accountsChangedCallback);
|
|
562
|
-
}
|
|
563
|
-
removeListeners() {
|
|
564
|
-
if (!this.provider?.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
|
-
init_polyfills();
|
|
572
|
-
var CoinbaseWalletAdapter = class {
|
|
573
|
-
constructor({ appName, appLogoUrl, telemetry }) {
|
|
574
|
-
this.id = WalletId.CoinbaseWallet;
|
|
575
|
-
this.name = WalletName.CoinbaseWallet;
|
|
576
|
-
this.icon = getLogoDataUri(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: 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 import("./dist-YBFFGXT3.mjs");
|
|
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
|
-
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
|
-
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
|
-
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 {
|
|
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
|
-
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 (!this.provider?.on) return;
|
|
688
|
-
if (this.accountsChangedCallback) {
|
|
689
|
-
this.provider.removeListener?.("accountsChanged", this.accountsChangedCallback);
|
|
690
|
-
}
|
|
691
|
-
this.accountsChangedCallback = callback;
|
|
692
|
-
this.provider.on("accountsChanged", this.accountsChangedCallback);
|
|
693
|
-
}
|
|
694
|
-
removeListeners() {
|
|
695
|
-
if (!this.provider?.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
|
init_polyfills();
|
|
703
189
|
var METAMASK_RDNS = "io.metamask";
|
|
704
|
-
var
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
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 (ethereum.providers?.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(this.provider ?? this.detectLegacyProvider());
|
|
767
|
-
}
|
|
768
|
-
async connect() {
|
|
769
|
-
if (!this.provider && this.providerPromise) {
|
|
770
|
-
await this.providerPromise;
|
|
771
|
-
}
|
|
772
|
-
if (!this.provider) {
|
|
773
|
-
sentryLogger.error("MetaMask is not available");
|
|
774
|
-
throw new Error("MetaMask is not available");
|
|
775
|
-
}
|
|
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
|
-
sentryLogger.error("No accounts returned from MetaMask");
|
|
786
|
-
throw new Error("No accounts returned from MetaMask");
|
|
787
|
-
}
|
|
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;
|
|
797
|
-
}
|
|
798
|
-
if (!this.provider) {
|
|
799
|
-
return null;
|
|
800
|
-
}
|
|
801
|
-
try {
|
|
802
|
-
const accounts = await this.provider.request({
|
|
803
|
-
method: "eth_accounts",
|
|
804
|
-
params: []
|
|
805
|
-
});
|
|
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 {
|
|
815
|
-
return null;
|
|
816
|
-
}
|
|
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 (!this.provider?.on) return;
|
|
827
|
-
if (this.accountsChangedCallback) {
|
|
828
|
-
this.provider.removeListener?.("accountsChanged", this.accountsChangedCallback);
|
|
829
|
-
}
|
|
830
|
-
this.accountsChangedCallback = callback;
|
|
831
|
-
this.provider.on("accountsChanged", this.accountsChangedCallback);
|
|
832
|
-
}
|
|
833
|
-
removeListeners() {
|
|
834
|
-
if (!this.provider?.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
|
-
init_polyfills();
|
|
842
|
-
|
|
843
|
-
// src/constants/adapters.ts
|
|
844
|
-
init_polyfills();
|
|
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 = namespaces?.eip155?.accounts || [];
|
|
932
|
-
const firstAccount = accounts[0];
|
|
933
|
-
return firstAccount?.split(":")[2] ?? null;
|
|
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;
|
|
934
196
|
}
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
import("
|
|
970
|
-
|
|
971
|
-
import("@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: this.config.telemetry ?? false
|
|
996
|
-
}
|
|
997
|
-
});
|
|
998
|
-
this.universalProvider = await this.modal.getUniversalProvider() ?? 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();
|
|
1020
|
-
});
|
|
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 (!this.wagmiAdapter?.wagmiConfig) return;
|
|
1045
|
-
const { state } = this.wagmiAdapter.wagmiConfig;
|
|
1046
|
-
if (state.current && state.connections) {
|
|
1047
|
-
const connection = state.connections.get(state.current);
|
|
1048
|
-
if (connection?.accounts?.[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 = providers?.["eip155"];
|
|
1060
|
-
if (eip155Provider) {
|
|
1061
|
-
this.provider = eip155Provider;
|
|
1062
|
-
return;
|
|
1063
|
-
}
|
|
1064
|
-
}
|
|
1065
|
-
if (this.wagmiAdapter?.wagmiConfig) {
|
|
1066
|
-
const { state } = this.wagmiAdapter.wagmiConfig;
|
|
1067
|
-
if (state.current && state.connections) {
|
|
1068
|
-
const connection = state.connections.get(state.current);
|
|
1069
|
-
const connector = connection?.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
|
-
sentryLogger.warn("Failed to get provider from wagmi connector", { error });
|
|
1078
|
-
}
|
|
1079
|
-
}
|
|
1080
|
-
}
|
|
1081
|
-
}
|
|
1082
|
-
} catch (error) {
|
|
1083
|
-
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 } = this.wagmiAdapter?.wagmiConfig || {};
|
|
1100
|
-
const connection = state?.current && state.connections?.get(state.current);
|
|
1101
|
-
if (connection && typeof connection !== "string" && connection.connector?.disconnect) {
|
|
1102
|
-
await connection.connector.disconnect();
|
|
1103
|
-
}
|
|
1104
|
-
} catch {
|
|
1105
|
-
}
|
|
1106
|
-
if (this.modal?.getIsConnectedState()) {
|
|
1107
|
-
try {
|
|
1108
|
-
await this.modal.disconnect("eip155");
|
|
1109
|
-
} catch {
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
if (this.universalProvider?.session) {
|
|
1113
|
-
try {
|
|
1114
|
-
await this.universalProvider.disconnect();
|
|
1115
|
-
} catch {
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
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 createConfigError("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 createConfigError("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 = () => unsubscribe?.();
|
|
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 (accounts?.length) {
|
|
1210
|
-
resolved = true;
|
|
1211
|
-
cleanup();
|
|
1212
|
-
this.modal?.close();
|
|
1213
|
-
this.lastKnownAccounts = accounts;
|
|
1214
|
-
resolve({ address: this.address, provider: this.provider, walletId: this.id });
|
|
1215
|
-
return true;
|
|
1216
|
-
}
|
|
1217
|
-
} catch {
|
|
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
|
-
}
|
|
1228
|
-
});
|
|
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 = state?.current && state.connections?.get(state.current);
|
|
1248
|
-
if (!connection || typeof connection === "string") return null;
|
|
1249
|
-
const address = connection.accounts?.[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 {
|
|
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 && this.provider?.removeListener) {
|
|
1279
|
-
this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
|
|
1280
|
-
}
|
|
1281
|
-
if (this.sessionUpdateHandler && this.universalProvider?.removeListener) {
|
|
1282
|
-
this.universalProvider.removeListener("session_update", this.sessionUpdateHandler);
|
|
197
|
+
function detectMetaMask() {
|
|
198
|
+
if (getAnnouncedProvider(METAMASK_RDNS)) return true;
|
|
199
|
+
const eth = getWindowEthereum();
|
|
200
|
+
if (!eth) return false;
|
|
201
|
+
if (eth.providers?.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 (phantom?.ethereum?.isPhantom) return true;
|
|
211
|
+
return Boolean(getWindowEthereum()?.isPhantom);
|
|
212
|
+
}
|
|
213
|
+
function detectRabby() {
|
|
214
|
+
if (getAnnouncedProvider(RABBY_RDNS)) return true;
|
|
215
|
+
return Boolean(getWindowEthereum()?.isRabby);
|
|
216
|
+
}
|
|
217
|
+
function detectBrave() {
|
|
218
|
+
if (getAnnouncedProvider(BRAVE_RDNS)) return true;
|
|
219
|
+
return Boolean(getWindowEthereum()?.isBraveWallet);
|
|
220
|
+
}
|
|
221
|
+
function createMetaMaskManifest() {
|
|
222
|
+
return {
|
|
223
|
+
id: WalletId.MetaMask,
|
|
224
|
+
name: WalletName.MetaMask,
|
|
225
|
+
icon: getLogoDataUri(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 import("./MetaMaskAdapter-KX7EJ73V.mjs");
|
|
232
|
+
return new MetaMaskAdapter();
|
|
1283
233
|
}
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
function createPhantomManifest() {
|
|
237
|
+
return {
|
|
238
|
+
id: WalletId.Phantom,
|
|
239
|
+
name: WalletName.Phantom,
|
|
240
|
+
icon: getLogoDataUri(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 import("./PhantomAdapter-REAJL27H.mjs");
|
|
247
|
+
return new PhantomAdapter();
|
|
1292
248
|
}
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
function createRabbyManifest() {
|
|
252
|
+
return {
|
|
253
|
+
id: WalletId.Rabby,
|
|
254
|
+
name: WalletName.Rabby,
|
|
255
|
+
icon: getLogoDataUri(WalletId.Rabby, "brand") ?? "",
|
|
256
|
+
hide: false,
|
|
257
|
+
downloadUrl: "https://rabby.io",
|
|
258
|
+
wcDeepLinkUrl: null,
|
|
259
|
+
isInstalled: detectRabby,
|
|
260
|
+
load: async () => {
|
|
261
|
+
const { RabbyAdapter } = await import("./RabbyAdapter-4SEMVMND.mjs");
|
|
262
|
+
return new RabbyAdapter();
|
|
1303
263
|
}
|
|
1304
|
-
}
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
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);
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
function createBraveManifest() {
|
|
267
|
+
return {
|
|
268
|
+
id: WalletId.Brave,
|
|
269
|
+
name: WalletName.Brave,
|
|
270
|
+
icon: getLogoDataUri(WalletId.Brave, "brand") ?? "",
|
|
271
|
+
downloadUrl: "https://brave.com/download",
|
|
272
|
+
wcDeepLinkUrl: null,
|
|
273
|
+
isInstalled: detectBrave,
|
|
274
|
+
get hide() {
|
|
275
|
+
return !detectBrave() && !isBraveBrowser();
|
|
276
|
+
},
|
|
277
|
+
load: async () => {
|
|
278
|
+
const { BraveAdapter } = await import("./BraveAdapter-GTB4OCMH.mjs");
|
|
279
|
+
return new BraveAdapter();
|
|
1326
280
|
}
|
|
1327
|
-
}
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
function createCoinbaseWalletManifest(config) {
|
|
284
|
+
return {
|
|
285
|
+
id: WalletId.CoinbaseWallet,
|
|
286
|
+
name: WalletName.CoinbaseWallet,
|
|
287
|
+
icon: getLogoDataUri(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 import("./CoinbaseWalletAdapter-A6RMB5AG.mjs");
|
|
294
|
+
return new CoinbaseWalletAdapter({
|
|
295
|
+
appName: config.appName,
|
|
296
|
+
appLogoUrl: config.appLogoUrl,
|
|
297
|
+
telemetry: config.telemetry
|
|
1335
298
|
});
|
|
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() !== this.lastKnownAccounts[i]?.toLowerCase());
|
|
1342
|
-
}
|
|
1343
|
-
removeListeners() {
|
|
1344
|
-
if (this.accountsChangedCallback) {
|
|
1345
|
-
this.provider?.removeListener?.("accountsChanged", this.accountsChangedCallback);
|
|
1346
|
-
this.accountsChangedCallback = null;
|
|
1347
|
-
}
|
|
1348
|
-
if (this.chainChangedCallback) {
|
|
1349
|
-
this.provider?.removeListener?.("chainChanged", this.chainChangedCallback);
|
|
1350
|
-
this.chainChangedCallback = null;
|
|
1351
|
-
}
|
|
1352
|
-
if (this.sessionUpdateHandler) {
|
|
1353
|
-
this.universalProvider?.removeListener?.("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
|
-
};
|
|
1363
|
-
|
|
1364
|
-
// src/wallet-adapters/EmailAdapter.ts
|
|
1365
|
-
init_polyfills();
|
|
1366
|
-
var _EmailAdapter = class _EmailAdapter {
|
|
1367
|
-
constructor(config) {
|
|
1368
|
-
this.id = WalletId.Email;
|
|
1369
|
-
this.name = WalletName.Email;
|
|
1370
|
-
this.icon = getLogoDataUri(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 = config?.projectId || "";
|
|
1378
|
-
this.telemetry = config?.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 createConfigError("Email");
|
|
1393
|
-
}
|
|
1394
|
-
await this.ensureInitialized();
|
|
1395
|
-
if (!this.provider) {
|
|
1396
|
-
sentryLogger.error("Email is not available");
|
|
1397
|
-
throw new Error("Email is not available");
|
|
1398
|
-
}
|
|
1399
|
-
const { signInWithEmail } = await import("./index.web-Q2L3EMC3.mjs");
|
|
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
|
-
sentryLogger.error("Email provider not initialized");
|
|
1410
|
-
throw new Error("Email provider not initialized");
|
|
1411
299
|
}
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
function createWalletConnectManifest(config) {
|
|
303
|
+
return {
|
|
304
|
+
id: WalletId.WalletConnect,
|
|
305
|
+
name: WalletName.WalletConnect,
|
|
306
|
+
icon: getLogoDataUri(WalletId.WalletConnect, "brand") ?? "",
|
|
307
|
+
hide: false,
|
|
308
|
+
downloadUrl: null,
|
|
309
|
+
wcDeepLinkUrl: null,
|
|
310
|
+
isInstalled: () => true,
|
|
311
|
+
load: async () => {
|
|
312
|
+
const { WalletConnectAdapter } = await import("./WalletConnectAdapter-J5J3ILFG.mjs");
|
|
313
|
+
return new WalletConnectAdapter({
|
|
314
|
+
projectId: config.walletConnectProjectId,
|
|
315
|
+
appName: config.appName,
|
|
316
|
+
modalZIndex: config.modalZIndex,
|
|
317
|
+
theme: config.theme,
|
|
318
|
+
telemetry: config.telemetry
|
|
1428
319
|
});
|
|
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 {
|
|
1438
|
-
return null;
|
|
1439
|
-
}
|
|
1440
|
-
}
|
|
1441
|
-
async disconnect() {
|
|
1442
|
-
try {
|
|
1443
|
-
await this.ensureInitialized();
|
|
1444
|
-
const { signOut } = await import("./index.web-Q2L3EMC3.mjs");
|
|
1445
|
-
await signOut();
|
|
1446
|
-
} catch {
|
|
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([import("viem/chains"), import("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
320
|
}
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
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 import("./index.web-Q2L3EMC3.mjs");
|
|
1509
|
-
const wallet = createCDPEmbeddedWallet({
|
|
1510
|
-
chains: _EmailAdapter.viemChains,
|
|
1511
|
-
transports: _EmailAdapter.viemTransports
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
function createEmailManifest(config) {
|
|
324
|
+
return {
|
|
325
|
+
id: WalletId.Email,
|
|
326
|
+
name: WalletName.Email,
|
|
327
|
+
icon: getLogoDataUri(WalletId.Email, "brand") ?? "",
|
|
328
|
+
hide: true,
|
|
329
|
+
downloadUrl: null,
|
|
330
|
+
wcDeepLinkUrl: null,
|
|
331
|
+
isInstalled: () => true,
|
|
332
|
+
load: async () => {
|
|
333
|
+
const { EmailAdapter } = await import("./EmailAdapter-T5FVQLCY.mjs");
|
|
334
|
+
return new EmailAdapter({
|
|
335
|
+
projectId: config.embeddedProjectId,
|
|
336
|
+
telemetry: config.telemetry
|
|
1512
337
|
});
|
|
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(err?.message || "");
|
|
1522
|
-
const isUnsupported = msg.includes("not supported") || msg.includes("Unsupported") || err?.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 {
|
|
1529
|
-
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
|
-
sentryLogger.error("Failed to initialize Email provider", { error });
|
|
1545
|
-
return null;
|
|
1546
338
|
}
|
|
1547
|
-
}
|
|
1548
|
-
|
|
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;
|
|
339
|
+
};
|
|
340
|
+
}
|
|
1559
341
|
|
|
1560
|
-
// src/utils/
|
|
1561
|
-
function
|
|
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: walletsConfig?.embedded?.projectId,
|
|
359
|
+
walletConnectProjectId: walletsConfig?.walletConnect?.projectId
|
|
360
|
+
};
|
|
1569
361
|
return [
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
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
|
-
init_polyfills();
|
|
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 = err?.code;
|
|
1724
|
-
const rawMessage = err?.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 context?.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) {
|
|
@@ -1773,7 +484,7 @@ var _AurumCore = class _AurumCore {
|
|
|
1773
484
|
initSentry(telemetryEnabled);
|
|
1774
485
|
this.brandConfig = this.resolveBrandConfig(config);
|
|
1775
486
|
this.excludedWallets = new Set(config.wallets?.exclude ?? []);
|
|
1776
|
-
this.
|
|
487
|
+
this.walletManifests = createWalletManifests({
|
|
1777
488
|
walletsConfig: config.wallets,
|
|
1778
489
|
appName: this.brandConfig.appName,
|
|
1779
490
|
appLogoUrl: this.brandConfig.logo,
|
|
@@ -1806,7 +517,7 @@ var _AurumCore = class _AurumCore {
|
|
|
1806
517
|
return this.brandConfig;
|
|
1807
518
|
}
|
|
1808
519
|
get walletAdapters() {
|
|
1809
|
-
return this.
|
|
520
|
+
return this.walletManifests;
|
|
1810
521
|
}
|
|
1811
522
|
get excludedWalletIds() {
|
|
1812
523
|
return this.excludedWallets;
|
|
@@ -1823,36 +534,38 @@ var _AurumCore = class _AurumCore {
|
|
|
1823
534
|
}
|
|
1824
535
|
await this.disconnect();
|
|
1825
536
|
}
|
|
1826
|
-
let adapter
|
|
537
|
+
let adapter;
|
|
1827
538
|
let result;
|
|
1828
539
|
if (walletId) {
|
|
1829
540
|
if (this.excludedWallets.has(walletId)) {
|
|
1830
541
|
throw new WalletExcludedError(walletId);
|
|
1831
542
|
}
|
|
1832
|
-
|
|
1833
|
-
if (!
|
|
543
|
+
const manifest = this.walletManifests.find((m) => m.id === walletId);
|
|
544
|
+
if (!manifest) {
|
|
1834
545
|
throw new WalletNotConfiguredError(walletId);
|
|
1835
546
|
}
|
|
547
|
+
adapter = await loadAdapter(manifest);
|
|
1836
548
|
if (walletId === WalletId.WalletConnect && adapter.openModal) {
|
|
1837
549
|
result = await adapter.openModal();
|
|
1838
550
|
} else {
|
|
1839
|
-
if (!
|
|
551
|
+
if (!manifest.isInstalled()) {
|
|
1840
552
|
throw new WalletNotInstalledError(adapter.name);
|
|
1841
553
|
}
|
|
1842
554
|
result = await adapter.connect();
|
|
1843
555
|
}
|
|
1844
556
|
} else {
|
|
1845
|
-
const displayedWallets = this.
|
|
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
560
|
sentryLogger.error("Missing modal result");
|
|
1849
561
|
throw new ConnectionError("Missing modal result");
|
|
1850
562
|
}
|
|
1851
|
-
|
|
1852
|
-
if (!
|
|
563
|
+
const manifest = this.walletManifests.find((m) => m.id === modalResult.walletId);
|
|
564
|
+
if (!manifest) {
|
|
1853
565
|
sentryLogger.error(`Selected wallet adapter not found: ${modalResult.walletId}`);
|
|
1854
566
|
throw new ConnectionError("Selected wallet adapter not found");
|
|
1855
567
|
}
|
|
568
|
+
adapter = await loadAdapter(manifest);
|
|
1856
569
|
result = modalResult;
|
|
1857
570
|
}
|
|
1858
571
|
const provider = result.provider ?? adapter.getProvider();
|
|
@@ -1907,8 +620,9 @@ var _AurumCore = class _AurumCore {
|
|
|
1907
620
|
async handleWidgetConnection(result) {
|
|
1908
621
|
try {
|
|
1909
622
|
await this.whenReady();
|
|
1910
|
-
const
|
|
1911
|
-
if (!
|
|
623
|
+
const manifest = this.walletManifests.find((m) => m.id === result.walletId);
|
|
624
|
+
if (!manifest) throw new ConnectionError("Selected wallet adapter not found");
|
|
625
|
+
const adapter = await loadAdapter(manifest);
|
|
1912
626
|
const provider = result.provider ?? adapter.getProvider();
|
|
1913
627
|
if (!provider) {
|
|
1914
628
|
sentryLogger.error(`Error fetching provider on widget login: ${result?.walletId}`);
|
|
@@ -1967,8 +681,12 @@ var _AurumCore = class _AurumCore {
|
|
|
1967
681
|
walletLayout: "walletLayout" in newConfig ? newConfig.walletLayout ?? defaultTheme.walletLayout : this.brandConfig.walletLayout
|
|
1968
682
|
};
|
|
1969
683
|
if ("theme" in newConfig && this.brandConfig.theme) {
|
|
1970
|
-
const
|
|
1971
|
-
|
|
684
|
+
const wcPromise = peekAdapter(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,8 +702,12 @@ var _AurumCore = class _AurumCore {
|
|
|
1984
702
|
async emailAuthStart(email) {
|
|
1985
703
|
try {
|
|
1986
704
|
await this.whenReady();
|
|
1987
|
-
const
|
|
1988
|
-
if (!
|
|
705
|
+
const manifest = this.walletManifests.find((m) => m.id === WalletId.Email);
|
|
706
|
+
if (!manifest) {
|
|
707
|
+
throw new WalletNotConfiguredError("email");
|
|
708
|
+
}
|
|
709
|
+
const emailAdapter = await loadAdapter(manifest);
|
|
710
|
+
if (!emailAdapter.emailAuthStart) {
|
|
1989
711
|
throw new WalletNotConfiguredError("email");
|
|
1990
712
|
}
|
|
1991
713
|
const result = await emailAdapter.emailAuthStart(email);
|
|
@@ -2003,8 +725,12 @@ var _AurumCore = class _AurumCore {
|
|
|
2003
725
|
async emailAuthVerify(flowId, otp) {
|
|
2004
726
|
try {
|
|
2005
727
|
await this.whenReady();
|
|
2006
|
-
const
|
|
2007
|
-
if (!
|
|
728
|
+
const manifest = this.walletManifests.find((m) => m.id === WalletId.Email);
|
|
729
|
+
if (!manifest) {
|
|
730
|
+
throw new WalletNotConfiguredError("email");
|
|
731
|
+
}
|
|
732
|
+
const emailAdapter = await loadAdapter(manifest);
|
|
733
|
+
if (!emailAdapter.emailAuthVerify) {
|
|
2008
734
|
throw new WalletNotConfiguredError("email");
|
|
2009
735
|
}
|
|
2010
736
|
const verifyResult = await emailAdapter.emailAuthVerify(flowId, otp);
|
|
@@ -2046,10 +772,11 @@ var _AurumCore = class _AurumCore {
|
|
|
2046
772
|
async getWalletConnectSession() {
|
|
2047
773
|
try {
|
|
2048
774
|
await this.whenReady();
|
|
2049
|
-
const
|
|
2050
|
-
if (!
|
|
775
|
+
const manifest = this.walletManifests.find((m) => m.id === WalletId.WalletConnect);
|
|
776
|
+
if (!manifest) {
|
|
2051
777
|
throw new WalletNotConfiguredError("walletconnect");
|
|
2052
778
|
}
|
|
779
|
+
const wcAdapter = await loadAdapter(manifest);
|
|
2053
780
|
const session = await wcAdapter.startSession();
|
|
2054
781
|
return {
|
|
2055
782
|
uri: session.uri,
|
|
@@ -2161,11 +888,12 @@ var _AurumCore = class _AurumCore {
|
|
|
2161
888
|
if (!store.isConnected || !store.walletId || !store.address || !store.walletName) {
|
|
2162
889
|
return;
|
|
2163
890
|
}
|
|
2164
|
-
const
|
|
2165
|
-
if (!
|
|
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 loadAdapter(manifest);
|
|
2169
897
|
const connectionResult = await persistedAdapter.tryRestoreConnection();
|
|
2170
898
|
if (!connectionResult || connectionResult.address.toLowerCase() !== store.address.toLowerCase()) {
|
|
2171
899
|
store.clearConnection();
|
|
@@ -2377,7 +1105,9 @@ var Aurum = class {
|
|
|
2377
1105
|
return this.core.resolvedBrandConfig;
|
|
2378
1106
|
}
|
|
2379
1107
|
/**
|
|
2380
|
-
* Returns the
|
|
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() {
|
|
@@ -2607,6 +1337,7 @@ var Aurum = class {
|
|
|
2607
1337
|
}
|
|
2608
1338
|
};
|
|
2609
1339
|
export {
|
|
1340
|
+
AdapterLoadError,
|
|
2610
1341
|
Aurum,
|
|
2611
1342
|
AurumError,
|
|
2612
1343
|
ChainNotSupportedError,
|