@metamask/connect-multichain 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -15
- package/README.md +1 -1
- package/dist/browser/es/connect-multichain.d.mts +0 -3
- package/dist/browser/es/connect-multichain.mjs +552 -567
- package/dist/browser/es/connect-multichain.mjs.map +1 -1
- package/dist/browser/es/metafile-esm.json +1 -1
- package/dist/browser/iife/connect-multichain.d.ts +0 -3
- package/dist/browser/iife/connect-multichain.js +3780 -2088
- package/dist/browser/iife/connect-multichain.js.map +1 -1
- package/dist/browser/iife/metafile-iife.json +1 -1
- package/dist/browser/umd/connect-multichain.d.ts +0 -3
- package/dist/browser/umd/connect-multichain.js +552 -567
- package/dist/browser/umd/connect-multichain.js.map +1 -1
- package/dist/browser/umd/metafile-cjs.json +1 -1
- package/dist/node/cjs/connect-multichain.d.ts +0 -3
- package/dist/node/cjs/connect-multichain.js +553 -579
- package/dist/node/cjs/connect-multichain.js.map +1 -1
- package/dist/node/cjs/metafile-cjs.json +1 -1
- package/dist/node/es/connect-multichain.d.mts +0 -3
- package/dist/node/es/connect-multichain.mjs +552 -578
- package/dist/node/es/connect-multichain.mjs.map +1 -1
- package/dist/node/es/metafile-esm.json +1 -1
- package/dist/react-native/es/connect-multichain.d.mts +0 -3
- package/dist/react-native/es/connect-multichain.mjs +539 -563
- package/dist/react-native/es/connect-multichain.mjs.map +1 -1
- package/dist/react-native/es/metafile-esm.json +1 -1
- package/dist/src/domain/multichain/types.d.ts +0 -3
- package/dist/src/domain/multichain/types.d.ts.map +1 -1
- package/dist/src/multichain/index.d.ts +3 -22
- package/dist/src/multichain/index.d.ts.map +1 -1
- package/dist/src/multichain/index.js +413 -420
- package/dist/src/multichain/index.js.map +1 -1
- package/dist/src/multichain/rpc/requestRouter.d.ts.map +1 -1
- package/dist/src/multichain/rpc/requestRouter.js +8 -15
- package/dist/src/multichain/rpc/requestRouter.js.map +1 -1
- package/dist/src/multichain/transports/mwp/index.d.ts.map +1 -1
- package/dist/src/multichain/transports/mwp/index.js +22 -4
- package/dist/src/multichain/transports/mwp/index.js.map +1 -1
- package/dist/src/ui/index.d.ts +0 -4
- package/dist/src/ui/index.d.ts.map +1 -1
- package/dist/src/ui/index.js +3 -44
- package/dist/src/ui/index.js.map +1 -1
- package/dist/src/ui/modals/node/install.js +2 -2
- package/dist/src/ui/modals/node/install.js.map +1 -1
- package/dist/src/ui/preload.native.d.ts +5 -0
- package/dist/src/ui/preload.native.d.ts.map +1 -0
- package/dist/src/ui/preload.native.js +18 -0
- package/dist/src/ui/preload.native.js.map +1 -0
- package/dist/src/ui/preload.web.d.ts +5 -0
- package/dist/src/ui/preload.web.d.ts.map +1 -0
- package/dist/src/ui/{qr.js → preload.web.js} +13 -18
- package/dist/src/ui/preload.web.js.map +1 -0
- package/dist/types/connect-multichain.d.ts +0 -3
- package/package.json +7 -7
- package/dist/src/ui/qr.d.ts +0 -3
- package/dist/src/ui/qr.d.ts.map +0 -1
- package/dist/src/ui/qr.js.map +0 -1
|
@@ -256,8 +256,8 @@ var init_logger = __esm({
|
|
|
256
256
|
import_debug.default.enable(namespace);
|
|
257
257
|
};
|
|
258
258
|
isEnabled = (namespace, storage) => __async(null, null, function* () {
|
|
259
|
-
var
|
|
260
|
-
if ("process" in globalThis && ((
|
|
259
|
+
var _a2;
|
|
260
|
+
if ("process" in globalThis && ((_a2 = process == null ? void 0 : process.env) == null ? void 0 : _a2.DEBUG)) {
|
|
261
261
|
const { DEBUG } = process.env;
|
|
262
262
|
return isNamespaceEnabled(DEBUG, namespace);
|
|
263
263
|
}
|
|
@@ -426,35 +426,35 @@ var init_multichain = __esm({
|
|
|
426
426
|
|
|
427
427
|
// src/domain/platform/index.ts
|
|
428
428
|
function isNotBrowser() {
|
|
429
|
-
var
|
|
429
|
+
var _a2;
|
|
430
430
|
if (typeof window === "undefined") {
|
|
431
431
|
return true;
|
|
432
432
|
}
|
|
433
433
|
if (!(window == null ? void 0 : window.navigator)) {
|
|
434
434
|
return true;
|
|
435
435
|
}
|
|
436
|
-
if (typeof global !== "undefined" && ((
|
|
436
|
+
if (typeof global !== "undefined" && ((_a2 = global == null ? void 0 : global.navigator) == null ? void 0 : _a2.product) === "ReactNative") {
|
|
437
437
|
return true;
|
|
438
438
|
}
|
|
439
439
|
return (navigator == null ? void 0 : navigator.product) === "ReactNative";
|
|
440
440
|
}
|
|
441
441
|
function isReactNative() {
|
|
442
|
-
var
|
|
442
|
+
var _a2;
|
|
443
443
|
const hasWindowNavigator = typeof window !== "undefined" && window.navigator !== void 0;
|
|
444
444
|
const nav = hasWindowNavigator ? window.navigator : void 0;
|
|
445
445
|
if (!nav) {
|
|
446
446
|
return false;
|
|
447
447
|
}
|
|
448
|
-
return hasWindowNavigator && ((
|
|
448
|
+
return hasWindowNavigator && ((_a2 = window.navigator) == null ? void 0 : _a2.product) === "ReactNative";
|
|
449
449
|
}
|
|
450
450
|
function isMetaMaskMobileWebView() {
|
|
451
451
|
return typeof window !== "undefined" && // @ts-expect-error ReactNativeWebView should be defined
|
|
452
452
|
Boolean(window.ReactNativeWebView) && Boolean(window.navigator.userAgent.endsWith("MetaMaskMobile"));
|
|
453
453
|
}
|
|
454
454
|
function isMobile() {
|
|
455
|
-
var
|
|
455
|
+
var _a2, _b;
|
|
456
456
|
const browser = import_bowser.default.parse(window.navigator.userAgent);
|
|
457
|
-
return ((
|
|
457
|
+
return ((_a2 = browser == null ? void 0 : browser.platform) == null ? void 0 : _a2.type) === "mobile" || ((_b = browser == null ? void 0 : browser.platform) == null ? void 0 : _b.type) === "tablet";
|
|
458
458
|
}
|
|
459
459
|
function getPlatformType() {
|
|
460
460
|
if (isReactNative()) {
|
|
@@ -472,11 +472,11 @@ function getPlatformType() {
|
|
|
472
472
|
return "web-desktop" /* DesktopWeb */;
|
|
473
473
|
}
|
|
474
474
|
function isMetamaskExtensionInstalled() {
|
|
475
|
-
var
|
|
475
|
+
var _a2;
|
|
476
476
|
if (typeof window === "undefined") {
|
|
477
477
|
return false;
|
|
478
478
|
}
|
|
479
|
-
return Boolean((
|
|
479
|
+
return Boolean((_a2 = window.ethereum) == null ? void 0 : _a2.isMetaMask);
|
|
480
480
|
}
|
|
481
481
|
function isSecure() {
|
|
482
482
|
const platformType = getPlatformType();
|
|
@@ -508,8 +508,8 @@ var init_platform = __esm({
|
|
|
508
508
|
return new Promise((resolve) => {
|
|
509
509
|
const providers = [];
|
|
510
510
|
const handler = (event) => {
|
|
511
|
-
var
|
|
512
|
-
if ((_b = (
|
|
511
|
+
var _a2, _b;
|
|
512
|
+
if ((_b = (_a2 = event == null ? void 0 : event.detail) == null ? void 0 : _a2.info) == null ? void 0 : _b.rdns) {
|
|
513
513
|
providers.push(event.detail);
|
|
514
514
|
}
|
|
515
515
|
};
|
|
@@ -519,8 +519,8 @@ var init_platform = __esm({
|
|
|
519
519
|
window.removeEventListener("eip6963:announceProvider", handler);
|
|
520
520
|
const hasMetaMask = providers.some(
|
|
521
521
|
(provider) => {
|
|
522
|
-
var
|
|
523
|
-
return (_b = (
|
|
522
|
+
var _a2, _b;
|
|
523
|
+
return (_b = (_a2 = provider == null ? void 0 : provider.info) == null ? void 0 : _a2.rdns) == null ? void 0 : _b.startsWith("io.metamask");
|
|
524
524
|
}
|
|
525
525
|
);
|
|
526
526
|
resolve(hasMetaMask);
|
|
@@ -619,8 +619,8 @@ function compressString(str) {
|
|
|
619
619
|
return base64Encode(binaryString);
|
|
620
620
|
}
|
|
621
621
|
function getDappId(dapp) {
|
|
622
|
-
var
|
|
623
|
-
return (
|
|
622
|
+
var _a2;
|
|
623
|
+
return (_a2 = dapp.url) != null ? _a2 : dapp.name;
|
|
624
624
|
}
|
|
625
625
|
function openDeeplink(options, deeplink, universalLink) {
|
|
626
626
|
const { mobile } = options;
|
|
@@ -650,10 +650,10 @@ function getOptionalScopes(scopes) {
|
|
|
650
650
|
);
|
|
651
651
|
}
|
|
652
652
|
function setupDappMetadata(options) {
|
|
653
|
-
var
|
|
653
|
+
var _a2, _b;
|
|
654
654
|
const platform = getPlatformType();
|
|
655
655
|
const isBrowser = platform === "web-desktop" /* DesktopWeb */ || platform === "web-mobile" /* MobileWeb */ || platform === "in-app-browser" /* MetaMaskMobileWebview */;
|
|
656
|
-
if (!((
|
|
656
|
+
if (!((_a2 = options.dapp) == null ? void 0 : _a2.name)) {
|
|
657
657
|
throw new Error("You must provide dapp name");
|
|
658
658
|
}
|
|
659
659
|
if (isBrowser) {
|
|
@@ -724,17 +724,17 @@ function getValidAccounts(caipAccountIds) {
|
|
|
724
724
|
);
|
|
725
725
|
}
|
|
726
726
|
function addValidAccounts(optionalScopes, validAccounts) {
|
|
727
|
-
var
|
|
727
|
+
var _a2;
|
|
728
728
|
if (!optionalScopes || !(validAccounts == null ? void 0 : validAccounts.length)) {
|
|
729
729
|
return optionalScopes;
|
|
730
730
|
}
|
|
731
731
|
const result = Object.fromEntries(
|
|
732
732
|
Object.entries(optionalScopes).map(([scope, scopeData]) => {
|
|
733
|
-
var
|
|
733
|
+
var _a3, _b, _c;
|
|
734
734
|
return [
|
|
735
735
|
scope,
|
|
736
736
|
{
|
|
737
|
-
methods: [...(
|
|
737
|
+
methods: [...(_a3 = scopeData == null ? void 0 : scopeData.methods) != null ? _a3 : []],
|
|
738
738
|
notifications: [...(_b = scopeData == null ? void 0 : scopeData.notifications) != null ? _b : []],
|
|
739
739
|
accounts: [...(_c = scopeData == null ? void 0 : scopeData.accounts) != null ? _c : []]
|
|
740
740
|
}
|
|
@@ -748,7 +748,7 @@ function addValidAccounts(optionalScopes, validAccounts) {
|
|
|
748
748
|
if (!accountsByChain.has(chainKey)) {
|
|
749
749
|
accountsByChain.set(chainKey, []);
|
|
750
750
|
}
|
|
751
|
-
(
|
|
751
|
+
(_a2 = accountsByChain.get(chainKey)) == null ? void 0 : _a2.push(accountId);
|
|
752
752
|
}
|
|
753
753
|
for (const [scopeKey, scopeData] of Object.entries(result)) {
|
|
754
754
|
if (!(scopeData == null ? void 0 : scopeData.accounts)) {
|
|
@@ -780,7 +780,7 @@ var init_utils = __esm({
|
|
|
780
780
|
import_utils = require("@metamask/utils");
|
|
781
781
|
init_domain();
|
|
782
782
|
extractFavicon = () => {
|
|
783
|
-
var
|
|
783
|
+
var _a2;
|
|
784
784
|
if (typeof document === "undefined") {
|
|
785
785
|
return void 0;
|
|
786
786
|
}
|
|
@@ -788,7 +788,7 @@ var init_utils = __esm({
|
|
|
788
788
|
const nodeList = document.getElementsByTagName("link");
|
|
789
789
|
for (let i = 0; i < nodeList.length; i++) {
|
|
790
790
|
if (nodeList[i].getAttribute("rel") === "icon" || nodeList[i].getAttribute("rel") === "shortcut icon") {
|
|
791
|
-
favicon = (
|
|
791
|
+
favicon = (_a2 = nodeList[i].getAttribute("href")) != null ? _a2 : void 0;
|
|
792
792
|
}
|
|
793
793
|
}
|
|
794
794
|
return favicon;
|
|
@@ -798,25 +798,25 @@ var init_utils = __esm({
|
|
|
798
798
|
|
|
799
799
|
// src/multichain/utils/analytics.ts
|
|
800
800
|
function isRejectionError(error) {
|
|
801
|
-
var
|
|
801
|
+
var _a2, _b;
|
|
802
802
|
if (typeof error !== "object" || error === null) {
|
|
803
803
|
return false;
|
|
804
804
|
}
|
|
805
805
|
const errorObj = error;
|
|
806
806
|
const errorCode = errorObj.code;
|
|
807
|
-
const errorMessage = (_b = (
|
|
807
|
+
const errorMessage = (_b = (_a2 = errorObj.message) == null ? void 0 : _a2.toLowerCase()) != null ? _b : "";
|
|
808
808
|
return errorCode === 4001 || // User rejected request (common EIP-1193 code)
|
|
809
809
|
errorCode === 4100 || // Unauthorized (common rejection code)
|
|
810
810
|
errorMessage.includes("reject") || errorMessage.includes("denied") || errorMessage.includes("cancel") || errorMessage.includes("user");
|
|
811
811
|
}
|
|
812
812
|
function getBaseAnalyticsProperties(options, storage) {
|
|
813
813
|
return __async(this, null, function* () {
|
|
814
|
-
var
|
|
814
|
+
var _a2, _b;
|
|
815
815
|
const version = getVersion();
|
|
816
816
|
const dappId = getDappId(options.dapp);
|
|
817
817
|
const platform = getPlatformType();
|
|
818
818
|
const anonId = yield storage.getAnonId();
|
|
819
|
-
const integrationType = (_b = (
|
|
819
|
+
const integrationType = (_b = (_a2 = options.analytics) == null ? void 0 : _a2.integrationType) != null ? _b : "unknown" /* UNKNOWN */;
|
|
820
820
|
return {
|
|
821
821
|
mmconnect_version: version,
|
|
822
822
|
dapp_id: dappId,
|
|
@@ -828,11 +828,11 @@ function getBaseAnalyticsProperties(options, storage) {
|
|
|
828
828
|
}
|
|
829
829
|
function getWalletActionAnalyticsProperties(options, storage, invokeOptions) {
|
|
830
830
|
return __async(this, null, function* () {
|
|
831
|
-
var
|
|
831
|
+
var _a2, _b;
|
|
832
832
|
const version = getVersion();
|
|
833
833
|
const dappId = getDappId(options.dapp);
|
|
834
834
|
const anonId = yield storage.getAnonId();
|
|
835
|
-
const integrationType = (_b = (
|
|
835
|
+
const integrationType = (_b = (_a2 = options.analytics) == null ? void 0 : _a2.integrationType) != null ? _b : "unknown";
|
|
836
836
|
return {
|
|
837
837
|
mmconnect_version: version,
|
|
838
838
|
dapp_id: dappId,
|
|
@@ -877,30 +877,6 @@ var init_domain = __esm({
|
|
|
877
877
|
}
|
|
878
878
|
});
|
|
879
879
|
|
|
880
|
-
// src/ui/qr.ts
|
|
881
|
-
function preloadQR() {
|
|
882
|
-
return __async(this, null, function* () {
|
|
883
|
-
if (encodeQRImpl) {
|
|
884
|
-
return;
|
|
885
|
-
}
|
|
886
|
-
const mod = yield import("@paulmillr/qr");
|
|
887
|
-
encodeQRImpl = mod.default;
|
|
888
|
-
});
|
|
889
|
-
}
|
|
890
|
-
function encodeQRSync(input) {
|
|
891
|
-
if (!encodeQRImpl) {
|
|
892
|
-
throw new Error("QR module not preloaded. Call preloadQR() first.");
|
|
893
|
-
}
|
|
894
|
-
return encodeQRImpl(input, "ascii");
|
|
895
|
-
}
|
|
896
|
-
var encodeQRImpl;
|
|
897
|
-
var init_qr = __esm({
|
|
898
|
-
"src/ui/qr.ts"() {
|
|
899
|
-
"use strict";
|
|
900
|
-
encodeQRImpl = null;
|
|
901
|
-
}
|
|
902
|
-
});
|
|
903
|
-
|
|
904
880
|
// src/ui/modals/base/utils.ts
|
|
905
881
|
function formatRemainingTime(milliseconds) {
|
|
906
882
|
if (milliseconds <= 0) return "EXPIRED";
|
|
@@ -1019,12 +995,12 @@ var init_AbstractInstallModal = __esm({
|
|
|
1019
995
|
});
|
|
1020
996
|
|
|
1021
997
|
// src/ui/modals/node/install.ts
|
|
1022
|
-
var logger4, InstallModal;
|
|
998
|
+
var import_qr, logger4, InstallModal;
|
|
1023
999
|
var init_install = __esm({
|
|
1024
1000
|
"src/ui/modals/node/install.ts"() {
|
|
1025
1001
|
"use strict";
|
|
1026
1002
|
init_domain();
|
|
1027
|
-
|
|
1003
|
+
import_qr = __toESM(require("@paulmillr/qr"));
|
|
1028
1004
|
init_AbstractInstallModal();
|
|
1029
1005
|
init_utils3();
|
|
1030
1006
|
logger4 = createLogger("metamask-sdk:ui");
|
|
@@ -1032,7 +1008,7 @@ var init_install = __esm({
|
|
|
1032
1008
|
displayQRWithCountdown(qrCodeLink, expiresInMs) {
|
|
1033
1009
|
const isExpired = expiresInMs <= 0;
|
|
1034
1010
|
const formattedTime = formatRemainingTime(expiresInMs);
|
|
1035
|
-
const qrCode =
|
|
1011
|
+
const qrCode = (0, import_qr.default)(qrCodeLink, "ascii");
|
|
1036
1012
|
console.clear();
|
|
1037
1013
|
console.log(qrCode);
|
|
1038
1014
|
if (isExpired) {
|
|
@@ -1140,8 +1116,8 @@ var init_node2 = __esm({
|
|
|
1140
1116
|
}
|
|
1141
1117
|
get(key) {
|
|
1142
1118
|
return __async(this, null, function* () {
|
|
1143
|
-
var
|
|
1144
|
-
return (
|
|
1119
|
+
var _a2;
|
|
1120
|
+
return (_a2 = this.storage.get(key)) != null ? _a2 : null;
|
|
1145
1121
|
});
|
|
1146
1122
|
}
|
|
1147
1123
|
set(key, value) {
|
|
@@ -1244,8 +1220,8 @@ var RpcClient = class {
|
|
|
1244
1220
|
});
|
|
1245
1221
|
}
|
|
1246
1222
|
getRpcEndpoint(scope) {
|
|
1247
|
-
var
|
|
1248
|
-
const supportedNetworks = (_c = (_b = (
|
|
1223
|
+
var _a2, _b, _c;
|
|
1224
|
+
const supportedNetworks = (_c = (_b = (_a2 = this.config) == null ? void 0 : _a2.api) == null ? void 0 : _b.supportedNetworks) != null ? _c : {};
|
|
1249
1225
|
const rpcEndpoint = supportedNetworks[scope];
|
|
1250
1226
|
if (!rpcEndpoint) {
|
|
1251
1227
|
throw new MissingRpcEndpointErr(`No RPC endpoint found for scope ${scope}`);
|
|
@@ -1400,24 +1376,17 @@ var RequestRouter = class {
|
|
|
1400
1376
|
_RequestRouter_instances = new WeakSet();
|
|
1401
1377
|
withAnalyticsTracking_fn = function(options, execute) {
|
|
1402
1378
|
return __async(this, null, function* () {
|
|
1403
|
-
|
|
1404
|
-
if ((_a = this.config.analytics) == null ? void 0 : _a.enabled) {
|
|
1405
|
-
yield __privateMethod(this, _RequestRouter_instances, trackWalletActionRequested_fn).call(this, options);
|
|
1406
|
-
}
|
|
1379
|
+
yield __privateMethod(this, _RequestRouter_instances, trackWalletActionRequested_fn).call(this, options);
|
|
1407
1380
|
try {
|
|
1408
1381
|
const result = yield execute();
|
|
1409
|
-
|
|
1410
|
-
yield __privateMethod(this, _RequestRouter_instances, trackWalletActionSucceeded_fn).call(this, options);
|
|
1411
|
-
}
|
|
1382
|
+
yield __privateMethod(this, _RequestRouter_instances, trackWalletActionSucceeded_fn).call(this, options);
|
|
1412
1383
|
return result;
|
|
1413
1384
|
} catch (error) {
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
yield __privateMethod(this, _RequestRouter_instances, trackWalletActionFailed_fn).call(this, options);
|
|
1420
|
-
}
|
|
1385
|
+
const isRejection = isRejectionError(error);
|
|
1386
|
+
if (isRejection) {
|
|
1387
|
+
yield __privateMethod(this, _RequestRouter_instances, trackWalletActionRejected_fn).call(this, options);
|
|
1388
|
+
} else {
|
|
1389
|
+
yield __privateMethod(this, _RequestRouter_instances, trackWalletActionFailed_fn).call(this, options);
|
|
1421
1390
|
}
|
|
1422
1391
|
throw new RPCInvokeMethodErr(error.message);
|
|
1423
1392
|
}
|
|
@@ -1477,11 +1446,11 @@ var DefaultTransport = class {
|
|
|
1477
1446
|
id: requestId
|
|
1478
1447
|
}, payload);
|
|
1479
1448
|
return new Promise((resolve, reject) => {
|
|
1480
|
-
var
|
|
1449
|
+
var _a2;
|
|
1481
1450
|
const timeout = setTimeout(() => {
|
|
1482
1451
|
__privateGet(this, _pendingRequests).delete(requestId);
|
|
1483
1452
|
reject(new Error("Request timeout"));
|
|
1484
|
-
}, (
|
|
1453
|
+
}, (_a2 = options == null ? void 0 : options.timeout) != null ? _a2 : __privateGet(this, _defaultRequestOptions).timeout);
|
|
1485
1454
|
__privateGet(this, _pendingRequests).set(requestId, {
|
|
1486
1455
|
resolve: (response) => {
|
|
1487
1456
|
resolve(response);
|
|
@@ -1505,7 +1474,7 @@ var DefaultTransport = class {
|
|
|
1505
1474
|
}
|
|
1506
1475
|
connect(options) {
|
|
1507
1476
|
return __async(this, null, function* () {
|
|
1508
|
-
var
|
|
1477
|
+
var _a2, _b, _c, _d, _e, _f, _g;
|
|
1509
1478
|
__privateMethod(this, _DefaultTransport_instances, setupMessageListener_fn).call(this);
|
|
1510
1479
|
yield __privateGet(this, _transport).connect();
|
|
1511
1480
|
const sessionRequest = yield this.request(
|
|
@@ -1518,7 +1487,7 @@ var DefaultTransport = class {
|
|
|
1518
1487
|
let walletSession = sessionRequest.result;
|
|
1519
1488
|
if (walletSession && options && !options.forceRequest) {
|
|
1520
1489
|
const currentScopes = Object.keys(
|
|
1521
|
-
(
|
|
1490
|
+
(_a2 = walletSession == null ? void 0 : walletSession.sessionScopes) != null ? _a2 : {}
|
|
1522
1491
|
);
|
|
1523
1492
|
const proposedScopes = (_b = options == null ? void 0 : options.scopes) != null ? _b : [];
|
|
1524
1493
|
const proposedCaipAccountIds = (_c = options == null ? void 0 : options.caipAccountIds) != null ? _c : [];
|
|
@@ -1632,16 +1601,16 @@ notifyCallbacks_fn = function(data) {
|
|
|
1632
1601
|
}
|
|
1633
1602
|
};
|
|
1634
1603
|
isMetamaskProviderEvent_fn = function(event) {
|
|
1635
|
-
var
|
|
1636
|
-
return ((_b = (
|
|
1604
|
+
var _a2, _b;
|
|
1605
|
+
return ((_b = (_a2 = event == null ? void 0 : event.data) == null ? void 0 : _a2.data) == null ? void 0 : _b.name) === "metamask-provider" && // eslint-disable-next-line no-restricted-globals
|
|
1637
1606
|
event.origin === location.origin;
|
|
1638
1607
|
};
|
|
1639
1608
|
handleResponse_fn = function(event) {
|
|
1640
|
-
var
|
|
1609
|
+
var _a2, _b;
|
|
1641
1610
|
if (!__privateMethod(this, _DefaultTransport_instances, isMetamaskProviderEvent_fn).call(this, event)) {
|
|
1642
1611
|
return;
|
|
1643
1612
|
}
|
|
1644
|
-
const responseData = (_b = (
|
|
1613
|
+
const responseData = (_b = (_a2 = event == null ? void 0 : event.data) == null ? void 0 : _a2.data) == null ? void 0 : _b.data;
|
|
1645
1614
|
if (typeof responseData === "object" && responseData !== null && "method" in responseData) {
|
|
1646
1615
|
return;
|
|
1647
1616
|
}
|
|
@@ -1663,11 +1632,11 @@ handleResponse_fn = function(event) {
|
|
|
1663
1632
|
}
|
|
1664
1633
|
};
|
|
1665
1634
|
handleNotification_fn = function(event) {
|
|
1666
|
-
var
|
|
1635
|
+
var _a2, _b;
|
|
1667
1636
|
if (!__privateMethod(this, _DefaultTransport_instances, isMetamaskProviderEvent_fn).call(this, event)) {
|
|
1668
1637
|
return;
|
|
1669
1638
|
}
|
|
1670
|
-
const responseData = (_b = (
|
|
1639
|
+
const responseData = (_b = (_a2 = event == null ? void 0 : event.data) == null ? void 0 : _a2.data) == null ? void 0 : _b.data;
|
|
1671
1640
|
if (typeof responseData === "object" && responseData.method === "metamask_chainChanged" || responseData.method === "metamask_accountsChanged") {
|
|
1672
1641
|
__privateMethod(this, _DefaultTransport_instances, notifyCallbacks_fn).call(this, responseData);
|
|
1673
1642
|
}
|
|
@@ -1793,7 +1762,7 @@ var MWPTransport = class {
|
|
|
1793
1762
|
}
|
|
1794
1763
|
onResumeSuccess(resumeResolve, resumeReject, options) {
|
|
1795
1764
|
return __async(this, null, function* () {
|
|
1796
|
-
var
|
|
1765
|
+
var _a2, _b, _c, _d, _e, _f, _g;
|
|
1797
1766
|
try {
|
|
1798
1767
|
const sessionRequest = yield this.request({
|
|
1799
1768
|
method: "wallet_getSession"
|
|
@@ -1804,7 +1773,7 @@ var MWPTransport = class {
|
|
|
1804
1773
|
let walletSession = sessionRequest.result;
|
|
1805
1774
|
if (walletSession && options) {
|
|
1806
1775
|
const currentScopes = Object.keys(
|
|
1807
|
-
(
|
|
1776
|
+
(_a2 = walletSession == null ? void 0 : walletSession.sessionScopes) != null ? _a2 : {}
|
|
1808
1777
|
);
|
|
1809
1778
|
const proposedScopes = (_b = options == null ? void 0 : options.scopes) != null ? _b : [];
|
|
1810
1779
|
const proposedCaipAccountIds = (_c = options == null ? void 0 : options.caipAccountIds) != null ? _c : [];
|
|
@@ -1869,10 +1838,10 @@ var MWPTransport = class {
|
|
|
1869
1838
|
return cachedWalletSession;
|
|
1870
1839
|
}
|
|
1871
1840
|
return new Promise((resolve, reject) => {
|
|
1872
|
-
var
|
|
1841
|
+
var _a2;
|
|
1873
1842
|
const timeout = setTimeout(() => {
|
|
1874
1843
|
this.rejectRequest(request.id, new import_multichain_api_client2.TransportTimeoutError());
|
|
1875
|
-
}, (
|
|
1844
|
+
}, (_a2 = options == null ? void 0 : options.timeout) != null ? _a2 : this.options.requestTimeout);
|
|
1876
1845
|
this.pendingRequests.set(request.id, {
|
|
1877
1846
|
request,
|
|
1878
1847
|
method: request.method,
|
|
@@ -1898,26 +1867,27 @@ var MWPTransport = class {
|
|
|
1898
1867
|
logger("active session found", session);
|
|
1899
1868
|
}
|
|
1900
1869
|
let timeout;
|
|
1870
|
+
let initialConnectionMessageHandler;
|
|
1901
1871
|
const connectionPromise = new Promise((resolve, reject) => {
|
|
1902
1872
|
let connection;
|
|
1903
1873
|
if (session) {
|
|
1904
1874
|
connection = new Promise((resumeResolve, resumeReject) => {
|
|
1905
|
-
var
|
|
1875
|
+
var _a2;
|
|
1906
1876
|
if (this.dappClient.state === "CONNECTED") {
|
|
1907
1877
|
this.onResumeSuccess(resumeResolve, resumeReject, options);
|
|
1908
1878
|
} else {
|
|
1909
1879
|
this.dappClient.once("connected", () => __async(this, null, function* () {
|
|
1910
1880
|
this.onResumeSuccess(resumeResolve, resumeReject, options);
|
|
1911
1881
|
}));
|
|
1912
|
-
dappClient.resume((
|
|
1882
|
+
dappClient.resume((_a2 = session == null ? void 0 : session.id) != null ? _a2 : "");
|
|
1913
1883
|
}
|
|
1914
1884
|
});
|
|
1915
1885
|
} else {
|
|
1916
1886
|
connection = new Promise(
|
|
1917
1887
|
(resolveConnection, rejectConnection) => {
|
|
1918
|
-
var
|
|
1888
|
+
var _a2, _b;
|
|
1919
1889
|
const optionalScopes = addValidAccounts(
|
|
1920
|
-
getOptionalScopes((
|
|
1890
|
+
getOptionalScopes((_a2 = options == null ? void 0 : options.scopes) != null ? _a2 : []),
|
|
1921
1891
|
getValidAccounts((_b = options == null ? void 0 : options.caipAccountIds) != null ? _b : [])
|
|
1922
1892
|
);
|
|
1923
1893
|
const sessionRequest = {
|
|
@@ -1929,12 +1899,18 @@ var MWPTransport = class {
|
|
|
1929
1899
|
method: "wallet_createSession",
|
|
1930
1900
|
params: sessionRequest
|
|
1931
1901
|
};
|
|
1932
|
-
|
|
1902
|
+
initialConnectionMessageHandler = (message) => __async(this, null, function* () {
|
|
1933
1903
|
if (typeof message === "object" && message !== null) {
|
|
1934
1904
|
if ("data" in message) {
|
|
1935
1905
|
const messagePayload = message.data;
|
|
1936
1906
|
if (messagePayload.method === "wallet_createSession" || messagePayload.method === "wallet_sessionChanged") {
|
|
1937
1907
|
if (messagePayload.error) {
|
|
1908
|
+
if (initialConnectionMessageHandler) {
|
|
1909
|
+
this.dappClient.off(
|
|
1910
|
+
"message",
|
|
1911
|
+
initialConnectionMessageHandler
|
|
1912
|
+
);
|
|
1913
|
+
}
|
|
1938
1914
|
return rejectConnection(messagePayload.error);
|
|
1939
1915
|
}
|
|
1940
1916
|
yield this.storeWalletSession(
|
|
@@ -1946,14 +1922,23 @@ var MWPTransport = class {
|
|
|
1946
1922
|
}
|
|
1947
1923
|
}
|
|
1948
1924
|
}
|
|
1949
|
-
})
|
|
1925
|
+
});
|
|
1926
|
+
this.dappClient.on("message", initialConnectionMessageHandler);
|
|
1950
1927
|
dappClient.connect({
|
|
1951
1928
|
mode: "trusted",
|
|
1952
1929
|
initialPayload: {
|
|
1953
1930
|
name: MULTICHAIN_PROVIDER_STREAM_NAME,
|
|
1954
1931
|
data: request
|
|
1955
1932
|
}
|
|
1956
|
-
}).catch(
|
|
1933
|
+
}).catch((error) => {
|
|
1934
|
+
if (initialConnectionMessageHandler) {
|
|
1935
|
+
this.dappClient.off(
|
|
1936
|
+
"message",
|
|
1937
|
+
initialConnectionMessageHandler
|
|
1938
|
+
);
|
|
1939
|
+
}
|
|
1940
|
+
rejectConnection(error);
|
|
1941
|
+
});
|
|
1957
1942
|
}
|
|
1958
1943
|
);
|
|
1959
1944
|
}
|
|
@@ -1962,10 +1947,16 @@ var MWPTransport = class {
|
|
|
1962
1947
|
}, this.options.connectionTimeout);
|
|
1963
1948
|
connection.then(resolve).catch(reject);
|
|
1964
1949
|
});
|
|
1965
|
-
return connectionPromise.
|
|
1950
|
+
return connectionPromise.catch((error) => {
|
|
1951
|
+
throw error;
|
|
1952
|
+
}).finally(() => {
|
|
1966
1953
|
if (timeout) {
|
|
1967
1954
|
clearTimeout(timeout);
|
|
1968
1955
|
}
|
|
1956
|
+
if (initialConnectionMessageHandler) {
|
|
1957
|
+
this.dappClient.off("message", initialConnectionMessageHandler);
|
|
1958
|
+
initialConnectionMessageHandler = void 0;
|
|
1959
|
+
}
|
|
1969
1960
|
});
|
|
1970
1961
|
});
|
|
1971
1962
|
}
|
|
@@ -2028,7 +2019,7 @@ var MWPTransport = class {
|
|
|
2028
2019
|
}
|
|
2029
2020
|
getCachedResponse(request) {
|
|
2030
2021
|
return __async(this, null, function* () {
|
|
2031
|
-
var
|
|
2022
|
+
var _a2;
|
|
2032
2023
|
if (request.method === "wallet_getSession") {
|
|
2033
2024
|
const walletGetSession = yield this.kvstore.get(SESSION_STORE_KEY);
|
|
2034
2025
|
if (walletGetSession) {
|
|
@@ -2036,7 +2027,7 @@ var MWPTransport = class {
|
|
|
2036
2027
|
return {
|
|
2037
2028
|
id: request.id,
|
|
2038
2029
|
jsonrpc: "2.0",
|
|
2039
|
-
result: (
|
|
2030
|
+
result: (_a2 = walletSession.params) != null ? _a2 : walletSession.result,
|
|
2040
2031
|
// "what?... why walletSession.params?.."
|
|
2041
2032
|
method: request.method
|
|
2042
2033
|
};
|
|
@@ -2100,10 +2091,10 @@ var MWPTransport = class {
|
|
|
2100
2091
|
yield this.attemptResumeSession();
|
|
2101
2092
|
}
|
|
2102
2093
|
return new Promise((resolve, reject) => {
|
|
2103
|
-
var
|
|
2094
|
+
var _a2;
|
|
2104
2095
|
const timeout = setTimeout(() => {
|
|
2105
2096
|
this.rejectRequest(request.id, new import_multichain_api_client2.TransportTimeoutError());
|
|
2106
|
-
}, (
|
|
2097
|
+
}, (_a2 = options == null ? void 0 : options.timeout) != null ? _a2 : this.options.requestTimeout);
|
|
2107
2098
|
this.pendingRequests.set(request.id, {
|
|
2108
2099
|
request,
|
|
2109
2100
|
method: request.method,
|
|
@@ -2172,73 +2163,74 @@ var keymanager = new KeyManager();
|
|
|
2172
2163
|
// src/multichain/index.ts
|
|
2173
2164
|
init_utils();
|
|
2174
2165
|
var logger2 = createLogger("metamask-sdk:core");
|
|
2175
|
-
var
|
|
2166
|
+
var _a, _provider, _transport2, _dappClient, _beforeUnloadListener, _listener, _sdkInfo, _MultichainSDK_instances, setupAnalytics_fn, onTransportNotification_fn, getStoredTransport_fn, setupTransport_fn, init_fn, createDappClient_fn, setupMWP_fn, onBeforeUnload_fn, createBeforeUnloadListener_fn, renderInstallModalAsync_fn, showInstallModal_fn, setupDefaultTransport_fn, deeplinkConnect_fn, handleConnection_fn;
|
|
2167
|
+
var _MultichainSDK = class _MultichainSDK extends MultichainCore {
|
|
2176
2168
|
constructor(options) {
|
|
2177
|
-
var
|
|
2169
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
2178
2170
|
const withDappMetadata = setupDappMetadata(options);
|
|
2179
|
-
const integrationType = ((
|
|
2171
|
+
const integrationType = (_b = (_a2 = options.analytics) == null ? void 0 : _a2.integrationType) != null ? _b : "direct";
|
|
2180
2172
|
const allOptions = __spreadProps(__spreadValues({}, withDappMetadata), {
|
|
2181
2173
|
ui: __spreadProps(__spreadValues({}, withDappMetadata.ui), {
|
|
2182
|
-
preferExtension: (
|
|
2183
|
-
showInstallModal: (
|
|
2184
|
-
headless: (
|
|
2174
|
+
preferExtension: (_c = withDappMetadata.ui.preferExtension) != null ? _c : true,
|
|
2175
|
+
showInstallModal: (_d = withDappMetadata.ui.showInstallModal) != null ? _d : false,
|
|
2176
|
+
headless: (_e = withDappMetadata.ui.headless) != null ? _e : false
|
|
2185
2177
|
}),
|
|
2186
|
-
analytics: __spreadProps(__spreadValues({}, (
|
|
2187
|
-
enabled: (_g = (_f = options.analytics) == null ? void 0 : _f.enabled) != null ? _g : true,
|
|
2178
|
+
analytics: __spreadProps(__spreadValues({}, (_f = options.analytics) != null ? _f : {}), {
|
|
2188
2179
|
integrationType
|
|
2189
2180
|
})
|
|
2190
2181
|
});
|
|
2191
2182
|
super(allOptions);
|
|
2192
|
-
this
|
|
2193
|
-
this
|
|
2194
|
-
this
|
|
2195
|
-
this
|
|
2183
|
+
__privateAdd(this, _MultichainSDK_instances);
|
|
2184
|
+
__privateAdd(this, _provider);
|
|
2185
|
+
__privateAdd(this, _transport2);
|
|
2186
|
+
__privateAdd(this, _dappClient);
|
|
2187
|
+
__privateAdd(this, _beforeUnloadListener);
|
|
2188
|
+
this._state = "pending";
|
|
2189
|
+
__privateAdd(this, _listener);
|
|
2190
|
+
__privateAdd(this, _sdkInfo, `Sdk/Javascript SdkVersion/${getVersion()} Platform/${getPlatformType()} dApp/${(_a = this.options.dapp.url) != null ? _a : this.options.dapp.name} dAppTitle/${this.options.dapp.name}`);
|
|
2196
2191
|
}
|
|
2197
2192
|
get state() {
|
|
2198
|
-
return this.
|
|
2193
|
+
return this._state;
|
|
2199
2194
|
}
|
|
2200
2195
|
set state(value) {
|
|
2201
|
-
var
|
|
2202
|
-
this.
|
|
2203
|
-
(_b = (
|
|
2196
|
+
var _a2, _b;
|
|
2197
|
+
this._state = value;
|
|
2198
|
+
(_b = (_a2 = this.options.transport) == null ? void 0 : _a2.onNotification) == null ? void 0 : _b.call(_a2, {
|
|
2204
2199
|
method: "stateChanged",
|
|
2205
2200
|
params: value
|
|
2206
2201
|
});
|
|
2207
2202
|
}
|
|
2208
2203
|
get provider() {
|
|
2209
|
-
if (!this
|
|
2210
|
-
this
|
|
2211
|
-
return this
|
|
2204
|
+
if (!__privateGet(this, _provider) && __privateGet(this, _transport2)) {
|
|
2205
|
+
__privateSet(this, _provider, (0, import_multichain_api_client3.getMultichainClient)({ transport: __privateGet(this, _transport2) }));
|
|
2206
|
+
return __privateGet(this, _provider);
|
|
2212
2207
|
}
|
|
2213
|
-
if (!this
|
|
2208
|
+
if (!__privateGet(this, _provider)) {
|
|
2214
2209
|
throw new Error("Provider not initialized, establish connection first");
|
|
2215
2210
|
}
|
|
2216
|
-
return this
|
|
2211
|
+
return __privateGet(this, _provider);
|
|
2217
2212
|
}
|
|
2218
2213
|
get transport() {
|
|
2219
|
-
if (!this
|
|
2214
|
+
if (!__privateGet(this, _transport2)) {
|
|
2220
2215
|
throw new Error("Transport not initialized, establish connection first");
|
|
2221
2216
|
}
|
|
2222
|
-
return this
|
|
2217
|
+
return __privateGet(this, _transport2);
|
|
2223
2218
|
}
|
|
2224
2219
|
get dappClient() {
|
|
2225
|
-
if (!this
|
|
2220
|
+
if (!__privateGet(this, _dappClient)) {
|
|
2226
2221
|
throw new Error("DappClient not initialized, establish connection first");
|
|
2227
2222
|
}
|
|
2228
|
-
return this
|
|
2223
|
+
return __privateGet(this, _dappClient);
|
|
2229
2224
|
}
|
|
2230
2225
|
get storage() {
|
|
2231
2226
|
return this.options.storage;
|
|
2232
2227
|
}
|
|
2233
2228
|
get transportType() {
|
|
2234
|
-
return this
|
|
2235
|
-
}
|
|
2236
|
-
get sdkInfo() {
|
|
2237
|
-
var _a;
|
|
2238
|
-
return `Sdk/Javascript SdkVersion/${getVersion()} Platform/${getPlatformType()} dApp/${(_a = this.options.dapp.url) != null ? _a : this.options.dapp.name} dAppTitle/${this.options.dapp.name}`;
|
|
2229
|
+
return __privateGet(this, _transport2) instanceof MWPTransport ? "mwp" /* MWP */ : "browser" /* Browser */;
|
|
2239
2230
|
}
|
|
2240
2231
|
static create(options) {
|
|
2241
2232
|
return __async(this, null, function* () {
|
|
2233
|
+
var _a2;
|
|
2242
2234
|
const instance = new _MultichainSDK(options);
|
|
2243
2235
|
const isEnabled2 = yield isEnabled(
|
|
2244
2236
|
"metamask-sdk:core",
|
|
@@ -2247,353 +2239,16 @@ var MultichainSDK = class _MultichainSDK extends MultichainCore {
|
|
|
2247
2239
|
if (isEnabled2) {
|
|
2248
2240
|
enableDebug("metamask-sdk:core");
|
|
2249
2241
|
}
|
|
2250
|
-
yield instance.
|
|
2242
|
+
yield __privateMethod(_a2 = instance, _MultichainSDK_instances, init_fn).call(_a2);
|
|
2251
2243
|
return instance;
|
|
2252
2244
|
});
|
|
2253
2245
|
}
|
|
2254
|
-
setupAnalytics() {
|
|
2255
|
-
return __async(this, null, function* () {
|
|
2256
|
-
var _a, _b;
|
|
2257
|
-
if (!((_a = this.options.analytics) == null ? void 0 : _a.enabled)) {
|
|
2258
|
-
return;
|
|
2259
|
-
}
|
|
2260
|
-
const platform = getPlatformType();
|
|
2261
|
-
const isBrowser = platform === "in-app-browser" /* MetaMaskMobileWebview */ || platform === "web-desktop" /* DesktopWeb */ || platform === "web-mobile" /* MobileWeb */;
|
|
2262
|
-
const isReactNative2 = platform === "react-native" /* ReactNative */;
|
|
2263
|
-
if (!isBrowser && !isReactNative2) {
|
|
2264
|
-
return;
|
|
2265
|
-
}
|
|
2266
|
-
const version = getVersion();
|
|
2267
|
-
const dappId = getDappId(this.options.dapp);
|
|
2268
|
-
const anonId = yield this.storage.getAnonId();
|
|
2269
|
-
const { integrationType } = (_b = this.options.analytics) != null ? _b : {
|
|
2270
|
-
integrationType: ""
|
|
2271
|
-
};
|
|
2272
|
-
import_analytics4.analytics.setGlobalProperty("mmconnect_version", version);
|
|
2273
|
-
import_analytics4.analytics.setGlobalProperty("dapp_id", dappId);
|
|
2274
|
-
import_analytics4.analytics.setGlobalProperty("anon_id", anonId);
|
|
2275
|
-
import_analytics4.analytics.setGlobalProperty("platform", platform);
|
|
2276
|
-
import_analytics4.analytics.setGlobalProperty("integration_type", integrationType);
|
|
2277
|
-
import_analytics4.analytics.enable();
|
|
2278
|
-
});
|
|
2279
|
-
}
|
|
2280
|
-
onTransportNotification(payload) {
|
|
2281
|
-
return __async(this, null, function* () {
|
|
2282
|
-
var _a;
|
|
2283
|
-
if (typeof payload === "object" && payload !== null && "method" in payload) {
|
|
2284
|
-
this.emit(payload.method, (_a = payload.params) != null ? _a : payload.result);
|
|
2285
|
-
}
|
|
2286
|
-
});
|
|
2287
|
-
}
|
|
2288
|
-
getStoredTransport() {
|
|
2289
|
-
return __async(this, null, function* () {
|
|
2290
|
-
const transportType = yield this.storage.getTransport();
|
|
2291
|
-
const hasExtensionInstalled = yield hasExtension();
|
|
2292
|
-
if (transportType) {
|
|
2293
|
-
if (transportType === "browser" /* Browser */) {
|
|
2294
|
-
if (hasExtensionInstalled) {
|
|
2295
|
-
const apiTransport = new DefaultTransport();
|
|
2296
|
-
this.__transport = apiTransport;
|
|
2297
|
-
this.listener = apiTransport.onNotification(
|
|
2298
|
-
this.onTransportNotification.bind(this)
|
|
2299
|
-
);
|
|
2300
|
-
return apiTransport;
|
|
2301
|
-
}
|
|
2302
|
-
} else if (transportType === "mwp" /* MWP */) {
|
|
2303
|
-
const { adapter: kvstore } = this.options.storage;
|
|
2304
|
-
const dappClient = yield this.createDappClient();
|
|
2305
|
-
const apiTransport = new MWPTransport(dappClient, kvstore);
|
|
2306
|
-
this.__dappClient = dappClient;
|
|
2307
|
-
this.__transport = apiTransport;
|
|
2308
|
-
this.listener = apiTransport.onNotification(
|
|
2309
|
-
this.onTransportNotification.bind(this)
|
|
2310
|
-
);
|
|
2311
|
-
return apiTransport;
|
|
2312
|
-
}
|
|
2313
|
-
yield this.storage.removeTransport();
|
|
2314
|
-
}
|
|
2315
|
-
return void 0;
|
|
2316
|
-
});
|
|
2317
|
-
}
|
|
2318
|
-
setupTransport() {
|
|
2319
|
-
return __async(this, null, function* () {
|
|
2320
|
-
const transport = yield this.getStoredTransport();
|
|
2321
|
-
if (transport) {
|
|
2322
|
-
if (!this.transport.isConnected()) {
|
|
2323
|
-
this.state = "connecting";
|
|
2324
|
-
yield this.transport.connect();
|
|
2325
|
-
}
|
|
2326
|
-
this.state = "connected";
|
|
2327
|
-
if (this.transport instanceof MWPTransport) {
|
|
2328
|
-
yield this.storage.setTransport("mwp" /* MWP */);
|
|
2329
|
-
} else {
|
|
2330
|
-
yield this.storage.setTransport("browser" /* Browser */);
|
|
2331
|
-
}
|
|
2332
|
-
} else {
|
|
2333
|
-
this.state = "loaded";
|
|
2334
|
-
}
|
|
2335
|
-
});
|
|
2336
|
-
}
|
|
2337
|
-
init() {
|
|
2338
|
-
return __async(this, null, function* () {
|
|
2339
|
-
var _a, _b;
|
|
2340
|
-
try {
|
|
2341
|
-
if (typeof window !== "undefined" && ((_a = window.mmsdk) == null ? void 0 : _a.isInitialized)) {
|
|
2342
|
-
logger2("MetaMaskSDK: init already initialized");
|
|
2343
|
-
} else {
|
|
2344
|
-
yield this.setupAnalytics();
|
|
2345
|
-
yield this.setupTransport();
|
|
2346
|
-
if ((_b = this.options.analytics) == null ? void 0 : _b.enabled) {
|
|
2347
|
-
try {
|
|
2348
|
-
const baseProps = yield getBaseAnalyticsProperties(
|
|
2349
|
-
this.options,
|
|
2350
|
-
this.storage
|
|
2351
|
-
);
|
|
2352
|
-
import_analytics4.analytics.track("mmconnect_initialized", baseProps);
|
|
2353
|
-
} catch (error) {
|
|
2354
|
-
logger2("Error tracking initialized event", error);
|
|
2355
|
-
}
|
|
2356
|
-
}
|
|
2357
|
-
if (typeof window !== "undefined") {
|
|
2358
|
-
window.mmsdk = this;
|
|
2359
|
-
}
|
|
2360
|
-
}
|
|
2361
|
-
} catch (error) {
|
|
2362
|
-
yield this.storage.removeTransport();
|
|
2363
|
-
this.state = "pending";
|
|
2364
|
-
logger2("MetaMaskSDK error during initialization", error);
|
|
2365
|
-
}
|
|
2366
|
-
});
|
|
2367
|
-
}
|
|
2368
|
-
createDappClient() {
|
|
2369
|
-
return __async(this, null, function* () {
|
|
2370
|
-
const { adapter: kvstore } = this.options.storage;
|
|
2371
|
-
const sessionstore = new import_mobile_wallet_protocol_core2.SessionStore(kvstore);
|
|
2372
|
-
const websocket = (
|
|
2373
|
-
// eslint-disable-next-line no-negated-condition
|
|
2374
|
-
typeof window !== "undefined" ? WebSocket : (yield import("ws")).WebSocket
|
|
2375
|
-
);
|
|
2376
|
-
const transport = yield import_mobile_wallet_protocol_core2.WebSocketTransport.create({
|
|
2377
|
-
url: MWP_RELAY_URL,
|
|
2378
|
-
kvstore,
|
|
2379
|
-
websocket
|
|
2380
|
-
});
|
|
2381
|
-
const dappClient = new import_mobile_wallet_protocol_dapp_client.DappClient({ transport, sessionstore, keymanager });
|
|
2382
|
-
return dappClient;
|
|
2383
|
-
});
|
|
2384
|
-
}
|
|
2385
|
-
setupMWP() {
|
|
2386
|
-
return __async(this, null, function* () {
|
|
2387
|
-
if (this.__transport instanceof MWPTransport) {
|
|
2388
|
-
return;
|
|
2389
|
-
}
|
|
2390
|
-
const { adapter: kvstore } = this.options.storage;
|
|
2391
|
-
const dappClient = yield this.createDappClient();
|
|
2392
|
-
this.__dappClient = dappClient;
|
|
2393
|
-
const apiTransport = new MWPTransport(dappClient, kvstore);
|
|
2394
|
-
this.__transport = apiTransport;
|
|
2395
|
-
this.listener = this.transport.onNotification(
|
|
2396
|
-
this.onTransportNotification.bind(this)
|
|
2397
|
-
);
|
|
2398
|
-
yield this.storage.setTransport("mwp" /* MWP */);
|
|
2399
|
-
});
|
|
2400
|
-
}
|
|
2401
|
-
onBeforeUnload() {
|
|
2402
|
-
return __async(this, null, function* () {
|
|
2403
|
-
var _a;
|
|
2404
|
-
if ((_a = this.options.ui.factory.modal) == null ? void 0 : _a.isMounted) {
|
|
2405
|
-
yield this.storage.removeTransport();
|
|
2406
|
-
}
|
|
2407
|
-
});
|
|
2408
|
-
}
|
|
2409
|
-
createBeforeUnloadListener() {
|
|
2410
|
-
if (typeof window !== "undefined" && typeof window.addEventListener !== "undefined") {
|
|
2411
|
-
window.addEventListener("beforeunload", this.onBeforeUnload.bind(this));
|
|
2412
|
-
}
|
|
2413
|
-
return () => {
|
|
2414
|
-
if (typeof window !== "undefined" && typeof window.removeEventListener !== "undefined") {
|
|
2415
|
-
window.removeEventListener(
|
|
2416
|
-
"beforeunload",
|
|
2417
|
-
this.onBeforeUnload.bind(this)
|
|
2418
|
-
);
|
|
2419
|
-
}
|
|
2420
|
-
};
|
|
2421
|
-
}
|
|
2422
|
-
showInstallModal(desktopPreferred, scopes, caipAccountIds) {
|
|
2423
|
-
return __async(this, null, function* () {
|
|
2424
|
-
var _a;
|
|
2425
|
-
(_a = this.__beforeUnloadListener) != null ? _a : this.__beforeUnloadListener = this.createBeforeUnloadListener();
|
|
2426
|
-
return new Promise((resolve, reject) => {
|
|
2427
|
-
this.options.ui.factory.renderInstallModal(
|
|
2428
|
-
desktopPreferred,
|
|
2429
|
-
() => __async(this, null, function* () {
|
|
2430
|
-
if (this.dappClient.state === "CONNECTED" || this.dappClient.state === "CONNECTING") {
|
|
2431
|
-
yield this.dappClient.disconnect();
|
|
2432
|
-
}
|
|
2433
|
-
return new Promise((resolveConnectionRequest) => {
|
|
2434
|
-
this.dappClient.on(
|
|
2435
|
-
"session_request",
|
|
2436
|
-
(sessionRequest) => {
|
|
2437
|
-
resolveConnectionRequest({
|
|
2438
|
-
sessionRequest,
|
|
2439
|
-
metadata: {
|
|
2440
|
-
dapp: this.options.dapp,
|
|
2441
|
-
sdk: {
|
|
2442
|
-
version: getVersion(),
|
|
2443
|
-
platform: getPlatformType()
|
|
2444
|
-
}
|
|
2445
|
-
}
|
|
2446
|
-
});
|
|
2447
|
-
}
|
|
2448
|
-
);
|
|
2449
|
-
this.transport.connect({ scopes, caipAccountIds }).then(() => {
|
|
2450
|
-
var _a2;
|
|
2451
|
-
this.options.ui.factory.unload();
|
|
2452
|
-
(_a2 = this.options.ui.factory.modal) == null ? void 0 : _a2.unmount();
|
|
2453
|
-
this.state = "connected";
|
|
2454
|
-
return this.storage.setTransport("mwp" /* MWP */);
|
|
2455
|
-
}).catch((error) => {
|
|
2456
|
-
if (error instanceof import_mobile_wallet_protocol_core2.ProtocolError) {
|
|
2457
|
-
if (error.code !== import_mobile_wallet_protocol_core2.ErrorCode.REQUEST_EXPIRED) {
|
|
2458
|
-
this.state = "disconnected";
|
|
2459
|
-
reject(error);
|
|
2460
|
-
}
|
|
2461
|
-
} else {
|
|
2462
|
-
this.state = "disconnected";
|
|
2463
|
-
reject(error);
|
|
2464
|
-
}
|
|
2465
|
-
});
|
|
2466
|
-
});
|
|
2467
|
-
}),
|
|
2468
|
-
(error) => __async(this, null, function* () {
|
|
2469
|
-
if (!error) {
|
|
2470
|
-
yield this.storage.setTransport("mwp" /* MWP */);
|
|
2471
|
-
resolve();
|
|
2472
|
-
} else {
|
|
2473
|
-
yield this.storage.removeTransport();
|
|
2474
|
-
reject(error);
|
|
2475
|
-
}
|
|
2476
|
-
})
|
|
2477
|
-
);
|
|
2478
|
-
});
|
|
2479
|
-
});
|
|
2480
|
-
}
|
|
2481
|
-
setupDefaultTransport() {
|
|
2482
|
-
return __async(this, null, function* () {
|
|
2483
|
-
this.state = "connecting";
|
|
2484
|
-
yield this.storage.setTransport("browser" /* Browser */);
|
|
2485
|
-
const transport = new DefaultTransport();
|
|
2486
|
-
this.listener = transport.onNotification(
|
|
2487
|
-
this.onTransportNotification.bind(this)
|
|
2488
|
-
);
|
|
2489
|
-
this.__transport = transport;
|
|
2490
|
-
return transport;
|
|
2491
|
-
});
|
|
2492
|
-
}
|
|
2493
|
-
deeplinkConnect(scopes, caipAccountIds) {
|
|
2494
|
-
return __async(this, null, function* () {
|
|
2495
|
-
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
2496
|
-
this.dappClient.on("message", (payload) => {
|
|
2497
|
-
var _a, _b, _c;
|
|
2498
|
-
const data = payload.data;
|
|
2499
|
-
if (typeof data === "object" && data !== null) {
|
|
2500
|
-
if ("method" in data && data.method === "wallet_createSession") {
|
|
2501
|
-
if (data.error) {
|
|
2502
|
-
this.state = "loaded";
|
|
2503
|
-
return reject(data.error);
|
|
2504
|
-
}
|
|
2505
|
-
const session = (_a = data.params) != null ? _a : data.result;
|
|
2506
|
-
if (session) {
|
|
2507
|
-
(_c = (_b = this.options.transport) == null ? void 0 : _b.onNotification) == null ? void 0 : _c.call(_b, payload.data);
|
|
2508
|
-
this.emit("wallet_sessionChanged", session);
|
|
2509
|
-
}
|
|
2510
|
-
}
|
|
2511
|
-
}
|
|
2512
|
-
});
|
|
2513
|
-
let timeout;
|
|
2514
|
-
if (!this.transport.isConnected()) {
|
|
2515
|
-
this.dappClient.once(
|
|
2516
|
-
"session_request",
|
|
2517
|
-
(sessionRequest) => {
|
|
2518
|
-
var _a;
|
|
2519
|
-
const connectionRequest = {
|
|
2520
|
-
sessionRequest,
|
|
2521
|
-
metadata: {
|
|
2522
|
-
dapp: this.options.dapp,
|
|
2523
|
-
sdk: { version: getVersion(), platform: getPlatformType() }
|
|
2524
|
-
}
|
|
2525
|
-
};
|
|
2526
|
-
const deeplink = this.options.ui.factory.createConnectionDeeplink(connectionRequest);
|
|
2527
|
-
const universalLink = this.options.ui.factory.createConnectionUniversalLink(connectionRequest);
|
|
2528
|
-
if ((_a = this.options.mobile) == null ? void 0 : _a.preferredOpenLink) {
|
|
2529
|
-
this.options.mobile.preferredOpenLink(deeplink, "_self");
|
|
2530
|
-
} else {
|
|
2531
|
-
openDeeplink(this.options, deeplink, universalLink);
|
|
2532
|
-
}
|
|
2533
|
-
}
|
|
2534
|
-
);
|
|
2535
|
-
}
|
|
2536
|
-
this.transport.connect({ scopes, caipAccountIds }).then(resolve).catch((error) => {
|
|
2537
|
-
this.storage.removeTransport();
|
|
2538
|
-
reject(error);
|
|
2539
|
-
}).finally(() => {
|
|
2540
|
-
if (timeout) {
|
|
2541
|
-
clearTimeout(timeout);
|
|
2542
|
-
}
|
|
2543
|
-
});
|
|
2544
|
-
}));
|
|
2545
|
-
});
|
|
2546
|
-
}
|
|
2547
|
-
handleConnection(promise, scopes, transportType) {
|
|
2548
|
-
return __async(this, null, function* () {
|
|
2549
|
-
this.state = "connecting";
|
|
2550
|
-
return promise.then(() => __async(this, null, function* () {
|
|
2551
|
-
var _a;
|
|
2552
|
-
this.state = "connected";
|
|
2553
|
-
if ((_a = this.options.analytics) == null ? void 0 : _a.enabled) {
|
|
2554
|
-
try {
|
|
2555
|
-
const baseProps = yield getBaseAnalyticsProperties(
|
|
2556
|
-
this.options,
|
|
2557
|
-
this.storage
|
|
2558
|
-
);
|
|
2559
|
-
import_analytics4.analytics.track("mmconnect_connection_established", __spreadProps(__spreadValues({}, baseProps), {
|
|
2560
|
-
transport_type: transportType,
|
|
2561
|
-
user_permissioned_chains: scopes
|
|
2562
|
-
}));
|
|
2563
|
-
} catch (error) {
|
|
2564
|
-
logger2("Error tracking connection_established event", error);
|
|
2565
|
-
}
|
|
2566
|
-
}
|
|
2567
|
-
})).catch((error) => __async(this, null, function* () {
|
|
2568
|
-
var _a;
|
|
2569
|
-
this.state = "disconnected";
|
|
2570
|
-
if ((_a = this.options.analytics) == null ? void 0 : _a.enabled) {
|
|
2571
|
-
try {
|
|
2572
|
-
const baseProps = yield getBaseAnalyticsProperties(
|
|
2573
|
-
this.options,
|
|
2574
|
-
this.storage
|
|
2575
|
-
);
|
|
2576
|
-
const isRejection = isRejectionError(error);
|
|
2577
|
-
if (isRejection) {
|
|
2578
|
-
import_analytics4.analytics.track("mmconnect_connection_rejected", __spreadProps(__spreadValues({}, baseProps), {
|
|
2579
|
-
transport_type: transportType
|
|
2580
|
-
}));
|
|
2581
|
-
} else {
|
|
2582
|
-
import_analytics4.analytics.track("mmconnect_connection_failed", __spreadProps(__spreadValues({}, baseProps), {
|
|
2583
|
-
transport_type: transportType
|
|
2584
|
-
}));
|
|
2585
|
-
}
|
|
2586
|
-
} catch (e) {
|
|
2587
|
-
logger2("Error tracking connection failed/rejected event", error);
|
|
2588
|
-
}
|
|
2589
|
-
}
|
|
2590
|
-
return Promise.reject(error);
|
|
2591
|
-
}));
|
|
2592
|
-
});
|
|
2593
|
-
}
|
|
2594
2246
|
connect(scopes, caipAccountIds, forceRequest) {
|
|
2595
2247
|
return __async(this, null, function* () {
|
|
2596
|
-
var
|
|
2248
|
+
var _a2;
|
|
2249
|
+
if (this.state !== "connected") {
|
|
2250
|
+
yield this.disconnect();
|
|
2251
|
+
}
|
|
2597
2252
|
const { ui } = this.options;
|
|
2598
2253
|
const platformType = getPlatformType();
|
|
2599
2254
|
const isWeb = platformType === "in-app-browser" /* MetaMaskMobileWebview */ || platformType === "web-desktop" /* DesktopWeb */;
|
|
@@ -2606,96 +2261,72 @@ var MultichainSDK = class _MultichainSDK extends MultichainCore {
|
|
|
2606
2261
|
} else {
|
|
2607
2262
|
transportType = "mwp" /* MWP */;
|
|
2608
2263
|
}
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
this.storage
|
|
2614
|
-
);
|
|
2615
|
-
const dappConfiguredChains = Object.keys(
|
|
2616
|
-
this.options.api.supportedNetworks
|
|
2617
|
-
);
|
|
2618
|
-
import_analytics4.analytics.track("mmconnect_connection_initiated", __spreadProps(__spreadValues({}, baseProps), {
|
|
2619
|
-
transport_type: transportType,
|
|
2620
|
-
dapp_configured_chains: dappConfiguredChains,
|
|
2621
|
-
dapp_requested_chains: scopes
|
|
2622
|
-
}));
|
|
2623
|
-
} catch (error) {
|
|
2624
|
-
logger2("Error tracking connection_initiated event", error);
|
|
2625
|
-
}
|
|
2626
|
-
}
|
|
2627
|
-
if (((_b = this.__transport) == null ? void 0 : _b.isConnected()) && !secure) {
|
|
2628
|
-
return this.handleConnection(
|
|
2629
|
-
this.__transport.connect({ scopes, caipAccountIds, forceRequest }).then(() => {
|
|
2630
|
-
if (this.__transport instanceof MWPTransport) {
|
|
2631
|
-
return this.storage.setTransport("mwp" /* MWP */);
|
|
2632
|
-
} else {
|
|
2633
|
-
return this.storage.setTransport("browser" /* Browser */);
|
|
2634
|
-
}
|
|
2635
|
-
}),
|
|
2636
|
-
scopes,
|
|
2637
|
-
transportType
|
|
2264
|
+
try {
|
|
2265
|
+
const baseProps = yield getBaseAnalyticsProperties(
|
|
2266
|
+
this.options,
|
|
2267
|
+
this.storage
|
|
2638
2268
|
);
|
|
2269
|
+
const dappConfiguredChains = Object.keys(
|
|
2270
|
+
this.options.api.supportedNetworks
|
|
2271
|
+
);
|
|
2272
|
+
import_analytics4.analytics.track("mmconnect_connection_initiated", __spreadProps(__spreadValues({}, baseProps), {
|
|
2273
|
+
transport_type: transportType,
|
|
2274
|
+
dapp_configured_chains: dappConfiguredChains,
|
|
2275
|
+
dapp_requested_chains: scopes
|
|
2276
|
+
}));
|
|
2277
|
+
} catch (error) {
|
|
2278
|
+
logger2("Error tracking connection_initiated event", error);
|
|
2279
|
+
}
|
|
2280
|
+
if (((_a2 = __privateGet(this, _transport2)) == null ? void 0 : _a2.isConnected()) && !secure) {
|
|
2281
|
+
return __privateMethod(this, _MultichainSDK_instances, handleConnection_fn).call(this, __privateGet(this, _transport2).connect({ scopes, caipAccountIds, forceRequest }).then(() => __async(this, null, function* () {
|
|
2282
|
+
if (__privateGet(this, _transport2) instanceof MWPTransport) {
|
|
2283
|
+
return this.storage.setTransport("mwp" /* MWP */);
|
|
2284
|
+
}
|
|
2285
|
+
return this.storage.setTransport("browser" /* Browser */);
|
|
2286
|
+
})), scopes, transportType);
|
|
2639
2287
|
}
|
|
2640
2288
|
if (platformType === "in-app-browser" /* MetaMaskMobileWebview */) {
|
|
2641
|
-
const defaultTransport = yield this.
|
|
2642
|
-
return this.
|
|
2643
|
-
defaultTransport.connect({ scopes, caipAccountIds, forceRequest }),
|
|
2644
|
-
scopes,
|
|
2645
|
-
transportType
|
|
2646
|
-
);
|
|
2289
|
+
const defaultTransport = yield __privateMethod(this, _MultichainSDK_instances, setupDefaultTransport_fn).call(this);
|
|
2290
|
+
return __privateMethod(this, _MultichainSDK_instances, handleConnection_fn).call(this, defaultTransport.connect({ scopes, caipAccountIds, forceRequest }), scopes, transportType);
|
|
2647
2291
|
}
|
|
2648
2292
|
if (isWeb && hasExtensionInstalled && preferExtension) {
|
|
2649
|
-
const defaultTransport = yield this.
|
|
2650
|
-
return this.
|
|
2651
|
-
defaultTransport.connect({ scopes, caipAccountIds, forceRequest }),
|
|
2652
|
-
scopes,
|
|
2653
|
-
transportType
|
|
2654
|
-
);
|
|
2293
|
+
const defaultTransport = yield __privateMethod(this, _MultichainSDK_instances, setupDefaultTransport_fn).call(this);
|
|
2294
|
+
return __privateMethod(this, _MultichainSDK_instances, handleConnection_fn).call(this, defaultTransport.connect({ scopes, caipAccountIds, forceRequest }), scopes, transportType);
|
|
2655
2295
|
}
|
|
2656
|
-
yield this.
|
|
2296
|
+
yield __privateMethod(this, _MultichainSDK_instances, setupMWP_fn).call(this);
|
|
2657
2297
|
const shouldShowInstallModal = hasExtensionInstalled ? showInstallModal : !preferExtension || showInstallModal;
|
|
2658
2298
|
if (secure && !shouldShowInstallModal) {
|
|
2659
|
-
return this.
|
|
2660
|
-
this.deeplinkConnect(scopes, caipAccountIds),
|
|
2661
|
-
scopes,
|
|
2662
|
-
transportType
|
|
2663
|
-
);
|
|
2299
|
+
return __privateMethod(this, _MultichainSDK_instances, handleConnection_fn).call(this, __privateMethod(this, _MultichainSDK_instances, deeplinkConnect_fn).call(this, scopes, caipAccountIds), scopes, transportType);
|
|
2664
2300
|
}
|
|
2665
|
-
return this.
|
|
2666
|
-
this.showInstallModal(shouldShowInstallModal, scopes, caipAccountIds),
|
|
2667
|
-
scopes,
|
|
2668
|
-
transportType
|
|
2669
|
-
);
|
|
2301
|
+
return __privateMethod(this, _MultichainSDK_instances, handleConnection_fn).call(this, __privateMethod(this, _MultichainSDK_instances, showInstallModal_fn).call(this, shouldShowInstallModal, scopes, caipAccountIds), scopes, transportType);
|
|
2670
2302
|
});
|
|
2671
2303
|
}
|
|
2672
2304
|
emit(event, args) {
|
|
2673
|
-
var
|
|
2674
|
-
(_b = (
|
|
2305
|
+
var _a2, _b;
|
|
2306
|
+
(_b = (_a2 = this.options.transport) == null ? void 0 : _a2.onNotification) == null ? void 0 : _b.call(_a2, { method: event, params: args });
|
|
2675
2307
|
super.emit(event, args);
|
|
2676
2308
|
}
|
|
2677
2309
|
disconnect() {
|
|
2678
2310
|
return __async(this, null, function* () {
|
|
2679
|
-
var
|
|
2680
|
-
(
|
|
2681
|
-
(_b = this
|
|
2682
|
-
yield (_c = this
|
|
2311
|
+
var _a2, _b, _c;
|
|
2312
|
+
yield (_a2 = __privateGet(this, _listener)) == null ? void 0 : _a2.call(this);
|
|
2313
|
+
(_b = __privateGet(this, _beforeUnloadListener)) == null ? void 0 : _b.call(this);
|
|
2314
|
+
yield (_c = __privateGet(this, _transport2)) == null ? void 0 : _c.disconnect();
|
|
2683
2315
|
yield this.storage.removeTransport();
|
|
2684
|
-
this.emit("wallet_sessionChanged", void 0);
|
|
2685
2316
|
this.emit("stateChanged", "disconnected");
|
|
2686
|
-
this
|
|
2687
|
-
this
|
|
2688
|
-
this
|
|
2689
|
-
this
|
|
2690
|
-
this
|
|
2317
|
+
__privateSet(this, _listener, void 0);
|
|
2318
|
+
__privateSet(this, _beforeUnloadListener, void 0);
|
|
2319
|
+
__privateSet(this, _transport2, void 0);
|
|
2320
|
+
__privateSet(this, _provider, void 0);
|
|
2321
|
+
__privateSet(this, _dappClient, void 0);
|
|
2691
2322
|
});
|
|
2692
2323
|
}
|
|
2693
2324
|
invokeMethod(request) {
|
|
2694
2325
|
return __async(this, null, function* () {
|
|
2695
|
-
var
|
|
2696
|
-
const {
|
|
2697
|
-
(
|
|
2698
|
-
const rpcClient = new RpcClient(options,
|
|
2326
|
+
var _a2;
|
|
2327
|
+
const { transport, options } = this;
|
|
2328
|
+
(_a2 = __privateGet(this, _provider)) != null ? _a2 : __privateSet(this, _provider, (0, import_multichain_api_client3.getMultichainClient)({ transport }));
|
|
2329
|
+
const rpcClient = new RpcClient(options, __privateGet(this, _sdkInfo));
|
|
2699
2330
|
const requestRouter = new RequestRouter(transport, rpcClient, options);
|
|
2700
2331
|
return requestRouter.invokeMethod(request);
|
|
2701
2332
|
});
|
|
@@ -2716,16 +2347,372 @@ var MultichainSDK = class _MultichainSDK extends MultichainCore {
|
|
|
2716
2347
|
if (mobile == null ? void 0 : mobile.preferredOpenLink) {
|
|
2717
2348
|
mobile.preferredOpenLink(url, "_self");
|
|
2718
2349
|
} else {
|
|
2719
|
-
openDeeplink(
|
|
2720
|
-
this.options,
|
|
2721
|
-
url,
|
|
2722
|
-
METAMASK_CONNECT_BASE_URL
|
|
2723
|
-
);
|
|
2350
|
+
openDeeplink(this.options, url, METAMASK_CONNECT_BASE_URL);
|
|
2724
2351
|
}
|
|
2725
2352
|
}), 10);
|
|
2726
2353
|
}
|
|
2727
2354
|
}
|
|
2728
2355
|
};
|
|
2356
|
+
_provider = new WeakMap();
|
|
2357
|
+
_transport2 = new WeakMap();
|
|
2358
|
+
_dappClient = new WeakMap();
|
|
2359
|
+
_beforeUnloadListener = new WeakMap();
|
|
2360
|
+
_listener = new WeakMap();
|
|
2361
|
+
_sdkInfo = new WeakMap();
|
|
2362
|
+
_MultichainSDK_instances = new WeakSet();
|
|
2363
|
+
setupAnalytics_fn = function() {
|
|
2364
|
+
return __async(this, null, function* () {
|
|
2365
|
+
var _a2;
|
|
2366
|
+
const platform = getPlatformType();
|
|
2367
|
+
const isBrowser = platform === "in-app-browser" /* MetaMaskMobileWebview */ || platform === "web-desktop" /* DesktopWeb */ || platform === "web-mobile" /* MobileWeb */;
|
|
2368
|
+
const isReactNative2 = platform === "react-native" /* ReactNative */;
|
|
2369
|
+
if (!isBrowser && !isReactNative2) {
|
|
2370
|
+
return;
|
|
2371
|
+
}
|
|
2372
|
+
const version = getVersion();
|
|
2373
|
+
const dappId = getDappId(this.options.dapp);
|
|
2374
|
+
const anonId = yield this.storage.getAnonId();
|
|
2375
|
+
const { integrationType } = (_a2 = this.options.analytics) != null ? _a2 : {
|
|
2376
|
+
integrationType: ""
|
|
2377
|
+
};
|
|
2378
|
+
import_analytics4.analytics.setGlobalProperty("mmconnect_version", version);
|
|
2379
|
+
import_analytics4.analytics.setGlobalProperty("dapp_id", dappId);
|
|
2380
|
+
import_analytics4.analytics.setGlobalProperty("anon_id", anonId);
|
|
2381
|
+
import_analytics4.analytics.setGlobalProperty("platform", platform);
|
|
2382
|
+
import_analytics4.analytics.setGlobalProperty("integration_type", integrationType);
|
|
2383
|
+
import_analytics4.analytics.enable();
|
|
2384
|
+
});
|
|
2385
|
+
};
|
|
2386
|
+
onTransportNotification_fn = function(payload) {
|
|
2387
|
+
return __async(this, null, function* () {
|
|
2388
|
+
var _a2;
|
|
2389
|
+
if (typeof payload === "object" && payload !== null && "method" in payload) {
|
|
2390
|
+
this.emit(payload.method, (_a2 = payload.params) != null ? _a2 : payload.result);
|
|
2391
|
+
}
|
|
2392
|
+
});
|
|
2393
|
+
};
|
|
2394
|
+
getStoredTransport_fn = function() {
|
|
2395
|
+
return __async(this, null, function* () {
|
|
2396
|
+
const transportType = yield this.storage.getTransport();
|
|
2397
|
+
const hasExtensionInstalled = yield hasExtension();
|
|
2398
|
+
if (transportType) {
|
|
2399
|
+
if (transportType === "browser" /* Browser */) {
|
|
2400
|
+
if (hasExtensionInstalled) {
|
|
2401
|
+
const apiTransport = new DefaultTransport();
|
|
2402
|
+
__privateSet(this, _transport2, apiTransport);
|
|
2403
|
+
__privateSet(this, _listener, apiTransport.onNotification(
|
|
2404
|
+
__privateMethod(this, _MultichainSDK_instances, onTransportNotification_fn).bind(this)
|
|
2405
|
+
));
|
|
2406
|
+
return apiTransport;
|
|
2407
|
+
}
|
|
2408
|
+
} else if (transportType === "mwp" /* MWP */) {
|
|
2409
|
+
const { adapter: kvstore } = this.options.storage;
|
|
2410
|
+
const dappClient = yield __privateMethod(this, _MultichainSDK_instances, createDappClient_fn).call(this);
|
|
2411
|
+
const apiTransport = new MWPTransport(dappClient, kvstore);
|
|
2412
|
+
__privateSet(this, _dappClient, dappClient);
|
|
2413
|
+
__privateSet(this, _transport2, apiTransport);
|
|
2414
|
+
__privateSet(this, _listener, apiTransport.onNotification(
|
|
2415
|
+
__privateMethod(this, _MultichainSDK_instances, onTransportNotification_fn).bind(this)
|
|
2416
|
+
));
|
|
2417
|
+
return apiTransport;
|
|
2418
|
+
}
|
|
2419
|
+
yield this.storage.removeTransport();
|
|
2420
|
+
}
|
|
2421
|
+
return void 0;
|
|
2422
|
+
});
|
|
2423
|
+
};
|
|
2424
|
+
setupTransport_fn = function() {
|
|
2425
|
+
return __async(this, null, function* () {
|
|
2426
|
+
const transport = yield __privateMethod(this, _MultichainSDK_instances, getStoredTransport_fn).call(this);
|
|
2427
|
+
if (transport) {
|
|
2428
|
+
if (!this.transport.isConnected()) {
|
|
2429
|
+
this.state = "connecting";
|
|
2430
|
+
yield this.transport.connect();
|
|
2431
|
+
}
|
|
2432
|
+
this.state = "connected";
|
|
2433
|
+
if (this.transport instanceof MWPTransport) {
|
|
2434
|
+
yield this.storage.setTransport("mwp" /* MWP */);
|
|
2435
|
+
} else {
|
|
2436
|
+
yield this.storage.setTransport("browser" /* Browser */);
|
|
2437
|
+
}
|
|
2438
|
+
} else {
|
|
2439
|
+
this.state = "loaded";
|
|
2440
|
+
}
|
|
2441
|
+
});
|
|
2442
|
+
};
|
|
2443
|
+
init_fn = function() {
|
|
2444
|
+
return __async(this, null, function* () {
|
|
2445
|
+
var _a2;
|
|
2446
|
+
try {
|
|
2447
|
+
if (typeof window !== "undefined" && ((_a2 = window.mmsdk) == null ? void 0 : _a2.isInitialized)) {
|
|
2448
|
+
logger2("MetaMaskSDK: init already initialized");
|
|
2449
|
+
} else {
|
|
2450
|
+
yield __privateMethod(this, _MultichainSDK_instances, setupAnalytics_fn).call(this);
|
|
2451
|
+
yield __privateMethod(this, _MultichainSDK_instances, setupTransport_fn).call(this);
|
|
2452
|
+
try {
|
|
2453
|
+
const baseProps = yield getBaseAnalyticsProperties(
|
|
2454
|
+
this.options,
|
|
2455
|
+
this.storage
|
|
2456
|
+
);
|
|
2457
|
+
import_analytics4.analytics.track("mmconnect_initialized", baseProps);
|
|
2458
|
+
} catch (error) {
|
|
2459
|
+
logger2("Error tracking initialized event", error);
|
|
2460
|
+
}
|
|
2461
|
+
if (typeof window !== "undefined") {
|
|
2462
|
+
window.mmsdk = this;
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
} catch (error) {
|
|
2466
|
+
yield this.storage.removeTransport();
|
|
2467
|
+
this.state = "pending";
|
|
2468
|
+
logger2("MetaMaskSDK error during initialization", error);
|
|
2469
|
+
}
|
|
2470
|
+
});
|
|
2471
|
+
};
|
|
2472
|
+
createDappClient_fn = function() {
|
|
2473
|
+
return __async(this, null, function* () {
|
|
2474
|
+
const { adapter: kvstore } = this.options.storage;
|
|
2475
|
+
const sessionstore = new import_mobile_wallet_protocol_core2.SessionStore(kvstore);
|
|
2476
|
+
const websocket = (
|
|
2477
|
+
// eslint-disable-next-line no-negated-condition
|
|
2478
|
+
typeof window !== "undefined" ? WebSocket : (yield import("ws")).WebSocket
|
|
2479
|
+
);
|
|
2480
|
+
const transport = yield import_mobile_wallet_protocol_core2.WebSocketTransport.create({
|
|
2481
|
+
url: MWP_RELAY_URL,
|
|
2482
|
+
kvstore,
|
|
2483
|
+
websocket
|
|
2484
|
+
});
|
|
2485
|
+
const dappClient = new import_mobile_wallet_protocol_dapp_client.DappClient({ transport, sessionstore, keymanager });
|
|
2486
|
+
return dappClient;
|
|
2487
|
+
});
|
|
2488
|
+
};
|
|
2489
|
+
setupMWP_fn = function() {
|
|
2490
|
+
return __async(this, null, function* () {
|
|
2491
|
+
if (__privateGet(this, _transport2) instanceof MWPTransport) {
|
|
2492
|
+
return;
|
|
2493
|
+
}
|
|
2494
|
+
const { adapter: kvstore } = this.options.storage;
|
|
2495
|
+
const dappClient = yield __privateMethod(this, _MultichainSDK_instances, createDappClient_fn).call(this);
|
|
2496
|
+
__privateSet(this, _dappClient, dappClient);
|
|
2497
|
+
const apiTransport = new MWPTransport(dappClient, kvstore);
|
|
2498
|
+
__privateSet(this, _transport2, apiTransport);
|
|
2499
|
+
__privateSet(this, _listener, this.transport.onNotification(
|
|
2500
|
+
__privateMethod(this, _MultichainSDK_instances, onTransportNotification_fn).bind(this)
|
|
2501
|
+
));
|
|
2502
|
+
yield this.storage.setTransport("mwp" /* MWP */);
|
|
2503
|
+
});
|
|
2504
|
+
};
|
|
2505
|
+
onBeforeUnload_fn = function() {
|
|
2506
|
+
return __async(this, null, function* () {
|
|
2507
|
+
var _a2;
|
|
2508
|
+
if ((_a2 = this.options.ui.factory.modal) == null ? void 0 : _a2.isMounted) {
|
|
2509
|
+
yield this.storage.removeTransport();
|
|
2510
|
+
}
|
|
2511
|
+
});
|
|
2512
|
+
};
|
|
2513
|
+
createBeforeUnloadListener_fn = function() {
|
|
2514
|
+
if (typeof window !== "undefined" && typeof window.addEventListener !== "undefined") {
|
|
2515
|
+
window.addEventListener("beforeunload", __privateMethod(this, _MultichainSDK_instances, onBeforeUnload_fn).bind(this));
|
|
2516
|
+
}
|
|
2517
|
+
return () => {
|
|
2518
|
+
if (typeof window !== "undefined" && typeof window.removeEventListener !== "undefined") {
|
|
2519
|
+
window.removeEventListener(
|
|
2520
|
+
"beforeunload",
|
|
2521
|
+
__privateMethod(this, _MultichainSDK_instances, onBeforeUnload_fn).bind(this)
|
|
2522
|
+
);
|
|
2523
|
+
}
|
|
2524
|
+
};
|
|
2525
|
+
};
|
|
2526
|
+
renderInstallModalAsync_fn = function(desktopPreferred, scopes, caipAccountIds) {
|
|
2527
|
+
return __async(this, null, function* () {
|
|
2528
|
+
return new Promise((resolve, reject) => {
|
|
2529
|
+
this.options.ui.factory.renderInstallModal(
|
|
2530
|
+
desktopPreferred,
|
|
2531
|
+
() => __async(this, null, function* () {
|
|
2532
|
+
if (this.dappClient.state === "CONNECTED" || this.dappClient.state === "CONNECTING") {
|
|
2533
|
+
yield this.dappClient.disconnect();
|
|
2534
|
+
}
|
|
2535
|
+
return new Promise((_resolve) => {
|
|
2536
|
+
this.dappClient.on(
|
|
2537
|
+
"session_request",
|
|
2538
|
+
(sessionRequest) => {
|
|
2539
|
+
_resolve({
|
|
2540
|
+
sessionRequest,
|
|
2541
|
+
metadata: {
|
|
2542
|
+
dapp: this.options.dapp,
|
|
2543
|
+
sdk: {
|
|
2544
|
+
version: getVersion(),
|
|
2545
|
+
platform: getPlatformType()
|
|
2546
|
+
}
|
|
2547
|
+
}
|
|
2548
|
+
});
|
|
2549
|
+
}
|
|
2550
|
+
);
|
|
2551
|
+
(() => __async(this, null, function* () {
|
|
2552
|
+
var _a2;
|
|
2553
|
+
try {
|
|
2554
|
+
yield this.transport.connect({ scopes, caipAccountIds });
|
|
2555
|
+
yield this.options.ui.factory.unload();
|
|
2556
|
+
(_a2 = this.options.ui.factory.modal) == null ? void 0 : _a2.unmount();
|
|
2557
|
+
this.state = "connected";
|
|
2558
|
+
yield this.storage.setTransport("mwp" /* MWP */);
|
|
2559
|
+
} catch (error) {
|
|
2560
|
+
if (error instanceof import_mobile_wallet_protocol_core2.ProtocolError) {
|
|
2561
|
+
if (error.code !== import_mobile_wallet_protocol_core2.ErrorCode.REQUEST_EXPIRED) {
|
|
2562
|
+
this.state = "disconnected";
|
|
2563
|
+
reject(error);
|
|
2564
|
+
}
|
|
2565
|
+
} else {
|
|
2566
|
+
this.state = "disconnected";
|
|
2567
|
+
reject(
|
|
2568
|
+
error instanceof Error ? error : new Error(String(error))
|
|
2569
|
+
);
|
|
2570
|
+
}
|
|
2571
|
+
}
|
|
2572
|
+
}))().catch(() => {
|
|
2573
|
+
});
|
|
2574
|
+
});
|
|
2575
|
+
}),
|
|
2576
|
+
(error) => __async(this, null, function* () {
|
|
2577
|
+
if (error) {
|
|
2578
|
+
yield this.storage.removeTransport();
|
|
2579
|
+
reject(error);
|
|
2580
|
+
} else {
|
|
2581
|
+
yield this.storage.setTransport("mwp" /* MWP */);
|
|
2582
|
+
resolve();
|
|
2583
|
+
}
|
|
2584
|
+
})
|
|
2585
|
+
).catch((error) => {
|
|
2586
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
2587
|
+
});
|
|
2588
|
+
});
|
|
2589
|
+
});
|
|
2590
|
+
};
|
|
2591
|
+
showInstallModal_fn = function(desktopPreferred, scopes, caipAccountIds) {
|
|
2592
|
+
return __async(this, null, function* () {
|
|
2593
|
+
var _a2;
|
|
2594
|
+
(_a2 = __privateGet(this, _beforeUnloadListener)) != null ? _a2 : __privateSet(this, _beforeUnloadListener, __privateMethod(this, _MultichainSDK_instances, createBeforeUnloadListener_fn).call(this));
|
|
2595
|
+
yield __privateMethod(this, _MultichainSDK_instances, renderInstallModalAsync_fn).call(this, desktopPreferred, scopes, caipAccountIds);
|
|
2596
|
+
});
|
|
2597
|
+
};
|
|
2598
|
+
setupDefaultTransport_fn = function() {
|
|
2599
|
+
return __async(this, null, function* () {
|
|
2600
|
+
this.state = "connecting";
|
|
2601
|
+
yield this.storage.setTransport("browser" /* Browser */);
|
|
2602
|
+
const transport = new DefaultTransport();
|
|
2603
|
+
__privateSet(this, _listener, transport.onNotification(
|
|
2604
|
+
__privateMethod(this, _MultichainSDK_instances, onTransportNotification_fn).bind(this)
|
|
2605
|
+
));
|
|
2606
|
+
__privateSet(this, _transport2, transport);
|
|
2607
|
+
return transport;
|
|
2608
|
+
});
|
|
2609
|
+
};
|
|
2610
|
+
deeplinkConnect_fn = function(scopes, caipAccountIds) {
|
|
2611
|
+
return __async(this, null, function* () {
|
|
2612
|
+
return new Promise((resolve, reject) => {
|
|
2613
|
+
const dappClientMessageHandler = (payload) => {
|
|
2614
|
+
var _a2;
|
|
2615
|
+
if (typeof payload !== "object" || payload === null || !("data" in payload)) {
|
|
2616
|
+
return;
|
|
2617
|
+
}
|
|
2618
|
+
const data = payload.data;
|
|
2619
|
+
if (typeof data === "object" && data !== null) {
|
|
2620
|
+
if (data.error) {
|
|
2621
|
+
this.dappClient.off("message", dappClientMessageHandler);
|
|
2622
|
+
reject(data.error);
|
|
2623
|
+
}
|
|
2624
|
+
if ((_a2 = data == null ? void 0 : data.result) == null ? void 0 : _a2.sessionScopes) {
|
|
2625
|
+
this.dappClient.off("message", dappClientMessageHandler);
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
};
|
|
2629
|
+
this.dappClient.on("message", dappClientMessageHandler);
|
|
2630
|
+
let timeout;
|
|
2631
|
+
if (this.transport.isConnected()) {
|
|
2632
|
+
timeout = setTimeout(() => {
|
|
2633
|
+
this.openDeeplinkIfNeeded();
|
|
2634
|
+
}, 250);
|
|
2635
|
+
} else {
|
|
2636
|
+
this.dappClient.once(
|
|
2637
|
+
"session_request",
|
|
2638
|
+
(sessionRequest) => {
|
|
2639
|
+
var _a2;
|
|
2640
|
+
const connectionRequest = {
|
|
2641
|
+
sessionRequest,
|
|
2642
|
+
metadata: {
|
|
2643
|
+
dapp: this.options.dapp,
|
|
2644
|
+
sdk: { version: getVersion(), platform: getPlatformType() }
|
|
2645
|
+
}
|
|
2646
|
+
};
|
|
2647
|
+
const deeplink = this.options.ui.factory.createConnectionDeeplink(
|
|
2648
|
+
connectionRequest
|
|
2649
|
+
);
|
|
2650
|
+
const universalLink = this.options.ui.factory.createConnectionUniversalLink(
|
|
2651
|
+
connectionRequest
|
|
2652
|
+
);
|
|
2653
|
+
if ((_a2 = this.options.mobile) == null ? void 0 : _a2.preferredOpenLink) {
|
|
2654
|
+
this.options.mobile.preferredOpenLink(deeplink, "_self");
|
|
2655
|
+
} else {
|
|
2656
|
+
openDeeplink(this.options, deeplink, universalLink);
|
|
2657
|
+
}
|
|
2658
|
+
}
|
|
2659
|
+
);
|
|
2660
|
+
}
|
|
2661
|
+
return this.transport.connect({ scopes, caipAccountIds }).then(resolve).catch((error) => __async(this, null, function* () {
|
|
2662
|
+
yield this.storage.removeTransport();
|
|
2663
|
+
this.dappClient.off("message", dappClientMessageHandler);
|
|
2664
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
2665
|
+
})).finally(() => {
|
|
2666
|
+
if (timeout) {
|
|
2667
|
+
clearTimeout(timeout);
|
|
2668
|
+
}
|
|
2669
|
+
});
|
|
2670
|
+
});
|
|
2671
|
+
});
|
|
2672
|
+
};
|
|
2673
|
+
handleConnection_fn = function(promise, scopes, transportType) {
|
|
2674
|
+
return __async(this, null, function* () {
|
|
2675
|
+
this.state = "connecting";
|
|
2676
|
+
return promise.then(() => __async(this, null, function* () {
|
|
2677
|
+
this.state = "connected";
|
|
2678
|
+
try {
|
|
2679
|
+
const baseProps = yield getBaseAnalyticsProperties(
|
|
2680
|
+
this.options,
|
|
2681
|
+
this.storage
|
|
2682
|
+
);
|
|
2683
|
+
import_analytics4.analytics.track("mmconnect_connection_established", __spreadProps(__spreadValues({}, baseProps), {
|
|
2684
|
+
transport_type: transportType,
|
|
2685
|
+
user_permissioned_chains: scopes
|
|
2686
|
+
}));
|
|
2687
|
+
} catch (error) {
|
|
2688
|
+
logger2("Error tracking connection_established event", error);
|
|
2689
|
+
}
|
|
2690
|
+
return void 0;
|
|
2691
|
+
})).catch((error) => __async(this, null, function* () {
|
|
2692
|
+
this.state = "disconnected";
|
|
2693
|
+
try {
|
|
2694
|
+
const baseProps = yield getBaseAnalyticsProperties(
|
|
2695
|
+
this.options,
|
|
2696
|
+
this.storage
|
|
2697
|
+
);
|
|
2698
|
+
const isRejection = isRejectionError(error);
|
|
2699
|
+
if (isRejection) {
|
|
2700
|
+
import_analytics4.analytics.track("mmconnect_connection_rejected", __spreadProps(__spreadValues({}, baseProps), {
|
|
2701
|
+
transport_type: transportType
|
|
2702
|
+
}));
|
|
2703
|
+
} else {
|
|
2704
|
+
import_analytics4.analytics.track("mmconnect_connection_failed", __spreadProps(__spreadValues({}, baseProps), {
|
|
2705
|
+
transport_type: transportType
|
|
2706
|
+
}));
|
|
2707
|
+
}
|
|
2708
|
+
} catch (e) {
|
|
2709
|
+
logger2("Error tracking connection failed/rejected event", error);
|
|
2710
|
+
}
|
|
2711
|
+
throw error;
|
|
2712
|
+
}));
|
|
2713
|
+
});
|
|
2714
|
+
};
|
|
2715
|
+
var MultichainSDK = _MultichainSDK;
|
|
2729
2716
|
|
|
2730
2717
|
// src/store/index.ts
|
|
2731
2718
|
var uuid = __toESM(require("uuid"));
|
|
@@ -2909,37 +2896,24 @@ var Store = class extends StoreClient {
|
|
|
2909
2896
|
// src/ui/index.ts
|
|
2910
2897
|
var import_onboarding = __toESM(require("@metamask/onboarding"));
|
|
2911
2898
|
init_domain();
|
|
2912
|
-
init_qr();
|
|
2913
2899
|
init_utils();
|
|
2914
|
-
|
|
2900
|
+
|
|
2901
|
+
// src/ui/preload.web.ts
|
|
2915
2902
|
function preload() {
|
|
2916
2903
|
return __async(this, null, function* () {
|
|
2917
|
-
if (
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
return Promise.resolve(void 0);
|
|
2926
|
-
}));
|
|
2927
|
-
} else {
|
|
2928
|
-
const dynamicImport = (0, eval)("import");
|
|
2929
|
-
__instance != null ? __instance : __instance = yield dynamicImport(
|
|
2930
|
-
"@metamask/multichain-ui/dist/loader/index.js"
|
|
2931
|
-
).then((loader) => __async(null, null, function* () {
|
|
2932
|
-
if (typeof (loader == null ? void 0 : loader.defineCustomElements) === "function") {
|
|
2933
|
-
loader.defineCustomElements();
|
|
2934
|
-
}
|
|
2935
|
-
return Promise.resolve(loader);
|
|
2936
|
-
})).catch((error) => __async(null, null, function* () {
|
|
2937
|
-
console.error(`Gracefully Failed to load modal customElements:`, error);
|
|
2938
|
-
return Promise.resolve(void 0);
|
|
2939
|
-
}));
|
|
2904
|
+
if (typeof document === "undefined") {
|
|
2905
|
+
return;
|
|
2906
|
+
}
|
|
2907
|
+
try {
|
|
2908
|
+
const { defineCustomElements } = yield import("@metamask/multichain-ui/loader");
|
|
2909
|
+
yield defineCustomElements();
|
|
2910
|
+
} catch (error) {
|
|
2911
|
+
console.error("Failed to load customElements:", error);
|
|
2940
2912
|
}
|
|
2941
2913
|
});
|
|
2942
2914
|
}
|
|
2915
|
+
|
|
2916
|
+
// src/ui/index.ts
|
|
2943
2917
|
var ModalFactory = class {
|
|
2944
2918
|
/**
|
|
2945
2919
|
* Creates a new modal factory instance.
|
|
@@ -2962,8 +2936,8 @@ var ModalFactory = class {
|
|
|
2962
2936
|
}
|
|
2963
2937
|
unload(error) {
|
|
2964
2938
|
return __async(this, null, function* () {
|
|
2965
|
-
var
|
|
2966
|
-
(
|
|
2939
|
+
var _a2, _b;
|
|
2940
|
+
(_a2 = this.modal) == null ? void 0 : _a2.unmount();
|
|
2967
2941
|
yield (_b = this.successCallback) == null ? void 0 : _b.call(this, error);
|
|
2968
2942
|
});
|
|
2969
2943
|
}
|
|
@@ -3031,9 +3005,9 @@ var ModalFactory = class {
|
|
|
3031
3005
|
}
|
|
3032
3006
|
renderInstallModal(showInstallModal, createConnectionRequest, successCallback) {
|
|
3033
3007
|
return __async(this, null, function* () {
|
|
3034
|
-
var
|
|
3035
|
-
(
|
|
3036
|
-
yield
|
|
3008
|
+
var _a2;
|
|
3009
|
+
(_a2 = this.modal) == null ? void 0 : _a2.unmount();
|
|
3010
|
+
yield preload();
|
|
3037
3011
|
this.successCallback = successCallback;
|
|
3038
3012
|
const parentElement = this.getMountedContainer();
|
|
3039
3013
|
const connectionRequest = yield createConnectionRequest();
|
|
@@ -3058,9 +3032,9 @@ var ModalFactory = class {
|
|
|
3058
3032
|
}
|
|
3059
3033
|
renderOTPCodeModal(createOTPCode, successCallback, updateOTPCode) {
|
|
3060
3034
|
return __async(this, null, function* () {
|
|
3061
|
-
var
|
|
3062
|
-
(
|
|
3063
|
-
yield
|
|
3035
|
+
var _a2;
|
|
3036
|
+
(_a2 = this.modal) == null ? void 0 : _a2.unmount();
|
|
3037
|
+
yield preload();
|
|
3064
3038
|
this.successCallback = successCallback;
|
|
3065
3039
|
const container = this.getMountedContainer();
|
|
3066
3040
|
const otpCode = yield createOTPCode();
|