@aurum-sdk/core 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Aurum-B0Okb4Qv.d.mts +294 -0
- package/dist/Aurum-B0Okb4Qv.d.ts +294 -0
- package/dist/{chunk-KD3A4VYB.js → chunk-2P33GXLJ.js} +2 -2
- package/dist/{chunk-UPYYZG5D.mjs → chunk-64XDE56K.mjs} +2 -2
- package/dist/index.d.mts +55 -268
- package/dist/index.d.ts +55 -268
- package/dist/index.js +399 -236
- package/dist/index.mjs +330 -167
- package/dist/widgets.d.mts +1 -1
- package/dist/widgets.d.ts +1 -1
- package/dist/widgets.js +12 -12
- package/dist/widgets.mjs +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
var
|
|
19
|
+
var _chunk2P33GXLJjs = require('./chunk-2P33GXLJ.js');
|
|
20
20
|
require('./chunk-4EBNC4R3.js');
|
|
21
21
|
|
|
22
22
|
|
|
@@ -64,20 +64,20 @@ var _react = require('react');
|
|
|
64
64
|
var _jsxruntime = require('react/jsx-runtime');
|
|
65
65
|
var ModalShell = ({ onClose, brandConfig }) => {
|
|
66
66
|
const [isOpen, setIsOpen] = _react.useState.call(void 0, true);
|
|
67
|
-
const { currentPage } =
|
|
67
|
+
const { currentPage } = _chunk2P33GXLJjs.useNavigation.call(void 0, );
|
|
68
68
|
const handleClose = () => {
|
|
69
69
|
setIsOpen(false);
|
|
70
70
|
onClose();
|
|
71
71
|
};
|
|
72
72
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
73
|
-
|
|
73
|
+
_chunk2P33GXLJjs.Modal,
|
|
74
74
|
{
|
|
75
75
|
isOpen,
|
|
76
76
|
closeOnOverlayClick: true,
|
|
77
77
|
onCloseComplete: handleClose,
|
|
78
78
|
brandConfig,
|
|
79
79
|
transitionKey: currentPage,
|
|
80
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
80
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2P33GXLJjs.ConnectPages, {})
|
|
81
81
|
}
|
|
82
82
|
);
|
|
83
83
|
};
|
|
@@ -91,7 +91,7 @@ _chunkQIPVNM7Tjs.init_polyfills.call(void 0, );
|
|
|
91
91
|
function createShadowRoot(container, brandConfig) {
|
|
92
92
|
const shadowRoot = container.attachShadow({ mode: "open" });
|
|
93
93
|
shadowRoot.innerHTML = `
|
|
94
|
-
<style>${
|
|
94
|
+
<style>${_chunk2P33GXLJjs.generateCompleteStyles.call(void 0, brandConfig)}</style>
|
|
95
95
|
<div class="aurum-modal-root"></div>
|
|
96
96
|
`;
|
|
97
97
|
return shadowRoot.querySelector(".aurum-modal-root");
|
|
@@ -128,7 +128,7 @@ function renderConnectModal({
|
|
|
128
128
|
brandConfig
|
|
129
129
|
}) {
|
|
130
130
|
return new Promise((resolve, reject) => {
|
|
131
|
-
const sortedWallets =
|
|
131
|
+
const sortedWallets = _chunk2P33GXLJjs.sortWallets.call(void 0, displayedWallets, { filterHidden: false });
|
|
132
132
|
const { root, cleanup } = createModalContainer(CONTAINER_ID, brandConfig);
|
|
133
133
|
const onConnect = (result) => {
|
|
134
134
|
cleanup();
|
|
@@ -139,7 +139,7 @@ function renderConnectModal({
|
|
|
139
139
|
reject(new Error("User rejected request"));
|
|
140
140
|
};
|
|
141
141
|
root.render(
|
|
142
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
142
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2P33GXLJjs.ThemeContainer, { theme: brandConfig.theme, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk2P33GXLJjs.ConnectUIProviders, { onConnect, displayedWallets: sortedWallets, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ModalShell, { onClose, brandConfig }) }) })
|
|
143
143
|
);
|
|
144
144
|
});
|
|
145
145
|
}
|
|
@@ -155,9 +155,9 @@ _chunkQIPVNM7Tjs.init_polyfills.call(void 0, );
|
|
|
155
155
|
var RABBY_RDNS = "io.rabby";
|
|
156
156
|
var RabbyAdapter = class {
|
|
157
157
|
constructor() {
|
|
158
|
-
this.id =
|
|
159
|
-
this.name =
|
|
160
|
-
this.icon = _nullishCoalesce(
|
|
158
|
+
this.id = _chunk2P33GXLJjs.WalletId.Rabby;
|
|
159
|
+
this.name = _chunk2P33GXLJjs.WalletName.Rabby;
|
|
160
|
+
this.icon = _nullishCoalesce(_chunk2P33GXLJjs.getLogoDataUri.call(void 0, _chunk2P33GXLJjs.WalletId.Rabby, "brand"), () => ( ""));
|
|
161
161
|
this.hide = false;
|
|
162
162
|
this.downloadUrl = "https://rabby.io";
|
|
163
163
|
this.wcDeepLinkUrl = null;
|
|
@@ -216,7 +216,7 @@ var RabbyAdapter = class {
|
|
|
216
216
|
await this.providerPromise;
|
|
217
217
|
}
|
|
218
218
|
if (!this.provider) {
|
|
219
|
-
|
|
219
|
+
_chunk2P33GXLJjs.sentryLogger.error("Rabby is not available");
|
|
220
220
|
throw new Error("Rabby is not available");
|
|
221
221
|
}
|
|
222
222
|
await this.provider.request({
|
|
@@ -228,7 +228,7 @@ var RabbyAdapter = class {
|
|
|
228
228
|
params: []
|
|
229
229
|
});
|
|
230
230
|
if (!accounts || accounts.length === 0 || !accounts[0]) {
|
|
231
|
-
|
|
231
|
+
_chunk2P33GXLJjs.sentryLogger.error("No accounts returned from Rabby");
|
|
232
232
|
throw new Error("No accounts returned from Rabby");
|
|
233
233
|
}
|
|
234
234
|
return {
|
|
@@ -297,9 +297,9 @@ function isBraveBrowser() {
|
|
|
297
297
|
var BRAVE_RDNS = "com.brave.wallet";
|
|
298
298
|
var BraveAdapter = class {
|
|
299
299
|
constructor() {
|
|
300
|
-
this.id =
|
|
301
|
-
this.name =
|
|
302
|
-
this.icon = _nullishCoalesce(
|
|
300
|
+
this.id = _chunk2P33GXLJjs.WalletId.Brave;
|
|
301
|
+
this.name = _chunk2P33GXLJjs.WalletName.Brave;
|
|
302
|
+
this.icon = _nullishCoalesce(_chunk2P33GXLJjs.getLogoDataUri.call(void 0, _chunk2P33GXLJjs.WalletId.Brave, "brand"), () => ( ""));
|
|
303
303
|
this.downloadUrl = "https://brave.com/download";
|
|
304
304
|
this.wcDeepLinkUrl = null;
|
|
305
305
|
this.provider = null;
|
|
@@ -362,7 +362,7 @@ var BraveAdapter = class {
|
|
|
362
362
|
await this.providerPromise;
|
|
363
363
|
}
|
|
364
364
|
if (!this.provider) {
|
|
365
|
-
|
|
365
|
+
_chunk2P33GXLJjs.sentryLogger.error("Brave Wallet is not available");
|
|
366
366
|
throw new Error("Brave Wallet is not available");
|
|
367
367
|
}
|
|
368
368
|
await this.provider.request({
|
|
@@ -374,7 +374,7 @@ var BraveAdapter = class {
|
|
|
374
374
|
params: []
|
|
375
375
|
});
|
|
376
376
|
if (!accounts || accounts.length === 0 || !accounts[0]) {
|
|
377
|
-
|
|
377
|
+
_chunk2P33GXLJjs.sentryLogger.error("No accounts returned from Brave Wallet");
|
|
378
378
|
throw new Error("No accounts returned from Brave Wallet");
|
|
379
379
|
}
|
|
380
380
|
return {
|
|
@@ -434,9 +434,9 @@ _chunkQIPVNM7Tjs.init_polyfills.call(void 0, );
|
|
|
434
434
|
var PHANTOM_RDNS = "app.phantom";
|
|
435
435
|
var PhantomAdapter = class {
|
|
436
436
|
constructor() {
|
|
437
|
-
this.id =
|
|
438
|
-
this.name =
|
|
439
|
-
this.icon = _nullishCoalesce(
|
|
437
|
+
this.id = _chunk2P33GXLJjs.WalletId.Phantom;
|
|
438
|
+
this.name = _chunk2P33GXLJjs.WalletName.Phantom;
|
|
439
|
+
this.icon = _nullishCoalesce(_chunk2P33GXLJjs.getLogoDataUri.call(void 0, _chunk2P33GXLJjs.WalletId.Phantom, "brand"), () => ( ""));
|
|
440
440
|
this.hide = false;
|
|
441
441
|
this.downloadUrl = "https://phantom.com/download";
|
|
442
442
|
this.wcDeepLinkUrl = "phantom://wc?uri=";
|
|
@@ -500,7 +500,7 @@ var PhantomAdapter = class {
|
|
|
500
500
|
await this.providerPromise;
|
|
501
501
|
}
|
|
502
502
|
if (!this.provider) {
|
|
503
|
-
|
|
503
|
+
_chunk2P33GXLJjs.sentryLogger.error("Phantom is not available");
|
|
504
504
|
throw new Error("Phantom is not available");
|
|
505
505
|
}
|
|
506
506
|
await this.provider.request({
|
|
@@ -512,7 +512,7 @@ var PhantomAdapter = class {
|
|
|
512
512
|
params: []
|
|
513
513
|
});
|
|
514
514
|
if (!accounts || accounts.length === 0 || !accounts[0]) {
|
|
515
|
-
|
|
515
|
+
_chunk2P33GXLJjs.sentryLogger.error("No accounts returned from Phantom");
|
|
516
516
|
throw new Error("No accounts returned from Phantom");
|
|
517
517
|
}
|
|
518
518
|
return {
|
|
@@ -571,9 +571,9 @@ var PhantomAdapter = class {
|
|
|
571
571
|
_chunkQIPVNM7Tjs.init_polyfills.call(void 0, );
|
|
572
572
|
var CoinbaseWalletAdapter = class {
|
|
573
573
|
constructor({ appName, appLogoUrl, telemetry }) {
|
|
574
|
-
this.id =
|
|
575
|
-
this.name =
|
|
576
|
-
this.icon = _nullishCoalesce(
|
|
574
|
+
this.id = _chunk2P33GXLJjs.WalletId.CoinbaseWallet;
|
|
575
|
+
this.name = _chunk2P33GXLJjs.WalletName.CoinbaseWallet;
|
|
576
|
+
this.icon = _nullishCoalesce(_chunk2P33GXLJjs.getLogoDataUri.call(void 0, _chunk2P33GXLJjs.WalletId.CoinbaseWallet, "brand"), () => ( ""));
|
|
577
577
|
this.hide = false;
|
|
578
578
|
this.downloadUrl = "https://www.coinbase.com/wallet/downloads";
|
|
579
579
|
this.wcDeepLinkUrl = "cbwallet://wc?uri=";
|
|
@@ -603,7 +603,7 @@ var CoinbaseWalletAdapter = class {
|
|
|
603
603
|
});
|
|
604
604
|
this.provider = coinbaseSdk.getProvider();
|
|
605
605
|
} catch (error) {
|
|
606
|
-
|
|
606
|
+
_chunk2P33GXLJjs.sentryLogger.warn("Failed to initialize Coinbase Wallet provider", { error });
|
|
607
607
|
}
|
|
608
608
|
}
|
|
609
609
|
isInstalled() {
|
|
@@ -612,7 +612,7 @@ var CoinbaseWalletAdapter = class {
|
|
|
612
612
|
async connect() {
|
|
613
613
|
await this.ensureInitialized();
|
|
614
614
|
if (!this.provider) {
|
|
615
|
-
|
|
615
|
+
_chunk2P33GXLJjs.sentryLogger.error("Coinbase Wallet is not available");
|
|
616
616
|
throw new Error("Coinbase Wallet is not available");
|
|
617
617
|
}
|
|
618
618
|
const accounts = await this.provider.request({
|
|
@@ -620,7 +620,7 @@ var CoinbaseWalletAdapter = class {
|
|
|
620
620
|
params: []
|
|
621
621
|
});
|
|
622
622
|
if (!accounts || accounts.length === 0 || !accounts[0]) {
|
|
623
|
-
|
|
623
|
+
_chunk2P33GXLJjs.sentryLogger.error("No accounts returned from Coinbase Wallet");
|
|
624
624
|
throw new Error("No accounts returned from Coinbase Wallet");
|
|
625
625
|
}
|
|
626
626
|
return {
|
|
@@ -660,7 +660,7 @@ var CoinbaseWalletAdapter = class {
|
|
|
660
660
|
await this.provider.disconnect();
|
|
661
661
|
}
|
|
662
662
|
} catch (error) {
|
|
663
|
-
|
|
663
|
+
_chunk2P33GXLJjs.sentryLogger.warn("Error disconnecting from Coinbase Wallet", { error });
|
|
664
664
|
} finally {
|
|
665
665
|
this.clearLocalStorage();
|
|
666
666
|
}
|
|
@@ -703,9 +703,9 @@ _chunkQIPVNM7Tjs.init_polyfills.call(void 0, );
|
|
|
703
703
|
var METAMASK_RDNS = "io.metamask";
|
|
704
704
|
var MetaMaskAdapter = class {
|
|
705
705
|
constructor() {
|
|
706
|
-
this.id =
|
|
707
|
-
this.name =
|
|
708
|
-
this.icon = _nullishCoalesce(
|
|
706
|
+
this.id = _chunk2P33GXLJjs.WalletId.MetaMask;
|
|
707
|
+
this.name = _chunk2P33GXLJjs.WalletName.MetaMask;
|
|
708
|
+
this.icon = _nullishCoalesce(_chunk2P33GXLJjs.getLogoDataUri.call(void 0, _chunk2P33GXLJjs.WalletId.MetaMask, "brand"), () => ( ""));
|
|
709
709
|
this.hide = false;
|
|
710
710
|
this.downloadUrl = "https://metamask.io/download";
|
|
711
711
|
this.wcDeepLinkUrl = "metamask://wc?uri=";
|
|
@@ -770,7 +770,7 @@ var MetaMaskAdapter = class {
|
|
|
770
770
|
await this.providerPromise;
|
|
771
771
|
}
|
|
772
772
|
if (!this.provider) {
|
|
773
|
-
|
|
773
|
+
_chunk2P33GXLJjs.sentryLogger.error("MetaMask is not available");
|
|
774
774
|
throw new Error("MetaMask is not available");
|
|
775
775
|
}
|
|
776
776
|
await this.provider.request({
|
|
@@ -782,7 +782,7 @@ var MetaMaskAdapter = class {
|
|
|
782
782
|
params: []
|
|
783
783
|
});
|
|
784
784
|
if (!accounts || accounts.length === 0 || !accounts[0]) {
|
|
785
|
-
|
|
785
|
+
_chunk2P33GXLJjs.sentryLogger.error("No accounts returned from MetaMask");
|
|
786
786
|
throw new Error("No accounts returned from MetaMask");
|
|
787
787
|
}
|
|
788
788
|
return {
|
|
@@ -934,9 +934,9 @@ function extractAddressFromSession(namespaces) {
|
|
|
934
934
|
}
|
|
935
935
|
var WalletConnectAdapter = class {
|
|
936
936
|
constructor(config) {
|
|
937
|
-
this.id =
|
|
938
|
-
this.name =
|
|
939
|
-
this.icon = _nullishCoalesce(
|
|
937
|
+
this.id = _chunk2P33GXLJjs.WalletId.WalletConnect;
|
|
938
|
+
this.name = _chunk2P33GXLJjs.WalletName.WalletConnect;
|
|
939
|
+
this.icon = _nullishCoalesce(_chunk2P33GXLJjs.getLogoDataUri.call(void 0, _chunk2P33GXLJjs.WalletId.WalletConnect, "brand"), () => ( ""));
|
|
940
940
|
this.hide = false;
|
|
941
941
|
this.downloadUrl = null;
|
|
942
942
|
this.wcDeepLinkUrl = null;
|
|
@@ -1074,13 +1074,13 @@ var WalletConnectAdapter = class {
|
|
|
1074
1074
|
this.provider = provider;
|
|
1075
1075
|
}
|
|
1076
1076
|
} catch (error) {
|
|
1077
|
-
|
|
1077
|
+
_chunk2P33GXLJjs.sentryLogger.warn("Failed to get provider from wagmi connector", { error });
|
|
1078
1078
|
}
|
|
1079
1079
|
}
|
|
1080
1080
|
}
|
|
1081
1081
|
}
|
|
1082
1082
|
} catch (error) {
|
|
1083
|
-
|
|
1083
|
+
_chunk2P33GXLJjs.sentryLogger.warn("Failed to get provider from WalletConnect", { error });
|
|
1084
1084
|
}
|
|
1085
1085
|
}
|
|
1086
1086
|
isInstalled() {
|
|
@@ -1123,7 +1123,7 @@ var WalletConnectAdapter = class {
|
|
|
1123
1123
|
* Emits walletconnect:uri event for QR code display.
|
|
1124
1124
|
*/
|
|
1125
1125
|
async connect() {
|
|
1126
|
-
if (!this.config.projectId) throw
|
|
1126
|
+
if (!this.config.projectId) throw _chunk2P33GXLJjs.createConfigError.call(void 0, "WalletConnect");
|
|
1127
1127
|
await this.ensureInitialized();
|
|
1128
1128
|
if (!this.universalProvider) throw new Error("WalletConnect is not available");
|
|
1129
1129
|
await this.resetConnectionState();
|
|
@@ -1186,7 +1186,7 @@ var WalletConnectAdapter = class {
|
|
|
1186
1186
|
* Used on mobile and when user clicks "Open Modal" button.
|
|
1187
1187
|
*/
|
|
1188
1188
|
async openModal() {
|
|
1189
|
-
if (!this.config.projectId) throw
|
|
1189
|
+
if (!this.config.projectId) throw _chunk2P33GXLJjs.createConfigError.call(void 0, "WalletConnect");
|
|
1190
1190
|
await this.ensureInitialized();
|
|
1191
1191
|
if (!this.modal) throw new Error("AppKit is not available");
|
|
1192
1192
|
await this.resetConnectionState();
|
|
@@ -1365,9 +1365,9 @@ var WalletConnectAdapter = class {
|
|
|
1365
1365
|
_chunkQIPVNM7Tjs.init_polyfills.call(void 0, );
|
|
1366
1366
|
var _EmailAdapter = class _EmailAdapter {
|
|
1367
1367
|
constructor(config) {
|
|
1368
|
-
this.id =
|
|
1369
|
-
this.name =
|
|
1370
|
-
this.icon = _nullishCoalesce(
|
|
1368
|
+
this.id = _chunk2P33GXLJjs.WalletId.Email;
|
|
1369
|
+
this.name = _chunk2P33GXLJjs.WalletName.Email;
|
|
1370
|
+
this.icon = _nullishCoalesce(_chunk2P33GXLJjs.getLogoDataUri.call(void 0, _chunk2P33GXLJjs.WalletId.Email, "brand"), () => ( ""));
|
|
1371
1371
|
this.hide = true;
|
|
1372
1372
|
this.downloadUrl = null;
|
|
1373
1373
|
this.wcDeepLinkUrl = null;
|
|
@@ -1389,11 +1389,11 @@ var _EmailAdapter = class _EmailAdapter {
|
|
|
1389
1389
|
}
|
|
1390
1390
|
async emailAuthStart(email) {
|
|
1391
1391
|
if (!this.projectId) {
|
|
1392
|
-
throw
|
|
1392
|
+
throw _chunk2P33GXLJjs.createConfigError.call(void 0, "Email");
|
|
1393
1393
|
}
|
|
1394
1394
|
await this.ensureInitialized();
|
|
1395
1395
|
if (!this.provider) {
|
|
1396
|
-
|
|
1396
|
+
_chunk2P33GXLJjs.sentryLogger.error("Email is not available");
|
|
1397
1397
|
throw new Error("Email is not available");
|
|
1398
1398
|
}
|
|
1399
1399
|
const { signInWithEmail } = await Promise.resolve().then(() => _interopRequireWildcard(require("./index.web-V7DLWC7H.js")));
|
|
@@ -1406,14 +1406,14 @@ var _EmailAdapter = class _EmailAdapter {
|
|
|
1406
1406
|
}
|
|
1407
1407
|
await this.ensureInitialized();
|
|
1408
1408
|
if (!this.provider) {
|
|
1409
|
-
|
|
1409
|
+
_chunk2P33GXLJjs.sentryLogger.error("Email provider not initialized");
|
|
1410
1410
|
throw new Error("Email provider not initialized");
|
|
1411
1411
|
}
|
|
1412
1412
|
const { verifyEmailOTP } = await Promise.resolve().then(() => _interopRequireWildcard(require("./index.web-V7DLWC7H.js")));
|
|
1413
1413
|
return verifyEmailOTP({ flowId, otp });
|
|
1414
1414
|
}
|
|
1415
1415
|
async connect() {
|
|
1416
|
-
|
|
1416
|
+
_chunk2P33GXLJjs.sentryLogger.error("EmailAdapter.connect() is not implemented");
|
|
1417
1417
|
throw new Error("EmailAdapter.connect() is not implemented");
|
|
1418
1418
|
}
|
|
1419
1419
|
async tryRestoreConnection() {
|
|
@@ -1526,7 +1526,7 @@ var _EmailAdapter = class _EmailAdapter {
|
|
|
1526
1526
|
const chainIdHex = await base.request({ method: "eth_chainId", params: [] });
|
|
1527
1527
|
chainId = parseInt(chainIdHex, 16);
|
|
1528
1528
|
} catch (e13) {
|
|
1529
|
-
|
|
1529
|
+
_chunk2P33GXLJjs.sentryLogger.error("Failed to get chainId for fallback request");
|
|
1530
1530
|
throw new Error("Failed to get chainId for fallback request");
|
|
1531
1531
|
}
|
|
1532
1532
|
const publicClient = await getPublicClient(chainId);
|
|
@@ -1541,7 +1541,7 @@ var _EmailAdapter = class _EmailAdapter {
|
|
|
1541
1541
|
};
|
|
1542
1542
|
return wrapped;
|
|
1543
1543
|
} catch (error) {
|
|
1544
|
-
|
|
1544
|
+
_chunk2P33GXLJjs.sentryLogger.error("Failed to initialize Email provider", { error });
|
|
1545
1545
|
return null;
|
|
1546
1546
|
}
|
|
1547
1547
|
}
|
|
@@ -1656,6 +1656,81 @@ var RpcProvider = class {
|
|
|
1656
1656
|
}
|
|
1657
1657
|
};
|
|
1658
1658
|
|
|
1659
|
+
// src/errors.ts
|
|
1660
|
+
_chunkQIPVNM7Tjs.init_polyfills.call(void 0, );
|
|
1661
|
+
var AurumError = class extends Error {
|
|
1662
|
+
constructor(message, cause) {
|
|
1663
|
+
super(message);
|
|
1664
|
+
this.name = this.constructor.name;
|
|
1665
|
+
this.cause = cause;
|
|
1666
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
1667
|
+
}
|
|
1668
|
+
};
|
|
1669
|
+
var UserRejectedError = class extends AurumError {
|
|
1670
|
+
constructor() {
|
|
1671
|
+
super(...arguments);
|
|
1672
|
+
this.code = "USER_REJECTED";
|
|
1673
|
+
}
|
|
1674
|
+
};
|
|
1675
|
+
var ChainSwitchRejectedError = class extends AurumError {
|
|
1676
|
+
constructor() {
|
|
1677
|
+
super(...arguments);
|
|
1678
|
+
this.code = "CHAIN_SWITCH_REJECTED";
|
|
1679
|
+
}
|
|
1680
|
+
};
|
|
1681
|
+
var WalletNotInstalledError = class extends AurumError {
|
|
1682
|
+
constructor(walletId, cause) {
|
|
1683
|
+
super(`${walletId} is not installed`, cause);
|
|
1684
|
+
this.walletId = walletId;
|
|
1685
|
+
this.code = "WALLET_NOT_INSTALLED";
|
|
1686
|
+
}
|
|
1687
|
+
};
|
|
1688
|
+
var WalletNotConfiguredError = class extends AurumError {
|
|
1689
|
+
constructor(walletId, cause) {
|
|
1690
|
+
super(`${walletId} is not configured`, cause);
|
|
1691
|
+
this.walletId = walletId;
|
|
1692
|
+
this.code = "WALLET_NOT_CONFIGURED";
|
|
1693
|
+
}
|
|
1694
|
+
};
|
|
1695
|
+
var WalletExcludedError = class extends AurumError {
|
|
1696
|
+
constructor(walletId, cause) {
|
|
1697
|
+
super(`${walletId} is excluded from wallet options`, cause);
|
|
1698
|
+
this.walletId = walletId;
|
|
1699
|
+
this.code = "WALLET_EXCLUDED";
|
|
1700
|
+
}
|
|
1701
|
+
};
|
|
1702
|
+
var ChainNotSupportedError = class extends AurumError {
|
|
1703
|
+
constructor() {
|
|
1704
|
+
super(...arguments);
|
|
1705
|
+
this.code = "CHAIN_NOT_SUPPORTED";
|
|
1706
|
+
}
|
|
1707
|
+
};
|
|
1708
|
+
var InvalidConfigError = class extends AurumError {
|
|
1709
|
+
constructor() {
|
|
1710
|
+
super(...arguments);
|
|
1711
|
+
this.code = "INVALID_CONFIG";
|
|
1712
|
+
}
|
|
1713
|
+
};
|
|
1714
|
+
var ConnectionError = class extends AurumError {
|
|
1715
|
+
constructor() {
|
|
1716
|
+
super(...arguments);
|
|
1717
|
+
this.code = "CONNECTION_FAILED";
|
|
1718
|
+
}
|
|
1719
|
+
};
|
|
1720
|
+
var USER_REJECTION_REGEX = /user (rejected|denied|cancel(l?)ed)/i;
|
|
1721
|
+
function normalizeError(err, context) {
|
|
1722
|
+
if (err instanceof AurumError) return err;
|
|
1723
|
+
const rawCode = _optionalChain([err, 'optionalAccess', _139 => _139.code]);
|
|
1724
|
+
const rawMessage = _optionalChain([err, 'optionalAccess', _140 => _140.message]);
|
|
1725
|
+
const message = typeof rawMessage === "string" ? rawMessage : "Unknown error";
|
|
1726
|
+
const isRejectionCode = rawCode === 4001 || rawCode === "4001" || rawCode === "ACTION_REJECTED";
|
|
1727
|
+
const isRejectionMessage = typeof rawMessage === "string" && USER_REJECTION_REGEX.test(rawMessage);
|
|
1728
|
+
if (isRejectionCode || isRejectionMessage) {
|
|
1729
|
+
return _optionalChain([context, 'optionalAccess', _141 => _141.operation]) === "switchChain" ? new ChainSwitchRejectedError(message, err) : new UserRejectedError(message, err);
|
|
1730
|
+
}
|
|
1731
|
+
return new ConnectionError(message, err);
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1659
1734
|
// src/AurumCore.ts
|
|
1660
1735
|
var _AurumCore = class _AurumCore {
|
|
1661
1736
|
constructor(config) {
|
|
@@ -1664,6 +1739,26 @@ var _AurumCore = class _AurumCore {
|
|
|
1664
1739
|
this.userInfo = void 0;
|
|
1665
1740
|
this.connectedWalletAdapter = null;
|
|
1666
1741
|
this.eventListeners = /* @__PURE__ */ new Map();
|
|
1742
|
+
// EIP-1193 event listener passthroughs. Delegates to the proxy rpcProvider so listeners survive
|
|
1743
|
+
// provider swaps (connect/disconnect) without consumers needing to re-register.
|
|
1744
|
+
this.on = (event, listener) => {
|
|
1745
|
+
this.rpcProvider.on(
|
|
1746
|
+
event,
|
|
1747
|
+
listener
|
|
1748
|
+
);
|
|
1749
|
+
};
|
|
1750
|
+
this.off = (event, listener) => {
|
|
1751
|
+
this.rpcProvider.removeListener(
|
|
1752
|
+
event,
|
|
1753
|
+
listener
|
|
1754
|
+
);
|
|
1755
|
+
};
|
|
1756
|
+
this.removeListener = (event, listener) => {
|
|
1757
|
+
this.rpcProvider.removeListener(
|
|
1758
|
+
event,
|
|
1759
|
+
listener
|
|
1760
|
+
);
|
|
1761
|
+
};
|
|
1667
1762
|
if (_AurumCore.instance) {
|
|
1668
1763
|
const incoming = _AurumCore.serializeConfig(config);
|
|
1669
1764
|
if (incoming !== null && incoming !== _AurumCore.storedConfigJson) {
|
|
@@ -1675,9 +1770,9 @@ var _AurumCore = class _AurumCore {
|
|
|
1675
1770
|
}
|
|
1676
1771
|
_AurumCore.storedConfigJson = _AurumCore.serializeConfig(config);
|
|
1677
1772
|
const telemetryEnabled = config.telemetry !== false;
|
|
1678
|
-
|
|
1773
|
+
_chunk2P33GXLJjs.initSentry.call(void 0, telemetryEnabled);
|
|
1679
1774
|
this.brandConfig = this.resolveBrandConfig(config);
|
|
1680
|
-
this.excludedWallets = new Set(_nullishCoalesce(_optionalChain([config, 'access',
|
|
1775
|
+
this.excludedWallets = new Set(_nullishCoalesce(_optionalChain([config, 'access', _142 => _142.wallets, 'optionalAccess', _143 => _143.exclude]), () => ( [])));
|
|
1681
1776
|
this.wallets = createWalletAdapters({
|
|
1682
1777
|
walletsConfig: config.wallets,
|
|
1683
1778
|
appName: this.brandConfig.appName,
|
|
@@ -1717,79 +1812,87 @@ var _AurumCore = class _AurumCore {
|
|
|
1717
1812
|
return this.excludedWallets;
|
|
1718
1813
|
}
|
|
1719
1814
|
async connect(walletId) {
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
if (_optionalChain([this, 'access', _141 => _141.userInfo, 'optionalAccess', _142 => _142.publicAddress]) && _optionalChain([this, 'access', _143 => _143.connectedWalletAdapter, 'optionalAccess', _144 => _144.getProvider, 'call', _145 => _145()])) {
|
|
1725
|
-
if (!walletId || this.userInfo.walletId === walletId) {
|
|
1726
|
-
return this.userInfo.publicAddress;
|
|
1727
|
-
}
|
|
1728
|
-
await this.disconnect();
|
|
1729
|
-
}
|
|
1730
|
-
let adapter = null;
|
|
1731
|
-
let result;
|
|
1732
|
-
if (walletId) {
|
|
1733
|
-
if (this.excludedWallets.has(walletId)) {
|
|
1734
|
-
throw new Error(`${walletId} is excluded from wallet options`);
|
|
1815
|
+
try {
|
|
1816
|
+
await this.whenReady();
|
|
1817
|
+
if (walletId === "email") {
|
|
1818
|
+
throw new InvalidConfigError("Use emailAuthStart() and emailAuthVerify() for email wallet connections");
|
|
1735
1819
|
}
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1820
|
+
if (_optionalChain([this, 'access', _144 => _144.userInfo, 'optionalAccess', _145 => _145.publicAddress]) && _optionalChain([this, 'access', _146 => _146.connectedWalletAdapter, 'optionalAccess', _147 => _147.getProvider, 'call', _148 => _148()])) {
|
|
1821
|
+
if (!walletId || this.userInfo.walletId === walletId) {
|
|
1822
|
+
return this.userInfo.publicAddress;
|
|
1823
|
+
}
|
|
1824
|
+
await this.disconnect();
|
|
1739
1825
|
}
|
|
1740
|
-
|
|
1741
|
-
|
|
1826
|
+
let adapter = null;
|
|
1827
|
+
let result;
|
|
1828
|
+
if (walletId) {
|
|
1829
|
+
if (this.excludedWallets.has(walletId)) {
|
|
1830
|
+
throw new WalletExcludedError(walletId);
|
|
1831
|
+
}
|
|
1832
|
+
adapter = this.wallets.find((w) => w.id === walletId) || null;
|
|
1833
|
+
if (!adapter) {
|
|
1834
|
+
throw new WalletNotConfiguredError(walletId);
|
|
1835
|
+
}
|
|
1836
|
+
if (walletId === _chunk2P33GXLJjs.WalletId.WalletConnect && adapter.openModal) {
|
|
1837
|
+
result = await adapter.openModal();
|
|
1838
|
+
} else {
|
|
1839
|
+
if (!adapter.isInstalled()) {
|
|
1840
|
+
throw new WalletNotInstalledError(adapter.name);
|
|
1841
|
+
}
|
|
1842
|
+
result = await adapter.connect();
|
|
1843
|
+
}
|
|
1742
1844
|
} else {
|
|
1743
|
-
|
|
1744
|
-
|
|
1845
|
+
const displayedWallets = this.wallets.filter((w) => !this.excludedWallets.has(w.id));
|
|
1846
|
+
const modalResult = await renderConnectModal({ displayedWallets, brandConfig: this.brandConfig });
|
|
1847
|
+
if (!modalResult) {
|
|
1848
|
+
_chunk2P33GXLJjs.sentryLogger.error("Missing modal result");
|
|
1849
|
+
throw new ConnectionError("Missing modal result");
|
|
1745
1850
|
}
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
_chunkKD3A4VYBjs.sentryLogger.error("Missing modal result");
|
|
1753
|
-
throw new Error("Missing modal result");
|
|
1851
|
+
adapter = this.wallets.find((w) => w.id === modalResult.walletId) || null;
|
|
1852
|
+
if (!adapter) {
|
|
1853
|
+
_chunk2P33GXLJjs.sentryLogger.error(`Selected wallet adapter not found: ${modalResult.walletId}`);
|
|
1854
|
+
throw new ConnectionError("Selected wallet adapter not found");
|
|
1855
|
+
}
|
|
1856
|
+
result = modalResult;
|
|
1754
1857
|
}
|
|
1755
|
-
|
|
1756
|
-
if (!
|
|
1757
|
-
|
|
1758
|
-
throw new
|
|
1858
|
+
const provider = _nullishCoalesce(result.provider, () => ( adapter.getProvider()));
|
|
1859
|
+
if (!provider) {
|
|
1860
|
+
_chunk2P33GXLJjs.sentryLogger.error(`Error fetching provider on login: ${adapter.id}`);
|
|
1861
|
+
throw new ConnectionError("Error fetching provider. Please try again.");
|
|
1759
1862
|
}
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
this.emitConnect(chainId);
|
|
1780
|
-
this.emitAccountsChanged([checksumAdr]);
|
|
1781
|
-
_chunkKD3A4VYBjs.sentryLogger.info(`Wallet connected: ${adapter.id} (${walletId ? "headless" : "modal"})`);
|
|
1782
|
-
return checksumAdr;
|
|
1863
|
+
const checksumAdr = _viem.checksumAddress.call(void 0, result.address);
|
|
1864
|
+
this.connectedWalletAdapter = adapter;
|
|
1865
|
+
this.updateProvider(provider);
|
|
1866
|
+
this.userInfo = {
|
|
1867
|
+
publicAddress: checksumAdr,
|
|
1868
|
+
walletName: adapter.name,
|
|
1869
|
+
walletId: adapter.id,
|
|
1870
|
+
email: result.email
|
|
1871
|
+
};
|
|
1872
|
+
this.persistConnectionState(adapter, checksumAdr, result.email);
|
|
1873
|
+
this.setInternalAccountChangeListener(adapter);
|
|
1874
|
+
const chainId = await provider.request({ method: "eth_chainId" });
|
|
1875
|
+
this.emitConnect(chainId);
|
|
1876
|
+
this.emitAccountsChanged([checksumAdr]);
|
|
1877
|
+
_chunk2P33GXLJjs.sentryLogger.info(`Wallet connected: ${adapter.id} (${walletId ? "headless" : "modal"})`);
|
|
1878
|
+
return checksumAdr;
|
|
1879
|
+
} catch (err) {
|
|
1880
|
+
throw normalizeError(err, { operation: "connect" });
|
|
1881
|
+
}
|
|
1783
1882
|
}
|
|
1784
1883
|
async disconnect() {
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
this.connectedWalletAdapter
|
|
1788
|
-
|
|
1884
|
+
try {
|
|
1885
|
+
await this.whenReady();
|
|
1886
|
+
if (this.connectedWalletAdapter) {
|
|
1887
|
+
this.connectedWalletAdapter.removeListeners();
|
|
1888
|
+
await this.connectedWalletAdapter.disconnect();
|
|
1889
|
+
}
|
|
1890
|
+
this.resetConnectionState();
|
|
1891
|
+
this.emitDisconnect();
|
|
1892
|
+
this.emitAccountsChanged([]);
|
|
1893
|
+
} catch (err) {
|
|
1894
|
+
throw normalizeError(err, { operation: "disconnect" });
|
|
1789
1895
|
}
|
|
1790
|
-
this.resetConnectionState();
|
|
1791
|
-
this.emitDisconnect();
|
|
1792
|
-
this.emitAccountsChanged([]);
|
|
1793
1896
|
}
|
|
1794
1897
|
async getUserInfo() {
|
|
1795
1898
|
await this.whenReady();
|
|
@@ -1798,34 +1901,38 @@ var _AurumCore = class _AurumCore {
|
|
|
1798
1901
|
async isConnected() {
|
|
1799
1902
|
await this.whenReady();
|
|
1800
1903
|
return Boolean(
|
|
1801
|
-
_optionalChain([this, 'access',
|
|
1904
|
+
_optionalChain([this, 'access', _149 => _149.userInfo, 'optionalAccess', _150 => _150.publicAddress]) && _optionalChain([this, 'access', _151 => _151.userInfo, 'optionalAccess', _152 => _152.walletName]) && _optionalChain([this, 'access', _153 => _153.connectedWalletAdapter, 'optionalAccess', _154 => _154.getProvider, 'call', _155 => _155()])
|
|
1802
1905
|
);
|
|
1803
1906
|
}
|
|
1804
1907
|
async handleWidgetConnection(result) {
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1908
|
+
try {
|
|
1909
|
+
await this.whenReady();
|
|
1910
|
+
const adapter = this.wallets.find((w) => w.id === result.walletId) || null;
|
|
1911
|
+
if (!adapter) throw new ConnectionError("Selected wallet adapter not found");
|
|
1912
|
+
const provider = _nullishCoalesce(result.provider, () => ( adapter.getProvider()));
|
|
1913
|
+
if (!provider) {
|
|
1914
|
+
_chunk2P33GXLJjs.sentryLogger.error(`Error fetching provider on widget login: ${_optionalChain([result, 'optionalAccess', _156 => _156.walletId])}`);
|
|
1915
|
+
throw new ConnectionError("Error fetching provider. Please try again.");
|
|
1916
|
+
}
|
|
1917
|
+
const checksumAdr = _viem.checksumAddress.call(void 0, result.address);
|
|
1918
|
+
this.connectedWalletAdapter = adapter;
|
|
1919
|
+
this.updateProvider(provider);
|
|
1920
|
+
this.userInfo = {
|
|
1921
|
+
publicAddress: checksumAdr,
|
|
1922
|
+
walletName: adapter.name,
|
|
1923
|
+
walletId: adapter.id,
|
|
1924
|
+
email: result.email
|
|
1925
|
+
};
|
|
1926
|
+
this.persistConnectionState(adapter, checksumAdr, result.email);
|
|
1927
|
+
this.setInternalAccountChangeListener(adapter);
|
|
1928
|
+
const chainId = await provider.request({ method: "eth_chainId" });
|
|
1929
|
+
this.emitConnect(chainId);
|
|
1930
|
+
this.emitAccountsChanged([checksumAdr]);
|
|
1931
|
+
_chunk2P33GXLJjs.sentryLogger.info(`Wallet connected: ${adapter.id} (widget)`);
|
|
1932
|
+
return this.userInfo;
|
|
1933
|
+
} catch (err) {
|
|
1934
|
+
throw normalizeError(err, { operation: "connect" });
|
|
1935
|
+
}
|
|
1829
1936
|
}
|
|
1830
1937
|
async getChainId() {
|
|
1831
1938
|
await this.whenReady();
|
|
@@ -1833,17 +1940,21 @@ var _AurumCore = class _AurumCore {
|
|
|
1833
1940
|
return Number(chainId);
|
|
1834
1941
|
}
|
|
1835
1942
|
async switchChain(chainId, chain) {
|
|
1836
|
-
await this.whenReady();
|
|
1837
|
-
const hexChainId = normalizeChainId(chainId);
|
|
1838
1943
|
try {
|
|
1839
|
-
await this.
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1944
|
+
await this.whenReady();
|
|
1945
|
+
const hexChainId = normalizeChainId(chainId);
|
|
1946
|
+
try {
|
|
1947
|
+
await this.attemptSwitchChain(hexChainId);
|
|
1948
|
+
} catch (switchError) {
|
|
1949
|
+
if (!isChainNotAddedError(switchError) || !chain) throw switchError;
|
|
1950
|
+
await this.handleMissingChain(hexChainId, chain);
|
|
1951
|
+
}
|
|
1952
|
+
} catch (err) {
|
|
1953
|
+
throw normalizeError(err, { operation: "switchChain" });
|
|
1843
1954
|
}
|
|
1844
1955
|
}
|
|
1845
1956
|
updateBrandConfig(newConfig) {
|
|
1846
|
-
const defaultTheme =
|
|
1957
|
+
const defaultTheme = _chunk2P33GXLJjs.getDefaultThemeConfig.call(void 0, _nullishCoalesce(newConfig.theme, () => ( this.brandConfig.theme)));
|
|
1847
1958
|
this.brandConfig = {
|
|
1848
1959
|
logo: "logo" in newConfig ? _nullishCoalesce(newConfig.logo, () => ( defaultTheme.logo)) : this.brandConfig.logo,
|
|
1849
1960
|
theme: "theme" in newConfig ? _nullishCoalesce(newConfig.theme, () => ( defaultTheme.theme)) : this.brandConfig.theme,
|
|
@@ -1856,8 +1967,8 @@ var _AurumCore = class _AurumCore {
|
|
|
1856
1967
|
walletLayout: "walletLayout" in newConfig ? _nullishCoalesce(newConfig.walletLayout, () => ( defaultTheme.walletLayout)) : this.brandConfig.walletLayout
|
|
1857
1968
|
};
|
|
1858
1969
|
if ("theme" in newConfig && this.brandConfig.theme) {
|
|
1859
|
-
const wcAdapter = this.wallets.find((w) => w.id ===
|
|
1860
|
-
_optionalChain([wcAdapter, 'optionalAccess',
|
|
1970
|
+
const wcAdapter = this.wallets.find((w) => w.id === _chunk2P33GXLJjs.WalletId.WalletConnect);
|
|
1971
|
+
_optionalChain([wcAdapter, 'optionalAccess', _157 => _157.updateTheme, 'call', _158 => _158(this.brandConfig.theme)]);
|
|
1861
1972
|
}
|
|
1862
1973
|
}
|
|
1863
1974
|
updateWalletsConfig(newConfig) {
|
|
@@ -1871,13 +1982,17 @@ var _AurumCore = class _AurumCore {
|
|
|
1871
1982
|
* @returns flowId to use with emailAuthVerify
|
|
1872
1983
|
*/
|
|
1873
1984
|
async emailAuthStart(email) {
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1985
|
+
try {
|
|
1986
|
+
await this.whenReady();
|
|
1987
|
+
const emailAdapter = this.wallets.find((w) => w.id === _chunk2P33GXLJjs.WalletId.Email);
|
|
1988
|
+
if (!emailAdapter || !emailAdapter.emailAuthStart) {
|
|
1989
|
+
throw new WalletNotConfiguredError("email");
|
|
1990
|
+
}
|
|
1991
|
+
const result = await emailAdapter.emailAuthStart(email);
|
|
1992
|
+
return { flowId: result.flowId };
|
|
1993
|
+
} catch (err) {
|
|
1994
|
+
throw normalizeError(err, { operation: "emailAuthStart" });
|
|
1878
1995
|
}
|
|
1879
|
-
const result = await emailAdapter.emailAuthStart(email);
|
|
1880
|
-
return { flowId: result.flowId };
|
|
1881
1996
|
}
|
|
1882
1997
|
/**
|
|
1883
1998
|
* Verifies the email OTP and completes the connection.
|
|
@@ -1886,77 +2001,89 @@ var _AurumCore = class _AurumCore {
|
|
|
1886
2001
|
* @returns The connected wallet address and email
|
|
1887
2002
|
*/
|
|
1888
2003
|
async emailAuthVerify(flowId, otp) {
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
2004
|
+
try {
|
|
2005
|
+
await this.whenReady();
|
|
2006
|
+
const emailAdapter = this.wallets.find((w) => w.id === _chunk2P33GXLJjs.WalletId.Email);
|
|
2007
|
+
if (!emailAdapter || !emailAdapter.emailAuthVerify) {
|
|
2008
|
+
throw new WalletNotConfiguredError("email");
|
|
2009
|
+
}
|
|
2010
|
+
const verifyResult = await emailAdapter.emailAuthVerify(flowId, otp);
|
|
2011
|
+
const provider = emailAdapter.getProvider();
|
|
2012
|
+
if (!provider) {
|
|
2013
|
+
_chunk2P33GXLJjs.sentryLogger.error("Failed to get provider after email verification");
|
|
2014
|
+
throw new ConnectionError("Failed to get provider after email verification");
|
|
2015
|
+
}
|
|
2016
|
+
const address = _optionalChain([verifyResult, 'access', _159 => _159.user, 'optionalAccess', _160 => _160.evmAccounts, 'optionalAccess', _161 => _161[0]]);
|
|
2017
|
+
const email = _optionalChain([verifyResult, 'access', _162 => _162.user, 'optionalAccess', _163 => _163.authenticationMethods, 'optionalAccess', _164 => _164.email, 'optionalAccess', _165 => _165.email]);
|
|
2018
|
+
if (!address || !email) {
|
|
2019
|
+
_chunk2P33GXLJjs.sentryLogger.error("Address or email not found after email verification");
|
|
2020
|
+
throw new ConnectionError("Address or email not found after email verification");
|
|
2021
|
+
}
|
|
2022
|
+
const checksumAdr = _viem.checksumAddress.call(void 0, address);
|
|
2023
|
+
this.connectedWalletAdapter = emailAdapter;
|
|
2024
|
+
this.updateProvider(provider);
|
|
2025
|
+
this.userInfo = {
|
|
2026
|
+
publicAddress: checksumAdr,
|
|
2027
|
+
walletName: emailAdapter.name,
|
|
2028
|
+
walletId: emailAdapter.id,
|
|
2029
|
+
email
|
|
2030
|
+
};
|
|
2031
|
+
this.persistConnectionState(emailAdapter, checksumAdr, email);
|
|
2032
|
+
this.setInternalAccountChangeListener(emailAdapter);
|
|
2033
|
+
const chainId = await provider.request({ method: "eth_chainId" });
|
|
2034
|
+
this.emitConnect(chainId);
|
|
2035
|
+
this.emitAccountsChanged([checksumAdr]);
|
|
2036
|
+
_chunk2P33GXLJjs.sentryLogger.info(`Wallet connected: ${emailAdapter.id} (headless)`);
|
|
2037
|
+
return { address: checksumAdr, email: _nullishCoalesce(email, () => ( "")), isNewUser: _nullishCoalesce(verifyResult.isNewUser, () => ( false)) };
|
|
2038
|
+
} catch (err) {
|
|
2039
|
+
throw normalizeError(err, { operation: "emailAuthVerify" });
|
|
2040
|
+
}
|
|
1922
2041
|
}
|
|
1923
2042
|
/**
|
|
1924
2043
|
* Initiates a WalletConnect session and returns the URI for displaying a custom QR code.
|
|
1925
2044
|
* @returns URI string and a promise that resolves when the user connects
|
|
1926
2045
|
*/
|
|
1927
2046
|
async getWalletConnectSession() {
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
const session = await wcAdapter.startSession();
|
|
1934
|
-
return {
|
|
1935
|
-
uri: session.uri,
|
|
1936
|
-
waitForConnection: async () => {
|
|
1937
|
-
const result = await session.waitForConnection();
|
|
1938
|
-
const provider = _nullishCoalesce(result.provider, () => ( wcAdapter.getProvider()));
|
|
1939
|
-
if (!provider) {
|
|
1940
|
-
_chunkKD3A4VYBjs.sentryLogger.error("Failed to get provider after WalletConnect connection");
|
|
1941
|
-
throw new Error("Failed to get provider after WalletConnect connection");
|
|
1942
|
-
}
|
|
1943
|
-
const checksumAdr = _viem.checksumAddress.call(void 0, result.address);
|
|
1944
|
-
this.connectedWalletAdapter = wcAdapter;
|
|
1945
|
-
this.updateProvider(provider);
|
|
1946
|
-
this.userInfo = {
|
|
1947
|
-
publicAddress: checksumAdr,
|
|
1948
|
-
walletName: wcAdapter.name,
|
|
1949
|
-
walletId: wcAdapter.id
|
|
1950
|
-
};
|
|
1951
|
-
this.persistConnectionState(wcAdapter, checksumAdr);
|
|
1952
|
-
this.setInternalAccountChangeListener(wcAdapter);
|
|
1953
|
-
const chainId = await provider.request({ method: "eth_chainId" });
|
|
1954
|
-
this.emitConnect(chainId);
|
|
1955
|
-
this.emitAccountsChanged([checksumAdr]);
|
|
1956
|
-
_chunkKD3A4VYBjs.sentryLogger.info(`Wallet connected: ${wcAdapter.id} (headless)`);
|
|
1957
|
-
return checksumAdr;
|
|
2047
|
+
try {
|
|
2048
|
+
await this.whenReady();
|
|
2049
|
+
const wcAdapter = this.wallets.find((w) => w.id === _chunk2P33GXLJjs.WalletId.WalletConnect);
|
|
2050
|
+
if (!wcAdapter) {
|
|
2051
|
+
throw new WalletNotConfiguredError("walletconnect");
|
|
1958
2052
|
}
|
|
1959
|
-
|
|
2053
|
+
const session = await wcAdapter.startSession();
|
|
2054
|
+
return {
|
|
2055
|
+
uri: session.uri,
|
|
2056
|
+
waitForConnection: async () => {
|
|
2057
|
+
try {
|
|
2058
|
+
const result = await session.waitForConnection();
|
|
2059
|
+
const provider = _nullishCoalesce(result.provider, () => ( wcAdapter.getProvider()));
|
|
2060
|
+
if (!provider) {
|
|
2061
|
+
_chunk2P33GXLJjs.sentryLogger.error("Failed to get provider after WalletConnect connection");
|
|
2062
|
+
throw new ConnectionError("Failed to get provider after WalletConnect connection");
|
|
2063
|
+
}
|
|
2064
|
+
const checksumAdr = _viem.checksumAddress.call(void 0, result.address);
|
|
2065
|
+
this.connectedWalletAdapter = wcAdapter;
|
|
2066
|
+
this.updateProvider(provider);
|
|
2067
|
+
this.userInfo = {
|
|
2068
|
+
publicAddress: checksumAdr,
|
|
2069
|
+
walletName: wcAdapter.name,
|
|
2070
|
+
walletId: wcAdapter.id
|
|
2071
|
+
};
|
|
2072
|
+
this.persistConnectionState(wcAdapter, checksumAdr);
|
|
2073
|
+
this.setInternalAccountChangeListener(wcAdapter);
|
|
2074
|
+
const chainId = await provider.request({ method: "eth_chainId" });
|
|
2075
|
+
this.emitConnect(chainId);
|
|
2076
|
+
this.emitAccountsChanged([checksumAdr]);
|
|
2077
|
+
_chunk2P33GXLJjs.sentryLogger.info(`Wallet connected: ${wcAdapter.id} (headless)`);
|
|
2078
|
+
return checksumAdr;
|
|
2079
|
+
} catch (err) {
|
|
2080
|
+
throw normalizeError(err, { operation: "connect" });
|
|
2081
|
+
}
|
|
2082
|
+
}
|
|
2083
|
+
};
|
|
2084
|
+
} catch (err) {
|
|
2085
|
+
throw normalizeError(err, { operation: "connect" });
|
|
2086
|
+
}
|
|
1960
2087
|
}
|
|
1961
2088
|
/* PROVIDER METHODS */
|
|
1962
2089
|
createProviderProxy() {
|
|
@@ -1969,15 +2096,15 @@ var _AurumCore = class _AurumCore {
|
|
|
1969
2096
|
}
|
|
1970
2097
|
this.eventListeners.get(event).add(callback);
|
|
1971
2098
|
if (!_AurumCore.MANAGED_EVENTS.includes(event)) {
|
|
1972
|
-
_optionalChain([this, 'access',
|
|
2099
|
+
_optionalChain([this, 'access', _166 => _166.currentProvider, 'access', _167 => _167.on, 'optionalCall', _168 => _168(event, callback)]);
|
|
1973
2100
|
}
|
|
1974
2101
|
};
|
|
1975
2102
|
}
|
|
1976
2103
|
if (prop === "removeListener") {
|
|
1977
2104
|
return (event, callback) => {
|
|
1978
|
-
_optionalChain([this, 'access',
|
|
2105
|
+
_optionalChain([this, 'access', _169 => _169.eventListeners, 'access', _170 => _170.get, 'call', _171 => _171(event), 'optionalAccess', _172 => _172.delete, 'call', _173 => _173(callback)]);
|
|
1979
2106
|
if (!_AurumCore.MANAGED_EVENTS.includes(event)) {
|
|
1980
|
-
_optionalChain([this, 'access',
|
|
2107
|
+
_optionalChain([this, 'access', _174 => _174.currentProvider, 'access', _175 => _175.removeListener, 'optionalCall', _176 => _176(event, callback)]);
|
|
1981
2108
|
}
|
|
1982
2109
|
};
|
|
1983
2110
|
}
|
|
@@ -2002,7 +2129,7 @@ var _AurumCore = class _AurumCore {
|
|
|
2002
2129
|
this.eventListeners.forEach((callbacks, event) => {
|
|
2003
2130
|
if (!_AurumCore.MANAGED_EVENTS.includes(event)) {
|
|
2004
2131
|
callbacks.forEach((callback) => {
|
|
2005
|
-
_optionalChain([newProvider, 'access',
|
|
2132
|
+
_optionalChain([newProvider, 'access', _177 => _177.on, 'optionalCall', _178 => _178(event, callback)]);
|
|
2006
2133
|
});
|
|
2007
2134
|
}
|
|
2008
2135
|
});
|
|
@@ -2010,7 +2137,7 @@ var _AurumCore = class _AurumCore {
|
|
|
2010
2137
|
/* BRAND & THEME METHODS */
|
|
2011
2138
|
resolveBrandConfig(config) {
|
|
2012
2139
|
const { brand = {} } = config || {};
|
|
2013
|
-
const themeConfig =
|
|
2140
|
+
const themeConfig = _chunk2P33GXLJjs.getDefaultThemeConfig.call(void 0, brand.theme || _chunk2P33GXLJjs.DEFAULT_THEME);
|
|
2014
2141
|
return {
|
|
2015
2142
|
logo: _nullishCoalesce(brand.logo, () => ( themeConfig.logo)),
|
|
2016
2143
|
theme: _nullishCoalesce(brand.theme, () => ( themeConfig.theme)),
|
|
@@ -2029,8 +2156,8 @@ var _AurumCore = class _AurumCore {
|
|
|
2029
2156
|
return;
|
|
2030
2157
|
}
|
|
2031
2158
|
try {
|
|
2032
|
-
await
|
|
2033
|
-
const store =
|
|
2159
|
+
await _chunk2P33GXLJjs.waitForStoreHydration.call(void 0, );
|
|
2160
|
+
const store = _chunk2P33GXLJjs.useAurumStore.getState();
|
|
2034
2161
|
if (!store.isConnected || !store.walletId || !store.address || !store.walletName) {
|
|
2035
2162
|
return;
|
|
2036
2163
|
}
|
|
@@ -2060,7 +2187,7 @@ var _AurumCore = class _AurumCore {
|
|
|
2060
2187
|
}
|
|
2061
2188
|
}
|
|
2062
2189
|
persistConnectionState(adapter, address, email) {
|
|
2063
|
-
|
|
2190
|
+
_chunk2P33GXLJjs.useAurumStore.getState().setConnection(adapter.id, _viem.checksumAddress.call(void 0, address), adapter.name, email);
|
|
2064
2191
|
}
|
|
2065
2192
|
/* INTERNAL LISTENER METHODS */
|
|
2066
2193
|
setInternalAccountChangeListener(adapter) {
|
|
@@ -2074,14 +2201,14 @@ var _AurumCore = class _AurumCore {
|
|
|
2074
2201
|
}
|
|
2075
2202
|
async syncStateFromAccountsChanged(accounts) {
|
|
2076
2203
|
if (!accounts.length || !accounts[0]) return;
|
|
2077
|
-
const prevAccount = _optionalChain([this, 'access',
|
|
2204
|
+
const prevAccount = _optionalChain([this, 'access', _179 => _179.userInfo, 'optionalAccess', _180 => _180.publicAddress]);
|
|
2078
2205
|
const newAccount = _viem.checksumAddress.call(void 0, accounts[0]);
|
|
2079
2206
|
if (newAccount !== prevAccount) {
|
|
2080
2207
|
this.userInfo = {
|
|
2081
2208
|
publicAddress: newAccount,
|
|
2082
|
-
walletName: _optionalChain([this, 'access',
|
|
2083
|
-
walletId: _optionalChain([this, 'access',
|
|
2084
|
-
email: _optionalChain([this, 'access',
|
|
2209
|
+
walletName: _optionalChain([this, 'access', _181 => _181.userInfo, 'optionalAccess', _182 => _182.walletName]),
|
|
2210
|
+
walletId: _optionalChain([this, 'access', _183 => _183.userInfo, 'optionalAccess', _184 => _184.walletId]),
|
|
2211
|
+
email: _optionalChain([this, 'access', _185 => _185.userInfo, 'optionalAccess', _186 => _186.email])
|
|
2085
2212
|
};
|
|
2086
2213
|
if (this.connectedWalletAdapter) {
|
|
2087
2214
|
this.persistConnectionState(this.connectedWalletAdapter, newAccount, this.userInfo.email);
|
|
@@ -2140,8 +2267,8 @@ var _AurumCore = class _AurumCore {
|
|
|
2140
2267
|
}
|
|
2141
2268
|
}
|
|
2142
2269
|
async addChain(chain) {
|
|
2143
|
-
if (!_optionalChain([chain, 'optionalAccess',
|
|
2144
|
-
throw new
|
|
2270
|
+
if (!_optionalChain([chain, 'optionalAccess', _187 => _187.id]) || !_optionalChain([chain, 'optionalAccess', _188 => _188.name]) || !_optionalChain([chain, 'optionalAccess', _189 => _189.nativeCurrency]) || !_optionalChain([chain, 'optionalAccess', _190 => _190.rpcUrls, 'optionalAccess', _191 => _191.default, 'optionalAccess', _192 => _192.http])) {
|
|
2271
|
+
throw new InvalidConfigError("Invalid chain configuration: missing required properties");
|
|
2145
2272
|
}
|
|
2146
2273
|
await this.rpcProvider.request({
|
|
2147
2274
|
method: "wallet_addEthereumChain",
|
|
@@ -2158,7 +2285,7 @@ var _AurumCore = class _AurumCore {
|
|
|
2158
2285
|
}
|
|
2159
2286
|
/* REST */
|
|
2160
2287
|
resetConnectionState() {
|
|
2161
|
-
|
|
2288
|
+
_chunk2P33GXLJjs.useAurumStore.getState().clearConnection();
|
|
2162
2289
|
this.connectedWalletAdapter = null;
|
|
2163
2290
|
this.updateProvider(this.skeletonProvider);
|
|
2164
2291
|
this.userInfo = void 0;
|
|
@@ -2193,6 +2320,32 @@ var Aurum = class {
|
|
|
2193
2320
|
* ```
|
|
2194
2321
|
*/
|
|
2195
2322
|
constructor(config) {
|
|
2323
|
+
/**
|
|
2324
|
+
* Registers an EIP-1193 event listener on the wallet provider.
|
|
2325
|
+
* Listeners survive provider swaps (connect/disconnect) so consumers register once.
|
|
2326
|
+
*
|
|
2327
|
+
* @example
|
|
2328
|
+
* ```typescript
|
|
2329
|
+
* aurum.on('accountsChanged', (accounts) => console.log(accounts));
|
|
2330
|
+
* aurum.on('chainChanged', (chainId) => console.log(chainId));
|
|
2331
|
+
* ```
|
|
2332
|
+
*/
|
|
2333
|
+
this.on = (event, listener) => {
|
|
2334
|
+
this.core.on(event, listener);
|
|
2335
|
+
};
|
|
2336
|
+
/**
|
|
2337
|
+
* Removes an EIP-1193 event listener previously registered with `on()`.
|
|
2338
|
+
* Alias for `removeListener`.
|
|
2339
|
+
*/
|
|
2340
|
+
this.off = (event, listener) => {
|
|
2341
|
+
this.core.off(event, listener);
|
|
2342
|
+
};
|
|
2343
|
+
/**
|
|
2344
|
+
* Removes an EIP-1193 event listener previously registered with `on()`.
|
|
2345
|
+
*/
|
|
2346
|
+
this.removeListener = (event, listener) => {
|
|
2347
|
+
this.core.removeListener(event, listener);
|
|
2348
|
+
};
|
|
2196
2349
|
this.core = new AurumCore(config);
|
|
2197
2350
|
}
|
|
2198
2351
|
/**
|
|
@@ -2455,5 +2608,15 @@ var Aurum = class {
|
|
|
2455
2608
|
};
|
|
2456
2609
|
|
|
2457
2610
|
|
|
2458
|
-
|
|
2611
|
+
|
|
2612
|
+
|
|
2613
|
+
|
|
2614
|
+
|
|
2615
|
+
|
|
2616
|
+
|
|
2617
|
+
|
|
2618
|
+
|
|
2619
|
+
|
|
2620
|
+
|
|
2621
|
+
exports.Aurum = Aurum; exports.AurumError = AurumError; exports.ChainNotSupportedError = ChainNotSupportedError; exports.ChainSwitchRejectedError = ChainSwitchRejectedError; exports.ConnectionError = ConnectionError; exports.InvalidConfigError = InvalidConfigError; exports.UserRejectedError = UserRejectedError; exports.WalletExcludedError = WalletExcludedError; exports.WalletNotConfiguredError = WalletNotConfiguredError; exports.WalletNotInstalledError = WalletNotInstalledError; exports.normalizeError = normalizeError;
|
|
2459
2622
|
//# sourceMappingURL=index.js.map
|