@aurum-sdk/core 0.2.0 → 0.2.1
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/{chunk-NKWY4I4L.js → chunk-AFVK5GA5.js} +99 -553
- package/dist/chunk-AFVK5GA5.js.map +1 -0
- package/dist/{chunk-NRC534B3.mjs → chunk-BSMOPBPL.mjs} +83 -537
- package/dist/chunk-BSMOPBPL.mjs.map +1 -0
- package/dist/index.d.mts +4 -8
- package/dist/index.d.ts +4 -8
- package/dist/index.js +581 -145
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +504 -68
- package/dist/index.mjs.map +1 -1
- package/dist/widgets.d.mts +3 -0
- package/dist/widgets.d.ts +3 -0
- package/dist/widgets.js +14 -15
- package/dist/widgets.js.map +1 -1
- package/dist/widgets.mjs +2 -3
- package/dist/widgets.mjs.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-NKWY4I4L.js.map +0 -1
- package/dist/chunk-NRC534B3.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -14,9 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var _chunkNKWY4I4Ljs = require('./chunk-NKWY4I4L.js');
|
|
17
|
+
var _chunkAFVK5GA5js = require('./chunk-AFVK5GA5.js');
|
|
20
18
|
|
|
21
19
|
// src/AurumCore.ts
|
|
22
20
|
var _viem = require('viem');
|
|
@@ -48,20 +46,20 @@ var _react = require('react');
|
|
|
48
46
|
var _jsxruntime = require('react/jsx-runtime');
|
|
49
47
|
var ModalShell = ({ onClose, brandConfig }) => {
|
|
50
48
|
const [isOpen, setIsOpen] = _react.useState.call(void 0, true);
|
|
51
|
-
const { currentPage } =
|
|
49
|
+
const { currentPage } = _chunkAFVK5GA5js.useNavigation.call(void 0, );
|
|
52
50
|
const handleClose = () => {
|
|
53
51
|
setIsOpen(false);
|
|
54
52
|
onClose();
|
|
55
53
|
};
|
|
56
54
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
57
|
-
|
|
55
|
+
_chunkAFVK5GA5js.Modal,
|
|
58
56
|
{
|
|
59
57
|
isOpen,
|
|
60
58
|
closeOnOverlayClick: true,
|
|
61
59
|
onCloseComplete: handleClose,
|
|
62
60
|
brandConfig,
|
|
63
61
|
transitionKey: currentPage,
|
|
64
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
62
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkAFVK5GA5js.ConnectPages, {})
|
|
65
63
|
}
|
|
66
64
|
);
|
|
67
65
|
};
|
|
@@ -73,7 +71,7 @@ var _client = require('react-dom/client');
|
|
|
73
71
|
function createShadowRoot(container, brandConfig) {
|
|
74
72
|
const shadowRoot = container.attachShadow({ mode: "open" });
|
|
75
73
|
shadowRoot.innerHTML = `
|
|
76
|
-
<style>${
|
|
74
|
+
<style>${_chunkAFVK5GA5js.generateCompleteStyles.call(void 0, brandConfig)}</style>
|
|
77
75
|
<div class="aurum-modal-root"></div>
|
|
78
76
|
`;
|
|
79
77
|
return shadowRoot.querySelector(".aurum-modal-root");
|
|
@@ -111,9 +109,9 @@ function renderConnectModal({
|
|
|
111
109
|
brandConfig
|
|
112
110
|
}) {
|
|
113
111
|
return new Promise((resolve, reject) => {
|
|
114
|
-
let sortedWallets =
|
|
115
|
-
const hasAppKit = sortedWallets.some((w) => w
|
|
116
|
-
if (
|
|
112
|
+
let sortedWallets = _chunkAFVK5GA5js.sortWallets.call(void 0, displayedWallets, { filterHidden: false });
|
|
113
|
+
const hasAppKit = sortedWallets.some((w) => w.id === _types.WalletId.AppKit);
|
|
114
|
+
if (_chunkAFVK5GA5js.isMobile.call(void 0, ) && !hasAppKit) {
|
|
117
115
|
sortedWallets = sortedWallets.filter((w) => w.id !== _types.WalletId.WalletConnect);
|
|
118
116
|
}
|
|
119
117
|
const { root, cleanup } = createModalContainer(CONTAINER_ID, brandConfig);
|
|
@@ -126,14 +124,275 @@ function renderConnectModal({
|
|
|
126
124
|
reject(new Error("User rejected request"));
|
|
127
125
|
};
|
|
128
126
|
root.render(
|
|
129
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
127
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkAFVK5GA5js.ThemeContainer, { theme: brandConfig.theme, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkAFVK5GA5js.ConnectUIProviders, { onConnect, displayedWallets: sortedWallets, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ModalShell, { onClose, brandConfig }) }) })
|
|
130
128
|
);
|
|
131
129
|
});
|
|
132
130
|
}
|
|
133
131
|
|
|
134
|
-
// src/wallet-adapters/
|
|
132
|
+
// src/wallet-adapters/AppKitAdapter.ts
|
|
135
133
|
var _logos = require('@aurum-sdk/logos');
|
|
136
134
|
|
|
135
|
+
var AppKitAdapter = class {
|
|
136
|
+
constructor(config) {
|
|
137
|
+
this.id = _types.WalletId.AppKit;
|
|
138
|
+
this.name = _types.WalletName.AppKit;
|
|
139
|
+
this.icon = _nullishCoalesce(_logos.getLogoDataUri.call(void 0, _types.WalletId.AppKit, "brand"), () => ( ""));
|
|
140
|
+
this.hide = true;
|
|
141
|
+
this.downloadUrl = null;
|
|
142
|
+
this.wcDeepLinkUrl = null;
|
|
143
|
+
this.modal = null;
|
|
144
|
+
this.wagmiAdapter = null;
|
|
145
|
+
this.provider = null;
|
|
146
|
+
this.address = null;
|
|
147
|
+
this.accountsChangedCallback = null;
|
|
148
|
+
this.unsubscribeFunctions = [];
|
|
149
|
+
this.initPromise = null;
|
|
150
|
+
this.config = {
|
|
151
|
+
projectId: config.projectId,
|
|
152
|
+
appName: config.appName,
|
|
153
|
+
modalZIndex: config.modalZIndex,
|
|
154
|
+
theme: config.theme
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
async ensureInitialized() {
|
|
158
|
+
if (this.modal) return;
|
|
159
|
+
if (!this.initPromise) {
|
|
160
|
+
this.initPromise = this.initializeAppKit();
|
|
161
|
+
}
|
|
162
|
+
await this.initPromise;
|
|
163
|
+
}
|
|
164
|
+
async initializeAppKit() {
|
|
165
|
+
if (typeof window === "undefined") return;
|
|
166
|
+
const [{ createAppKit }, { WagmiAdapter }, { mainnet: mainnet2 }] = await Promise.all([
|
|
167
|
+
Promise.resolve().then(() => _interopRequireWildcard(require("@reown/appkit"))),
|
|
168
|
+
Promise.resolve().then(() => _interopRequireWildcard(require("@reown/appkit-adapter-wagmi"))),
|
|
169
|
+
Promise.resolve().then(() => _interopRequireWildcard(require("@reown/appkit/networks")))
|
|
170
|
+
]);
|
|
171
|
+
const networks = [mainnet2];
|
|
172
|
+
this.wagmiAdapter = new WagmiAdapter({
|
|
173
|
+
projectId: this.config.projectId,
|
|
174
|
+
networks,
|
|
175
|
+
ssr: true
|
|
176
|
+
});
|
|
177
|
+
this.modal = createAppKit({
|
|
178
|
+
adapters: [this.wagmiAdapter],
|
|
179
|
+
networks,
|
|
180
|
+
projectId: this.config.projectId,
|
|
181
|
+
metadata: {
|
|
182
|
+
name: this.config.appName,
|
|
183
|
+
description: this.config.appName,
|
|
184
|
+
url: window.location.origin,
|
|
185
|
+
icons: []
|
|
186
|
+
},
|
|
187
|
+
allowUnsupportedChain: true,
|
|
188
|
+
themeMode: this.config.theme,
|
|
189
|
+
themeVariables: {
|
|
190
|
+
"--apkt-z-index": this.config.modalZIndex + 1
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
this.setupEventListeners();
|
|
194
|
+
}
|
|
195
|
+
setupEventListeners() {
|
|
196
|
+
if (!this.modal) return;
|
|
197
|
+
const unsubscribeProviders = this.modal.subscribeProviders((state) => {
|
|
198
|
+
const eip155Provider = state["eip155"];
|
|
199
|
+
this.provider = eip155Provider || null;
|
|
200
|
+
if (!eip155Provider) {
|
|
201
|
+
this.address = null;
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
this.unsubscribeFunctions.push(unsubscribeProviders);
|
|
205
|
+
}
|
|
206
|
+
syncAddressFromWagmi() {
|
|
207
|
+
if (!_optionalChain([this, 'access', _21 => _21.wagmiAdapter, 'optionalAccess', _22 => _22.wagmiConfig])) return;
|
|
208
|
+
const { state } = this.wagmiAdapter.wagmiConfig;
|
|
209
|
+
if (state.current && state.connections) {
|
|
210
|
+
const connection = state.connections.get(state.current);
|
|
211
|
+
if (_optionalChain([connection, 'optionalAccess', _23 => _23.accounts, 'optionalAccess', _24 => _24[0]])) {
|
|
212
|
+
this.address = connection.accounts[0];
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
async syncProviderFromModal() {
|
|
217
|
+
if (!this.modal) return;
|
|
218
|
+
try {
|
|
219
|
+
const getProvidersFn = this.modal.getProviders;
|
|
220
|
+
if (typeof getProvidersFn === "function") {
|
|
221
|
+
const providers = getProvidersFn.call(this.modal);
|
|
222
|
+
const eip155Provider = _optionalChain([providers, 'optionalAccess', _25 => _25["eip155"]]);
|
|
223
|
+
if (eip155Provider) {
|
|
224
|
+
this.provider = eip155Provider;
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if (_optionalChain([this, 'access', _26 => _26.wagmiAdapter, 'optionalAccess', _27 => _27.wagmiConfig])) {
|
|
229
|
+
const { state } = this.wagmiAdapter.wagmiConfig;
|
|
230
|
+
if (state.current && state.connections) {
|
|
231
|
+
const connection = state.connections.get(state.current);
|
|
232
|
+
const connector = _optionalChain([connection, 'optionalAccess', _28 => _28.connector]);
|
|
233
|
+
if (connector && typeof connector.getProvider === "function") {
|
|
234
|
+
try {
|
|
235
|
+
const provider = await connector.getProvider();
|
|
236
|
+
if (provider) {
|
|
237
|
+
this.provider = provider;
|
|
238
|
+
}
|
|
239
|
+
} catch (error) {
|
|
240
|
+
_chunkAFVK5GA5js.sentryLogger.warn("Failed to get provider from wagmi connector", { error });
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
} catch (error) {
|
|
246
|
+
_chunkAFVK5GA5js.sentryLogger.warn("Failed to get provider from AppKit", { error });
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
isInstalled() {
|
|
250
|
+
return true;
|
|
251
|
+
}
|
|
252
|
+
async connect() {
|
|
253
|
+
if (!this.config.projectId) {
|
|
254
|
+
throw _chunkAFVK5GA5js.createConfigError.call(void 0, "AppKit");
|
|
255
|
+
}
|
|
256
|
+
await this.ensureInitialized();
|
|
257
|
+
if (!this.modal) {
|
|
258
|
+
_chunkAFVK5GA5js.sentryLogger.error("AppKit is not available");
|
|
259
|
+
throw new Error("AppKit is not available");
|
|
260
|
+
}
|
|
261
|
+
const existingAddress = this.modal.getAddress();
|
|
262
|
+
if (this.modal.getIsConnectedState() && existingAddress) {
|
|
263
|
+
await this.syncProviderFromModal();
|
|
264
|
+
if (this.provider) {
|
|
265
|
+
this.address = existingAddress;
|
|
266
|
+
return {
|
|
267
|
+
address: existingAddress,
|
|
268
|
+
provider: this.provider,
|
|
269
|
+
walletId: this.id
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
await this.disconnect();
|
|
273
|
+
}
|
|
274
|
+
this.modal.open({ view: "AllWallets" });
|
|
275
|
+
return await this.waitForConnection();
|
|
276
|
+
}
|
|
277
|
+
waitForConnection(timeout = 6e4) {
|
|
278
|
+
return new Promise((resolve, reject) => {
|
|
279
|
+
const startTime = Date.now();
|
|
280
|
+
let unsubscribeState = null;
|
|
281
|
+
let isResolved = false;
|
|
282
|
+
const cleanup = () => {
|
|
283
|
+
_optionalChain([unsubscribeState, 'optionalCall', _29 => _29()]);
|
|
284
|
+
};
|
|
285
|
+
const checkConnection = async () => {
|
|
286
|
+
if (isResolved) return true;
|
|
287
|
+
this.syncAddressFromWagmi();
|
|
288
|
+
if (this.address && !this.provider) {
|
|
289
|
+
await this.syncProviderFromModal();
|
|
290
|
+
}
|
|
291
|
+
if (this.provider && this.address) {
|
|
292
|
+
try {
|
|
293
|
+
const accounts = await this.provider.request({ method: "eth_accounts" });
|
|
294
|
+
if (accounts && accounts.length > 0) {
|
|
295
|
+
isResolved = true;
|
|
296
|
+
cleanup();
|
|
297
|
+
_optionalChain([this, 'access', _30 => _30.modal, 'optionalAccess', _31 => _31.close, 'call', _32 => _32()]);
|
|
298
|
+
resolve({
|
|
299
|
+
address: this.address,
|
|
300
|
+
provider: this.provider,
|
|
301
|
+
walletId: this.id
|
|
302
|
+
});
|
|
303
|
+
return true;
|
|
304
|
+
}
|
|
305
|
+
return false;
|
|
306
|
+
} catch (e) {
|
|
307
|
+
return false;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return false;
|
|
311
|
+
};
|
|
312
|
+
unsubscribeState = this.modal.subscribeState(async (state) => {
|
|
313
|
+
if (await checkConnection()) return;
|
|
314
|
+
if (state.open === false && !this.address && !isResolved) {
|
|
315
|
+
cleanup();
|
|
316
|
+
reject(new Error("Connection rejected by user"));
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
const pollTimeout = async () => {
|
|
320
|
+
if (await checkConnection()) return;
|
|
321
|
+
if (Date.now() - startTime > timeout) {
|
|
322
|
+
cleanup();
|
|
323
|
+
reject(new Error("Connection timeout"));
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
setTimeout(pollTimeout, 500);
|
|
327
|
+
};
|
|
328
|
+
pollTimeout();
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
async tryRestoreConnection() {
|
|
332
|
+
await this.ensureInitialized();
|
|
333
|
+
if (!this.modal || !this.wagmiAdapter) return null;
|
|
334
|
+
try {
|
|
335
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
336
|
+
const wagmiConfig = this.wagmiAdapter.wagmiConfig;
|
|
337
|
+
if (_optionalChain([wagmiConfig, 'optionalAccess', _33 => _33.state, 'optionalAccess', _34 => _34.current]) && wagmiConfig.state.connections) {
|
|
338
|
+
const connection = wagmiConfig.state.connections.get(wagmiConfig.state.current);
|
|
339
|
+
if (_optionalChain([connection, 'optionalAccess', _35 => _35.accounts, 'optionalAccess', _36 => _36[0]])) {
|
|
340
|
+
this.address = connection.accounts[0];
|
|
341
|
+
if (this.provider && this.address) {
|
|
342
|
+
return {
|
|
343
|
+
address: this.address,
|
|
344
|
+
provider: this.provider,
|
|
345
|
+
walletId: this.id
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return null;
|
|
351
|
+
} catch (e2) {
|
|
352
|
+
return null;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
async disconnect() {
|
|
356
|
+
if (!this.modal) {
|
|
357
|
+
this.address = null;
|
|
358
|
+
this.provider = null;
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
await this.modal.disconnect("eip155");
|
|
362
|
+
const timeout = Date.now() + 2e3;
|
|
363
|
+
while (Date.now() < timeout && (this.modal.getIsConnectedState() || this.modal.getAddress())) {
|
|
364
|
+
await new Promise((r) => setTimeout(r, 100));
|
|
365
|
+
}
|
|
366
|
+
this.address = null;
|
|
367
|
+
this.provider = null;
|
|
368
|
+
}
|
|
369
|
+
getProvider() {
|
|
370
|
+
return this.provider;
|
|
371
|
+
}
|
|
372
|
+
onAccountsChanged(callback) {
|
|
373
|
+
if (!_optionalChain([this, 'access', _37 => _37.provider, 'optionalAccess', _38 => _38.on])) return;
|
|
374
|
+
if (this.accountsChangedCallback) {
|
|
375
|
+
_optionalChain([this, 'access', _39 => _39.provider, 'access', _40 => _40.removeListener, 'optionalCall', _41 => _41("accountsChanged", this.accountsChangedCallback)]);
|
|
376
|
+
}
|
|
377
|
+
this.accountsChangedCallback = (accounts) => {
|
|
378
|
+
this.address = accounts[0] || null;
|
|
379
|
+
callback(accounts);
|
|
380
|
+
};
|
|
381
|
+
this.provider.on("accountsChanged", this.accountsChangedCallback);
|
|
382
|
+
}
|
|
383
|
+
removeListeners() {
|
|
384
|
+
if (_optionalChain([this, 'access', _42 => _42.provider, 'optionalAccess', _43 => _43.removeListener]) && this.accountsChangedCallback) {
|
|
385
|
+
this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
|
|
386
|
+
this.accountsChangedCallback = null;
|
|
387
|
+
}
|
|
388
|
+
this.unsubscribeFunctions.forEach((unsub) => unsub());
|
|
389
|
+
this.unsubscribeFunctions = [];
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
// src/wallet-adapters/RabbyAdapter.ts
|
|
394
|
+
|
|
395
|
+
|
|
137
396
|
var RABBY_RDNS = "io.rabby";
|
|
138
397
|
var RabbyAdapter = class {
|
|
139
398
|
constructor() {
|
|
@@ -185,7 +444,7 @@ var RabbyAdapter = class {
|
|
|
185
444
|
*/
|
|
186
445
|
detectLegacyProvider() {
|
|
187
446
|
const ethereum = window.ethereum;
|
|
188
|
-
if (_optionalChain([ethereum, 'optionalAccess',
|
|
447
|
+
if (_optionalChain([ethereum, 'optionalAccess', _44 => _44.isRabby])) {
|
|
189
448
|
return ethereum;
|
|
190
449
|
}
|
|
191
450
|
return null;
|
|
@@ -198,7 +457,7 @@ var RabbyAdapter = class {
|
|
|
198
457
|
await this.providerPromise;
|
|
199
458
|
}
|
|
200
459
|
if (!this.provider) {
|
|
201
|
-
|
|
460
|
+
_chunkAFVK5GA5js.sentryLogger.error("Rabby is not available");
|
|
202
461
|
throw new Error("Rabby is not available");
|
|
203
462
|
}
|
|
204
463
|
try {
|
|
@@ -211,7 +470,7 @@ var RabbyAdapter = class {
|
|
|
211
470
|
params: []
|
|
212
471
|
});
|
|
213
472
|
if (!accounts || accounts.length === 0 || !accounts[0]) {
|
|
214
|
-
|
|
473
|
+
_chunkAFVK5GA5js.sentryLogger.error("No accounts returned from Rabby");
|
|
215
474
|
throw new Error("No accounts returned from Rabby");
|
|
216
475
|
}
|
|
217
476
|
return {
|
|
@@ -219,7 +478,7 @@ var RabbyAdapter = class {
|
|
|
219
478
|
provider: this.provider,
|
|
220
479
|
walletId: this.id
|
|
221
480
|
};
|
|
222
|
-
} catch (
|
|
481
|
+
} catch (e3) {
|
|
223
482
|
throw new Error("Failed to connect to Rabby");
|
|
224
483
|
}
|
|
225
484
|
}
|
|
@@ -243,7 +502,7 @@ var RabbyAdapter = class {
|
|
|
243
502
|
provider: this.provider,
|
|
244
503
|
walletId: this.id
|
|
245
504
|
};
|
|
246
|
-
} catch (
|
|
505
|
+
} catch (e4) {
|
|
247
506
|
return null;
|
|
248
507
|
}
|
|
249
508
|
}
|
|
@@ -255,15 +514,15 @@ var RabbyAdapter = class {
|
|
|
255
514
|
// Called by Aurum when user connects wallet
|
|
256
515
|
// Passes Aurum.ts --> syncStateFromAccountsChanged() to handle the provider accounts changed event
|
|
257
516
|
onAccountsChanged(callback) {
|
|
258
|
-
if (!_optionalChain([this, 'access',
|
|
517
|
+
if (!_optionalChain([this, 'access', _45 => _45.provider, 'optionalAccess', _46 => _46.on])) return;
|
|
259
518
|
if (this.accountsChangedCallback) {
|
|
260
|
-
_optionalChain([this, 'access',
|
|
519
|
+
_optionalChain([this, 'access', _47 => _47.provider, 'access', _48 => _48.removeListener, 'optionalCall', _49 => _49("accountsChanged", this.accountsChangedCallback)]);
|
|
261
520
|
}
|
|
262
521
|
this.accountsChangedCallback = callback;
|
|
263
522
|
this.provider.on("accountsChanged", this.accountsChangedCallback);
|
|
264
523
|
}
|
|
265
524
|
removeListeners() {
|
|
266
|
-
if (!_optionalChain([this, 'access',
|
|
525
|
+
if (!_optionalChain([this, 'access', _50 => _50.provider, 'optionalAccess', _51 => _51.removeListener]) || !this.accountsChangedCallback) return;
|
|
267
526
|
this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
|
|
268
527
|
this.accountsChangedCallback = null;
|
|
269
528
|
}
|
|
@@ -335,7 +594,7 @@ var BraveAdapter = class {
|
|
|
335
594
|
*/
|
|
336
595
|
detectLegacyProvider() {
|
|
337
596
|
const ethereum = window.ethereum;
|
|
338
|
-
if (_optionalChain([ethereum, 'optionalAccess',
|
|
597
|
+
if (_optionalChain([ethereum, 'optionalAccess', _52 => _52.isBraveWallet])) {
|
|
339
598
|
return ethereum;
|
|
340
599
|
}
|
|
341
600
|
return null;
|
|
@@ -348,7 +607,7 @@ var BraveAdapter = class {
|
|
|
348
607
|
await this.providerPromise;
|
|
349
608
|
}
|
|
350
609
|
if (!this.provider) {
|
|
351
|
-
|
|
610
|
+
_chunkAFVK5GA5js.sentryLogger.error("Brave Wallet is not available");
|
|
352
611
|
throw new Error("Brave Wallet is not available");
|
|
353
612
|
}
|
|
354
613
|
try {
|
|
@@ -361,7 +620,7 @@ var BraveAdapter = class {
|
|
|
361
620
|
params: []
|
|
362
621
|
});
|
|
363
622
|
if (!accounts || accounts.length === 0 || !accounts[0]) {
|
|
364
|
-
|
|
623
|
+
_chunkAFVK5GA5js.sentryLogger.error("No accounts returned from Brave Wallet");
|
|
365
624
|
throw new Error("No accounts returned from Brave Wallet");
|
|
366
625
|
}
|
|
367
626
|
return {
|
|
@@ -369,7 +628,7 @@ var BraveAdapter = class {
|
|
|
369
628
|
provider: this.provider,
|
|
370
629
|
walletId: this.id
|
|
371
630
|
};
|
|
372
|
-
} catch (
|
|
631
|
+
} catch (e5) {
|
|
373
632
|
throw new Error("Failed to connect to Brave Wallet");
|
|
374
633
|
}
|
|
375
634
|
}
|
|
@@ -393,7 +652,7 @@ var BraveAdapter = class {
|
|
|
393
652
|
provider: this.provider,
|
|
394
653
|
walletId: this.id
|
|
395
654
|
};
|
|
396
|
-
} catch (
|
|
655
|
+
} catch (e6) {
|
|
397
656
|
return null;
|
|
398
657
|
}
|
|
399
658
|
}
|
|
@@ -405,15 +664,15 @@ var BraveAdapter = class {
|
|
|
405
664
|
// Called by Aurum when user connects wallet
|
|
406
665
|
// Passes Aurum.ts --> syncStateFromAccountsChanged() to handle the provider accounts changed event
|
|
407
666
|
onAccountsChanged(callback) {
|
|
408
|
-
if (!_optionalChain([this, 'access',
|
|
667
|
+
if (!_optionalChain([this, 'access', _53 => _53.provider, 'optionalAccess', _54 => _54.on])) return;
|
|
409
668
|
if (this.accountsChangedCallback) {
|
|
410
|
-
_optionalChain([this, 'access',
|
|
669
|
+
_optionalChain([this, 'access', _55 => _55.provider, 'access', _56 => _56.removeListener, 'optionalCall', _57 => _57("accountsChanged", this.accountsChangedCallback)]);
|
|
411
670
|
}
|
|
412
671
|
this.accountsChangedCallback = callback;
|
|
413
672
|
this.provider.on("accountsChanged", this.accountsChangedCallback);
|
|
414
673
|
}
|
|
415
674
|
removeListeners() {
|
|
416
|
-
if (!_optionalChain([this, 'access',
|
|
675
|
+
if (!_optionalChain([this, 'access', _58 => _58.provider, 'optionalAccess', _59 => _59.removeListener]) || !this.accountsChangedCallback) return;
|
|
417
676
|
this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
|
|
418
677
|
this.accountsChangedCallback = null;
|
|
419
678
|
}
|
|
@@ -434,7 +693,7 @@ var LedgerAdapter = class {
|
|
|
434
693
|
this.wcDeepLinkUrl = "ledgerlive://wc?uri=";
|
|
435
694
|
this.provider = null;
|
|
436
695
|
this.accountsChangedCallback = null;
|
|
437
|
-
this.walletConnectProjectId = _optionalChain([config, 'optionalAccess',
|
|
696
|
+
this.walletConnectProjectId = _optionalChain([config, 'optionalAccess', _60 => _60.walletConnectProjectId]);
|
|
438
697
|
}
|
|
439
698
|
isInstalled() {
|
|
440
699
|
return true;
|
|
@@ -442,7 +701,7 @@ var LedgerAdapter = class {
|
|
|
442
701
|
async connect() {
|
|
443
702
|
try {
|
|
444
703
|
if (!this.walletConnectProjectId) {
|
|
445
|
-
throw
|
|
704
|
+
throw _chunkAFVK5GA5js.createConfigError.call(void 0, "Ledger");
|
|
446
705
|
}
|
|
447
706
|
const { loadConnectKit } = await Promise.resolve().then(() => _interopRequireWildcard(require("@ledgerhq/connect-kit-loader")));
|
|
448
707
|
const connectKit = await loadConnectKit();
|
|
@@ -456,7 +715,7 @@ var LedgerAdapter = class {
|
|
|
456
715
|
});
|
|
457
716
|
this.provider = await connectKit.getProvider();
|
|
458
717
|
if (!this.provider) {
|
|
459
|
-
|
|
718
|
+
_chunkAFVK5GA5js.sentryLogger.error("Failed to get Ledger provider");
|
|
460
719
|
throw new Error("Failed to get Ledger provider");
|
|
461
720
|
}
|
|
462
721
|
const accounts = await this.provider.request({
|
|
@@ -464,7 +723,7 @@ var LedgerAdapter = class {
|
|
|
464
723
|
params: []
|
|
465
724
|
});
|
|
466
725
|
if (!accounts || accounts.length === 0 || !accounts[0]) {
|
|
467
|
-
|
|
726
|
+
_chunkAFVK5GA5js.sentryLogger.error("No accounts returned from Ledger");
|
|
468
727
|
throw new Error("No accounts returned from Ledger");
|
|
469
728
|
}
|
|
470
729
|
return {
|
|
@@ -472,7 +731,7 @@ var LedgerAdapter = class {
|
|
|
472
731
|
provider: this.provider,
|
|
473
732
|
walletId: this.id
|
|
474
733
|
};
|
|
475
|
-
} catch (
|
|
734
|
+
} catch (e7) {
|
|
476
735
|
throw new Error("Failed to connect to Ledger");
|
|
477
736
|
}
|
|
478
737
|
}
|
|
@@ -503,34 +762,34 @@ var LedgerAdapter = class {
|
|
|
503
762
|
provider: this.provider,
|
|
504
763
|
walletId: this.id
|
|
505
764
|
};
|
|
506
|
-
} catch (
|
|
765
|
+
} catch (e8) {
|
|
507
766
|
return null;
|
|
508
767
|
}
|
|
509
768
|
}
|
|
510
769
|
async disconnect() {
|
|
511
770
|
try {
|
|
512
771
|
const provider = this.provider;
|
|
513
|
-
if (_optionalChain([provider, 'optionalAccess',
|
|
772
|
+
if (_optionalChain([provider, 'optionalAccess', _61 => _61.disconnect])) {
|
|
514
773
|
await provider.disconnect();
|
|
515
774
|
}
|
|
516
775
|
this.provider = null;
|
|
517
776
|
} catch (error) {
|
|
518
|
-
|
|
777
|
+
_chunkAFVK5GA5js.sentryLogger.warn("Failed to disconnect from Ledger", { error });
|
|
519
778
|
}
|
|
520
779
|
}
|
|
521
780
|
getProvider() {
|
|
522
781
|
return this.provider;
|
|
523
782
|
}
|
|
524
783
|
onAccountsChanged(callback) {
|
|
525
|
-
if (!_optionalChain([this, 'access',
|
|
784
|
+
if (!_optionalChain([this, 'access', _62 => _62.provider, 'optionalAccess', _63 => _63.on])) return;
|
|
526
785
|
if (this.accountsChangedCallback) {
|
|
527
|
-
_optionalChain([this, 'access',
|
|
786
|
+
_optionalChain([this, 'access', _64 => _64.provider, 'access', _65 => _65.removeListener, 'optionalCall', _66 => _66("accountsChanged", this.accountsChangedCallback)]);
|
|
528
787
|
}
|
|
529
788
|
this.accountsChangedCallback = callback;
|
|
530
789
|
this.provider.on("accountsChanged", this.accountsChangedCallback);
|
|
531
790
|
}
|
|
532
791
|
removeListeners() {
|
|
533
|
-
if (!_optionalChain([this, 'access',
|
|
792
|
+
if (!_optionalChain([this, 'access', _67 => _67.provider, 'optionalAccess', _68 => _68.removeListener]) || !this.accountsChangedCallback) return;
|
|
534
793
|
this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
|
|
535
794
|
this.accountsChangedCallback = null;
|
|
536
795
|
}
|
|
@@ -591,11 +850,11 @@ var PhantomAdapter = class {
|
|
|
591
850
|
*/
|
|
592
851
|
detectLegacyProvider() {
|
|
593
852
|
const phantom = window.phantom;
|
|
594
|
-
if (_optionalChain([phantom, 'optionalAccess',
|
|
853
|
+
if (_optionalChain([phantom, 'optionalAccess', _69 => _69.ethereum, 'optionalAccess', _70 => _70.isPhantom])) {
|
|
595
854
|
return phantom.ethereum;
|
|
596
855
|
}
|
|
597
856
|
const ethereum = window.ethereum;
|
|
598
|
-
if (_optionalChain([ethereum, 'optionalAccess',
|
|
857
|
+
if (_optionalChain([ethereum, 'optionalAccess', _71 => _71.isPhantom])) {
|
|
599
858
|
return ethereum;
|
|
600
859
|
}
|
|
601
860
|
return null;
|
|
@@ -608,7 +867,7 @@ var PhantomAdapter = class {
|
|
|
608
867
|
await this.providerPromise;
|
|
609
868
|
}
|
|
610
869
|
if (!this.provider) {
|
|
611
|
-
|
|
870
|
+
_chunkAFVK5GA5js.sentryLogger.error("Phantom is not available");
|
|
612
871
|
throw new Error("Phantom is not available");
|
|
613
872
|
}
|
|
614
873
|
try {
|
|
@@ -621,7 +880,7 @@ var PhantomAdapter = class {
|
|
|
621
880
|
params: []
|
|
622
881
|
});
|
|
623
882
|
if (!accounts || accounts.length === 0 || !accounts[0]) {
|
|
624
|
-
|
|
883
|
+
_chunkAFVK5GA5js.sentryLogger.error("No accounts returned from Phantom");
|
|
625
884
|
throw new Error("No accounts returned from Phantom");
|
|
626
885
|
}
|
|
627
886
|
return {
|
|
@@ -629,7 +888,7 @@ var PhantomAdapter = class {
|
|
|
629
888
|
provider: this.provider,
|
|
630
889
|
walletId: this.id
|
|
631
890
|
};
|
|
632
|
-
} catch (
|
|
891
|
+
} catch (e9) {
|
|
633
892
|
throw new Error("Failed to connect to Phantom");
|
|
634
893
|
}
|
|
635
894
|
}
|
|
@@ -653,7 +912,7 @@ var PhantomAdapter = class {
|
|
|
653
912
|
provider: this.provider,
|
|
654
913
|
walletId: this.id
|
|
655
914
|
};
|
|
656
|
-
} catch (
|
|
915
|
+
} catch (e10) {
|
|
657
916
|
return null;
|
|
658
917
|
}
|
|
659
918
|
}
|
|
@@ -665,15 +924,15 @@ var PhantomAdapter = class {
|
|
|
665
924
|
// Called by Aurum when user connects wallet
|
|
666
925
|
// Passes Aurum.ts --> syncStateFromAccountsChanged() to handle the provider accounts changed event
|
|
667
926
|
onAccountsChanged(callback) {
|
|
668
|
-
if (!_optionalChain([this, 'access',
|
|
927
|
+
if (!_optionalChain([this, 'access', _72 => _72.provider, 'optionalAccess', _73 => _73.on])) return;
|
|
669
928
|
if (this.accountsChangedCallback) {
|
|
670
|
-
_optionalChain([this, 'access',
|
|
929
|
+
_optionalChain([this, 'access', _74 => _74.provider, 'access', _75 => _75.removeListener, 'optionalCall', _76 => _76("accountsChanged", this.accountsChangedCallback)]);
|
|
671
930
|
}
|
|
672
931
|
this.accountsChangedCallback = callback;
|
|
673
932
|
this.provider.on("accountsChanged", this.accountsChangedCallback);
|
|
674
933
|
}
|
|
675
934
|
removeListeners() {
|
|
676
|
-
if (!_optionalChain([this, 'access',
|
|
935
|
+
if (!_optionalChain([this, 'access', _77 => _77.provider, 'optionalAccess', _78 => _78.removeListener]) || !this.accountsChangedCallback) return;
|
|
677
936
|
this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
|
|
678
937
|
this.accountsChangedCallback = null;
|
|
679
938
|
}
|
|
@@ -704,7 +963,7 @@ var CoinbaseWalletAdapter = class {
|
|
|
704
963
|
});
|
|
705
964
|
return coinbaseSdk.getProvider();
|
|
706
965
|
} catch (error) {
|
|
707
|
-
|
|
966
|
+
_chunkAFVK5GA5js.sentryLogger.warn("Failed to initialize Coinbase Wallet provider", { error });
|
|
708
967
|
return null;
|
|
709
968
|
}
|
|
710
969
|
}
|
|
@@ -713,7 +972,7 @@ var CoinbaseWalletAdapter = class {
|
|
|
713
972
|
}
|
|
714
973
|
async connect() {
|
|
715
974
|
if (!this.isInstalled() || !this.provider) {
|
|
716
|
-
|
|
975
|
+
_chunkAFVK5GA5js.sentryLogger.error("Coinbase Wallet is not available");
|
|
717
976
|
throw new Error("Coinbase Wallet is not available");
|
|
718
977
|
}
|
|
719
978
|
try {
|
|
@@ -722,7 +981,7 @@ var CoinbaseWalletAdapter = class {
|
|
|
722
981
|
params: []
|
|
723
982
|
});
|
|
724
983
|
if (!accounts || accounts.length === 0 || !accounts[0]) {
|
|
725
|
-
|
|
984
|
+
_chunkAFVK5GA5js.sentryLogger.error("No accounts returned from Coinbase Wallet");
|
|
726
985
|
throw new Error("No accounts returned from Coinbase Wallet");
|
|
727
986
|
}
|
|
728
987
|
return {
|
|
@@ -730,7 +989,7 @@ var CoinbaseWalletAdapter = class {
|
|
|
730
989
|
provider: this.provider,
|
|
731
990
|
walletId: this.id
|
|
732
991
|
};
|
|
733
|
-
} catch (
|
|
992
|
+
} catch (e11) {
|
|
734
993
|
throw new Error("Failed to connect to Coinbase Wallet");
|
|
735
994
|
}
|
|
736
995
|
}
|
|
@@ -751,19 +1010,19 @@ var CoinbaseWalletAdapter = class {
|
|
|
751
1010
|
provider: this.provider,
|
|
752
1011
|
walletId: this.id
|
|
753
1012
|
};
|
|
754
|
-
} catch (
|
|
1013
|
+
} catch (e12) {
|
|
755
1014
|
return null;
|
|
756
1015
|
}
|
|
757
1016
|
}
|
|
758
1017
|
async disconnect() {
|
|
759
1018
|
try {
|
|
760
|
-
if (_optionalChain([this, 'access',
|
|
1019
|
+
if (_optionalChain([this, 'access', _79 => _79.provider, 'optionalAccess', _80 => _80.close])) {
|
|
761
1020
|
await this.provider.close();
|
|
762
|
-
} else if (_optionalChain([this, 'access',
|
|
1021
|
+
} else if (_optionalChain([this, 'access', _81 => _81.provider, 'optionalAccess', _82 => _82.disconnect])) {
|
|
763
1022
|
await this.provider.disconnect();
|
|
764
1023
|
}
|
|
765
1024
|
} catch (error) {
|
|
766
|
-
|
|
1025
|
+
_chunkAFVK5GA5js.sentryLogger.warn("Error disconnecting from Coinbase Wallet", { error });
|
|
767
1026
|
} finally {
|
|
768
1027
|
this.clearLocalStorage();
|
|
769
1028
|
}
|
|
@@ -787,15 +1046,15 @@ var CoinbaseWalletAdapter = class {
|
|
|
787
1046
|
// Called by Aurum when user connects wallet
|
|
788
1047
|
// Passes Aurum.ts --> syncStateFromAccountsChanged() to handle the provider accounts changed event
|
|
789
1048
|
onAccountsChanged(callback) {
|
|
790
|
-
if (!_optionalChain([this, 'access',
|
|
1049
|
+
if (!_optionalChain([this, 'access', _83 => _83.provider, 'optionalAccess', _84 => _84.on])) return;
|
|
791
1050
|
if (this.accountsChangedCallback) {
|
|
792
|
-
_optionalChain([this, 'access',
|
|
1051
|
+
_optionalChain([this, 'access', _85 => _85.provider, 'access', _86 => _86.removeListener, 'optionalCall', _87 => _87("accountsChanged", this.accountsChangedCallback)]);
|
|
793
1052
|
}
|
|
794
1053
|
this.accountsChangedCallback = callback;
|
|
795
1054
|
this.provider.on("accountsChanged", this.accountsChangedCallback);
|
|
796
1055
|
}
|
|
797
1056
|
removeListeners() {
|
|
798
|
-
if (!_optionalChain([this, 'access',
|
|
1057
|
+
if (!_optionalChain([this, 'access', _88 => _88.provider, 'optionalAccess', _89 => _89.removeListener]) || !this.accountsChangedCallback) return;
|
|
799
1058
|
this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
|
|
800
1059
|
this.accountsChangedCallback = null;
|
|
801
1060
|
}
|
|
@@ -857,7 +1116,7 @@ var MetaMaskAdapter = class {
|
|
|
857
1116
|
detectLegacyProvider() {
|
|
858
1117
|
const ethereum = window.ethereum;
|
|
859
1118
|
if (!ethereum) return null;
|
|
860
|
-
if (_optionalChain([ethereum, 'access',
|
|
1119
|
+
if (_optionalChain([ethereum, 'access', _90 => _90.providers, 'optionalAccess', _91 => _91.length])) {
|
|
861
1120
|
const metaMaskProvider = ethereum.providers.find((p) => p.isMetaMask && !p.isBraveWallet);
|
|
862
1121
|
if (metaMaskProvider) return metaMaskProvider;
|
|
863
1122
|
}
|
|
@@ -874,7 +1133,7 @@ var MetaMaskAdapter = class {
|
|
|
874
1133
|
await this.providerPromise;
|
|
875
1134
|
}
|
|
876
1135
|
if (!this.provider) {
|
|
877
|
-
|
|
1136
|
+
_chunkAFVK5GA5js.sentryLogger.error("MetaMask is not available");
|
|
878
1137
|
throw new Error("MetaMask is not available");
|
|
879
1138
|
}
|
|
880
1139
|
try {
|
|
@@ -887,7 +1146,7 @@ var MetaMaskAdapter = class {
|
|
|
887
1146
|
params: []
|
|
888
1147
|
});
|
|
889
1148
|
if (!accounts || accounts.length === 0 || !accounts[0]) {
|
|
890
|
-
|
|
1149
|
+
_chunkAFVK5GA5js.sentryLogger.error("No accounts returned from MetaMask");
|
|
891
1150
|
throw new Error("No accounts returned from MetaMask");
|
|
892
1151
|
}
|
|
893
1152
|
return {
|
|
@@ -895,7 +1154,7 @@ var MetaMaskAdapter = class {
|
|
|
895
1154
|
provider: this.provider,
|
|
896
1155
|
walletId: this.id
|
|
897
1156
|
};
|
|
898
|
-
} catch (
|
|
1157
|
+
} catch (e13) {
|
|
899
1158
|
throw new Error("Failed to connect to MetaMask");
|
|
900
1159
|
}
|
|
901
1160
|
}
|
|
@@ -919,11 +1178,202 @@ var MetaMaskAdapter = class {
|
|
|
919
1178
|
provider: this.provider,
|
|
920
1179
|
walletId: this.id
|
|
921
1180
|
};
|
|
922
|
-
} catch (
|
|
1181
|
+
} catch (e14) {
|
|
1182
|
+
return null;
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
async disconnect() {
|
|
1186
|
+
}
|
|
1187
|
+
getProvider() {
|
|
1188
|
+
return this.provider;
|
|
1189
|
+
}
|
|
1190
|
+
// Called by Aurum when user connects wallet
|
|
1191
|
+
// Passes Aurum.ts --> syncStateFromAccountsChanged() to handle the provider accounts changed event
|
|
1192
|
+
onAccountsChanged(callback) {
|
|
1193
|
+
if (!_optionalChain([this, 'access', _92 => _92.provider, 'optionalAccess', _93 => _93.on])) return;
|
|
1194
|
+
if (this.accountsChangedCallback) {
|
|
1195
|
+
_optionalChain([this, 'access', _94 => _94.provider, 'access', _95 => _95.removeListener, 'optionalCall', _96 => _96("accountsChanged", this.accountsChangedCallback)]);
|
|
1196
|
+
}
|
|
1197
|
+
this.accountsChangedCallback = callback;
|
|
1198
|
+
this.provider.on("accountsChanged", this.accountsChangedCallback);
|
|
1199
|
+
}
|
|
1200
|
+
removeListeners() {
|
|
1201
|
+
if (!_optionalChain([this, 'access', _97 => _97.provider, 'optionalAccess', _98 => _98.removeListener]) || !this.accountsChangedCallback) return;
|
|
1202
|
+
this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
|
|
1203
|
+
this.accountsChangedCallback = null;
|
|
1204
|
+
}
|
|
1205
|
+
};
|
|
1206
|
+
|
|
1207
|
+
// src/wallet-adapters/WalletConnectAdapter.ts
|
|
1208
|
+
|
|
1209
|
+
|
|
1210
|
+
var WalletConnectAdapter = class {
|
|
1211
|
+
constructor(config) {
|
|
1212
|
+
this.id = _types.WalletId.WalletConnect;
|
|
1213
|
+
this.name = _types.WalletName.WalletConnect;
|
|
1214
|
+
this.icon = _nullishCoalesce(_logos.getLogoDataUri.call(void 0, _types.WalletId.WalletConnect, "brand"), () => ( ""));
|
|
1215
|
+
this.hide = false;
|
|
1216
|
+
this.downloadUrl = null;
|
|
1217
|
+
this.wcDeepLinkUrl = null;
|
|
1218
|
+
this.provider = null;
|
|
1219
|
+
this.connectionUri = null;
|
|
1220
|
+
this.accountsChangedCallback = null;
|
|
1221
|
+
this.initPromise = null;
|
|
1222
|
+
this.config = {
|
|
1223
|
+
projectId: config.projectId,
|
|
1224
|
+
appName: config.appName
|
|
1225
|
+
};
|
|
1226
|
+
}
|
|
1227
|
+
async ensureInitialized() {
|
|
1228
|
+
if (this.provider) return;
|
|
1229
|
+
if (!this.initPromise) {
|
|
1230
|
+
this.initPromise = this.initializeProvider();
|
|
1231
|
+
}
|
|
1232
|
+
await this.initPromise;
|
|
1233
|
+
}
|
|
1234
|
+
async initializeProvider() {
|
|
1235
|
+
if (typeof window === "undefined") return;
|
|
1236
|
+
const { EthereumProvider } = await Promise.resolve().then(() => _interopRequireWildcard(require("@walletconnect/ethereum-provider")));
|
|
1237
|
+
this.provider = await EthereumProvider.init({
|
|
1238
|
+
projectId: _nullishCoalesce(this.config.projectId, () => ( "")),
|
|
1239
|
+
optionalChains: [1],
|
|
1240
|
+
showQrModal: false,
|
|
1241
|
+
metadata: {
|
|
1242
|
+
name: this.config.appName,
|
|
1243
|
+
description: this.config.appName,
|
|
1244
|
+
url: window.location.origin,
|
|
1245
|
+
icons: []
|
|
1246
|
+
}
|
|
1247
|
+
});
|
|
1248
|
+
this.provider.on("display_uri", (uri) => {
|
|
1249
|
+
this.connectionUri = uri;
|
|
1250
|
+
if (typeof window !== "undefined") {
|
|
1251
|
+
window.dispatchEvent(new CustomEvent("walletconnect:uri", { detail: { uri } }));
|
|
1252
|
+
}
|
|
1253
|
+
});
|
|
1254
|
+
this.provider.on("connect", (session) => {
|
|
1255
|
+
if (typeof window !== "undefined") {
|
|
1256
|
+
window.dispatchEvent(new CustomEvent("walletconnect:connect", { detail: { session } }));
|
|
1257
|
+
}
|
|
1258
|
+
});
|
|
1259
|
+
this.provider.on("disconnect", () => {
|
|
1260
|
+
this.connectionUri = null;
|
|
1261
|
+
});
|
|
1262
|
+
this.provider.on("session_delete", () => {
|
|
1263
|
+
if (typeof window !== "undefined") {
|
|
1264
|
+
window.dispatchEvent(new CustomEvent("walletconnect:disconnect"));
|
|
1265
|
+
}
|
|
1266
|
+
});
|
|
1267
|
+
}
|
|
1268
|
+
isInstalled() {
|
|
1269
|
+
return true;
|
|
1270
|
+
}
|
|
1271
|
+
async connect() {
|
|
1272
|
+
if (!this.config.projectId) {
|
|
1273
|
+
throw _chunkAFVK5GA5js.createConfigError.call(void 0, "WalletConnect");
|
|
1274
|
+
}
|
|
1275
|
+
try {
|
|
1276
|
+
await this.ensureInitialized();
|
|
1277
|
+
if (!this.provider) {
|
|
1278
|
+
_chunkAFVK5GA5js.sentryLogger.error("connect: WalletConnect is not available");
|
|
1279
|
+
throw new Error("WalletConnect is not available");
|
|
1280
|
+
}
|
|
1281
|
+
const accounts = await this.provider.enable();
|
|
1282
|
+
if (!accounts || accounts.length === 0 || !accounts[0]) {
|
|
1283
|
+
_chunkAFVK5GA5js.sentryLogger.error("connect: No accounts returned from WalletConnect");
|
|
1284
|
+
throw new Error("No accounts returned from WalletConnect");
|
|
1285
|
+
}
|
|
1286
|
+
return {
|
|
1287
|
+
address: accounts[0],
|
|
1288
|
+
provider: this.provider,
|
|
1289
|
+
walletId: this.id
|
|
1290
|
+
};
|
|
1291
|
+
} catch (e15) {
|
|
1292
|
+
this.connectionUri = null;
|
|
1293
|
+
throw new Error("Failed to connect to WalletConnect");
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
getConnectionUri() {
|
|
1297
|
+
return this.connectionUri;
|
|
1298
|
+
}
|
|
1299
|
+
/**
|
|
1300
|
+
* Starts a WalletConnect session for headless/custom QR code flows.
|
|
1301
|
+
* Returns the URI immediately and a function to wait for the connection.
|
|
1302
|
+
*/
|
|
1303
|
+
async startSession(timeout = 1e4) {
|
|
1304
|
+
if (!this.config.projectId) {
|
|
1305
|
+
throw new Error("WalletConnect projectId is required");
|
|
1306
|
+
}
|
|
1307
|
+
await this.ensureInitialized();
|
|
1308
|
+
if (!this.provider) {
|
|
1309
|
+
_chunkAFVK5GA5js.sentryLogger.error("startSession: WalletConnect is not available");
|
|
1310
|
+
throw new Error("WalletConnect is not available");
|
|
1311
|
+
}
|
|
1312
|
+
this.connectionUri = null;
|
|
1313
|
+
const uriPromise = new Promise((resolve, reject) => {
|
|
1314
|
+
const timeoutId = setTimeout(() => {
|
|
1315
|
+
reject(new Error("Timeout waiting for WalletConnect URI"));
|
|
1316
|
+
}, timeout);
|
|
1317
|
+
this.provider.once("display_uri", (uri2) => {
|
|
1318
|
+
clearTimeout(timeoutId);
|
|
1319
|
+
this.connectionUri = uri2;
|
|
1320
|
+
resolve(uri2);
|
|
1321
|
+
});
|
|
1322
|
+
});
|
|
1323
|
+
const connectionPromise = (async () => {
|
|
1324
|
+
const accounts = await this.provider.enable();
|
|
1325
|
+
if (!accounts || accounts.length === 0 || !accounts[0]) {
|
|
1326
|
+
_chunkAFVK5GA5js.sentryLogger.error("startSession: No accounts returned from WalletConnect");
|
|
1327
|
+
throw new Error("No accounts returned from WalletConnect");
|
|
1328
|
+
}
|
|
1329
|
+
return {
|
|
1330
|
+
address: accounts[0],
|
|
1331
|
+
provider: this.provider,
|
|
1332
|
+
walletId: this.id
|
|
1333
|
+
};
|
|
1334
|
+
})();
|
|
1335
|
+
const uri = await uriPromise;
|
|
1336
|
+
return {
|
|
1337
|
+
uri,
|
|
1338
|
+
waitForConnection: async () => {
|
|
1339
|
+
try {
|
|
1340
|
+
return await connectionPromise;
|
|
1341
|
+
} catch (e16) {
|
|
1342
|
+
this.connectionUri = null;
|
|
1343
|
+
throw new Error("Failed to connect via WalletConnect");
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
};
|
|
1347
|
+
}
|
|
1348
|
+
async tryRestoreConnection() {
|
|
1349
|
+
try {
|
|
1350
|
+
await this.ensureInitialized();
|
|
1351
|
+
if (!this.provider) {
|
|
1352
|
+
return null;
|
|
1353
|
+
}
|
|
1354
|
+
const accounts = this.provider.accounts;
|
|
1355
|
+
if (!accounts || accounts.length === 0 || !accounts[0]) {
|
|
1356
|
+
return null;
|
|
1357
|
+
}
|
|
1358
|
+
return {
|
|
1359
|
+
address: accounts[0],
|
|
1360
|
+
provider: this.provider,
|
|
1361
|
+
walletId: this.id
|
|
1362
|
+
};
|
|
1363
|
+
} catch (e17) {
|
|
923
1364
|
return null;
|
|
924
1365
|
}
|
|
925
1366
|
}
|
|
926
1367
|
async disconnect() {
|
|
1368
|
+
try {
|
|
1369
|
+
if (this.provider) {
|
|
1370
|
+
await this.provider.disconnect();
|
|
1371
|
+
}
|
|
1372
|
+
} finally {
|
|
1373
|
+
this.connectionUri = null;
|
|
1374
|
+
this.provider = null;
|
|
1375
|
+
this.initPromise = null;
|
|
1376
|
+
}
|
|
927
1377
|
}
|
|
928
1378
|
getProvider() {
|
|
929
1379
|
return this.provider;
|
|
@@ -931,15 +1381,15 @@ var MetaMaskAdapter = class {
|
|
|
931
1381
|
// Called by Aurum when user connects wallet
|
|
932
1382
|
// Passes Aurum.ts --> syncStateFromAccountsChanged() to handle the provider accounts changed event
|
|
933
1383
|
onAccountsChanged(callback) {
|
|
934
|
-
if (!_optionalChain([this, 'access',
|
|
1384
|
+
if (!_optionalChain([this, 'access', _99 => _99.provider, 'optionalAccess', _100 => _100.on])) return;
|
|
935
1385
|
if (this.accountsChangedCallback) {
|
|
936
|
-
_optionalChain([this, 'access',
|
|
1386
|
+
_optionalChain([this, 'access', _101 => _101.provider, 'access', _102 => _102.removeListener, 'optionalCall', _103 => _103("accountsChanged", this.accountsChangedCallback)]);
|
|
937
1387
|
}
|
|
938
1388
|
this.accountsChangedCallback = callback;
|
|
939
1389
|
this.provider.on("accountsChanged", this.accountsChangedCallback);
|
|
940
1390
|
}
|
|
941
1391
|
removeListeners() {
|
|
942
|
-
if (!_optionalChain([this, 'access',
|
|
1392
|
+
if (!_optionalChain([this, 'access', _104 => _104.provider, 'optionalAccess', _105 => _105.removeListener]) || !this.accountsChangedCallback) return;
|
|
943
1393
|
this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
|
|
944
1394
|
this.accountsChangedCallback = null;
|
|
945
1395
|
}
|
|
@@ -959,7 +1409,7 @@ var _EmailAdapter = class _EmailAdapter {
|
|
|
959
1409
|
this.provider = null;
|
|
960
1410
|
this.initPromise = null;
|
|
961
1411
|
this.publicClientCache = /* @__PURE__ */ new Map();
|
|
962
|
-
this.projectId = _optionalChain([config, 'optionalAccess',
|
|
1412
|
+
this.projectId = _optionalChain([config, 'optionalAccess', _106 => _106.projectId]) || "";
|
|
963
1413
|
}
|
|
964
1414
|
async ensureInitialized() {
|
|
965
1415
|
if (this.provider) return;
|
|
@@ -973,11 +1423,11 @@ var _EmailAdapter = class _EmailAdapter {
|
|
|
973
1423
|
}
|
|
974
1424
|
async emailAuthStart(email) {
|
|
975
1425
|
if (!this.projectId) {
|
|
976
|
-
throw
|
|
1426
|
+
throw _chunkAFVK5GA5js.createConfigError.call(void 0, "Email");
|
|
977
1427
|
}
|
|
978
1428
|
await this.ensureInitialized();
|
|
979
1429
|
if (!this.provider) {
|
|
980
|
-
|
|
1430
|
+
_chunkAFVK5GA5js.sentryLogger.error("Email is not available");
|
|
981
1431
|
throw new Error("Email is not available");
|
|
982
1432
|
}
|
|
983
1433
|
try {
|
|
@@ -985,7 +1435,7 @@ var _EmailAdapter = class _EmailAdapter {
|
|
|
985
1435
|
const authResult = await signInWithEmail({ email });
|
|
986
1436
|
return authResult;
|
|
987
1437
|
} catch (error) {
|
|
988
|
-
|
|
1438
|
+
_chunkAFVK5GA5js.sentryLogger.error("Failed to start email authentication", { error });
|
|
989
1439
|
throw error;
|
|
990
1440
|
}
|
|
991
1441
|
}
|
|
@@ -995,14 +1445,14 @@ var _EmailAdapter = class _EmailAdapter {
|
|
|
995
1445
|
}
|
|
996
1446
|
await this.ensureInitialized();
|
|
997
1447
|
if (!this.provider) {
|
|
998
|
-
|
|
1448
|
+
_chunkAFVK5GA5js.sentryLogger.error("Email provider not initialized");
|
|
999
1449
|
throw new Error("Email provider not initialized");
|
|
1000
1450
|
}
|
|
1001
1451
|
const { verifyEmailOTP } = await Promise.resolve().then(() => _interopRequireWildcard(require("@coinbase/cdp-core")));
|
|
1002
1452
|
return verifyEmailOTP({ flowId, otp });
|
|
1003
1453
|
}
|
|
1004
1454
|
async connect() {
|
|
1005
|
-
|
|
1455
|
+
_chunkAFVK5GA5js.sentryLogger.error("EmailAdapter.connect() is not implemented");
|
|
1006
1456
|
throw new Error("EmailAdapter.connect() is not implemented");
|
|
1007
1457
|
}
|
|
1008
1458
|
async tryRestoreConnection() {
|
|
@@ -1023,7 +1473,7 @@ var _EmailAdapter = class _EmailAdapter {
|
|
|
1023
1473
|
provider: this.provider,
|
|
1024
1474
|
walletId: this.id
|
|
1025
1475
|
};
|
|
1026
|
-
} catch (
|
|
1476
|
+
} catch (e18) {
|
|
1027
1477
|
return null;
|
|
1028
1478
|
}
|
|
1029
1479
|
}
|
|
@@ -1032,7 +1482,7 @@ var _EmailAdapter = class _EmailAdapter {
|
|
|
1032
1482
|
await this.ensureInitialized();
|
|
1033
1483
|
const { signOut } = await Promise.resolve().then(() => _interopRequireWildcard(require("@coinbase/cdp-core")));
|
|
1034
1484
|
await signOut();
|
|
1035
|
-
} catch (
|
|
1485
|
+
} catch (e19) {
|
|
1036
1486
|
}
|
|
1037
1487
|
}
|
|
1038
1488
|
getProvider() {
|
|
@@ -1106,15 +1556,15 @@ var _EmailAdapter = class _EmailAdapter {
|
|
|
1106
1556
|
try {
|
|
1107
1557
|
return await base.request(args);
|
|
1108
1558
|
} catch (err) {
|
|
1109
|
-
const msg = String(_optionalChain([err, 'optionalAccess',
|
|
1110
|
-
const isUnsupported = msg.includes("not supported") || msg.includes("Unsupported") || _optionalChain([err, 'optionalAccess',
|
|
1559
|
+
const msg = String(_optionalChain([err, 'optionalAccess', _107 => _107.message]) || "");
|
|
1560
|
+
const isUnsupported = msg.includes("not supported") || msg.includes("Unsupported") || _optionalChain([err, 'optionalAccess', _108 => _108.code]) === -32601;
|
|
1111
1561
|
if (isUnsupported) {
|
|
1112
1562
|
let chainId;
|
|
1113
1563
|
try {
|
|
1114
1564
|
const chainIdHex = await base.request({ method: "eth_chainId", params: [] });
|
|
1115
1565
|
chainId = parseInt(chainIdHex, 16);
|
|
1116
|
-
} catch (
|
|
1117
|
-
|
|
1566
|
+
} catch (e20) {
|
|
1567
|
+
_chunkAFVK5GA5js.sentryLogger.error("Failed to get chainId for fallback request");
|
|
1118
1568
|
throw new Error("Failed to get chainId for fallback request");
|
|
1119
1569
|
}
|
|
1120
1570
|
const publicClient = await getPublicClient(chainId);
|
|
@@ -1129,7 +1579,7 @@ var _EmailAdapter = class _EmailAdapter {
|
|
|
1129
1579
|
};
|
|
1130
1580
|
return wrapped;
|
|
1131
1581
|
} catch (error) {
|
|
1132
|
-
|
|
1582
|
+
_chunkAFVK5GA5js.sentryLogger.error("Failed to initialize Email provider", { error });
|
|
1133
1583
|
return null;
|
|
1134
1584
|
}
|
|
1135
1585
|
}
|
|
@@ -1154,15 +1604,15 @@ function createWalletAdapters({
|
|
|
1154
1604
|
theme
|
|
1155
1605
|
}) {
|
|
1156
1606
|
return [
|
|
1157
|
-
new EmailAdapter({ projectId: _optionalChain([walletsConfig, 'optionalAccess',
|
|
1607
|
+
new EmailAdapter({ projectId: _optionalChain([walletsConfig, 'optionalAccess', _109 => _109.embedded, 'optionalAccess', _110 => _110.projectId]) }),
|
|
1158
1608
|
new MetaMaskAdapter(),
|
|
1159
|
-
new
|
|
1609
|
+
new WalletConnectAdapter({ projectId: _optionalChain([walletsConfig, 'optionalAccess', _111 => _111.walletConnect, 'optionalAccess', _112 => _112.projectId]), appName }),
|
|
1160
1610
|
new CoinbaseWalletAdapter({ appName, appLogoUrl }),
|
|
1161
1611
|
new PhantomAdapter(),
|
|
1162
1612
|
new RabbyAdapter(),
|
|
1163
1613
|
new BraveAdapter(),
|
|
1164
|
-
new LedgerAdapter({ walletConnectProjectId: _optionalChain([walletsConfig, 'optionalAccess',
|
|
1165
|
-
new
|
|
1614
|
+
new LedgerAdapter({ walletConnectProjectId: _optionalChain([walletsConfig, 'optionalAccess', _113 => _113.walletConnect, 'optionalAccess', _114 => _114.projectId]) }),
|
|
1615
|
+
new AppKitAdapter({ projectId: _optionalChain([walletsConfig, 'optionalAccess', _115 => _115.walletConnect, 'optionalAccess', _116 => _116.projectId]), appName, modalZIndex, theme })
|
|
1166
1616
|
];
|
|
1167
1617
|
}
|
|
1168
1618
|
|
|
@@ -1229,9 +1679,9 @@ var _AurumCore = class _AurumCore {
|
|
|
1229
1679
|
return _AurumCore.instance;
|
|
1230
1680
|
}
|
|
1231
1681
|
const telemetryEnabled = config.telemetry !== false;
|
|
1232
|
-
|
|
1682
|
+
_chunkAFVK5GA5js.initSentry.call(void 0, telemetryEnabled);
|
|
1233
1683
|
this.brandConfig = this.resolveBrandConfig(config);
|
|
1234
|
-
this.excludedWallets = new Set(_nullishCoalesce(_optionalChain([config, 'access',
|
|
1684
|
+
this.excludedWallets = new Set(_nullishCoalesce(_optionalChain([config, 'access', _117 => _117.wallets, 'optionalAccess', _118 => _118.exclude]), () => ( [])));
|
|
1235
1685
|
this.wallets = createWalletAdapters({
|
|
1236
1686
|
walletsConfig: config.wallets,
|
|
1237
1687
|
appName: this.brandConfig.appName,
|
|
@@ -1248,7 +1698,7 @@ var _AurumCore = class _AurumCore {
|
|
|
1248
1698
|
async whenReady() {
|
|
1249
1699
|
try {
|
|
1250
1700
|
await this.readyPromise;
|
|
1251
|
-
} catch (
|
|
1701
|
+
} catch (e21) {
|
|
1252
1702
|
this.resetConnectionState();
|
|
1253
1703
|
this.ready = true;
|
|
1254
1704
|
}
|
|
@@ -1267,7 +1717,10 @@ var _AurumCore = class _AurumCore {
|
|
|
1267
1717
|
if (walletId === "email") {
|
|
1268
1718
|
throw new Error("Use emailAuthStart() and emailAuthVerify() for email wallet connections");
|
|
1269
1719
|
}
|
|
1270
|
-
if (
|
|
1720
|
+
if (walletId === "walletconnect") {
|
|
1721
|
+
throw new Error("Use getWalletConnectSession() for WalletConnect connections");
|
|
1722
|
+
}
|
|
1723
|
+
if (_optionalChain([this, 'access', _119 => _119.userInfo, 'optionalAccess', _120 => _120.publicAddress]) && _optionalChain([this, 'access', _121 => _121.connectedWalletAdapter, 'optionalAccess', _122 => _122.getProvider, 'call', _123 => _123()])) {
|
|
1271
1724
|
if (!walletId || this.userInfo.walletId === walletId) {
|
|
1272
1725
|
return this.userInfo.publicAddress;
|
|
1273
1726
|
}
|
|
@@ -1275,22 +1728,13 @@ var _AurumCore = class _AurumCore {
|
|
|
1275
1728
|
}
|
|
1276
1729
|
let adapter = null;
|
|
1277
1730
|
let result;
|
|
1278
|
-
if (walletId
|
|
1279
|
-
if (this.excludedWallets.has(walletId)) {
|
|
1280
|
-
throw new Error(`${walletId} is excluded from wallet options`);
|
|
1281
|
-
}
|
|
1282
|
-
adapter = this.wallets.find((w) => w instanceof _chunkNKWY4I4Ljs.AppKitAdapter) || null;
|
|
1283
|
-
if (!adapter) {
|
|
1284
|
-
throw new Error("WalletConnect is not enabled");
|
|
1285
|
-
}
|
|
1286
|
-
result = await adapter.connect();
|
|
1287
|
-
} else if (walletId) {
|
|
1731
|
+
if (walletId) {
|
|
1288
1732
|
if (this.excludedWallets.has(walletId)) {
|
|
1289
1733
|
throw new Error(`${walletId} is excluded from wallet options`);
|
|
1290
1734
|
}
|
|
1291
1735
|
adapter = this.wallets.find((w) => w.id === walletId) || null;
|
|
1292
1736
|
if (!adapter) {
|
|
1293
|
-
throw new Error(`${walletId} is not
|
|
1737
|
+
throw new Error(`${walletId} is not configured`);
|
|
1294
1738
|
}
|
|
1295
1739
|
if (!adapter.isInstalled()) {
|
|
1296
1740
|
throw new Error(`${adapter.name} is not installed`);
|
|
@@ -1300,19 +1744,19 @@ var _AurumCore = class _AurumCore {
|
|
|
1300
1744
|
const displayedWallets = this.wallets.filter((w) => !this.excludedWallets.has(w.id));
|
|
1301
1745
|
const modalResult = await renderConnectModal({ displayedWallets, brandConfig: this.brandConfig });
|
|
1302
1746
|
if (!modalResult) {
|
|
1303
|
-
|
|
1747
|
+
_chunkAFVK5GA5js.sentryLogger.error("Missing modal result");
|
|
1304
1748
|
throw new Error("Missing modal result");
|
|
1305
1749
|
}
|
|
1306
1750
|
adapter = this.wallets.find((w) => w.id === modalResult.walletId) || null;
|
|
1307
1751
|
if (!adapter) {
|
|
1308
|
-
|
|
1752
|
+
_chunkAFVK5GA5js.sentryLogger.error(`Selected wallet adapter not found: ${modalResult.walletId}`);
|
|
1309
1753
|
throw new Error("Selected wallet adapter not found");
|
|
1310
1754
|
}
|
|
1311
1755
|
result = modalResult;
|
|
1312
1756
|
}
|
|
1313
1757
|
const provider = _nullishCoalesce(result.provider, () => ( adapter.getProvider()));
|
|
1314
1758
|
if (!provider) {
|
|
1315
|
-
|
|
1759
|
+
_chunkAFVK5GA5js.sentryLogger.error(`Error fetching provider on login: ${adapter.id}`);
|
|
1316
1760
|
throw new Error("Error fetching provider. Please try again.");
|
|
1317
1761
|
}
|
|
1318
1762
|
const checksumAdr = _viem.checksumAddress.call(void 0, result.address);
|
|
@@ -1329,7 +1773,7 @@ var _AurumCore = class _AurumCore {
|
|
|
1329
1773
|
const chainId = await provider.request({ method: "eth_chainId" });
|
|
1330
1774
|
this.emitConnect(chainId);
|
|
1331
1775
|
this.emitAccountsChanged([checksumAdr]);
|
|
1332
|
-
|
|
1776
|
+
_chunkAFVK5GA5js.sentryLogger.info(`Wallet connected: ${adapter.id} (${walletId ? "headless" : "modal"})`);
|
|
1333
1777
|
return checksumAdr;
|
|
1334
1778
|
}
|
|
1335
1779
|
async disconnect() {
|
|
@@ -1349,7 +1793,7 @@ var _AurumCore = class _AurumCore {
|
|
|
1349
1793
|
async isConnected() {
|
|
1350
1794
|
await this.whenReady();
|
|
1351
1795
|
return Boolean(
|
|
1352
|
-
_optionalChain([this, 'access',
|
|
1796
|
+
_optionalChain([this, 'access', _124 => _124.userInfo, 'optionalAccess', _125 => _125.publicAddress]) && _optionalChain([this, 'access', _126 => _126.userInfo, 'optionalAccess', _127 => _127.walletName]) && _optionalChain([this, 'access', _128 => _128.connectedWalletAdapter, 'optionalAccess', _129 => _129.getProvider, 'call', _130 => _130()])
|
|
1353
1797
|
);
|
|
1354
1798
|
}
|
|
1355
1799
|
async handleWidgetConnection(result) {
|
|
@@ -1358,7 +1802,7 @@ var _AurumCore = class _AurumCore {
|
|
|
1358
1802
|
if (!adapter) throw new Error("Selected wallet adapter not found");
|
|
1359
1803
|
const provider = _nullishCoalesce(result.provider, () => ( adapter.getProvider()));
|
|
1360
1804
|
if (!provider) {
|
|
1361
|
-
|
|
1805
|
+
_chunkAFVK5GA5js.sentryLogger.error(`Error fetching provider on widget login: ${_optionalChain([result, 'optionalAccess', _131 => _131.walletId])}`);
|
|
1362
1806
|
throw new Error("Error fetching provider. Please try again.");
|
|
1363
1807
|
}
|
|
1364
1808
|
const checksumAdr = _viem.checksumAddress.call(void 0, result.address);
|
|
@@ -1375,7 +1819,7 @@ var _AurumCore = class _AurumCore {
|
|
|
1375
1819
|
const chainId = await provider.request({ method: "eth_chainId" });
|
|
1376
1820
|
this.emitConnect(chainId);
|
|
1377
1821
|
this.emitAccountsChanged([checksumAdr]);
|
|
1378
|
-
|
|
1822
|
+
_chunkAFVK5GA5js.sentryLogger.info(`Wallet connected: ${adapter.id} (widget)`);
|
|
1379
1823
|
return this.userInfo;
|
|
1380
1824
|
}
|
|
1381
1825
|
async getChainId() {
|
|
@@ -1394,7 +1838,7 @@ var _AurumCore = class _AurumCore {
|
|
|
1394
1838
|
}
|
|
1395
1839
|
}
|
|
1396
1840
|
updateBrandConfig(newConfig) {
|
|
1397
|
-
const defaultTheme =
|
|
1841
|
+
const defaultTheme = _chunkAFVK5GA5js.getDefaultThemeConfig.call(void 0, _nullishCoalesce(newConfig.theme, () => ( this.brandConfig.theme)));
|
|
1398
1842
|
this.brandConfig = {
|
|
1399
1843
|
logo: "logo" in newConfig ? _nullishCoalesce(newConfig.logo, () => ( defaultTheme.logo)) : this.brandConfig.logo,
|
|
1400
1844
|
theme: "theme" in newConfig ? _nullishCoalesce(newConfig.theme, () => ( defaultTheme.theme)) : this.brandConfig.theme,
|
|
@@ -1421,7 +1865,7 @@ var _AurumCore = class _AurumCore {
|
|
|
1421
1865
|
await this.whenReady();
|
|
1422
1866
|
const emailAdapter = this.wallets.find((w) => w.id === _types.WalletId.Email);
|
|
1423
1867
|
if (!emailAdapter || !emailAdapter.emailAuthStart) {
|
|
1424
|
-
throw new Error("Email wallet is not
|
|
1868
|
+
throw new Error("Email wallet is not configured");
|
|
1425
1869
|
}
|
|
1426
1870
|
const result = await emailAdapter.emailAuthStart(email);
|
|
1427
1871
|
return { flowId: result.flowId };
|
|
@@ -1436,18 +1880,18 @@ var _AurumCore = class _AurumCore {
|
|
|
1436
1880
|
await this.whenReady();
|
|
1437
1881
|
const emailAdapter = this.wallets.find((w) => w.id === _types.WalletId.Email);
|
|
1438
1882
|
if (!emailAdapter || !emailAdapter.emailAuthVerify) {
|
|
1439
|
-
throw new Error("Email wallet is not
|
|
1883
|
+
throw new Error("Email wallet is not configured");
|
|
1440
1884
|
}
|
|
1441
1885
|
const verifyResult = await emailAdapter.emailAuthVerify(flowId, otp);
|
|
1442
1886
|
const provider = emailAdapter.getProvider();
|
|
1443
1887
|
if (!provider) {
|
|
1444
|
-
|
|
1888
|
+
_chunkAFVK5GA5js.sentryLogger.error("Failed to get provider after email verification");
|
|
1445
1889
|
throw new Error("Failed to get provider after email verification");
|
|
1446
1890
|
}
|
|
1447
|
-
const address = _optionalChain([verifyResult, 'access',
|
|
1448
|
-
const email = _optionalChain([verifyResult, 'access',
|
|
1891
|
+
const address = _optionalChain([verifyResult, 'access', _132 => _132.user, 'optionalAccess', _133 => _133.evmAccounts, 'optionalAccess', _134 => _134[0]]);
|
|
1892
|
+
const email = _optionalChain([verifyResult, 'access', _135 => _135.user, 'optionalAccess', _136 => _136.authenticationMethods, 'optionalAccess', _137 => _137.email, 'optionalAccess', _138 => _138.email]);
|
|
1449
1893
|
if (!address || !email) {
|
|
1450
|
-
|
|
1894
|
+
_chunkAFVK5GA5js.sentryLogger.error("Address or email not found after email verification");
|
|
1451
1895
|
throw new Error("Address or email not found after email verification");
|
|
1452
1896
|
}
|
|
1453
1897
|
const checksumAdr = _viem.checksumAddress.call(void 0, address);
|
|
@@ -1464,7 +1908,7 @@ var _AurumCore = class _AurumCore {
|
|
|
1464
1908
|
const chainId = await provider.request({ method: "eth_chainId" });
|
|
1465
1909
|
this.emitConnect(chainId);
|
|
1466
1910
|
this.emitAccountsChanged([checksumAdr]);
|
|
1467
|
-
|
|
1911
|
+
_chunkAFVK5GA5js.sentryLogger.info(`Wallet connected: ${emailAdapter.id} (headless)`);
|
|
1468
1912
|
return { address: checksumAdr, email: _nullishCoalesce(email, () => ( "")), isNewUser: _nullishCoalesce(verifyResult.isNewUser, () => ( false)) };
|
|
1469
1913
|
}
|
|
1470
1914
|
/**
|
|
@@ -1473,10 +1917,7 @@ var _AurumCore = class _AurumCore {
|
|
|
1473
1917
|
*/
|
|
1474
1918
|
async getWalletConnectSession() {
|
|
1475
1919
|
await this.whenReady();
|
|
1476
|
-
|
|
1477
|
-
throw new Error("WalletConnect is excluded from wallet options");
|
|
1478
|
-
}
|
|
1479
|
-
const wcAdapter = this.wallets.find((w) => w instanceof _chunkNKWY4I4Ljs.WalletConnectAdapter);
|
|
1920
|
+
const wcAdapter = this.wallets.find((w) => w.id === _types.WalletId.WalletConnect);
|
|
1480
1921
|
if (!wcAdapter) {
|
|
1481
1922
|
throw new Error("WalletConnect is not enabled");
|
|
1482
1923
|
}
|
|
@@ -1487,7 +1928,7 @@ var _AurumCore = class _AurumCore {
|
|
|
1487
1928
|
const result = await session.waitForConnection();
|
|
1488
1929
|
const provider = _nullishCoalesce(result.provider, () => ( wcAdapter.getProvider()));
|
|
1489
1930
|
if (!provider) {
|
|
1490
|
-
|
|
1931
|
+
_chunkAFVK5GA5js.sentryLogger.error("Failed to get provider after WalletConnect connection");
|
|
1491
1932
|
throw new Error("Failed to get provider after WalletConnect connection");
|
|
1492
1933
|
}
|
|
1493
1934
|
const checksumAdr = _viem.checksumAddress.call(void 0, result.address);
|
|
@@ -1496,15 +1937,14 @@ var _AurumCore = class _AurumCore {
|
|
|
1496
1937
|
this.userInfo = {
|
|
1497
1938
|
publicAddress: checksumAdr,
|
|
1498
1939
|
walletName: wcAdapter.name,
|
|
1499
|
-
walletId: wcAdapter.id
|
|
1500
|
-
email: void 0
|
|
1940
|
+
walletId: wcAdapter.id
|
|
1501
1941
|
};
|
|
1502
1942
|
this.persistConnectionState(wcAdapter, checksumAdr);
|
|
1503
1943
|
this.setInternalAccountChangeListener(wcAdapter);
|
|
1504
1944
|
const chainId = await provider.request({ method: "eth_chainId" });
|
|
1505
1945
|
this.emitConnect(chainId);
|
|
1506
1946
|
this.emitAccountsChanged([checksumAdr]);
|
|
1507
|
-
|
|
1947
|
+
_chunkAFVK5GA5js.sentryLogger.info(`Wallet connected: ${wcAdapter.id} (headless)`);
|
|
1508
1948
|
return checksumAdr;
|
|
1509
1949
|
}
|
|
1510
1950
|
};
|
|
@@ -1520,15 +1960,15 @@ var _AurumCore = class _AurumCore {
|
|
|
1520
1960
|
}
|
|
1521
1961
|
this.eventListeners.get(event).add(callback);
|
|
1522
1962
|
if (!_AurumCore.MANAGED_EVENTS.includes(event)) {
|
|
1523
|
-
_optionalChain([this, 'access',
|
|
1963
|
+
_optionalChain([this, 'access', _139 => _139.currentProvider, 'access', _140 => _140.on, 'optionalCall', _141 => _141(event, callback)]);
|
|
1524
1964
|
}
|
|
1525
1965
|
};
|
|
1526
1966
|
}
|
|
1527
1967
|
if (prop === "removeListener") {
|
|
1528
1968
|
return (event, callback) => {
|
|
1529
|
-
_optionalChain([this, 'access',
|
|
1969
|
+
_optionalChain([this, 'access', _142 => _142.eventListeners, 'access', _143 => _143.get, 'call', _144 => _144(event), 'optionalAccess', _145 => _145.delete, 'call', _146 => _146(callback)]);
|
|
1530
1970
|
if (!_AurumCore.MANAGED_EVENTS.includes(event)) {
|
|
1531
|
-
_optionalChain([this, 'access',
|
|
1971
|
+
_optionalChain([this, 'access', _147 => _147.currentProvider, 'access', _148 => _148.removeListener, 'optionalCall', _149 => _149(event, callback)]);
|
|
1532
1972
|
}
|
|
1533
1973
|
};
|
|
1534
1974
|
}
|
|
@@ -1553,7 +1993,7 @@ var _AurumCore = class _AurumCore {
|
|
|
1553
1993
|
this.eventListeners.forEach((callbacks, event) => {
|
|
1554
1994
|
if (!_AurumCore.MANAGED_EVENTS.includes(event)) {
|
|
1555
1995
|
callbacks.forEach((callback) => {
|
|
1556
|
-
_optionalChain([newProvider, 'access',
|
|
1996
|
+
_optionalChain([newProvider, 'access', _150 => _150.on, 'optionalCall', _151 => _151(event, callback)]);
|
|
1557
1997
|
});
|
|
1558
1998
|
}
|
|
1559
1999
|
});
|
|
@@ -1561,7 +2001,7 @@ var _AurumCore = class _AurumCore {
|
|
|
1561
2001
|
/* BRAND & THEME METHODS */
|
|
1562
2002
|
resolveBrandConfig(config) {
|
|
1563
2003
|
const { brand = {} } = config || {};
|
|
1564
|
-
const themeConfig =
|
|
2004
|
+
const themeConfig = _chunkAFVK5GA5js.getDefaultThemeConfig.call(void 0, brand.theme || _chunkAFVK5GA5js.DEFAULT_THEME);
|
|
1565
2005
|
return {
|
|
1566
2006
|
logo: _nullishCoalesce(brand.logo, () => ( themeConfig.logo)),
|
|
1567
2007
|
theme: _nullishCoalesce(brand.theme, () => ( themeConfig.theme)),
|
|
@@ -1576,8 +2016,8 @@ var _AurumCore = class _AurumCore {
|
|
|
1576
2016
|
}
|
|
1577
2017
|
async tryRestoreConnection() {
|
|
1578
2018
|
try {
|
|
1579
|
-
await
|
|
1580
|
-
const store =
|
|
2019
|
+
await _chunkAFVK5GA5js.waitForStoreHydration.call(void 0, );
|
|
2020
|
+
const store = _chunkAFVK5GA5js.useAurumStore.getState();
|
|
1581
2021
|
if (!store.isConnected || !store.walletId || !store.address || !store.walletName) {
|
|
1582
2022
|
return;
|
|
1583
2023
|
}
|
|
@@ -1600,14 +2040,14 @@ var _AurumCore = class _AurumCore {
|
|
|
1600
2040
|
email: _nullishCoalesce(store.email, () => ( void 0))
|
|
1601
2041
|
};
|
|
1602
2042
|
this.setInternalAccountChangeListener(persistedAdapter);
|
|
1603
|
-
} catch (
|
|
2043
|
+
} catch (e22) {
|
|
1604
2044
|
this.resetConnectionState();
|
|
1605
2045
|
} finally {
|
|
1606
2046
|
this.ready = true;
|
|
1607
2047
|
}
|
|
1608
2048
|
}
|
|
1609
2049
|
persistConnectionState(adapter, address, email) {
|
|
1610
|
-
|
|
2050
|
+
_chunkAFVK5GA5js.useAurumStore.getState().setConnection(adapter.id, _viem.checksumAddress.call(void 0, address), adapter.name, email);
|
|
1611
2051
|
}
|
|
1612
2052
|
/* INTERNAL LISTENER METHODS */
|
|
1613
2053
|
setInternalAccountChangeListener(adapter) {
|
|
@@ -1621,14 +2061,14 @@ var _AurumCore = class _AurumCore {
|
|
|
1621
2061
|
}
|
|
1622
2062
|
async syncStateFromAccountsChanged(accounts) {
|
|
1623
2063
|
if (!accounts.length || !accounts[0]) return;
|
|
1624
|
-
const prevAccount = _optionalChain([this, 'access',
|
|
2064
|
+
const prevAccount = _optionalChain([this, 'access', _152 => _152.userInfo, 'optionalAccess', _153 => _153.publicAddress]);
|
|
1625
2065
|
const newAccount = _viem.checksumAddress.call(void 0, accounts[0]);
|
|
1626
2066
|
if (newAccount !== prevAccount) {
|
|
1627
2067
|
this.userInfo = {
|
|
1628
2068
|
publicAddress: newAccount,
|
|
1629
|
-
walletName: _optionalChain([this, 'access',
|
|
1630
|
-
walletId: _optionalChain([this, 'access',
|
|
1631
|
-
email: _optionalChain([this, 'access',
|
|
2069
|
+
walletName: _optionalChain([this, 'access', _154 => _154.userInfo, 'optionalAccess', _155 => _155.walletName]),
|
|
2070
|
+
walletId: _optionalChain([this, 'access', _156 => _156.userInfo, 'optionalAccess', _157 => _157.walletId]),
|
|
2071
|
+
email: _optionalChain([this, 'access', _158 => _158.userInfo, 'optionalAccess', _159 => _159.email])
|
|
1632
2072
|
};
|
|
1633
2073
|
if (this.connectedWalletAdapter) {
|
|
1634
2074
|
this.persistConnectionState(this.connectedWalletAdapter, newAccount, this.userInfo.email);
|
|
@@ -1687,7 +2127,7 @@ var _AurumCore = class _AurumCore {
|
|
|
1687
2127
|
}
|
|
1688
2128
|
}
|
|
1689
2129
|
async addChain(chain) {
|
|
1690
|
-
if (!_optionalChain([chain, 'optionalAccess',
|
|
2130
|
+
if (!_optionalChain([chain, 'optionalAccess', _160 => _160.id]) || !_optionalChain([chain, 'optionalAccess', _161 => _161.name]) || !_optionalChain([chain, 'optionalAccess', _162 => _162.nativeCurrency]) || !_optionalChain([chain, 'optionalAccess', _163 => _163.rpcUrls, 'optionalAccess', _164 => _164.default, 'optionalAccess', _165 => _165.http])) {
|
|
1691
2131
|
throw new Error("Invalid chain configuration: missing required properties");
|
|
1692
2132
|
}
|
|
1693
2133
|
await this.rpcProvider.request({
|
|
@@ -1705,7 +2145,7 @@ var _AurumCore = class _AurumCore {
|
|
|
1705
2145
|
}
|
|
1706
2146
|
/* REST */
|
|
1707
2147
|
resetConnectionState() {
|
|
1708
|
-
|
|
2148
|
+
_chunkAFVK5GA5js.useAurumStore.getState().clearConnection();
|
|
1709
2149
|
this.connectedWalletAdapter = null;
|
|
1710
2150
|
this.updateProvider(this.skeletonProvider);
|
|
1711
2151
|
this.userInfo = void 0;
|
|
@@ -1800,8 +2240,7 @@ var Aurum = class {
|
|
|
1800
2240
|
* Opens the wallet connection modal or connects directly to a specific wallet.
|
|
1801
2241
|
*
|
|
1802
2242
|
* @param walletId - Optional wallet ID for direct connection (bypasses modal).
|
|
1803
|
-
* Cannot be 'email' (use
|
|
1804
|
-
* For 'walletconnect', opens the WalletConnect modal directly.
|
|
2243
|
+
* Cannot be 'email' or 'walletconnect' (use their dedicated methods).
|
|
1805
2244
|
* @returns The connected wallet address
|
|
1806
2245
|
* @throws Error if user closes the modal without connecting a wallet
|
|
1807
2246
|
*
|
|
@@ -1813,9 +2252,6 @@ var Aurum = class {
|
|
|
1813
2252
|
* // Or connect directly to a specific wallet
|
|
1814
2253
|
* import { WalletId } from '@aurum-sdk/types';
|
|
1815
2254
|
* const address = await aurum.connect(WalletId.MetaMask);
|
|
1816
|
-
*
|
|
1817
|
-
* // Open WalletConnect modal directly
|
|
1818
|
-
* const address = await aurum.connect(WalletId.WalletConnect);
|
|
1819
2255
|
* ```
|
|
1820
2256
|
*/
|
|
1821
2257
|
async connect(walletId) {
|
|
@@ -1923,7 +2359,7 @@ var Aurum = class {
|
|
|
1923
2359
|
* import { WalletId } from '@aurum-sdk/types';
|
|
1924
2360
|
*
|
|
1925
2361
|
* aurum.updateWalletsConfig({
|
|
1926
|
-
* exclude: [WalletId.Email, WalletId.
|
|
2362
|
+
* exclude: [WalletId.Email, WalletId.AppKit],
|
|
1927
2363
|
* });
|
|
1928
2364
|
* ```
|
|
1929
2365
|
*/
|
|
@@ -1945,7 +2381,7 @@ var Aurum = class {
|
|
|
1945
2381
|
*
|
|
1946
2382
|
* @param email - The email address to send the OTP to
|
|
1947
2383
|
* @returns Object containing flowId to use with emailAuthVerify
|
|
1948
|
-
* @throws Error if email wallet is not
|
|
2384
|
+
* @throws Error if email wallet is not configured
|
|
1949
2385
|
*
|
|
1950
2386
|
* @example
|
|
1951
2387
|
* ```typescript
|
|
@@ -1981,7 +2417,7 @@ var Aurum = class {
|
|
|
1981
2417
|
* Use this for building custom QR code UIs instead of using the built-in modal.
|
|
1982
2418
|
*
|
|
1983
2419
|
* @returns Object containing the URI and a function to wait for the connection
|
|
1984
|
-
* @throws Error if WalletConnect is not
|
|
2420
|
+
* @throws Error if WalletConnect is not configured
|
|
1985
2421
|
*
|
|
1986
2422
|
* @example
|
|
1987
2423
|
* ```typescript
|