@aurum-sdk/core 0.2.5 → 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-27AOACEW.js → chunk-2P33GXLJ.js} +2 -2
- package/dist/{chunk-X6ADRWYF.mjs → chunk-64XDE56K.mjs} +2 -2
- package/dist/empty-stub-JW2K2GSS.js +14 -0
- package/dist/empty-stub-X6WHS3X3.mjs +14 -0
- package/dist/index.d.mts +55 -268
- package/dist/index.d.ts +55 -268
- package/dist/index.js +428 -243
- package/dist/index.mjs +357 -172
- package/dist/{index.web-T26HBS3X.mjs → index.web-Q2L3EMC3.mjs} +2 -2
- package/dist/{index.web-WXUV52ZW.js → index.web-V7DLWC7H.js} +2 -2
- 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 +5 -5
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,14 +1389,14 @@ 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
|
-
const { signInWithEmail } = await Promise.resolve().then(() => _interopRequireWildcard(require("./index.web-
|
|
1399
|
+
const { signInWithEmail } = await Promise.resolve().then(() => _interopRequireWildcard(require("./index.web-V7DLWC7H.js")));
|
|
1400
1400
|
const authResult = await signInWithEmail({ email });
|
|
1401
1401
|
return authResult;
|
|
1402
1402
|
}
|
|
@@ -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
|
-
const { verifyEmailOTP } = await Promise.resolve().then(() => _interopRequireWildcard(require("./index.web-
|
|
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() {
|
|
@@ -1441,7 +1441,7 @@ var _EmailAdapter = class _EmailAdapter {
|
|
|
1441
1441
|
async disconnect() {
|
|
1442
1442
|
try {
|
|
1443
1443
|
await this.ensureInitialized();
|
|
1444
|
-
const { signOut } = await Promise.resolve().then(() => _interopRequireWildcard(require("./index.web-
|
|
1444
|
+
const { signOut } = await Promise.resolve().then(() => _interopRequireWildcard(require("./index.web-V7DLWC7H.js")));
|
|
1445
1445
|
await signOut();
|
|
1446
1446
|
} catch (e12) {
|
|
1447
1447
|
}
|
|
@@ -1487,7 +1487,7 @@ var _EmailAdapter = class _EmailAdapter {
|
|
|
1487
1487
|
* Called by ensureInitialized() - deduplication handled via initPromise.
|
|
1488
1488
|
*/
|
|
1489
1489
|
async initializeProvider() {
|
|
1490
|
-
const { initialize } = await Promise.resolve().then(() => _interopRequireWildcard(require("./index.web-
|
|
1490
|
+
const { initialize } = await Promise.resolve().then(() => _interopRequireWildcard(require("./index.web-V7DLWC7H.js")));
|
|
1491
1491
|
await initialize({
|
|
1492
1492
|
projectId: this.projectId,
|
|
1493
1493
|
ethereum: {
|
|
@@ -1505,7 +1505,7 @@ var _EmailAdapter = class _EmailAdapter {
|
|
|
1505
1505
|
async createProvider() {
|
|
1506
1506
|
try {
|
|
1507
1507
|
await _EmailAdapter.initializeChainData();
|
|
1508
|
-
const { createCDPEmbeddedWallet } = await Promise.resolve().then(() => _interopRequireWildcard(require("./index.web-
|
|
1508
|
+
const { createCDPEmbeddedWallet } = await Promise.resolve().then(() => _interopRequireWildcard(require("./index.web-V7DLWC7H.js")));
|
|
1509
1509
|
const wallet = createCDPEmbeddedWallet({
|
|
1510
1510
|
chains: _EmailAdapter.viemChains,
|
|
1511
1511
|
transports: _EmailAdapter.viemTransports
|
|
@@ -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,13 +1739,40 @@ 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) {
|
|
1763
|
+
const incoming = _AurumCore.serializeConfig(config);
|
|
1764
|
+
if (incoming !== null && incoming !== _AurumCore.storedConfigJson) {
|
|
1765
|
+
console.warn(
|
|
1766
|
+
"Aurum Constructor called a second time with a different config; the original config is kept. Use updateBrandConfig() / updateWalletsConfig() to change config at runtime."
|
|
1767
|
+
);
|
|
1768
|
+
}
|
|
1668
1769
|
return _AurumCore.instance;
|
|
1669
1770
|
}
|
|
1771
|
+
_AurumCore.storedConfigJson = _AurumCore.serializeConfig(config);
|
|
1670
1772
|
const telemetryEnabled = config.telemetry !== false;
|
|
1671
|
-
|
|
1773
|
+
_chunk2P33GXLJjs.initSentry.call(void 0, telemetryEnabled);
|
|
1672
1774
|
this.brandConfig = this.resolveBrandConfig(config);
|
|
1673
|
-
this.excludedWallets = new Set(_nullishCoalesce(_optionalChain([config, 'access',
|
|
1775
|
+
this.excludedWallets = new Set(_nullishCoalesce(_optionalChain([config, 'access', _142 => _142.wallets, 'optionalAccess', _143 => _143.exclude]), () => ( [])));
|
|
1674
1776
|
this.wallets = createWalletAdapters({
|
|
1675
1777
|
walletsConfig: config.wallets,
|
|
1676
1778
|
appName: this.brandConfig.appName,
|
|
@@ -1685,10 +1787,17 @@ var _AurumCore = class _AurumCore {
|
|
|
1685
1787
|
this.readyPromise = this.tryRestoreConnection();
|
|
1686
1788
|
_AurumCore.instance = this;
|
|
1687
1789
|
}
|
|
1790
|
+
static serializeConfig(config) {
|
|
1791
|
+
try {
|
|
1792
|
+
return JSON.stringify(config);
|
|
1793
|
+
} catch (e14) {
|
|
1794
|
+
return null;
|
|
1795
|
+
}
|
|
1796
|
+
}
|
|
1688
1797
|
async whenReady() {
|
|
1689
1798
|
try {
|
|
1690
1799
|
await this.readyPromise;
|
|
1691
|
-
} catch (
|
|
1800
|
+
} catch (e15) {
|
|
1692
1801
|
this.resetConnectionState();
|
|
1693
1802
|
this.ready = true;
|
|
1694
1803
|
}
|
|
@@ -1703,79 +1812,87 @@ var _AurumCore = class _AurumCore {
|
|
|
1703
1812
|
return this.excludedWallets;
|
|
1704
1813
|
}
|
|
1705
1814
|
async connect(walletId) {
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
if (_optionalChain([this, 'access', _141 => _141.userInfo, 'optionalAccess', _142 => _142.publicAddress]) && _optionalChain([this, 'access', _143 => _143.connectedWalletAdapter, 'optionalAccess', _144 => _144.getProvider, 'call', _145 => _145()])) {
|
|
1711
|
-
if (!walletId || this.userInfo.walletId === walletId) {
|
|
1712
|
-
return this.userInfo.publicAddress;
|
|
1713
|
-
}
|
|
1714
|
-
await this.disconnect();
|
|
1715
|
-
}
|
|
1716
|
-
let adapter = null;
|
|
1717
|
-
let result;
|
|
1718
|
-
if (walletId) {
|
|
1719
|
-
if (this.excludedWallets.has(walletId)) {
|
|
1720
|
-
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");
|
|
1721
1819
|
}
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
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();
|
|
1725
1825
|
}
|
|
1726
|
-
|
|
1727
|
-
|
|
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
|
+
}
|
|
1728
1844
|
} else {
|
|
1729
|
-
|
|
1730
|
-
|
|
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");
|
|
1731
1850
|
}
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
_chunk27AOACEWjs.sentryLogger.error("Missing modal result");
|
|
1739
|
-
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;
|
|
1740
1857
|
}
|
|
1741
|
-
|
|
1742
|
-
if (!
|
|
1743
|
-
|
|
1744
|
-
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.");
|
|
1745
1862
|
}
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
this.emitConnect(chainId);
|
|
1766
|
-
this.emitAccountsChanged([checksumAdr]);
|
|
1767
|
-
_chunk27AOACEWjs.sentryLogger.info(`Wallet connected: ${adapter.id} (${walletId ? "headless" : "modal"})`);
|
|
1768
|
-
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
|
+
}
|
|
1769
1882
|
}
|
|
1770
1883
|
async disconnect() {
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
this.connectedWalletAdapter
|
|
1774
|
-
|
|
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" });
|
|
1775
1895
|
}
|
|
1776
|
-
this.resetConnectionState();
|
|
1777
|
-
this.emitDisconnect();
|
|
1778
|
-
this.emitAccountsChanged([]);
|
|
1779
1896
|
}
|
|
1780
1897
|
async getUserInfo() {
|
|
1781
1898
|
await this.whenReady();
|
|
@@ -1784,34 +1901,38 @@ var _AurumCore = class _AurumCore {
|
|
|
1784
1901
|
async isConnected() {
|
|
1785
1902
|
await this.whenReady();
|
|
1786
1903
|
return Boolean(
|
|
1787
|
-
_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()])
|
|
1788
1905
|
);
|
|
1789
1906
|
}
|
|
1790
1907
|
async handleWidgetConnection(result) {
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
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
|
+
}
|
|
1815
1936
|
}
|
|
1816
1937
|
async getChainId() {
|
|
1817
1938
|
await this.whenReady();
|
|
@@ -1819,17 +1940,21 @@ var _AurumCore = class _AurumCore {
|
|
|
1819
1940
|
return Number(chainId);
|
|
1820
1941
|
}
|
|
1821
1942
|
async switchChain(chainId, chain) {
|
|
1822
|
-
await this.whenReady();
|
|
1823
|
-
const hexChainId = normalizeChainId(chainId);
|
|
1824
1943
|
try {
|
|
1825
|
-
await this.
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
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" });
|
|
1829
1954
|
}
|
|
1830
1955
|
}
|
|
1831
1956
|
updateBrandConfig(newConfig) {
|
|
1832
|
-
const defaultTheme =
|
|
1957
|
+
const defaultTheme = _chunk2P33GXLJjs.getDefaultThemeConfig.call(void 0, _nullishCoalesce(newConfig.theme, () => ( this.brandConfig.theme)));
|
|
1833
1958
|
this.brandConfig = {
|
|
1834
1959
|
logo: "logo" in newConfig ? _nullishCoalesce(newConfig.logo, () => ( defaultTheme.logo)) : this.brandConfig.logo,
|
|
1835
1960
|
theme: "theme" in newConfig ? _nullishCoalesce(newConfig.theme, () => ( defaultTheme.theme)) : this.brandConfig.theme,
|
|
@@ -1842,8 +1967,8 @@ var _AurumCore = class _AurumCore {
|
|
|
1842
1967
|
walletLayout: "walletLayout" in newConfig ? _nullishCoalesce(newConfig.walletLayout, () => ( defaultTheme.walletLayout)) : this.brandConfig.walletLayout
|
|
1843
1968
|
};
|
|
1844
1969
|
if ("theme" in newConfig && this.brandConfig.theme) {
|
|
1845
|
-
const wcAdapter = this.wallets.find((w) => w.id ===
|
|
1846
|
-
_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)]);
|
|
1847
1972
|
}
|
|
1848
1973
|
}
|
|
1849
1974
|
updateWalletsConfig(newConfig) {
|
|
@@ -1857,13 +1982,17 @@ var _AurumCore = class _AurumCore {
|
|
|
1857
1982
|
* @returns flowId to use with emailAuthVerify
|
|
1858
1983
|
*/
|
|
1859
1984
|
async emailAuthStart(email) {
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
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" });
|
|
1864
1995
|
}
|
|
1865
|
-
const result = await emailAdapter.emailAuthStart(email);
|
|
1866
|
-
return { flowId: result.flowId };
|
|
1867
1996
|
}
|
|
1868
1997
|
/**
|
|
1869
1998
|
* Verifies the email OTP and completes the connection.
|
|
@@ -1872,77 +2001,89 @@ var _AurumCore = class _AurumCore {
|
|
|
1872
2001
|
* @returns The connected wallet address and email
|
|
1873
2002
|
*/
|
|
1874
2003
|
async emailAuthVerify(flowId, otp) {
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
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
|
+
}
|
|
1908
2041
|
}
|
|
1909
2042
|
/**
|
|
1910
2043
|
* Initiates a WalletConnect session and returns the URI for displaying a custom QR code.
|
|
1911
2044
|
* @returns URI string and a promise that resolves when the user connects
|
|
1912
2045
|
*/
|
|
1913
2046
|
async getWalletConnectSession() {
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
const session = await wcAdapter.startSession();
|
|
1920
|
-
return {
|
|
1921
|
-
uri: session.uri,
|
|
1922
|
-
waitForConnection: async () => {
|
|
1923
|
-
const result = await session.waitForConnection();
|
|
1924
|
-
const provider = _nullishCoalesce(result.provider, () => ( wcAdapter.getProvider()));
|
|
1925
|
-
if (!provider) {
|
|
1926
|
-
_chunk27AOACEWjs.sentryLogger.error("Failed to get provider after WalletConnect connection");
|
|
1927
|
-
throw new Error("Failed to get provider after WalletConnect connection");
|
|
1928
|
-
}
|
|
1929
|
-
const checksumAdr = _viem.checksumAddress.call(void 0, result.address);
|
|
1930
|
-
this.connectedWalletAdapter = wcAdapter;
|
|
1931
|
-
this.updateProvider(provider);
|
|
1932
|
-
this.userInfo = {
|
|
1933
|
-
publicAddress: checksumAdr,
|
|
1934
|
-
walletName: wcAdapter.name,
|
|
1935
|
-
walletId: wcAdapter.id
|
|
1936
|
-
};
|
|
1937
|
-
this.persistConnectionState(wcAdapter, checksumAdr);
|
|
1938
|
-
this.setInternalAccountChangeListener(wcAdapter);
|
|
1939
|
-
const chainId = await provider.request({ method: "eth_chainId" });
|
|
1940
|
-
this.emitConnect(chainId);
|
|
1941
|
-
this.emitAccountsChanged([checksumAdr]);
|
|
1942
|
-
_chunk27AOACEWjs.sentryLogger.info(`Wallet connected: ${wcAdapter.id} (headless)`);
|
|
1943
|
-
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");
|
|
1944
2052
|
}
|
|
1945
|
-
|
|
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
|
+
}
|
|
1946
2087
|
}
|
|
1947
2088
|
/* PROVIDER METHODS */
|
|
1948
2089
|
createProviderProxy() {
|
|
@@ -1955,15 +2096,15 @@ var _AurumCore = class _AurumCore {
|
|
|
1955
2096
|
}
|
|
1956
2097
|
this.eventListeners.get(event).add(callback);
|
|
1957
2098
|
if (!_AurumCore.MANAGED_EVENTS.includes(event)) {
|
|
1958
|
-
_optionalChain([this, 'access',
|
|
2099
|
+
_optionalChain([this, 'access', _166 => _166.currentProvider, 'access', _167 => _167.on, 'optionalCall', _168 => _168(event, callback)]);
|
|
1959
2100
|
}
|
|
1960
2101
|
};
|
|
1961
2102
|
}
|
|
1962
2103
|
if (prop === "removeListener") {
|
|
1963
2104
|
return (event, callback) => {
|
|
1964
|
-
_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)]);
|
|
1965
2106
|
if (!_AurumCore.MANAGED_EVENTS.includes(event)) {
|
|
1966
|
-
_optionalChain([this, 'access',
|
|
2107
|
+
_optionalChain([this, 'access', _174 => _174.currentProvider, 'access', _175 => _175.removeListener, 'optionalCall', _176 => _176(event, callback)]);
|
|
1967
2108
|
}
|
|
1968
2109
|
};
|
|
1969
2110
|
}
|
|
@@ -1988,7 +2129,7 @@ var _AurumCore = class _AurumCore {
|
|
|
1988
2129
|
this.eventListeners.forEach((callbacks, event) => {
|
|
1989
2130
|
if (!_AurumCore.MANAGED_EVENTS.includes(event)) {
|
|
1990
2131
|
callbacks.forEach((callback) => {
|
|
1991
|
-
_optionalChain([newProvider, 'access',
|
|
2132
|
+
_optionalChain([newProvider, 'access', _177 => _177.on, 'optionalCall', _178 => _178(event, callback)]);
|
|
1992
2133
|
});
|
|
1993
2134
|
}
|
|
1994
2135
|
});
|
|
@@ -1996,7 +2137,7 @@ var _AurumCore = class _AurumCore {
|
|
|
1996
2137
|
/* BRAND & THEME METHODS */
|
|
1997
2138
|
resolveBrandConfig(config) {
|
|
1998
2139
|
const { brand = {} } = config || {};
|
|
1999
|
-
const themeConfig =
|
|
2140
|
+
const themeConfig = _chunk2P33GXLJjs.getDefaultThemeConfig.call(void 0, brand.theme || _chunk2P33GXLJjs.DEFAULT_THEME);
|
|
2000
2141
|
return {
|
|
2001
2142
|
logo: _nullishCoalesce(brand.logo, () => ( themeConfig.logo)),
|
|
2002
2143
|
theme: _nullishCoalesce(brand.theme, () => ( themeConfig.theme)),
|
|
@@ -2010,9 +2151,13 @@ var _AurumCore = class _AurumCore {
|
|
|
2010
2151
|
};
|
|
2011
2152
|
}
|
|
2012
2153
|
async tryRestoreConnection() {
|
|
2154
|
+
if (typeof window === "undefined") {
|
|
2155
|
+
this.ready = true;
|
|
2156
|
+
return;
|
|
2157
|
+
}
|
|
2013
2158
|
try {
|
|
2014
|
-
await
|
|
2015
|
-
const store =
|
|
2159
|
+
await _chunk2P33GXLJjs.waitForStoreHydration.call(void 0, );
|
|
2160
|
+
const store = _chunk2P33GXLJjs.useAurumStore.getState();
|
|
2016
2161
|
if (!store.isConnected || !store.walletId || !store.address || !store.walletName) {
|
|
2017
2162
|
return;
|
|
2018
2163
|
}
|
|
@@ -2035,14 +2180,14 @@ var _AurumCore = class _AurumCore {
|
|
|
2035
2180
|
email: _nullishCoalesce(store.email, () => ( void 0))
|
|
2036
2181
|
};
|
|
2037
2182
|
this.setInternalAccountChangeListener(persistedAdapter);
|
|
2038
|
-
} catch (
|
|
2183
|
+
} catch (e16) {
|
|
2039
2184
|
this.resetConnectionState();
|
|
2040
2185
|
} finally {
|
|
2041
2186
|
this.ready = true;
|
|
2042
2187
|
}
|
|
2043
2188
|
}
|
|
2044
2189
|
persistConnectionState(adapter, address, email) {
|
|
2045
|
-
|
|
2190
|
+
_chunk2P33GXLJjs.useAurumStore.getState().setConnection(adapter.id, _viem.checksumAddress.call(void 0, address), adapter.name, email);
|
|
2046
2191
|
}
|
|
2047
2192
|
/* INTERNAL LISTENER METHODS */
|
|
2048
2193
|
setInternalAccountChangeListener(adapter) {
|
|
@@ -2056,14 +2201,14 @@ var _AurumCore = class _AurumCore {
|
|
|
2056
2201
|
}
|
|
2057
2202
|
async syncStateFromAccountsChanged(accounts) {
|
|
2058
2203
|
if (!accounts.length || !accounts[0]) return;
|
|
2059
|
-
const prevAccount = _optionalChain([this, 'access',
|
|
2204
|
+
const prevAccount = _optionalChain([this, 'access', _179 => _179.userInfo, 'optionalAccess', _180 => _180.publicAddress]);
|
|
2060
2205
|
const newAccount = _viem.checksumAddress.call(void 0, accounts[0]);
|
|
2061
2206
|
if (newAccount !== prevAccount) {
|
|
2062
2207
|
this.userInfo = {
|
|
2063
2208
|
publicAddress: newAccount,
|
|
2064
|
-
walletName: _optionalChain([this, 'access',
|
|
2065
|
-
walletId: _optionalChain([this, 'access',
|
|
2066
|
-
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])
|
|
2067
2212
|
};
|
|
2068
2213
|
if (this.connectedWalletAdapter) {
|
|
2069
2214
|
this.persistConnectionState(this.connectedWalletAdapter, newAccount, this.userInfo.email);
|
|
@@ -2122,8 +2267,8 @@ var _AurumCore = class _AurumCore {
|
|
|
2122
2267
|
}
|
|
2123
2268
|
}
|
|
2124
2269
|
async addChain(chain) {
|
|
2125
|
-
if (!_optionalChain([chain, 'optionalAccess',
|
|
2126
|
-
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");
|
|
2127
2272
|
}
|
|
2128
2273
|
await this.rpcProvider.request({
|
|
2129
2274
|
method: "wallet_addEthereumChain",
|
|
@@ -2140,7 +2285,7 @@ var _AurumCore = class _AurumCore {
|
|
|
2140
2285
|
}
|
|
2141
2286
|
/* REST */
|
|
2142
2287
|
resetConnectionState() {
|
|
2143
|
-
|
|
2288
|
+
_chunk2P33GXLJjs.useAurumStore.getState().clearConnection();
|
|
2144
2289
|
this.connectedWalletAdapter = null;
|
|
2145
2290
|
this.updateProvider(this.skeletonProvider);
|
|
2146
2291
|
this.userInfo = void 0;
|
|
@@ -2148,6 +2293,10 @@ var _AurumCore = class _AurumCore {
|
|
|
2148
2293
|
};
|
|
2149
2294
|
// Singleton instance
|
|
2150
2295
|
_AurumCore.instance = null;
|
|
2296
|
+
// Serialized first-construction config used to detect mismatched re-inits (dev footgun: HMR,
|
|
2297
|
+
// cross-module imports, etc). Stored as a string so re-construction with structurally-equal
|
|
2298
|
+
// config doesn't false-positive.
|
|
2299
|
+
_AurumCore.storedConfigJson = null;
|
|
2151
2300
|
// Events managed by AurumCore (not forwarded to underlying provider)
|
|
2152
2301
|
_AurumCore.MANAGED_EVENTS = ["accountsChanged", "connect", "disconnect"];
|
|
2153
2302
|
var AurumCore = _AurumCore;
|
|
@@ -2171,6 +2320,32 @@ var Aurum = class {
|
|
|
2171
2320
|
* ```
|
|
2172
2321
|
*/
|
|
2173
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
|
+
};
|
|
2174
2349
|
this.core = new AurumCore(config);
|
|
2175
2350
|
}
|
|
2176
2351
|
/**
|
|
@@ -2433,5 +2608,15 @@ var Aurum = class {
|
|
|
2433
2608
|
};
|
|
2434
2609
|
|
|
2435
2610
|
|
|
2436
|
-
|
|
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;
|
|
2437
2622
|
//# sourceMappingURL=index.js.map
|