@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
|
@@ -119,325 +119,6 @@ function sortWallets(wallets, options = {}) {
|
|
|
119
119
|
return result;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
// src/services/sentry.ts
|
|
123
|
-
import * as Sentry from "@sentry/browser";
|
|
124
|
-
var initialized = false;
|
|
125
|
-
var telemetryEnabled = true;
|
|
126
|
-
function getEnvironment() {
|
|
127
|
-
if (typeof window !== "undefined") {
|
|
128
|
-
const hostname = window.location.hostname;
|
|
129
|
-
if (hostname === "localhost" || hostname === "127.0.0.1") {
|
|
130
|
-
return "development";
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return "production";
|
|
134
|
-
}
|
|
135
|
-
function initSentry(enabled = true) {
|
|
136
|
-
telemetryEnabled = enabled;
|
|
137
|
-
if (initialized || !telemetryEnabled || false) return;
|
|
138
|
-
initialized = true;
|
|
139
|
-
Sentry.init({
|
|
140
|
-
dsn: "https://0bb16fd7057ac7b45ae0ab416cdbea8b@o4505953815494656.ingest.us.sentry.io/4509747448184832",
|
|
141
|
-
environment: getEnvironment(),
|
|
142
|
-
release: `@aurum-sdk/core@${"0.2.0"}`,
|
|
143
|
-
sendDefaultPii: false,
|
|
144
|
-
enableLogs: true
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
function getUrl() {
|
|
148
|
-
if (typeof window !== "undefined") {
|
|
149
|
-
return window.location.href;
|
|
150
|
-
}
|
|
151
|
-
return void 0;
|
|
152
|
-
}
|
|
153
|
-
var sentryLogger = {
|
|
154
|
-
info: (message, attributes) => {
|
|
155
|
-
if (telemetryEnabled) Sentry.logger.info(message, { url: getUrl(), ...attributes });
|
|
156
|
-
},
|
|
157
|
-
warn: (message, attributes) => {
|
|
158
|
-
if (telemetryEnabled) Sentry.logger.warn(message, { url: getUrl(), ...attributes });
|
|
159
|
-
},
|
|
160
|
-
error: (message, attributes) => {
|
|
161
|
-
if (telemetryEnabled) Sentry.logger.error(message, { url: getUrl(), ...attributes });
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
// src/wallet-adapters/AppKitAdapter.ts
|
|
166
|
-
import { getLogoDataUri } from "@aurum-sdk/logos";
|
|
167
|
-
import { WalletId as WalletId2, WalletName } from "@aurum-sdk/types";
|
|
168
|
-
|
|
169
|
-
// src/utils/isConfigError.ts
|
|
170
|
-
var isConfigError = (error) => {
|
|
171
|
-
const name = error?.name;
|
|
172
|
-
return name === "ConfigError";
|
|
173
|
-
};
|
|
174
|
-
var createConfigError = (adapterName) => {
|
|
175
|
-
const error = new Error(`Missing required project ID for ${adapterName}`);
|
|
176
|
-
error.name = "ConfigError";
|
|
177
|
-
return error;
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
// src/wallet-adapters/AppKitAdapter.ts
|
|
181
|
-
var AppKitAdapter = class {
|
|
182
|
-
constructor(config) {
|
|
183
|
-
this.id = WalletId2.WalletConnect;
|
|
184
|
-
this.name = WalletName.WalletConnect;
|
|
185
|
-
this.icon = getLogoDataUri(WalletId2.WalletConnect, "brand") ?? "";
|
|
186
|
-
this.hide = true;
|
|
187
|
-
this.downloadUrl = null;
|
|
188
|
-
this.wcDeepLinkUrl = null;
|
|
189
|
-
this.modal = null;
|
|
190
|
-
this.wagmiAdapter = null;
|
|
191
|
-
this.provider = null;
|
|
192
|
-
this.address = null;
|
|
193
|
-
this.accountsChangedCallback = null;
|
|
194
|
-
this.unsubscribeFunctions = [];
|
|
195
|
-
this.initPromise = null;
|
|
196
|
-
this.config = {
|
|
197
|
-
projectId: config.projectId,
|
|
198
|
-
appName: config.appName,
|
|
199
|
-
modalZIndex: config.modalZIndex,
|
|
200
|
-
theme: config.theme
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
async ensureInitialized() {
|
|
204
|
-
if (this.modal) return;
|
|
205
|
-
if (!this.initPromise) {
|
|
206
|
-
this.initPromise = this.initializeAppKit();
|
|
207
|
-
}
|
|
208
|
-
await this.initPromise;
|
|
209
|
-
}
|
|
210
|
-
async initializeAppKit() {
|
|
211
|
-
if (typeof window === "undefined") return;
|
|
212
|
-
const [{ createAppKit }, { WagmiAdapter }, { mainnet }] = await Promise.all([
|
|
213
|
-
import("@reown/appkit"),
|
|
214
|
-
import("@reown/appkit-adapter-wagmi"),
|
|
215
|
-
import("@reown/appkit/networks")
|
|
216
|
-
]);
|
|
217
|
-
const networks = [mainnet];
|
|
218
|
-
this.wagmiAdapter = new WagmiAdapter({
|
|
219
|
-
projectId: this.config.projectId,
|
|
220
|
-
networks,
|
|
221
|
-
ssr: true
|
|
222
|
-
});
|
|
223
|
-
this.modal = createAppKit({
|
|
224
|
-
adapters: [this.wagmiAdapter],
|
|
225
|
-
networks,
|
|
226
|
-
projectId: this.config.projectId,
|
|
227
|
-
metadata: {
|
|
228
|
-
name: this.config.appName,
|
|
229
|
-
description: this.config.appName,
|
|
230
|
-
url: window.location.origin,
|
|
231
|
-
icons: []
|
|
232
|
-
},
|
|
233
|
-
allowUnsupportedChain: true,
|
|
234
|
-
themeMode: this.config.theme,
|
|
235
|
-
themeVariables: {
|
|
236
|
-
"--apkt-z-index": this.config.modalZIndex + 1
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
this.setupEventListeners();
|
|
240
|
-
}
|
|
241
|
-
setupEventListeners() {
|
|
242
|
-
if (!this.modal) return;
|
|
243
|
-
const unsubscribeProviders = this.modal.subscribeProviders((state) => {
|
|
244
|
-
const eip155Provider = state["eip155"];
|
|
245
|
-
this.provider = eip155Provider || null;
|
|
246
|
-
if (!eip155Provider) {
|
|
247
|
-
this.address = null;
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
this.unsubscribeFunctions.push(unsubscribeProviders);
|
|
251
|
-
}
|
|
252
|
-
syncAddressFromWagmi() {
|
|
253
|
-
if (!this.wagmiAdapter?.wagmiConfig) return;
|
|
254
|
-
const { state } = this.wagmiAdapter.wagmiConfig;
|
|
255
|
-
if (state.current && state.connections) {
|
|
256
|
-
const connection = state.connections.get(state.current);
|
|
257
|
-
if (connection?.accounts?.[0]) {
|
|
258
|
-
this.address = connection.accounts[0];
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
async syncProviderFromModal() {
|
|
263
|
-
if (!this.modal) return;
|
|
264
|
-
try {
|
|
265
|
-
const getProvidersFn = this.modal.getProviders;
|
|
266
|
-
if (typeof getProvidersFn === "function") {
|
|
267
|
-
const providers = getProvidersFn.call(this.modal);
|
|
268
|
-
const eip155Provider = providers?.["eip155"];
|
|
269
|
-
if (eip155Provider) {
|
|
270
|
-
this.provider = eip155Provider;
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
if (this.wagmiAdapter?.wagmiConfig) {
|
|
275
|
-
const { state } = this.wagmiAdapter.wagmiConfig;
|
|
276
|
-
if (state.current && state.connections) {
|
|
277
|
-
const connection = state.connections.get(state.current);
|
|
278
|
-
const connector = connection?.connector;
|
|
279
|
-
if (connector && typeof connector.getProvider === "function") {
|
|
280
|
-
try {
|
|
281
|
-
const provider = await connector.getProvider();
|
|
282
|
-
if (provider) {
|
|
283
|
-
this.provider = provider;
|
|
284
|
-
}
|
|
285
|
-
} catch (error) {
|
|
286
|
-
sentryLogger.warn("Failed to get provider from wagmi connector", { error });
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
} catch (error) {
|
|
292
|
-
sentryLogger.warn("Failed to get provider from WalletConnect modal", { error });
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
isInstalled() {
|
|
296
|
-
return true;
|
|
297
|
-
}
|
|
298
|
-
async connect() {
|
|
299
|
-
if (!this.config.projectId) {
|
|
300
|
-
throw createConfigError("WalletConnect");
|
|
301
|
-
}
|
|
302
|
-
await this.ensureInitialized();
|
|
303
|
-
if (!this.modal) {
|
|
304
|
-
sentryLogger.error("WalletConnect modal is not available");
|
|
305
|
-
throw new Error("WalletConnect modal is not available");
|
|
306
|
-
}
|
|
307
|
-
const existingAddress = this.modal.getAddress();
|
|
308
|
-
if (this.modal.getIsConnectedState() && existingAddress) {
|
|
309
|
-
await this.syncProviderFromModal();
|
|
310
|
-
if (this.provider) {
|
|
311
|
-
this.address = existingAddress;
|
|
312
|
-
return {
|
|
313
|
-
address: existingAddress,
|
|
314
|
-
provider: this.provider,
|
|
315
|
-
walletId: this.id
|
|
316
|
-
};
|
|
317
|
-
}
|
|
318
|
-
await this.disconnect();
|
|
319
|
-
}
|
|
320
|
-
this.modal.open({ view: "AllWallets" });
|
|
321
|
-
return await this.waitForConnection();
|
|
322
|
-
}
|
|
323
|
-
waitForConnection(timeout = 6e4) {
|
|
324
|
-
return new Promise((resolve, reject) => {
|
|
325
|
-
const startTime = Date.now();
|
|
326
|
-
let unsubscribeState = null;
|
|
327
|
-
let isResolved = false;
|
|
328
|
-
const cleanup = () => {
|
|
329
|
-
unsubscribeState?.();
|
|
330
|
-
};
|
|
331
|
-
const checkConnection = async () => {
|
|
332
|
-
if (isResolved) return true;
|
|
333
|
-
this.syncAddressFromWagmi();
|
|
334
|
-
if (this.address && !this.provider) {
|
|
335
|
-
await this.syncProviderFromModal();
|
|
336
|
-
}
|
|
337
|
-
if (this.provider && this.address) {
|
|
338
|
-
try {
|
|
339
|
-
const accounts = await this.provider.request({ method: "eth_accounts" });
|
|
340
|
-
if (accounts && accounts.length > 0) {
|
|
341
|
-
isResolved = true;
|
|
342
|
-
cleanup();
|
|
343
|
-
this.modal?.close();
|
|
344
|
-
resolve({
|
|
345
|
-
address: this.address,
|
|
346
|
-
provider: this.provider,
|
|
347
|
-
walletId: this.id
|
|
348
|
-
});
|
|
349
|
-
return true;
|
|
350
|
-
}
|
|
351
|
-
return false;
|
|
352
|
-
} catch {
|
|
353
|
-
return false;
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
return false;
|
|
357
|
-
};
|
|
358
|
-
unsubscribeState = this.modal.subscribeState(async (state) => {
|
|
359
|
-
if (await checkConnection()) return;
|
|
360
|
-
if (state.open === false && !this.address && !isResolved) {
|
|
361
|
-
cleanup();
|
|
362
|
-
reject(new Error("Connection rejected by user"));
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
|
-
const pollTimeout = async () => {
|
|
366
|
-
if (await checkConnection()) return;
|
|
367
|
-
if (Date.now() - startTime > timeout) {
|
|
368
|
-
cleanup();
|
|
369
|
-
reject(new Error("Connection timeout"));
|
|
370
|
-
return;
|
|
371
|
-
}
|
|
372
|
-
setTimeout(pollTimeout, 500);
|
|
373
|
-
};
|
|
374
|
-
pollTimeout();
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
async tryRestoreConnection() {
|
|
378
|
-
await this.ensureInitialized();
|
|
379
|
-
if (!this.modal || !this.wagmiAdapter) return null;
|
|
380
|
-
try {
|
|
381
|
-
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
382
|
-
const wagmiConfig = this.wagmiAdapter.wagmiConfig;
|
|
383
|
-
if (wagmiConfig?.state?.current && wagmiConfig.state.connections) {
|
|
384
|
-
const connection = wagmiConfig.state.connections.get(wagmiConfig.state.current);
|
|
385
|
-
if (connection?.accounts?.[0]) {
|
|
386
|
-
this.address = connection.accounts[0];
|
|
387
|
-
if (this.provider && this.address) {
|
|
388
|
-
return {
|
|
389
|
-
address: this.address,
|
|
390
|
-
provider: this.provider,
|
|
391
|
-
walletId: this.id
|
|
392
|
-
};
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
return null;
|
|
397
|
-
} catch {
|
|
398
|
-
return null;
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
async disconnect() {
|
|
402
|
-
if (!this.modal) {
|
|
403
|
-
this.address = null;
|
|
404
|
-
this.provider = null;
|
|
405
|
-
return;
|
|
406
|
-
}
|
|
407
|
-
await this.modal.disconnect("eip155");
|
|
408
|
-
const timeout = Date.now() + 2e3;
|
|
409
|
-
while (Date.now() < timeout && (this.modal.getIsConnectedState() || this.modal.getAddress())) {
|
|
410
|
-
await new Promise((r) => setTimeout(r, 100));
|
|
411
|
-
}
|
|
412
|
-
this.address = null;
|
|
413
|
-
this.provider = null;
|
|
414
|
-
}
|
|
415
|
-
getProvider() {
|
|
416
|
-
return this.provider;
|
|
417
|
-
}
|
|
418
|
-
onAccountsChanged(callback) {
|
|
419
|
-
if (!this.provider?.on) return;
|
|
420
|
-
if (this.accountsChangedCallback) {
|
|
421
|
-
this.provider.removeListener?.("accountsChanged", this.accountsChangedCallback);
|
|
422
|
-
}
|
|
423
|
-
this.accountsChangedCallback = (accounts) => {
|
|
424
|
-
this.address = accounts[0] || null;
|
|
425
|
-
callback(accounts);
|
|
426
|
-
};
|
|
427
|
-
this.provider.on("accountsChanged", this.accountsChangedCallback);
|
|
428
|
-
}
|
|
429
|
-
removeListeners() {
|
|
430
|
-
if (this.provider?.removeListener && this.accountsChangedCallback) {
|
|
431
|
-
this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
|
|
432
|
-
this.accountsChangedCallback = null;
|
|
433
|
-
}
|
|
434
|
-
this.unsubscribeFunctions.forEach((unsub) => unsub());
|
|
435
|
-
this.unsubscribeFunctions = [];
|
|
436
|
-
}
|
|
437
|
-
};
|
|
438
|
-
/** Internal identifier for distinguishing from WalletConnectAdapter */
|
|
439
|
-
AppKitAdapter.INTERNAL_ID = "appkit-modal";
|
|
440
|
-
|
|
441
122
|
// src/utils/platform/isMobile.ts
|
|
442
123
|
import MobileDetect from "mobile-detect";
|
|
443
124
|
function isMobile() {
|
|
@@ -1054,6 +735,62 @@ import { useEffect as useEffect4, useState as useState7 } from "react";
|
|
|
1054
735
|
|
|
1055
736
|
// src/contexts/EmailAuthContext.tsx
|
|
1056
737
|
import { createContext as createContext3, useContext as useContext3, useState as useState6 } from "react";
|
|
738
|
+
|
|
739
|
+
// src/services/sentry.ts
|
|
740
|
+
import * as Sentry from "@sentry/browser";
|
|
741
|
+
var initialized = false;
|
|
742
|
+
var telemetryEnabled = true;
|
|
743
|
+
function getEnvironment() {
|
|
744
|
+
if (typeof window !== "undefined") {
|
|
745
|
+
const hostname = window.location.hostname;
|
|
746
|
+
if (hostname === "localhost" || hostname === "127.0.0.1") {
|
|
747
|
+
return "development";
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
return "production";
|
|
751
|
+
}
|
|
752
|
+
function initSentry(enabled = true) {
|
|
753
|
+
telemetryEnabled = enabled;
|
|
754
|
+
if (initialized || !telemetryEnabled || false) return;
|
|
755
|
+
initialized = true;
|
|
756
|
+
Sentry.init({
|
|
757
|
+
dsn: "https://0bb16fd7057ac7b45ae0ab416cdbea8b@o4505953815494656.ingest.us.sentry.io/4509747448184832",
|
|
758
|
+
environment: getEnvironment(),
|
|
759
|
+
release: `@aurum-sdk/core@${"0.2.1"}`,
|
|
760
|
+
sendDefaultPii: false,
|
|
761
|
+
enableLogs: true
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
function getUrl() {
|
|
765
|
+
if (typeof window !== "undefined") {
|
|
766
|
+
return window.location.href;
|
|
767
|
+
}
|
|
768
|
+
return void 0;
|
|
769
|
+
}
|
|
770
|
+
var sentryLogger = {
|
|
771
|
+
info: (message, attributes) => {
|
|
772
|
+
if (telemetryEnabled) Sentry.logger.info(message, { url: getUrl(), ...attributes });
|
|
773
|
+
},
|
|
774
|
+
warn: (message, attributes) => {
|
|
775
|
+
if (telemetryEnabled) Sentry.logger.warn(message, { url: getUrl(), ...attributes });
|
|
776
|
+
},
|
|
777
|
+
error: (message, attributes) => {
|
|
778
|
+
if (telemetryEnabled) Sentry.logger.error(message, { url: getUrl(), ...attributes });
|
|
779
|
+
}
|
|
780
|
+
};
|
|
781
|
+
|
|
782
|
+
// src/utils/isConfigError.ts
|
|
783
|
+
var isConfigError = (error) => {
|
|
784
|
+
const name = error?.name;
|
|
785
|
+
return name === "ConfigError";
|
|
786
|
+
};
|
|
787
|
+
var createConfigError = (adapterName) => {
|
|
788
|
+
const error = new Error(`Missing required project ID for ${adapterName}`);
|
|
789
|
+
error.name = "ConfigError";
|
|
790
|
+
return error;
|
|
791
|
+
};
|
|
792
|
+
|
|
793
|
+
// src/contexts/EmailAuthContext.tsx
|
|
1057
794
|
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
1058
795
|
var EmailAuthContext = createContext3(null);
|
|
1059
796
|
var useEmailAuth = () => {
|
|
@@ -1313,7 +1050,7 @@ var WalletButtonLabel = ({ type }) => {
|
|
|
1313
1050
|
};
|
|
1314
1051
|
|
|
1315
1052
|
// src/components/WalletButton/WalletButton.tsx
|
|
1316
|
-
import { WalletId as
|
|
1053
|
+
import { WalletId as WalletId2 } from "@aurum-sdk/types";
|
|
1317
1054
|
import { jsx as jsx23, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1318
1055
|
var WalletButton = ({
|
|
1319
1056
|
wallet,
|
|
@@ -1334,7 +1071,7 @@ var WalletButton = ({
|
|
|
1334
1071
|
/* @__PURE__ */ jsx23(WalletLogoWrapper, { id: wallet.id, size: iconSize, sizeSlot: "sm" }),
|
|
1335
1072
|
/* @__PURE__ */ jsx23(Text, { weight: "semibold", size: "md", children: wallet.name })
|
|
1336
1073
|
] }),
|
|
1337
|
-
wallet.id ===
|
|
1074
|
+
wallet.id === WalletId2.WalletConnect && !isLastUsed ? /* @__PURE__ */ jsx23(QrCode, { color: "var(--color-foreground)", size: 18 }) : /* @__PURE__ */ jsx23(WalletButtonLabel, { type: label })
|
|
1338
1075
|
] })
|
|
1339
1076
|
},
|
|
1340
1077
|
wallet.id
|
|
@@ -1435,12 +1172,12 @@ var WalletListStacked = ({ wallets, hasEmailAuth }) => {
|
|
|
1435
1172
|
};
|
|
1436
1173
|
|
|
1437
1174
|
// src/components/ConnectModal/SelectWallet.tsx
|
|
1438
|
-
import { WalletId as
|
|
1175
|
+
import { WalletId as WalletId3 } from "@aurum-sdk/types";
|
|
1439
1176
|
import { Fragment as Fragment3, jsx as jsx26, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1440
1177
|
var SelectWalletPage = () => {
|
|
1441
1178
|
const { displayedWallets } = useConnectModal();
|
|
1442
1179
|
const { onDismiss, brandConfig } = useWidgetContext();
|
|
1443
|
-
const hasEmailAuth = displayedWallets.some((wallet) => wallet.id ===
|
|
1180
|
+
const hasEmailAuth = displayedWallets.some((wallet) => wallet.id === WalletId3.Email);
|
|
1444
1181
|
const sortedWallets = useMemo3(() => sortWallets(displayedWallets), [displayedWallets]);
|
|
1445
1182
|
const isGridLayout = brandConfig.walletLayout === "grid";
|
|
1446
1183
|
return /* @__PURE__ */ jsxs11(Fragment3, { children: [
|
|
@@ -1648,7 +1385,7 @@ var ConnectionStatusBase = ({
|
|
|
1648
1385
|
};
|
|
1649
1386
|
|
|
1650
1387
|
// src/components/ConnectModal/ConnectionStatus/Desktop.tsx
|
|
1651
|
-
import { WalletId as
|
|
1388
|
+
import { WalletId as WalletId4 } from "@aurum-sdk/types";
|
|
1652
1389
|
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
1653
1390
|
var ConnectionStatusPage = () => {
|
|
1654
1391
|
const { selectedWallet } = useConnectModal();
|
|
@@ -1656,7 +1393,7 @@ var ConnectionStatusPage = () => {
|
|
|
1656
1393
|
ConnectionStatusBase,
|
|
1657
1394
|
{
|
|
1658
1395
|
pendingHeaderText: `Approve in ${selectedWallet?.name}`,
|
|
1659
|
-
pendingSubContent: /* @__PURE__ */ jsx31(Text, { align: "center", size: "sm", variant: "secondary", children: selectedWallet?.id ===
|
|
1396
|
+
pendingSubContent: /* @__PURE__ */ jsx31(Text, { align: "center", size: "sm", variant: "secondary", children: selectedWallet?.id === WalletId4.Ledger ? `Please wait for the Ledger Live modal to open` : `Please check your wallet to
|
|
1660
1397
|
approve the connection` })
|
|
1661
1398
|
}
|
|
1662
1399
|
);
|
|
@@ -1695,13 +1432,13 @@ import { useRef as useRef4, useEffect as useEffect7 } from "react";
|
|
|
1695
1432
|
import { QRCode } from "react-qrcode-logo";
|
|
1696
1433
|
|
|
1697
1434
|
// src/utils/generateQrCodeWalletLogo.tsx
|
|
1698
|
-
import { getLogoDataUri
|
|
1699
|
-
import { WalletId as
|
|
1435
|
+
import { getLogoDataUri } from "@aurum-sdk/logos";
|
|
1436
|
+
import { WalletId as WalletId5 } from "@aurum-sdk/types";
|
|
1700
1437
|
var generateQrCodeWalletLogo = (walletAdapter) => {
|
|
1701
|
-
if (walletAdapter &&
|
|
1438
|
+
if (walletAdapter && walletAdapter.id !== WalletId5.AppKit && walletAdapter.icon) {
|
|
1702
1439
|
return walletAdapter.icon;
|
|
1703
1440
|
}
|
|
1704
|
-
return
|
|
1441
|
+
return getLogoDataUri(WalletId5.WalletConnect) ?? "";
|
|
1705
1442
|
};
|
|
1706
1443
|
|
|
1707
1444
|
// src/components/QRCodeDisplay/QREye.tsx
|
|
@@ -1860,6 +1597,7 @@ var QRCodeSkeleton = ({ size = 128 }) => {
|
|
|
1860
1597
|
};
|
|
1861
1598
|
|
|
1862
1599
|
// src/components/QRCodeDisplay/QRCodeDisplay.tsx
|
|
1600
|
+
import { WalletId as WalletId6 } from "@aurum-sdk/types";
|
|
1863
1601
|
import { jsx as jsx36, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
1864
1602
|
var QRCodeDisplay = ({ uri, size = 256 }) => {
|
|
1865
1603
|
const { brandConfig } = useWidgetContext();
|
|
@@ -1868,12 +1606,12 @@ var QRCodeDisplay = ({ uri, size = 256 }) => {
|
|
|
1868
1606
|
const bgColor = brandConfig.theme === "light" ? "#ffffff" : "#121212";
|
|
1869
1607
|
const logoWalletRef = useRef4(null);
|
|
1870
1608
|
useEffect7(() => {
|
|
1871
|
-
if (selectedWallet &&
|
|
1609
|
+
if (selectedWallet && selectedWallet.id !== WalletId6.AppKit) {
|
|
1872
1610
|
logoWalletRef.current = selectedWallet;
|
|
1873
1611
|
}
|
|
1874
1612
|
}, [selectedWallet]);
|
|
1875
1613
|
const logoWallet = logoWalletRef.current || selectedWallet;
|
|
1876
|
-
const appKitAdapter = displayedWallets.find((
|
|
1614
|
+
const appKitAdapter = displayedWallets.find(({ id }) => id === WalletId6.AppKit);
|
|
1877
1615
|
const handleAppKitConnect = async () => {
|
|
1878
1616
|
if (appKitAdapter) {
|
|
1879
1617
|
connectWallet(appKitAdapter);
|
|
@@ -1925,7 +1663,7 @@ var QRCodeDisplay = ({ uri, size = 256 }) => {
|
|
|
1925
1663
|
|
|
1926
1664
|
// src/components/ConnectModal/QRCodePage.tsx
|
|
1927
1665
|
import { ChevronLeft as ChevronLeft2, X as X4, SquareArrowOutUpRight, CircleCheck as CircleCheck2 } from "lucide-react";
|
|
1928
|
-
import {
|
|
1666
|
+
import { WalletId as WalletId7, WalletName } from "@aurum-sdk/types";
|
|
1929
1667
|
import { Fragment as Fragment5, jsx as jsx37, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
1930
1668
|
var QRCodePage = () => {
|
|
1931
1669
|
const { onDismiss } = useWidgetContext();
|
|
@@ -1934,7 +1672,7 @@ var QRCodePage = () => {
|
|
|
1934
1672
|
const [connectionUri, setConnectionUri] = useState10(null);
|
|
1935
1673
|
const originalWalletRef = useRef5(null);
|
|
1936
1674
|
useEffect8(() => {
|
|
1937
|
-
if (selectedWallet &&
|
|
1675
|
+
if (selectedWallet && selectedWallet.id !== WalletId7.AppKit) {
|
|
1938
1676
|
originalWalletRef.current = selectedWallet;
|
|
1939
1677
|
}
|
|
1940
1678
|
}, [selectedWallet]);
|
|
@@ -1942,7 +1680,7 @@ var QRCodePage = () => {
|
|
|
1942
1680
|
const goBackToHome = () => {
|
|
1943
1681
|
navigateTo(PAGE_IDS.SELECT_WALLET);
|
|
1944
1682
|
};
|
|
1945
|
-
const title = displayWallet?.name ===
|
|
1683
|
+
const title = displayWallet?.name === WalletName.WalletConnect || displayWallet?.name === WalletName.AppKit ? "Scan QR code" : `Scan with ${displayWallet?.name} app`;
|
|
1946
1684
|
useEffect8(() => {
|
|
1947
1685
|
const handleWalletConnectURI = (event) => {
|
|
1948
1686
|
setConnectionUri(event.detail.uri);
|
|
@@ -2422,198 +2160,8 @@ var registerGlobalCleanup = (cleanupFn) => {
|
|
|
2422
2160
|
return cleanup;
|
|
2423
2161
|
};
|
|
2424
2162
|
|
|
2425
|
-
// src/wallet-adapters/WalletConnectAdapter.ts
|
|
2426
|
-
import { getLogoDataUri as getLogoDataUri3 } from "@aurum-sdk/logos";
|
|
2427
|
-
import { WalletId as WalletId7, WalletName as WalletName3 } from "@aurum-sdk/types";
|
|
2428
|
-
var WalletConnectAdapter = class {
|
|
2429
|
-
constructor(config) {
|
|
2430
|
-
this.id = WalletId7.WalletConnect;
|
|
2431
|
-
this.name = WalletName3.WalletConnect;
|
|
2432
|
-
this.icon = getLogoDataUri3(WalletId7.WalletConnect, "brand") ?? "";
|
|
2433
|
-
this.hide = false;
|
|
2434
|
-
this.downloadUrl = null;
|
|
2435
|
-
this.wcDeepLinkUrl = null;
|
|
2436
|
-
this.provider = null;
|
|
2437
|
-
this.connectionUri = null;
|
|
2438
|
-
this.accountsChangedCallback = null;
|
|
2439
|
-
this.initPromise = null;
|
|
2440
|
-
this.config = {
|
|
2441
|
-
projectId: config.projectId,
|
|
2442
|
-
appName: config.appName
|
|
2443
|
-
};
|
|
2444
|
-
}
|
|
2445
|
-
async ensureInitialized() {
|
|
2446
|
-
if (this.provider) return;
|
|
2447
|
-
if (!this.initPromise) {
|
|
2448
|
-
this.initPromise = this.initializeProvider();
|
|
2449
|
-
}
|
|
2450
|
-
await this.initPromise;
|
|
2451
|
-
}
|
|
2452
|
-
async initializeProvider() {
|
|
2453
|
-
if (typeof window === "undefined") return;
|
|
2454
|
-
const { EthereumProvider } = await import("@walletconnect/ethereum-provider");
|
|
2455
|
-
this.provider = await EthereumProvider.init({
|
|
2456
|
-
projectId: this.config.projectId ?? "",
|
|
2457
|
-
optionalChains: [1],
|
|
2458
|
-
showQrModal: false,
|
|
2459
|
-
metadata: {
|
|
2460
|
-
name: this.config.appName,
|
|
2461
|
-
description: this.config.appName,
|
|
2462
|
-
url: window.location.origin,
|
|
2463
|
-
icons: []
|
|
2464
|
-
}
|
|
2465
|
-
});
|
|
2466
|
-
this.provider.on("display_uri", (uri) => {
|
|
2467
|
-
this.connectionUri = uri;
|
|
2468
|
-
if (typeof window !== "undefined") {
|
|
2469
|
-
window.dispatchEvent(new CustomEvent("walletconnect:uri", { detail: { uri } }));
|
|
2470
|
-
}
|
|
2471
|
-
});
|
|
2472
|
-
this.provider.on("connect", (session) => {
|
|
2473
|
-
if (typeof window !== "undefined") {
|
|
2474
|
-
window.dispatchEvent(new CustomEvent("walletconnect:connect", { detail: { session } }));
|
|
2475
|
-
}
|
|
2476
|
-
});
|
|
2477
|
-
this.provider.on("disconnect", () => {
|
|
2478
|
-
this.connectionUri = null;
|
|
2479
|
-
});
|
|
2480
|
-
this.provider.on("session_delete", () => {
|
|
2481
|
-
if (typeof window !== "undefined") {
|
|
2482
|
-
window.dispatchEvent(new CustomEvent("walletconnect:disconnect"));
|
|
2483
|
-
}
|
|
2484
|
-
});
|
|
2485
|
-
}
|
|
2486
|
-
isInstalled() {
|
|
2487
|
-
return true;
|
|
2488
|
-
}
|
|
2489
|
-
async connect() {
|
|
2490
|
-
if (!this.config.projectId) {
|
|
2491
|
-
throw createConfigError("WalletConnect");
|
|
2492
|
-
}
|
|
2493
|
-
try {
|
|
2494
|
-
await this.ensureInitialized();
|
|
2495
|
-
if (!this.provider) {
|
|
2496
|
-
sentryLogger.error("connect: WalletConnect is not available");
|
|
2497
|
-
throw new Error("WalletConnect is not available");
|
|
2498
|
-
}
|
|
2499
|
-
const accounts = await this.provider.enable();
|
|
2500
|
-
if (!accounts || accounts.length === 0 || !accounts[0]) {
|
|
2501
|
-
sentryLogger.error("connect: No accounts returned from WalletConnect");
|
|
2502
|
-
throw new Error("No accounts returned from WalletConnect");
|
|
2503
|
-
}
|
|
2504
|
-
return {
|
|
2505
|
-
address: accounts[0],
|
|
2506
|
-
provider: this.provider,
|
|
2507
|
-
walletId: this.id
|
|
2508
|
-
};
|
|
2509
|
-
} catch {
|
|
2510
|
-
this.connectionUri = null;
|
|
2511
|
-
throw new Error("Failed to connect to WalletConnect");
|
|
2512
|
-
}
|
|
2513
|
-
}
|
|
2514
|
-
getConnectionUri() {
|
|
2515
|
-
return this.connectionUri;
|
|
2516
|
-
}
|
|
2517
|
-
/**
|
|
2518
|
-
* Starts a WalletConnect session for headless/custom QR code flows.
|
|
2519
|
-
* Returns the URI immediately and a function to wait for the connection.
|
|
2520
|
-
*/
|
|
2521
|
-
async startSession(timeout = 1e4) {
|
|
2522
|
-
if (!this.config.projectId) {
|
|
2523
|
-
throw new Error("WalletConnect projectId is required");
|
|
2524
|
-
}
|
|
2525
|
-
await this.ensureInitialized();
|
|
2526
|
-
if (!this.provider) {
|
|
2527
|
-
sentryLogger.error("startSession: WalletConnect is not available");
|
|
2528
|
-
throw new Error("WalletConnect is not available");
|
|
2529
|
-
}
|
|
2530
|
-
this.connectionUri = null;
|
|
2531
|
-
const uriPromise = new Promise((resolve, reject) => {
|
|
2532
|
-
const timeoutId = setTimeout(() => {
|
|
2533
|
-
reject(new Error("Timeout waiting for WalletConnect URI"));
|
|
2534
|
-
}, timeout);
|
|
2535
|
-
this.provider.once("display_uri", (uri2) => {
|
|
2536
|
-
clearTimeout(timeoutId);
|
|
2537
|
-
this.connectionUri = uri2;
|
|
2538
|
-
resolve(uri2);
|
|
2539
|
-
});
|
|
2540
|
-
});
|
|
2541
|
-
const connectionPromise = (async () => {
|
|
2542
|
-
const accounts = await this.provider.enable();
|
|
2543
|
-
if (!accounts || accounts.length === 0 || !accounts[0]) {
|
|
2544
|
-
sentryLogger.error("startSession: No accounts returned from WalletConnect");
|
|
2545
|
-
throw new Error("No accounts returned from WalletConnect");
|
|
2546
|
-
}
|
|
2547
|
-
return {
|
|
2548
|
-
address: accounts[0],
|
|
2549
|
-
provider: this.provider,
|
|
2550
|
-
walletId: this.id
|
|
2551
|
-
};
|
|
2552
|
-
})();
|
|
2553
|
-
const uri = await uriPromise;
|
|
2554
|
-
return {
|
|
2555
|
-
uri,
|
|
2556
|
-
waitForConnection: async () => {
|
|
2557
|
-
try {
|
|
2558
|
-
return await connectionPromise;
|
|
2559
|
-
} catch {
|
|
2560
|
-
this.connectionUri = null;
|
|
2561
|
-
throw new Error("Failed to connect via WalletConnect");
|
|
2562
|
-
}
|
|
2563
|
-
}
|
|
2564
|
-
};
|
|
2565
|
-
}
|
|
2566
|
-
async tryRestoreConnection() {
|
|
2567
|
-
try {
|
|
2568
|
-
await this.ensureInitialized();
|
|
2569
|
-
if (!this.provider) {
|
|
2570
|
-
return null;
|
|
2571
|
-
}
|
|
2572
|
-
const accounts = this.provider.accounts;
|
|
2573
|
-
if (!accounts || accounts.length === 0 || !accounts[0]) {
|
|
2574
|
-
return null;
|
|
2575
|
-
}
|
|
2576
|
-
return {
|
|
2577
|
-
address: accounts[0],
|
|
2578
|
-
provider: this.provider,
|
|
2579
|
-
walletId: this.id
|
|
2580
|
-
};
|
|
2581
|
-
} catch {
|
|
2582
|
-
return null;
|
|
2583
|
-
}
|
|
2584
|
-
}
|
|
2585
|
-
async disconnect() {
|
|
2586
|
-
try {
|
|
2587
|
-
if (this.provider) {
|
|
2588
|
-
await this.provider.disconnect();
|
|
2589
|
-
}
|
|
2590
|
-
} finally {
|
|
2591
|
-
this.connectionUri = null;
|
|
2592
|
-
this.provider = null;
|
|
2593
|
-
this.initPromise = null;
|
|
2594
|
-
}
|
|
2595
|
-
}
|
|
2596
|
-
getProvider() {
|
|
2597
|
-
return this.provider;
|
|
2598
|
-
}
|
|
2599
|
-
// Called by Aurum when user connects wallet
|
|
2600
|
-
// Passes Aurum.ts --> syncStateFromAccountsChanged() to handle the provider accounts changed event
|
|
2601
|
-
onAccountsChanged(callback) {
|
|
2602
|
-
if (!this.provider?.on) return;
|
|
2603
|
-
if (this.accountsChangedCallback) {
|
|
2604
|
-
this.provider.removeListener?.("accountsChanged", this.accountsChangedCallback);
|
|
2605
|
-
}
|
|
2606
|
-
this.accountsChangedCallback = callback;
|
|
2607
|
-
this.provider.on("accountsChanged", this.accountsChangedCallback);
|
|
2608
|
-
}
|
|
2609
|
-
removeListeners() {
|
|
2610
|
-
if (!this.provider?.removeListener || !this.accountsChangedCallback) return;
|
|
2611
|
-
this.provider.removeListener("accountsChanged", this.accountsChangedCallback);
|
|
2612
|
-
this.accountsChangedCallback = null;
|
|
2613
|
-
}
|
|
2614
|
-
};
|
|
2615
|
-
|
|
2616
2163
|
// src/hooks/useConnectSelectedWallet.tsx
|
|
2164
|
+
import { WalletId as WalletId8 } from "@aurum-sdk/types";
|
|
2617
2165
|
var useConnectSelectedWallet = () => {
|
|
2618
2166
|
const { navigateTo } = useNavigation();
|
|
2619
2167
|
const connectInstalledWallet = async ({ adapter, onConnect, setSuccess }) => {
|
|
@@ -2633,7 +2181,7 @@ var useConnectSelectedWallet = () => {
|
|
|
2633
2181
|
}
|
|
2634
2182
|
};
|
|
2635
2183
|
const connectUninstalledWalletQRCode = async ({ displayedWallets, onConnect, setSuccess }) => {
|
|
2636
|
-
const walletConnectAdapter = displayedWallets?.find((
|
|
2184
|
+
const walletConnectAdapter = displayedWallets?.find(({ id }) => id === WalletId8.WalletConnect);
|
|
2637
2185
|
if (!walletConnectAdapter) {
|
|
2638
2186
|
sentryLogger.error("connectUninstalledWalletQRCode: WalletConnect adapter not found");
|
|
2639
2187
|
throw new Error("WalletConnect adapter not found");
|
|
@@ -2659,7 +2207,7 @@ var useConnectSelectedWallet = () => {
|
|
|
2659
2207
|
onConnect,
|
|
2660
2208
|
setSuccess
|
|
2661
2209
|
}) => {
|
|
2662
|
-
const walletConnectAdapter = displayedWallets?.find((
|
|
2210
|
+
const walletConnectAdapter = displayedWallets?.find(({ id }) => id === WalletId8.WalletConnect);
|
|
2663
2211
|
if (!walletConnectAdapter) {
|
|
2664
2212
|
sentryLogger.error("connectWithMobileDeepLink: WalletConnect adapter not found");
|
|
2665
2213
|
throw new Error("WalletConnect adapter not found");
|
|
@@ -2721,7 +2269,7 @@ var useConnectSelectedWallet = () => {
|
|
|
2721
2269
|
};
|
|
2722
2270
|
|
|
2723
2271
|
// src/contexts/ConnectModalContext.tsx
|
|
2724
|
-
import { WalletId as
|
|
2272
|
+
import { WalletId as WalletId9 } from "@aurum-sdk/types";
|
|
2725
2273
|
import { jsx as jsx43 } from "react/jsx-runtime";
|
|
2726
2274
|
var ConnectModalContext = createContext4(null);
|
|
2727
2275
|
var useConnectModal = () => {
|
|
@@ -2756,12 +2304,12 @@ var ConnectModalProvider = ({ children, displayedWallets, onConnect }) => {
|
|
|
2756
2304
|
const isDesktop = !isOnMobile;
|
|
2757
2305
|
const hasDeepLink = Boolean(wallet.wcDeepLinkUrl);
|
|
2758
2306
|
if (isDesktop) {
|
|
2759
|
-
if (wallet
|
|
2307
|
+
if (wallet.id === WalletId9.AppKit)
|
|
2760
2308
|
return await connectAppKit({ adapter: wallet, onConnect, setSuccess: setQrSuccess });
|
|
2761
2309
|
if (!wallet.isInstalled() && !hasDeepLink) {
|
|
2762
2310
|
return await redirectToDownloadPage();
|
|
2763
2311
|
}
|
|
2764
|
-
if (wallet.id ===
|
|
2312
|
+
if (wallet.id === WalletId9.WalletConnect || !wallet.isInstalled())
|
|
2765
2313
|
return await connectUninstalledWalletQRCode({
|
|
2766
2314
|
adapter: wallet,
|
|
2767
2315
|
displayedWallets,
|
|
@@ -2771,11 +2319,11 @@ var ConnectModalProvider = ({ children, displayedWallets, onConnect }) => {
|
|
|
2771
2319
|
return await connectInstalledWallet({ adapter: wallet, onConnect, setSuccess });
|
|
2772
2320
|
}
|
|
2773
2321
|
if (isOnMobile) {
|
|
2774
|
-
if (wallet.id ===
|
|
2775
|
-
const appkitAdapter = displayedWallets?.find((
|
|
2322
|
+
if (wallet.id === WalletId9.WalletConnect || wallet.id === WalletId9.AppKit) {
|
|
2323
|
+
const appkitAdapter = displayedWallets?.find(({ id }) => id === WalletId9.AppKit);
|
|
2776
2324
|
if (!appkitAdapter) {
|
|
2777
|
-
sentryLogger.error("
|
|
2778
|
-
throw new Error("
|
|
2325
|
+
sentryLogger.error("AppKit adapter not found");
|
|
2326
|
+
throw new Error("AppKit adapter not found");
|
|
2779
2327
|
}
|
|
2780
2328
|
return await connectAppKit({ adapter: appkitAdapter, onConnect, setSuccess: setQrSuccess });
|
|
2781
2329
|
}
|
|
@@ -2883,11 +2431,9 @@ export {
|
|
|
2883
2431
|
initSentry,
|
|
2884
2432
|
sentryLogger,
|
|
2885
2433
|
createConfigError,
|
|
2886
|
-
AppKitAdapter,
|
|
2887
2434
|
isMobile,
|
|
2888
|
-
WalletConnectAdapter,
|
|
2889
2435
|
ConnectUIProviders,
|
|
2890
2436
|
ConnectPages,
|
|
2891
2437
|
generateCompleteStyles
|
|
2892
2438
|
};
|
|
2893
|
-
//# sourceMappingURL=chunk-
|
|
2439
|
+
//# sourceMappingURL=chunk-BSMOPBPL.mjs.map
|