@metamask/connect-multichain 0.3.2 → 0.5.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 +55 -15
- package/README.md +1 -1
- package/dist/browser/es/connect-multichain.d.mts +26 -12
- package/dist/browser/es/connect-multichain.mjs +846 -598
- 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 +26 -12
- package/dist/browser/iife/connect-multichain.js +4793 -2291
- 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 +26 -12
- package/dist/browser/umd/connect-multichain.js +846 -598
- 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 +26 -12
- package/dist/node/cjs/connect-multichain.js +846 -609
- 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 +26 -12
- package/dist/node/es/connect-multichain.mjs +844 -607
- 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 +26 -12
- package/dist/react-native/es/connect-multichain.mjs +827 -592
- 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/index.d.ts +4 -4
- package/dist/src/domain/multichain/index.d.ts.map +1 -1
- package/dist/src/domain/multichain/index.js.map +1 -1
- package/dist/src/domain/multichain/types.d.ts +4 -6
- package/dist/src/domain/multichain/types.d.ts.map +1 -1
- package/dist/src/domain/ui/types.d.ts +7 -0
- package/dist/src/domain/ui/types.d.ts.map +1 -1
- package/dist/src/domain/ui/types.js.map +1 -1
- package/dist/src/index.browser.d.ts +1 -1
- package/dist/src/index.browser.d.ts.map +1 -1
- package/dist/src/index.browser.js +1 -1
- package/dist/src/index.browser.js.map +1 -1
- package/dist/src/index.native.d.ts +1 -1
- package/dist/src/index.native.d.ts.map +1 -1
- package/dist/src/index.native.js +2 -2
- package/dist/src/index.native.js.map +1 -1
- package/dist/src/index.node.d.ts +1 -1
- package/dist/src/index.node.d.ts.map +1 -1
- package/dist/src/index.node.js +1 -1
- package/dist/src/index.node.js.map +1 -1
- package/dist/src/multichain/index.d.ts +8 -27
- package/dist/src/multichain/index.d.ts.map +1 -1
- package/dist/src/multichain/index.js +480 -427
- 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/default/index.d.ts +2 -1
- package/dist/src/multichain/transports/default/index.d.ts.map +1 -1
- package/dist/src/multichain/transports/default/index.js +1 -0
- package/dist/src/multichain/transports/default/index.js.map +1 -1
- package/dist/src/multichain/transports/multichainApiClientWrapper/index.d.ts +21 -0
- package/dist/src/multichain/transports/multichainApiClientWrapper/index.d.ts.map +1 -0
- package/dist/src/multichain/transports/multichainApiClientWrapper/index.js +159 -0
- package/dist/src/multichain/transports/multichainApiClientWrapper/index.js.map +1 -0
- package/dist/src/multichain/transports/mwp/index.d.ts +4 -1
- package/dist/src/multichain/transports/mwp/index.d.ts.map +1 -1
- package/dist/src/multichain/transports/mwp/index.js +76 -6
- package/dist/src/multichain/transports/mwp/index.js.map +1 -1
- package/dist/src/ui/ModalFactory.d.ts +54 -0
- package/dist/src/ui/ModalFactory.d.ts.map +1 -0
- package/dist/src/ui/ModalFactory.js +171 -0
- package/dist/src/ui/ModalFactory.js.map +1 -0
- package/dist/src/ui/index.d.ts +11 -39
- package/dist/src/ui/index.d.ts.map +1 -1
- package/dist/src/ui/index.js +20 -179
- package/dist/src/ui/index.js.map +1 -1
- package/dist/src/ui/index.native.d.ts +13 -0
- package/dist/src/ui/index.native.d.ts.map +1 -0
- package/dist/src/ui/index.native.js +24 -0
- package/dist/src/ui/index.native.js.map +1 -0
- package/dist/src/ui/modals/base/AbstractInstallModal.d.ts.map +1 -1
- package/dist/src/ui/modals/base/AbstractInstallModal.js +0 -4
- package/dist/src/ui/modals/base/AbstractInstallModal.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/types/connect-multichain.d.ts +26 -12
- package/package.json +10 -8
- 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 +0 -32
- package/dist/src/ui/qr.js.map +0 -1
|
@@ -235,8 +235,8 @@ var init_logger = __esm({
|
|
|
235
235
|
debug.enable(namespace);
|
|
236
236
|
};
|
|
237
237
|
isEnabled = (namespace, storage) => __async(null, null, function* () {
|
|
238
|
-
var
|
|
239
|
-
if ("process" in globalThis && ((
|
|
238
|
+
var _a2;
|
|
239
|
+
if ("process" in globalThis && ((_a2 = process == null ? void 0 : process.env) == null ? void 0 : _a2.DEBUG)) {
|
|
240
240
|
const { DEBUG } = process.env;
|
|
241
241
|
return isNamespaceEnabled(DEBUG, namespace);
|
|
242
242
|
}
|
|
@@ -406,35 +406,35 @@ var init_multichain = __esm({
|
|
|
406
406
|
// src/domain/platform/index.ts
|
|
407
407
|
import Bowser from "bowser";
|
|
408
408
|
function isNotBrowser() {
|
|
409
|
-
var
|
|
409
|
+
var _a2;
|
|
410
410
|
if (typeof window === "undefined") {
|
|
411
411
|
return true;
|
|
412
412
|
}
|
|
413
413
|
if (!(window == null ? void 0 : window.navigator)) {
|
|
414
414
|
return true;
|
|
415
415
|
}
|
|
416
|
-
if (typeof global !== "undefined" && ((
|
|
416
|
+
if (typeof global !== "undefined" && ((_a2 = global == null ? void 0 : global.navigator) == null ? void 0 : _a2.product) === "ReactNative") {
|
|
417
417
|
return true;
|
|
418
418
|
}
|
|
419
419
|
return (navigator == null ? void 0 : navigator.product) === "ReactNative";
|
|
420
420
|
}
|
|
421
421
|
function isReactNative() {
|
|
422
|
-
var
|
|
422
|
+
var _a2;
|
|
423
423
|
const hasWindowNavigator = typeof window !== "undefined" && window.navigator !== void 0;
|
|
424
424
|
const nav = hasWindowNavigator ? window.navigator : void 0;
|
|
425
425
|
if (!nav) {
|
|
426
426
|
return false;
|
|
427
427
|
}
|
|
428
|
-
return hasWindowNavigator && ((
|
|
428
|
+
return hasWindowNavigator && ((_a2 = window.navigator) == null ? void 0 : _a2.product) === "ReactNative";
|
|
429
429
|
}
|
|
430
430
|
function isMetaMaskMobileWebView() {
|
|
431
431
|
return typeof window !== "undefined" && // @ts-expect-error ReactNativeWebView should be defined
|
|
432
432
|
Boolean(window.ReactNativeWebView) && Boolean(window.navigator.userAgent.endsWith("MetaMaskMobile"));
|
|
433
433
|
}
|
|
434
434
|
function isMobile() {
|
|
435
|
-
var
|
|
435
|
+
var _a2, _b;
|
|
436
436
|
const browser = Bowser.parse(window.navigator.userAgent);
|
|
437
|
-
return ((
|
|
437
|
+
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";
|
|
438
438
|
}
|
|
439
439
|
function getPlatformType() {
|
|
440
440
|
if (isReactNative()) {
|
|
@@ -452,11 +452,11 @@ function getPlatformType() {
|
|
|
452
452
|
return "web-desktop" /* DesktopWeb */;
|
|
453
453
|
}
|
|
454
454
|
function isMetamaskExtensionInstalled() {
|
|
455
|
-
var
|
|
455
|
+
var _a2;
|
|
456
456
|
if (typeof window === "undefined") {
|
|
457
457
|
return false;
|
|
458
458
|
}
|
|
459
|
-
return Boolean((
|
|
459
|
+
return Boolean((_a2 = window.ethereum) == null ? void 0 : _a2.isMetaMask);
|
|
460
460
|
}
|
|
461
461
|
function isSecure() {
|
|
462
462
|
const platformType = getPlatformType();
|
|
@@ -487,8 +487,8 @@ var init_platform = __esm({
|
|
|
487
487
|
return new Promise((resolve) => {
|
|
488
488
|
const providers = [];
|
|
489
489
|
const handler = (event) => {
|
|
490
|
-
var
|
|
491
|
-
if ((_b = (
|
|
490
|
+
var _a2, _b;
|
|
491
|
+
if ((_b = (_a2 = event == null ? void 0 : event.detail) == null ? void 0 : _a2.info) == null ? void 0 : _b.rdns) {
|
|
492
492
|
providers.push(event.detail);
|
|
493
493
|
}
|
|
494
494
|
};
|
|
@@ -498,8 +498,8 @@ var init_platform = __esm({
|
|
|
498
498
|
window.removeEventListener("eip6963:announceProvider", handler);
|
|
499
499
|
const hasMetaMask = providers.some(
|
|
500
500
|
(provider) => {
|
|
501
|
-
var
|
|
502
|
-
return (_b = (
|
|
501
|
+
var _a2, _b;
|
|
502
|
+
return (_b = (_a2 = provider == null ? void 0 : provider.info) == null ? void 0 : _a2.rdns) == null ? void 0 : _b.startsWith("io.metamask");
|
|
503
503
|
}
|
|
504
504
|
);
|
|
505
505
|
resolve(hasMetaMask);
|
|
@@ -603,8 +603,8 @@ function compressString(str) {
|
|
|
603
603
|
return base64Encode(binaryString);
|
|
604
604
|
}
|
|
605
605
|
function getDappId(dapp) {
|
|
606
|
-
var
|
|
607
|
-
return (
|
|
606
|
+
var _a2;
|
|
607
|
+
return (_a2 = dapp.url) != null ? _a2 : dapp.name;
|
|
608
608
|
}
|
|
609
609
|
function openDeeplink(options, deeplink, universalLink) {
|
|
610
610
|
const { mobile } = options;
|
|
@@ -634,10 +634,10 @@ function getOptionalScopes(scopes) {
|
|
|
634
634
|
);
|
|
635
635
|
}
|
|
636
636
|
function setupDappMetadata(options) {
|
|
637
|
-
var
|
|
637
|
+
var _a2, _b;
|
|
638
638
|
const platform = getPlatformType();
|
|
639
639
|
const isBrowser = platform === "web-desktop" /* DesktopWeb */ || platform === "web-mobile" /* MobileWeb */ || platform === "in-app-browser" /* MetaMaskMobileWebview */;
|
|
640
|
-
if (!((
|
|
640
|
+
if (!((_a2 = options.dapp) == null ? void 0 : _a2.name)) {
|
|
641
641
|
throw new Error("You must provide dapp name");
|
|
642
642
|
}
|
|
643
643
|
if (isBrowser) {
|
|
@@ -708,17 +708,17 @@ function getValidAccounts(caipAccountIds) {
|
|
|
708
708
|
);
|
|
709
709
|
}
|
|
710
710
|
function addValidAccounts(optionalScopes, validAccounts) {
|
|
711
|
-
var
|
|
711
|
+
var _a2;
|
|
712
712
|
if (!optionalScopes || !(validAccounts == null ? void 0 : validAccounts.length)) {
|
|
713
713
|
return optionalScopes;
|
|
714
714
|
}
|
|
715
715
|
const result = Object.fromEntries(
|
|
716
716
|
Object.entries(optionalScopes).map(([scope, scopeData]) => {
|
|
717
|
-
var
|
|
717
|
+
var _a3, _b, _c;
|
|
718
718
|
return [
|
|
719
719
|
scope,
|
|
720
720
|
{
|
|
721
|
-
methods: [...(
|
|
721
|
+
methods: [...(_a3 = scopeData == null ? void 0 : scopeData.methods) != null ? _a3 : []],
|
|
722
722
|
notifications: [...(_b = scopeData == null ? void 0 : scopeData.notifications) != null ? _b : []],
|
|
723
723
|
accounts: [...(_c = scopeData == null ? void 0 : scopeData.accounts) != null ? _c : []]
|
|
724
724
|
}
|
|
@@ -732,7 +732,7 @@ function addValidAccounts(optionalScopes, validAccounts) {
|
|
|
732
732
|
if (!accountsByChain.has(chainKey)) {
|
|
733
733
|
accountsByChain.set(chainKey, []);
|
|
734
734
|
}
|
|
735
|
-
(
|
|
735
|
+
(_a2 = accountsByChain.get(chainKey)) == null ? void 0 : _a2.push(accountId);
|
|
736
736
|
}
|
|
737
737
|
for (const [scopeKey, scopeData] of Object.entries(result)) {
|
|
738
738
|
if (!(scopeData == null ? void 0 : scopeData.accounts)) {
|
|
@@ -762,7 +762,7 @@ var init_utils = __esm({
|
|
|
762
762
|
"use strict";
|
|
763
763
|
init_domain();
|
|
764
764
|
extractFavicon = () => {
|
|
765
|
-
var
|
|
765
|
+
var _a2;
|
|
766
766
|
if (typeof document === "undefined") {
|
|
767
767
|
return void 0;
|
|
768
768
|
}
|
|
@@ -770,7 +770,7 @@ var init_utils = __esm({
|
|
|
770
770
|
const nodeList = document.getElementsByTagName("link");
|
|
771
771
|
for (let i = 0; i < nodeList.length; i++) {
|
|
772
772
|
if (nodeList[i].getAttribute("rel") === "icon" || nodeList[i].getAttribute("rel") === "shortcut icon") {
|
|
773
|
-
favicon = (
|
|
773
|
+
favicon = (_a2 = nodeList[i].getAttribute("href")) != null ? _a2 : void 0;
|
|
774
774
|
}
|
|
775
775
|
}
|
|
776
776
|
return favicon;
|
|
@@ -780,25 +780,25 @@ var init_utils = __esm({
|
|
|
780
780
|
|
|
781
781
|
// src/multichain/utils/analytics.ts
|
|
782
782
|
function isRejectionError(error) {
|
|
783
|
-
var
|
|
783
|
+
var _a2, _b;
|
|
784
784
|
if (typeof error !== "object" || error === null) {
|
|
785
785
|
return false;
|
|
786
786
|
}
|
|
787
787
|
const errorObj = error;
|
|
788
788
|
const errorCode = errorObj.code;
|
|
789
|
-
const errorMessage = (_b = (
|
|
789
|
+
const errorMessage = (_b = (_a2 = errorObj.message) == null ? void 0 : _a2.toLowerCase()) != null ? _b : "";
|
|
790
790
|
return errorCode === 4001 || // User rejected request (common EIP-1193 code)
|
|
791
791
|
errorCode === 4100 || // Unauthorized (common rejection code)
|
|
792
792
|
errorMessage.includes("reject") || errorMessage.includes("denied") || errorMessage.includes("cancel") || errorMessage.includes("user");
|
|
793
793
|
}
|
|
794
794
|
function getBaseAnalyticsProperties(options, storage) {
|
|
795
795
|
return __async(this, null, function* () {
|
|
796
|
-
var
|
|
796
|
+
var _a2, _b;
|
|
797
797
|
const version = getVersion();
|
|
798
798
|
const dappId = getDappId(options.dapp);
|
|
799
799
|
const platform = getPlatformType();
|
|
800
800
|
const anonId = yield storage.getAnonId();
|
|
801
|
-
const integrationType = (_b = (
|
|
801
|
+
const integrationType = (_b = (_a2 = options.analytics) == null ? void 0 : _a2.integrationType) != null ? _b : "unknown" /* UNKNOWN */;
|
|
802
802
|
return {
|
|
803
803
|
mmconnect_version: version,
|
|
804
804
|
dapp_id: dappId,
|
|
@@ -810,11 +810,11 @@ function getBaseAnalyticsProperties(options, storage) {
|
|
|
810
810
|
}
|
|
811
811
|
function getWalletActionAnalyticsProperties(options, storage, invokeOptions) {
|
|
812
812
|
return __async(this, null, function* () {
|
|
813
|
-
var
|
|
813
|
+
var _a2, _b;
|
|
814
814
|
const version = getVersion();
|
|
815
815
|
const dappId = getDappId(options.dapp);
|
|
816
816
|
const anonId = yield storage.getAnonId();
|
|
817
|
-
const integrationType = (_b = (
|
|
817
|
+
const integrationType = (_b = (_a2 = options.analytics) == null ? void 0 : _a2.integrationType) != null ? _b : "unknown";
|
|
818
818
|
return {
|
|
819
819
|
mmconnect_version: version,
|
|
820
820
|
dapp_id: dappId,
|
|
@@ -955,11 +955,6 @@ var init_AbstractInstallModal = __esm({
|
|
|
955
955
|
`[UI: InstallModal-nodejs()] \u274C Error generating new QR code: ${error}`
|
|
956
956
|
);
|
|
957
957
|
}
|
|
958
|
-
} else {
|
|
959
|
-
const generateQRCode = yield this.options.generateQRCode(
|
|
960
|
-
currentConnectionRequest
|
|
961
|
-
);
|
|
962
|
-
this.renderQRCode(generateQRCode, currentConnectionRequest);
|
|
963
958
|
}
|
|
964
959
|
}), 1e3);
|
|
965
960
|
}
|
|
@@ -986,7 +981,7 @@ var init_install = __esm({
|
|
|
986
981
|
renderQRCode() {
|
|
987
982
|
}
|
|
988
983
|
mount() {
|
|
989
|
-
var
|
|
984
|
+
var _a2;
|
|
990
985
|
const { options } = this;
|
|
991
986
|
const modal = document.createElement(
|
|
992
987
|
"mm-install-modal"
|
|
@@ -1003,14 +998,14 @@ var init_install = __esm({
|
|
|
1003
998
|
);
|
|
1004
999
|
modal.link = options.link;
|
|
1005
1000
|
this.instance = modal;
|
|
1006
|
-
(
|
|
1001
|
+
(_a2 = options.parentElement) == null ? void 0 : _a2.appendChild(modal);
|
|
1007
1002
|
this.startExpirationCheck(options.connectionRequest);
|
|
1008
1003
|
}
|
|
1009
1004
|
unmount() {
|
|
1010
|
-
var
|
|
1005
|
+
var _a2;
|
|
1011
1006
|
const { options, instance: modal } = this;
|
|
1012
1007
|
this.stopExpirationCheck();
|
|
1013
|
-
if (modal && ((
|
|
1008
|
+
if (modal && ((_a2 = options.parentElement) == null ? void 0 : _a2.contains(modal))) {
|
|
1014
1009
|
options.parentElement.removeChild(modal);
|
|
1015
1010
|
this.instance = void 0;
|
|
1016
1011
|
}
|
|
@@ -1122,8 +1117,8 @@ var init_web2 = __esm({
|
|
|
1122
1117
|
const request = store.get(key);
|
|
1123
1118
|
request.onerror = () => reject(new Error("Failed to get value from IndexedDB."));
|
|
1124
1119
|
request.onsuccess = () => {
|
|
1125
|
-
var
|
|
1126
|
-
return resolve((
|
|
1120
|
+
var _a2;
|
|
1121
|
+
return resolve((_a2 = request.result) != null ? _a2 : null);
|
|
1127
1122
|
};
|
|
1128
1123
|
} catch (error) {
|
|
1129
1124
|
reject(error);
|
|
@@ -1232,8 +1227,8 @@ var RpcClient = class {
|
|
|
1232
1227
|
});
|
|
1233
1228
|
}
|
|
1234
1229
|
getRpcEndpoint(scope) {
|
|
1235
|
-
var
|
|
1236
|
-
const supportedNetworks = (_c = (_b = (
|
|
1230
|
+
var _a2, _b, _c;
|
|
1231
|
+
const supportedNetworks = (_c = (_b = (_a2 = this.config) == null ? void 0 : _a2.api) == null ? void 0 : _b.supportedNetworks) != null ? _c : {};
|
|
1237
1232
|
const rpcEndpoint = supportedNetworks[scope];
|
|
1238
1233
|
if (!rpcEndpoint) {
|
|
1239
1234
|
throw new MissingRpcEndpointErr(`No RPC endpoint found for scope ${scope}`);
|
|
@@ -1388,24 +1383,17 @@ var RequestRouter = class {
|
|
|
1388
1383
|
_RequestRouter_instances = new WeakSet();
|
|
1389
1384
|
withAnalyticsTracking_fn = function(options, execute) {
|
|
1390
1385
|
return __async(this, null, function* () {
|
|
1391
|
-
|
|
1392
|
-
if ((_a = this.config.analytics) == null ? void 0 : _a.enabled) {
|
|
1393
|
-
yield __privateMethod(this, _RequestRouter_instances, trackWalletActionRequested_fn).call(this, options);
|
|
1394
|
-
}
|
|
1386
|
+
yield __privateMethod(this, _RequestRouter_instances, trackWalletActionRequested_fn).call(this, options);
|
|
1395
1387
|
try {
|
|
1396
1388
|
const result = yield execute();
|
|
1397
|
-
|
|
1398
|
-
yield __privateMethod(this, _RequestRouter_instances, trackWalletActionSucceeded_fn).call(this, options);
|
|
1399
|
-
}
|
|
1389
|
+
yield __privateMethod(this, _RequestRouter_instances, trackWalletActionSucceeded_fn).call(this, options);
|
|
1400
1390
|
return result;
|
|
1401
1391
|
} catch (error) {
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
yield __privateMethod(this, _RequestRouter_instances, trackWalletActionFailed_fn).call(this, options);
|
|
1408
|
-
}
|
|
1392
|
+
const isRejection = isRejectionError(error);
|
|
1393
|
+
if (isRejection) {
|
|
1394
|
+
yield __privateMethod(this, _RequestRouter_instances, trackWalletActionRejected_fn).call(this, options);
|
|
1395
|
+
} else {
|
|
1396
|
+
yield __privateMethod(this, _RequestRouter_instances, trackWalletActionFailed_fn).call(this, options);
|
|
1409
1397
|
}
|
|
1410
1398
|
throw new RPCInvokeMethodErr(error.message);
|
|
1411
1399
|
}
|
|
@@ -1467,11 +1455,11 @@ var DefaultTransport = class {
|
|
|
1467
1455
|
id: requestId
|
|
1468
1456
|
}, payload);
|
|
1469
1457
|
return new Promise((resolve, reject) => {
|
|
1470
|
-
var
|
|
1458
|
+
var _a2;
|
|
1471
1459
|
const timeout = setTimeout(() => {
|
|
1472
1460
|
__privateGet(this, _pendingRequests).delete(requestId);
|
|
1473
1461
|
reject(new Error("Request timeout"));
|
|
1474
|
-
}, (
|
|
1462
|
+
}, (_a2 = options == null ? void 0 : options.timeout) != null ? _a2 : __privateGet(this, _defaultRequestOptions).timeout);
|
|
1475
1463
|
__privateGet(this, _pendingRequests).set(requestId, {
|
|
1476
1464
|
resolve: (response) => {
|
|
1477
1465
|
resolve(response);
|
|
@@ -1495,7 +1483,7 @@ var DefaultTransport = class {
|
|
|
1495
1483
|
}
|
|
1496
1484
|
connect(options) {
|
|
1497
1485
|
return __async(this, null, function* () {
|
|
1498
|
-
var
|
|
1486
|
+
var _a2, _b, _c, _d, _e, _f, _g;
|
|
1499
1487
|
__privateMethod(this, _DefaultTransport_instances, setupMessageListener_fn).call(this);
|
|
1500
1488
|
yield __privateGet(this, _transport).connect();
|
|
1501
1489
|
const sessionRequest = yield this.request(
|
|
@@ -1508,7 +1496,7 @@ var DefaultTransport = class {
|
|
|
1508
1496
|
let walletSession = sessionRequest.result;
|
|
1509
1497
|
if (walletSession && options && !options.forceRequest) {
|
|
1510
1498
|
const currentScopes = Object.keys(
|
|
1511
|
-
(
|
|
1499
|
+
(_a2 = walletSession == null ? void 0 : walletSession.sessionScopes) != null ? _a2 : {}
|
|
1512
1500
|
);
|
|
1513
1501
|
const proposedScopes = (_b = options == null ? void 0 : options.scopes) != null ? _b : [];
|
|
1514
1502
|
const proposedCaipAccountIds = (_c = options == null ? void 0 : options.caipAccountIds) != null ? _c : [];
|
|
@@ -1545,7 +1533,8 @@ var DefaultTransport = class {
|
|
|
1545
1533
|
getValidAccounts((_g = options == null ? void 0 : options.caipAccountIds) != null ? _g : [])
|
|
1546
1534
|
);
|
|
1547
1535
|
const createSessionParams = {
|
|
1548
|
-
optionalScopes
|
|
1536
|
+
optionalScopes,
|
|
1537
|
+
sessionProperties: options == null ? void 0 : options.sessionProperties
|
|
1549
1538
|
};
|
|
1550
1539
|
const response = yield this.request(
|
|
1551
1540
|
{ method: "wallet_createSession", params: createSessionParams },
|
|
@@ -1622,16 +1611,16 @@ notifyCallbacks_fn = function(data) {
|
|
|
1622
1611
|
}
|
|
1623
1612
|
};
|
|
1624
1613
|
isMetamaskProviderEvent_fn = function(event) {
|
|
1625
|
-
var
|
|
1626
|
-
return ((_b = (
|
|
1614
|
+
var _a2, _b;
|
|
1615
|
+
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
|
|
1627
1616
|
event.origin === location.origin;
|
|
1628
1617
|
};
|
|
1629
1618
|
handleResponse_fn = function(event) {
|
|
1630
|
-
var
|
|
1619
|
+
var _a2, _b;
|
|
1631
1620
|
if (!__privateMethod(this, _DefaultTransport_instances, isMetamaskProviderEvent_fn).call(this, event)) {
|
|
1632
1621
|
return;
|
|
1633
1622
|
}
|
|
1634
|
-
const responseData = (_b = (
|
|
1623
|
+
const responseData = (_b = (_a2 = event == null ? void 0 : event.data) == null ? void 0 : _a2.data) == null ? void 0 : _b.data;
|
|
1635
1624
|
if (typeof responseData === "object" && responseData !== null && "method" in responseData) {
|
|
1636
1625
|
return;
|
|
1637
1626
|
}
|
|
@@ -1653,11 +1642,11 @@ handleResponse_fn = function(event) {
|
|
|
1653
1642
|
}
|
|
1654
1643
|
};
|
|
1655
1644
|
handleNotification_fn = function(event) {
|
|
1656
|
-
var
|
|
1645
|
+
var _a2, _b;
|
|
1657
1646
|
if (!__privateMethod(this, _DefaultTransport_instances, isMetamaskProviderEvent_fn).call(this, event)) {
|
|
1658
1647
|
return;
|
|
1659
1648
|
}
|
|
1660
|
-
const responseData = (_b = (
|
|
1649
|
+
const responseData = (_b = (_a2 = event == null ? void 0 : event.data) == null ? void 0 : _a2.data) == null ? void 0 : _b.data;
|
|
1661
1650
|
if (typeof responseData === "object" && responseData.method === "metamask_chainChanged" || responseData.method === "metamask_accountsChanged") {
|
|
1662
1651
|
__privateMethod(this, _DefaultTransport_instances, notifyCallbacks_fn).call(this, responseData);
|
|
1663
1652
|
}
|
|
@@ -1687,6 +1676,7 @@ var MULTICHAIN_PROVIDER_STREAM_NAME = "metamask-multichain-provider";
|
|
|
1687
1676
|
var DEFAULT_REQUEST_TIMEOUT2 = 60 * 1e3;
|
|
1688
1677
|
var CONNECTION_GRACE_PERIOD = 60 * 1e3;
|
|
1689
1678
|
var DEFAULT_CONNECTION_TIMEOUT = DEFAULT_REQUEST_TIMEOUT2 + CONNECTION_GRACE_PERIOD;
|
|
1679
|
+
var DEFAULT_RESUME_TIMEOUT = 10 * 1e3;
|
|
1690
1680
|
var SESSION_STORE_KEY = "cache_wallet_getSession";
|
|
1691
1681
|
var ACCOUNTS_STORE_KEY = "cache_eth_accounts";
|
|
1692
1682
|
var CHAIN_STORE_KEY = "cache_eth_chainId";
|
|
@@ -1703,7 +1693,8 @@ var logger = createLogger("metamask-sdk:transport");
|
|
|
1703
1693
|
var MWPTransport = class {
|
|
1704
1694
|
constructor(dappClient, kvstore, options = {
|
|
1705
1695
|
requestTimeout: DEFAULT_REQUEST_TIMEOUT2,
|
|
1706
|
-
connectionTimeout: DEFAULT_CONNECTION_TIMEOUT
|
|
1696
|
+
connectionTimeout: DEFAULT_CONNECTION_TIMEOUT,
|
|
1697
|
+
resumeTimeout: DEFAULT_RESUME_TIMEOUT
|
|
1707
1698
|
}) {
|
|
1708
1699
|
this.dappClient = dappClient;
|
|
1709
1700
|
this.kvstore = kvstore;
|
|
@@ -1778,6 +1769,13 @@ var MWPTransport = class {
|
|
|
1778
1769
|
)
|
|
1779
1770
|
);
|
|
1780
1771
|
}
|
|
1772
|
+
if (message.data.method === "wallet_sessionChanged") {
|
|
1773
|
+
const notification = message.data;
|
|
1774
|
+
const response = {
|
|
1775
|
+
result: notification.params
|
|
1776
|
+
};
|
|
1777
|
+
this.kvstore.set(SESSION_STORE_KEY, JSON.stringify(response));
|
|
1778
|
+
}
|
|
1781
1779
|
this.notifyCallbacks(message.data);
|
|
1782
1780
|
}
|
|
1783
1781
|
}
|
|
@@ -1785,8 +1783,9 @@ var MWPTransport = class {
|
|
|
1785
1783
|
}
|
|
1786
1784
|
onResumeSuccess(resumeResolve, resumeReject, options) {
|
|
1787
1785
|
return __async(this, null, function* () {
|
|
1788
|
-
var
|
|
1786
|
+
var _a2, _b, _c, _d, _e, _f, _g;
|
|
1789
1787
|
try {
|
|
1788
|
+
yield this.waitForWalletSessionIfNotCached();
|
|
1790
1789
|
const sessionRequest = yield this.request({
|
|
1791
1790
|
method: "wallet_getSession"
|
|
1792
1791
|
});
|
|
@@ -1796,7 +1795,7 @@ var MWPTransport = class {
|
|
|
1796
1795
|
let walletSession = sessionRequest.result;
|
|
1797
1796
|
if (walletSession && options) {
|
|
1798
1797
|
const currentScopes = Object.keys(
|
|
1799
|
-
(
|
|
1798
|
+
(_a2 = walletSession == null ? void 0 : walletSession.sessionScopes) != null ? _a2 : {}
|
|
1800
1799
|
);
|
|
1801
1800
|
const proposedScopes = (_b = options == null ? void 0 : options.scopes) != null ? _b : [];
|
|
1802
1801
|
const proposedCaipAccountIds = (_c = options == null ? void 0 : options.caipAccountIds) != null ? _c : [];
|
|
@@ -1861,10 +1860,10 @@ var MWPTransport = class {
|
|
|
1861
1860
|
return cachedWalletSession;
|
|
1862
1861
|
}
|
|
1863
1862
|
return new Promise((resolve, reject) => {
|
|
1864
|
-
var
|
|
1863
|
+
var _a2;
|
|
1865
1864
|
const timeout = setTimeout(() => {
|
|
1866
1865
|
this.rejectRequest(request.id, new TransportTimeoutError());
|
|
1867
|
-
}, (
|
|
1866
|
+
}, (_a2 = options == null ? void 0 : options.timeout) != null ? _a2 : this.options.requestTimeout);
|
|
1868
1867
|
this.pendingRequests.set(request.id, {
|
|
1869
1868
|
request,
|
|
1870
1869
|
method: request.method,
|
|
@@ -1890,30 +1889,32 @@ var MWPTransport = class {
|
|
|
1890
1889
|
logger("active session found", session);
|
|
1891
1890
|
}
|
|
1892
1891
|
let timeout;
|
|
1893
|
-
|
|
1892
|
+
let initialConnectionMessageHandler;
|
|
1893
|
+
const connectionPromise = new Promise((resolve, reject) => __async(this, null, function* () {
|
|
1894
1894
|
let connection;
|
|
1895
1895
|
if (session) {
|
|
1896
1896
|
connection = new Promise((resumeResolve, resumeReject) => {
|
|
1897
|
-
var
|
|
1897
|
+
var _a2;
|
|
1898
1898
|
if (this.dappClient.state === "CONNECTED") {
|
|
1899
1899
|
this.onResumeSuccess(resumeResolve, resumeReject, options);
|
|
1900
1900
|
} else {
|
|
1901
1901
|
this.dappClient.once("connected", () => __async(this, null, function* () {
|
|
1902
1902
|
this.onResumeSuccess(resumeResolve, resumeReject, options);
|
|
1903
1903
|
}));
|
|
1904
|
-
dappClient.resume((
|
|
1904
|
+
dappClient.resume((_a2 = session == null ? void 0 : session.id) != null ? _a2 : "");
|
|
1905
1905
|
}
|
|
1906
1906
|
});
|
|
1907
1907
|
} else {
|
|
1908
1908
|
connection = new Promise(
|
|
1909
1909
|
(resolveConnection, rejectConnection) => {
|
|
1910
|
-
var
|
|
1910
|
+
var _a2, _b;
|
|
1911
1911
|
const optionalScopes = addValidAccounts(
|
|
1912
|
-
getOptionalScopes((
|
|
1912
|
+
getOptionalScopes((_a2 = options == null ? void 0 : options.scopes) != null ? _a2 : []),
|
|
1913
1913
|
getValidAccounts((_b = options == null ? void 0 : options.caipAccountIds) != null ? _b : [])
|
|
1914
1914
|
);
|
|
1915
1915
|
const sessionRequest = {
|
|
1916
|
-
optionalScopes
|
|
1916
|
+
optionalScopes,
|
|
1917
|
+
sessionProperties: options == null ? void 0 : options.sessionProperties
|
|
1917
1918
|
};
|
|
1918
1919
|
const request = {
|
|
1919
1920
|
jsonrpc: "2.0",
|
|
@@ -1921,12 +1922,18 @@ var MWPTransport = class {
|
|
|
1921
1922
|
method: "wallet_createSession",
|
|
1922
1923
|
params: sessionRequest
|
|
1923
1924
|
};
|
|
1924
|
-
|
|
1925
|
+
initialConnectionMessageHandler = (message) => __async(this, null, function* () {
|
|
1925
1926
|
if (typeof message === "object" && message !== null) {
|
|
1926
1927
|
if ("data" in message) {
|
|
1927
1928
|
const messagePayload = message.data;
|
|
1928
1929
|
if (messagePayload.method === "wallet_createSession" || messagePayload.method === "wallet_sessionChanged") {
|
|
1929
1930
|
if (messagePayload.error) {
|
|
1931
|
+
if (initialConnectionMessageHandler) {
|
|
1932
|
+
this.dappClient.off(
|
|
1933
|
+
"message",
|
|
1934
|
+
initialConnectionMessageHandler
|
|
1935
|
+
);
|
|
1936
|
+
}
|
|
1930
1937
|
return rejectConnection(messagePayload.error);
|
|
1931
1938
|
}
|
|
1932
1939
|
yield this.storeWalletSession(
|
|
@@ -1938,14 +1945,23 @@ var MWPTransport = class {
|
|
|
1938
1945
|
}
|
|
1939
1946
|
}
|
|
1940
1947
|
}
|
|
1941
|
-
})
|
|
1948
|
+
});
|
|
1949
|
+
this.dappClient.on("message", initialConnectionMessageHandler);
|
|
1942
1950
|
dappClient.connect({
|
|
1943
1951
|
mode: "trusted",
|
|
1944
1952
|
initialPayload: {
|
|
1945
1953
|
name: MULTICHAIN_PROVIDER_STREAM_NAME,
|
|
1946
1954
|
data: request
|
|
1947
1955
|
}
|
|
1948
|
-
}).catch(
|
|
1956
|
+
}).catch((error) => {
|
|
1957
|
+
if (initialConnectionMessageHandler) {
|
|
1958
|
+
this.dappClient.off(
|
|
1959
|
+
"message",
|
|
1960
|
+
initialConnectionMessageHandler
|
|
1961
|
+
);
|
|
1962
|
+
}
|
|
1963
|
+
rejectConnection(error);
|
|
1964
|
+
});
|
|
1949
1965
|
}
|
|
1950
1966
|
);
|
|
1951
1967
|
}
|
|
@@ -1953,11 +1969,17 @@ var MWPTransport = class {
|
|
|
1953
1969
|
reject(new TransportTimeoutError());
|
|
1954
1970
|
}, this.options.connectionTimeout);
|
|
1955
1971
|
connection.then(resolve).catch(reject);
|
|
1956
|
-
});
|
|
1957
|
-
return connectionPromise.
|
|
1972
|
+
}));
|
|
1973
|
+
return connectionPromise.catch((error) => {
|
|
1974
|
+
throw error;
|
|
1975
|
+
}).finally(() => {
|
|
1958
1976
|
if (timeout) {
|
|
1959
1977
|
clearTimeout(timeout);
|
|
1960
1978
|
}
|
|
1979
|
+
if (initialConnectionMessageHandler) {
|
|
1980
|
+
this.dappClient.off("message", initialConnectionMessageHandler);
|
|
1981
|
+
initialConnectionMessageHandler = void 0;
|
|
1982
|
+
}
|
|
1961
1983
|
});
|
|
1962
1984
|
});
|
|
1963
1985
|
}
|
|
@@ -2020,7 +2042,7 @@ var MWPTransport = class {
|
|
|
2020
2042
|
}
|
|
2021
2043
|
getCachedResponse(request) {
|
|
2022
2044
|
return __async(this, null, function* () {
|
|
2023
|
-
var
|
|
2045
|
+
var _a2;
|
|
2024
2046
|
if (request.method === "wallet_getSession") {
|
|
2025
2047
|
const walletGetSession = yield this.kvstore.get(SESSION_STORE_KEY);
|
|
2026
2048
|
if (walletGetSession) {
|
|
@@ -2028,7 +2050,7 @@ var MWPTransport = class {
|
|
|
2028
2050
|
return {
|
|
2029
2051
|
id: request.id,
|
|
2030
2052
|
jsonrpc: "2.0",
|
|
2031
|
-
result: (
|
|
2053
|
+
result: (_a2 = walletSession.params) != null ? _a2 : walletSession.result,
|
|
2032
2054
|
// "what?... why walletSession.params?.."
|
|
2033
2055
|
method: request.method
|
|
2034
2056
|
};
|
|
@@ -2092,10 +2114,10 @@ var MWPTransport = class {
|
|
|
2092
2114
|
yield this.attemptResumeSession();
|
|
2093
2115
|
}
|
|
2094
2116
|
return new Promise((resolve, reject) => {
|
|
2095
|
-
var
|
|
2117
|
+
var _a2;
|
|
2096
2118
|
const timeout = setTimeout(() => {
|
|
2097
2119
|
this.rejectRequest(request.id, new TransportTimeoutError());
|
|
2098
|
-
}, (
|
|
2120
|
+
}, (_a2 = options == null ? void 0 : options.timeout) != null ? _a2 : this.options.requestTimeout);
|
|
2099
2121
|
this.pendingRequests.set(request.id, {
|
|
2100
2122
|
request,
|
|
2101
2123
|
method: request.method,
|
|
@@ -2132,6 +2154,43 @@ var MWPTransport = class {
|
|
|
2132
2154
|
}
|
|
2133
2155
|
});
|
|
2134
2156
|
}
|
|
2157
|
+
// This method checks if an existing CAIP session response is cached or waits for one
|
|
2158
|
+
// to be received from the wallet if not cached. This is necessary because there is an edge
|
|
2159
|
+
// case during the initial connection flow where after the user has accepted the permission approval
|
|
2160
|
+
// and returned back to the dapp from the wallet, the dapp page may have gotten unloaded and refreshed.
|
|
2161
|
+
// When it is unloaded and refreshed, it will try to resume the session by making a request for wallet_getSession
|
|
2162
|
+
// which should resolve from cache, but because a race condition makes it possible for the response from the wallet
|
|
2163
|
+
// for the initial wallet_createSession connection request to not have been handled and cached yet. This results
|
|
2164
|
+
// in the wallet_getSession request never resolving unless we wait for it explicitly as done in this method.
|
|
2165
|
+
waitForWalletSessionIfNotCached() {
|
|
2166
|
+
return __async(this, null, function* () {
|
|
2167
|
+
const cachedWalletGetSessionResponse = yield this.kvstore.get(SESSION_STORE_KEY);
|
|
2168
|
+
if (cachedWalletGetSessionResponse) {
|
|
2169
|
+
return;
|
|
2170
|
+
}
|
|
2171
|
+
let unsubscribe;
|
|
2172
|
+
const responsePromise = new Promise((resolve) => {
|
|
2173
|
+
unsubscribe = this.onNotification((message) => {
|
|
2174
|
+
if (typeof message === "object" && message !== null) {
|
|
2175
|
+
if ("data" in message) {
|
|
2176
|
+
const messagePayload = message.data;
|
|
2177
|
+
if (messagePayload.method === "wallet_getSession" || messagePayload.method === "wallet_sessionChanged") {
|
|
2178
|
+
unsubscribe();
|
|
2179
|
+
resolve();
|
|
2180
|
+
}
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
});
|
|
2184
|
+
});
|
|
2185
|
+
const timeoutPromise = new Promise((_resolve, reject) => {
|
|
2186
|
+
setTimeout(() => {
|
|
2187
|
+
unsubscribe();
|
|
2188
|
+
reject(new TransportTimeoutError());
|
|
2189
|
+
}, this.options.resumeTimeout);
|
|
2190
|
+
});
|
|
2191
|
+
return Promise.race([responsePromise, timeoutPromise]);
|
|
2192
|
+
});
|
|
2193
|
+
}
|
|
2135
2194
|
};
|
|
2136
2195
|
|
|
2137
2196
|
// src/multichain/transports/mwp/KeyManager.ts
|
|
@@ -2163,74 +2222,229 @@ var keymanager = new KeyManager();
|
|
|
2163
2222
|
|
|
2164
2223
|
// src/multichain/index.ts
|
|
2165
2224
|
init_utils();
|
|
2225
|
+
|
|
2226
|
+
// src/multichain/transports/multichainApiClientWrapper/index.ts
|
|
2227
|
+
import { providerErrors } from "@metamask/rpc-errors";
|
|
2228
|
+
var MAX = 4294967295;
|
|
2229
|
+
var idCounter = Math.floor(Math.random() * MAX);
|
|
2230
|
+
var getUniqueId = () => {
|
|
2231
|
+
idCounter = (idCounter + 1) % MAX;
|
|
2232
|
+
return idCounter;
|
|
2233
|
+
};
|
|
2234
|
+
var _MultichainApiClientWrapperTransport_instances, walletCreateSession_fn, walletGetSession_fn, walletRevokeSession_fn, walletInvokeMethod_fn;
|
|
2235
|
+
var MultichainApiClientWrapperTransport = class {
|
|
2236
|
+
constructor(multichainSDK) {
|
|
2237
|
+
this.multichainSDK = multichainSDK;
|
|
2238
|
+
__privateAdd(this, _MultichainApiClientWrapperTransport_instances);
|
|
2239
|
+
this.requestId = getUniqueId();
|
|
2240
|
+
this.notificationCallbacks = /* @__PURE__ */ new Set();
|
|
2241
|
+
}
|
|
2242
|
+
isTransportDefined() {
|
|
2243
|
+
try {
|
|
2244
|
+
return Boolean(this.multichainSDK.transport);
|
|
2245
|
+
} catch (error) {
|
|
2246
|
+
return false;
|
|
2247
|
+
}
|
|
2248
|
+
}
|
|
2249
|
+
clearNotificationCallbacks() {
|
|
2250
|
+
this.notificationCallbacks.clear();
|
|
2251
|
+
}
|
|
2252
|
+
notifyCallbacks(data) {
|
|
2253
|
+
this.notificationCallbacks.forEach((callback) => {
|
|
2254
|
+
callback(data);
|
|
2255
|
+
});
|
|
2256
|
+
}
|
|
2257
|
+
setupNotifcationListener() {
|
|
2258
|
+
this.multichainSDK.transport.onNotification(
|
|
2259
|
+
this.notifyCallbacks.bind(this)
|
|
2260
|
+
);
|
|
2261
|
+
}
|
|
2262
|
+
connect() {
|
|
2263
|
+
return __async(this, null, function* () {
|
|
2264
|
+
console.log("\u{1F4DA} connect");
|
|
2265
|
+
return Promise.resolve();
|
|
2266
|
+
});
|
|
2267
|
+
}
|
|
2268
|
+
disconnect() {
|
|
2269
|
+
return __async(this, null, function* () {
|
|
2270
|
+
return Promise.resolve();
|
|
2271
|
+
});
|
|
2272
|
+
}
|
|
2273
|
+
isConnected() {
|
|
2274
|
+
return true;
|
|
2275
|
+
}
|
|
2276
|
+
request(_0) {
|
|
2277
|
+
return __async(this, arguments, function* (params, _options = {}) {
|
|
2278
|
+
const id = this.requestId++;
|
|
2279
|
+
const requestPayload = __spreadValues({
|
|
2280
|
+
id,
|
|
2281
|
+
jsonrpc: "2.0"
|
|
2282
|
+
}, params);
|
|
2283
|
+
switch (requestPayload.method) {
|
|
2284
|
+
case "wallet_createSession":
|
|
2285
|
+
return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletCreateSession_fn).call(this, requestPayload);
|
|
2286
|
+
case "wallet_getSession":
|
|
2287
|
+
return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletGetSession_fn).call(this, requestPayload);
|
|
2288
|
+
case "wallet_revokeSession":
|
|
2289
|
+
return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletRevokeSession_fn).call(this, requestPayload);
|
|
2290
|
+
case "wallet_invokeMethod":
|
|
2291
|
+
return __privateMethod(this, _MultichainApiClientWrapperTransport_instances, walletInvokeMethod_fn).call(this, requestPayload);
|
|
2292
|
+
default:
|
|
2293
|
+
throw new Error(`Unsupported method: ${requestPayload.method}`);
|
|
2294
|
+
}
|
|
2295
|
+
throw new Error(`Unknown method: ${requestPayload.method}`);
|
|
2296
|
+
});
|
|
2297
|
+
}
|
|
2298
|
+
onNotification(callback) {
|
|
2299
|
+
if (!this.isTransportDefined()) {
|
|
2300
|
+
this.notificationCallbacks.add(callback);
|
|
2301
|
+
return () => {
|
|
2302
|
+
this.notificationCallbacks.delete(callback);
|
|
2303
|
+
};
|
|
2304
|
+
}
|
|
2305
|
+
return this.multichainSDK.transport.onNotification(callback);
|
|
2306
|
+
}
|
|
2307
|
+
};
|
|
2308
|
+
_MultichainApiClientWrapperTransport_instances = new WeakSet();
|
|
2309
|
+
walletCreateSession_fn = function(request) {
|
|
2310
|
+
return __async(this, null, function* () {
|
|
2311
|
+
console.log("\u{1F4DA} #walletCreateSession", request);
|
|
2312
|
+
const createSessionParams = request.params;
|
|
2313
|
+
const scopes = Object.keys(__spreadValues(__spreadValues({}, createSessionParams.optionalScopes), createSessionParams.requiredScopes));
|
|
2314
|
+
const scopeAccounts = [];
|
|
2315
|
+
scopes.forEach((scope) => {
|
|
2316
|
+
var _a2, _b, _c, _d;
|
|
2317
|
+
const requiredScope = (_a2 = createSessionParams.requiredScopes) == null ? void 0 : _a2[scope];
|
|
2318
|
+
const optionalScope = (_b = createSessionParams.optionalScopes) == null ? void 0 : _b[scope];
|
|
2319
|
+
if (requiredScope) {
|
|
2320
|
+
scopeAccounts.push(...(_c = requiredScope.accounts) != null ? _c : []);
|
|
2321
|
+
}
|
|
2322
|
+
if (optionalScope) {
|
|
2323
|
+
scopeAccounts.push(...(_d = optionalScope.accounts) != null ? _d : []);
|
|
2324
|
+
}
|
|
2325
|
+
});
|
|
2326
|
+
const accounts = [...new Set(scopeAccounts)];
|
|
2327
|
+
console.log("\u{1F4DA} SDK connect");
|
|
2328
|
+
yield this.multichainSDK.connect(
|
|
2329
|
+
scopes,
|
|
2330
|
+
accounts,
|
|
2331
|
+
createSessionParams.sessionProperties
|
|
2332
|
+
);
|
|
2333
|
+
console.log("\u{1F4DA} SDK connected");
|
|
2334
|
+
return this.multichainSDK.transport.request({
|
|
2335
|
+
method: "wallet_getSession"
|
|
2336
|
+
});
|
|
2337
|
+
});
|
|
2338
|
+
};
|
|
2339
|
+
walletGetSession_fn = function(request) {
|
|
2340
|
+
return __async(this, null, function* () {
|
|
2341
|
+
if (!this.isTransportDefined()) {
|
|
2342
|
+
return {
|
|
2343
|
+
jsonrpc: "2.0",
|
|
2344
|
+
id: request.id,
|
|
2345
|
+
result: {
|
|
2346
|
+
sessionScopes: {}
|
|
2347
|
+
}
|
|
2348
|
+
};
|
|
2349
|
+
}
|
|
2350
|
+
return this.multichainSDK.transport.request({
|
|
2351
|
+
method: "wallet_getSession"
|
|
2352
|
+
});
|
|
2353
|
+
});
|
|
2354
|
+
};
|
|
2355
|
+
walletRevokeSession_fn = function(request) {
|
|
2356
|
+
return __async(this, null, function* () {
|
|
2357
|
+
if (!this.isTransportDefined()) {
|
|
2358
|
+
return { jsonrpc: "2.0", id: request.id, result: true };
|
|
2359
|
+
}
|
|
2360
|
+
try {
|
|
2361
|
+
this.multichainSDK.disconnect();
|
|
2362
|
+
return { jsonrpc: "2.0", id: request.id, result: true };
|
|
2363
|
+
} catch (error) {
|
|
2364
|
+
return { jsonrpc: "2.0", id: request.id, result: false };
|
|
2365
|
+
}
|
|
2366
|
+
});
|
|
2367
|
+
};
|
|
2368
|
+
walletInvokeMethod_fn = function(request) {
|
|
2369
|
+
return __async(this, null, function* () {
|
|
2370
|
+
if (!this.isTransportDefined()) {
|
|
2371
|
+
return { error: providerErrors.unauthorized() };
|
|
2372
|
+
}
|
|
2373
|
+
const result = this.multichainSDK.invokeMethod(
|
|
2374
|
+
request.params
|
|
2375
|
+
);
|
|
2376
|
+
return {
|
|
2377
|
+
result
|
|
2378
|
+
};
|
|
2379
|
+
});
|
|
2380
|
+
};
|
|
2381
|
+
|
|
2382
|
+
// src/multichain/index.ts
|
|
2166
2383
|
var logger2 = createLogger("metamask-sdk:core");
|
|
2167
|
-
var
|
|
2384
|
+
var _a, _provider, _providerTransportWrapper, _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, headlessConnect_fn, setupDefaultTransport_fn, deeplinkConnect_fn, handleConnection_fn;
|
|
2385
|
+
var _MultichainSDK = class _MultichainSDK extends MultichainCore {
|
|
2168
2386
|
constructor(options) {
|
|
2169
|
-
var
|
|
2387
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
2170
2388
|
const withDappMetadata = setupDappMetadata(options);
|
|
2171
|
-
const integrationType = ((
|
|
2389
|
+
const integrationType = (_b = (_a2 = options.analytics) == null ? void 0 : _a2.integrationType) != null ? _b : "direct";
|
|
2172
2390
|
const allOptions = __spreadProps(__spreadValues({}, withDappMetadata), {
|
|
2173
2391
|
ui: __spreadProps(__spreadValues({}, withDappMetadata.ui), {
|
|
2174
|
-
preferExtension: (
|
|
2175
|
-
showInstallModal: (
|
|
2176
|
-
headless: (
|
|
2392
|
+
preferExtension: (_c = withDappMetadata.ui.preferExtension) != null ? _c : true,
|
|
2393
|
+
showInstallModal: (_d = withDappMetadata.ui.showInstallModal) != null ? _d : false,
|
|
2394
|
+
headless: (_e = withDappMetadata.ui.headless) != null ? _e : false
|
|
2177
2395
|
}),
|
|
2178
|
-
analytics: __spreadProps(__spreadValues({}, (
|
|
2179
|
-
enabled: (_g = (_f = options.analytics) == null ? void 0 : _f.enabled) != null ? _g : true,
|
|
2396
|
+
analytics: __spreadProps(__spreadValues({}, (_f = options.analytics) != null ? _f : {}), {
|
|
2180
2397
|
integrationType
|
|
2181
2398
|
})
|
|
2182
2399
|
});
|
|
2183
2400
|
super(allOptions);
|
|
2184
|
-
this
|
|
2185
|
-
this
|
|
2186
|
-
this
|
|
2187
|
-
this
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
this
|
|
2195
|
-
|
|
2401
|
+
__privateAdd(this, _MultichainSDK_instances);
|
|
2402
|
+
__privateAdd(this, _provider);
|
|
2403
|
+
__privateAdd(this, _providerTransportWrapper);
|
|
2404
|
+
__privateAdd(this, _transport2);
|
|
2405
|
+
__privateAdd(this, _dappClient);
|
|
2406
|
+
__privateAdd(this, _beforeUnloadListener);
|
|
2407
|
+
this._status = "pending";
|
|
2408
|
+
__privateAdd(this, _listener);
|
|
2409
|
+
__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}`);
|
|
2410
|
+
__privateSet(this, _providerTransportWrapper, new MultichainApiClientWrapperTransport(this));
|
|
2411
|
+
__privateSet(this, _provider, getMultichainClient({ transport: __privateGet(this, _providerTransportWrapper) }));
|
|
2412
|
+
}
|
|
2413
|
+
get status() {
|
|
2414
|
+
return this._status;
|
|
2415
|
+
}
|
|
2416
|
+
set status(value) {
|
|
2417
|
+
var _a2, _b;
|
|
2418
|
+
this._status = value;
|
|
2419
|
+
(_b = (_a2 = this.options.transport) == null ? void 0 : _a2.onNotification) == null ? void 0 : _b.call(_a2, {
|
|
2196
2420
|
method: "stateChanged",
|
|
2197
2421
|
params: value
|
|
2198
2422
|
});
|
|
2199
2423
|
}
|
|
2200
2424
|
get provider() {
|
|
2201
|
-
|
|
2202
|
-
this.__provider = getMultichainClient({ transport: this.__transport });
|
|
2203
|
-
return this.__provider;
|
|
2204
|
-
}
|
|
2205
|
-
if (!this.__provider) {
|
|
2206
|
-
throw new Error("Provider not initialized, establish connection first");
|
|
2207
|
-
}
|
|
2208
|
-
return this.__provider;
|
|
2425
|
+
return __privateGet(this, _provider);
|
|
2209
2426
|
}
|
|
2210
2427
|
get transport() {
|
|
2211
|
-
if (!this
|
|
2428
|
+
if (!__privateGet(this, _transport2)) {
|
|
2212
2429
|
throw new Error("Transport not initialized, establish connection first");
|
|
2213
2430
|
}
|
|
2214
|
-
return this
|
|
2431
|
+
return __privateGet(this, _transport2);
|
|
2215
2432
|
}
|
|
2216
2433
|
get dappClient() {
|
|
2217
|
-
if (!this
|
|
2434
|
+
if (!__privateGet(this, _dappClient)) {
|
|
2218
2435
|
throw new Error("DappClient not initialized, establish connection first");
|
|
2219
2436
|
}
|
|
2220
|
-
return this
|
|
2437
|
+
return __privateGet(this, _dappClient);
|
|
2221
2438
|
}
|
|
2222
2439
|
get storage() {
|
|
2223
2440
|
return this.options.storage;
|
|
2224
2441
|
}
|
|
2225
2442
|
get transportType() {
|
|
2226
|
-
return this
|
|
2227
|
-
}
|
|
2228
|
-
get sdkInfo() {
|
|
2229
|
-
var _a;
|
|
2230
|
-
return `Sdk/Javascript SdkVersion/${getVersion()} Platform/${getPlatformType()} dApp/${(_a = this.options.dapp.url) != null ? _a : this.options.dapp.name} dAppTitle/${this.options.dapp.name}`;
|
|
2443
|
+
return __privateGet(this, _transport2) instanceof MWPTransport ? "mwp" /* MWP */ : "browser" /* Browser */;
|
|
2231
2444
|
}
|
|
2232
2445
|
static create(options) {
|
|
2233
2446
|
return __async(this, null, function* () {
|
|
2447
|
+
var _a2;
|
|
2234
2448
|
const instance = new _MultichainSDK(options);
|
|
2235
2449
|
const isEnabled2 = yield isEnabled(
|
|
2236
2450
|
"metamask-sdk:core",
|
|
@@ -2239,353 +2453,17 @@ var MultichainSDK = class _MultichainSDK extends MultichainCore {
|
|
|
2239
2453
|
if (isEnabled2) {
|
|
2240
2454
|
enableDebug("metamask-sdk:core");
|
|
2241
2455
|
}
|
|
2242
|
-
yield instance.
|
|
2456
|
+
yield __privateMethod(_a2 = instance, _MultichainSDK_instances, init_fn).call(_a2);
|
|
2243
2457
|
return instance;
|
|
2244
2458
|
});
|
|
2245
2459
|
}
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
var _a, _b;
|
|
2249
|
-
if (!((_a = this.options.analytics) == null ? void 0 : _a.enabled)) {
|
|
2250
|
-
return;
|
|
2251
|
-
}
|
|
2252
|
-
const platform = getPlatformType();
|
|
2253
|
-
const isBrowser = platform === "in-app-browser" /* MetaMaskMobileWebview */ || platform === "web-desktop" /* DesktopWeb */ || platform === "web-mobile" /* MobileWeb */;
|
|
2254
|
-
const isReactNative2 = platform === "react-native" /* ReactNative */;
|
|
2255
|
-
if (!isBrowser && !isReactNative2) {
|
|
2256
|
-
return;
|
|
2257
|
-
}
|
|
2258
|
-
const version = getVersion();
|
|
2259
|
-
const dappId = getDappId(this.options.dapp);
|
|
2260
|
-
const anonId = yield this.storage.getAnonId();
|
|
2261
|
-
const { integrationType } = (_b = this.options.analytics) != null ? _b : {
|
|
2262
|
-
integrationType: ""
|
|
2263
|
-
};
|
|
2264
|
-
analytics2.setGlobalProperty("mmconnect_version", version);
|
|
2265
|
-
analytics2.setGlobalProperty("dapp_id", dappId);
|
|
2266
|
-
analytics2.setGlobalProperty("anon_id", anonId);
|
|
2267
|
-
analytics2.setGlobalProperty("platform", platform);
|
|
2268
|
-
analytics2.setGlobalProperty("integration_type", integrationType);
|
|
2269
|
-
analytics2.enable();
|
|
2270
|
-
});
|
|
2271
|
-
}
|
|
2272
|
-
onTransportNotification(payload) {
|
|
2273
|
-
return __async(this, null, function* () {
|
|
2274
|
-
var _a;
|
|
2275
|
-
if (typeof payload === "object" && payload !== null && "method" in payload) {
|
|
2276
|
-
this.emit(payload.method, (_a = payload.params) != null ? _a : payload.result);
|
|
2277
|
-
}
|
|
2278
|
-
});
|
|
2279
|
-
}
|
|
2280
|
-
getStoredTransport() {
|
|
2460
|
+
// TODO: make this into param object
|
|
2461
|
+
connect(scopes, caipAccountIds, sessionProperties, forceRequest) {
|
|
2281
2462
|
return __async(this, null, function* () {
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
if (transportType === "browser" /* Browser */) {
|
|
2286
|
-
if (hasExtensionInstalled) {
|
|
2287
|
-
const apiTransport = new DefaultTransport();
|
|
2288
|
-
this.__transport = apiTransport;
|
|
2289
|
-
this.listener = apiTransport.onNotification(
|
|
2290
|
-
this.onTransportNotification.bind(this)
|
|
2291
|
-
);
|
|
2292
|
-
return apiTransport;
|
|
2293
|
-
}
|
|
2294
|
-
} else if (transportType === "mwp" /* MWP */) {
|
|
2295
|
-
const { adapter: kvstore } = this.options.storage;
|
|
2296
|
-
const dappClient = yield this.createDappClient();
|
|
2297
|
-
const apiTransport = new MWPTransport(dappClient, kvstore);
|
|
2298
|
-
this.__dappClient = dappClient;
|
|
2299
|
-
this.__transport = apiTransport;
|
|
2300
|
-
this.listener = apiTransport.onNotification(
|
|
2301
|
-
this.onTransportNotification.bind(this)
|
|
2302
|
-
);
|
|
2303
|
-
return apiTransport;
|
|
2304
|
-
}
|
|
2305
|
-
yield this.storage.removeTransport();
|
|
2463
|
+
var _a2;
|
|
2464
|
+
if (this.status !== "connected") {
|
|
2465
|
+
yield this.disconnect();
|
|
2306
2466
|
}
|
|
2307
|
-
return void 0;
|
|
2308
|
-
});
|
|
2309
|
-
}
|
|
2310
|
-
setupTransport() {
|
|
2311
|
-
return __async(this, null, function* () {
|
|
2312
|
-
const transport = yield this.getStoredTransport();
|
|
2313
|
-
if (transport) {
|
|
2314
|
-
if (!this.transport.isConnected()) {
|
|
2315
|
-
this.state = "connecting";
|
|
2316
|
-
yield this.transport.connect();
|
|
2317
|
-
}
|
|
2318
|
-
this.state = "connected";
|
|
2319
|
-
if (this.transport instanceof MWPTransport) {
|
|
2320
|
-
yield this.storage.setTransport("mwp" /* MWP */);
|
|
2321
|
-
} else {
|
|
2322
|
-
yield this.storage.setTransport("browser" /* Browser */);
|
|
2323
|
-
}
|
|
2324
|
-
} else {
|
|
2325
|
-
this.state = "loaded";
|
|
2326
|
-
}
|
|
2327
|
-
});
|
|
2328
|
-
}
|
|
2329
|
-
init() {
|
|
2330
|
-
return __async(this, null, function* () {
|
|
2331
|
-
var _a, _b;
|
|
2332
|
-
try {
|
|
2333
|
-
if (typeof window !== "undefined" && ((_a = window.mmsdk) == null ? void 0 : _a.isInitialized)) {
|
|
2334
|
-
logger2("MetaMaskSDK: init already initialized");
|
|
2335
|
-
} else {
|
|
2336
|
-
yield this.setupAnalytics();
|
|
2337
|
-
yield this.setupTransport();
|
|
2338
|
-
if ((_b = this.options.analytics) == null ? void 0 : _b.enabled) {
|
|
2339
|
-
try {
|
|
2340
|
-
const baseProps = yield getBaseAnalyticsProperties(
|
|
2341
|
-
this.options,
|
|
2342
|
-
this.storage
|
|
2343
|
-
);
|
|
2344
|
-
analytics2.track("mmconnect_initialized", baseProps);
|
|
2345
|
-
} catch (error) {
|
|
2346
|
-
logger2("Error tracking initialized event", error);
|
|
2347
|
-
}
|
|
2348
|
-
}
|
|
2349
|
-
if (typeof window !== "undefined") {
|
|
2350
|
-
window.mmsdk = this;
|
|
2351
|
-
}
|
|
2352
|
-
}
|
|
2353
|
-
} catch (error) {
|
|
2354
|
-
yield this.storage.removeTransport();
|
|
2355
|
-
this.state = "pending";
|
|
2356
|
-
logger2("MetaMaskSDK error during initialization", error);
|
|
2357
|
-
}
|
|
2358
|
-
});
|
|
2359
|
-
}
|
|
2360
|
-
createDappClient() {
|
|
2361
|
-
return __async(this, null, function* () {
|
|
2362
|
-
const { adapter: kvstore } = this.options.storage;
|
|
2363
|
-
const sessionstore = new SessionStore2(kvstore);
|
|
2364
|
-
const websocket = (
|
|
2365
|
-
// eslint-disable-next-line no-negated-condition
|
|
2366
|
-
typeof window !== "undefined" ? WebSocket : (yield import("ws")).WebSocket
|
|
2367
|
-
);
|
|
2368
|
-
const transport = yield WebSocketTransport.create({
|
|
2369
|
-
url: MWP_RELAY_URL,
|
|
2370
|
-
kvstore,
|
|
2371
|
-
websocket
|
|
2372
|
-
});
|
|
2373
|
-
const dappClient = new DappClient({ transport, sessionstore, keymanager });
|
|
2374
|
-
return dappClient;
|
|
2375
|
-
});
|
|
2376
|
-
}
|
|
2377
|
-
setupMWP() {
|
|
2378
|
-
return __async(this, null, function* () {
|
|
2379
|
-
if (this.__transport instanceof MWPTransport) {
|
|
2380
|
-
return;
|
|
2381
|
-
}
|
|
2382
|
-
const { adapter: kvstore } = this.options.storage;
|
|
2383
|
-
const dappClient = yield this.createDappClient();
|
|
2384
|
-
this.__dappClient = dappClient;
|
|
2385
|
-
const apiTransport = new MWPTransport(dappClient, kvstore);
|
|
2386
|
-
this.__transport = apiTransport;
|
|
2387
|
-
this.listener = this.transport.onNotification(
|
|
2388
|
-
this.onTransportNotification.bind(this)
|
|
2389
|
-
);
|
|
2390
|
-
yield this.storage.setTransport("mwp" /* MWP */);
|
|
2391
|
-
});
|
|
2392
|
-
}
|
|
2393
|
-
onBeforeUnload() {
|
|
2394
|
-
return __async(this, null, function* () {
|
|
2395
|
-
var _a;
|
|
2396
|
-
if ((_a = this.options.ui.factory.modal) == null ? void 0 : _a.isMounted) {
|
|
2397
|
-
yield this.storage.removeTransport();
|
|
2398
|
-
}
|
|
2399
|
-
});
|
|
2400
|
-
}
|
|
2401
|
-
createBeforeUnloadListener() {
|
|
2402
|
-
if (typeof window !== "undefined" && typeof window.addEventListener !== "undefined") {
|
|
2403
|
-
window.addEventListener("beforeunload", this.onBeforeUnload.bind(this));
|
|
2404
|
-
}
|
|
2405
|
-
return () => {
|
|
2406
|
-
if (typeof window !== "undefined" && typeof window.removeEventListener !== "undefined") {
|
|
2407
|
-
window.removeEventListener(
|
|
2408
|
-
"beforeunload",
|
|
2409
|
-
this.onBeforeUnload.bind(this)
|
|
2410
|
-
);
|
|
2411
|
-
}
|
|
2412
|
-
};
|
|
2413
|
-
}
|
|
2414
|
-
showInstallModal(desktopPreferred, scopes, caipAccountIds) {
|
|
2415
|
-
return __async(this, null, function* () {
|
|
2416
|
-
var _a;
|
|
2417
|
-
(_a = this.__beforeUnloadListener) != null ? _a : this.__beforeUnloadListener = this.createBeforeUnloadListener();
|
|
2418
|
-
return new Promise((resolve, reject) => {
|
|
2419
|
-
this.options.ui.factory.renderInstallModal(
|
|
2420
|
-
desktopPreferred,
|
|
2421
|
-
() => __async(this, null, function* () {
|
|
2422
|
-
if (this.dappClient.state === "CONNECTED" || this.dappClient.state === "CONNECTING") {
|
|
2423
|
-
yield this.dappClient.disconnect();
|
|
2424
|
-
}
|
|
2425
|
-
return new Promise((resolveConnectionRequest) => {
|
|
2426
|
-
this.dappClient.on(
|
|
2427
|
-
"session_request",
|
|
2428
|
-
(sessionRequest) => {
|
|
2429
|
-
resolveConnectionRequest({
|
|
2430
|
-
sessionRequest,
|
|
2431
|
-
metadata: {
|
|
2432
|
-
dapp: this.options.dapp,
|
|
2433
|
-
sdk: {
|
|
2434
|
-
version: getVersion(),
|
|
2435
|
-
platform: getPlatformType()
|
|
2436
|
-
}
|
|
2437
|
-
}
|
|
2438
|
-
});
|
|
2439
|
-
}
|
|
2440
|
-
);
|
|
2441
|
-
this.transport.connect({ scopes, caipAccountIds }).then(() => {
|
|
2442
|
-
var _a2;
|
|
2443
|
-
this.options.ui.factory.unload();
|
|
2444
|
-
(_a2 = this.options.ui.factory.modal) == null ? void 0 : _a2.unmount();
|
|
2445
|
-
this.state = "connected";
|
|
2446
|
-
return this.storage.setTransport("mwp" /* MWP */);
|
|
2447
|
-
}).catch((error) => {
|
|
2448
|
-
if (error instanceof ProtocolError) {
|
|
2449
|
-
if (error.code !== ErrorCode.REQUEST_EXPIRED) {
|
|
2450
|
-
this.state = "disconnected";
|
|
2451
|
-
reject(error);
|
|
2452
|
-
}
|
|
2453
|
-
} else {
|
|
2454
|
-
this.state = "disconnected";
|
|
2455
|
-
reject(error);
|
|
2456
|
-
}
|
|
2457
|
-
});
|
|
2458
|
-
});
|
|
2459
|
-
}),
|
|
2460
|
-
(error) => __async(this, null, function* () {
|
|
2461
|
-
if (!error) {
|
|
2462
|
-
yield this.storage.setTransport("mwp" /* MWP */);
|
|
2463
|
-
resolve();
|
|
2464
|
-
} else {
|
|
2465
|
-
yield this.storage.removeTransport();
|
|
2466
|
-
reject(error);
|
|
2467
|
-
}
|
|
2468
|
-
})
|
|
2469
|
-
);
|
|
2470
|
-
});
|
|
2471
|
-
});
|
|
2472
|
-
}
|
|
2473
|
-
setupDefaultTransport() {
|
|
2474
|
-
return __async(this, null, function* () {
|
|
2475
|
-
this.state = "connecting";
|
|
2476
|
-
yield this.storage.setTransport("browser" /* Browser */);
|
|
2477
|
-
const transport = new DefaultTransport();
|
|
2478
|
-
this.listener = transport.onNotification(
|
|
2479
|
-
this.onTransportNotification.bind(this)
|
|
2480
|
-
);
|
|
2481
|
-
this.__transport = transport;
|
|
2482
|
-
return transport;
|
|
2483
|
-
});
|
|
2484
|
-
}
|
|
2485
|
-
deeplinkConnect(scopes, caipAccountIds) {
|
|
2486
|
-
return __async(this, null, function* () {
|
|
2487
|
-
return new Promise((resolve, reject) => __async(this, null, function* () {
|
|
2488
|
-
this.dappClient.on("message", (payload) => {
|
|
2489
|
-
var _a, _b, _c;
|
|
2490
|
-
const data = payload.data;
|
|
2491
|
-
if (typeof data === "object" && data !== null) {
|
|
2492
|
-
if ("method" in data && data.method === "wallet_createSession") {
|
|
2493
|
-
if (data.error) {
|
|
2494
|
-
this.state = "loaded";
|
|
2495
|
-
return reject(data.error);
|
|
2496
|
-
}
|
|
2497
|
-
const session = (_a = data.params) != null ? _a : data.result;
|
|
2498
|
-
if (session) {
|
|
2499
|
-
(_c = (_b = this.options.transport) == null ? void 0 : _b.onNotification) == null ? void 0 : _c.call(_b, payload.data);
|
|
2500
|
-
this.emit("wallet_sessionChanged", session);
|
|
2501
|
-
}
|
|
2502
|
-
}
|
|
2503
|
-
}
|
|
2504
|
-
});
|
|
2505
|
-
let timeout;
|
|
2506
|
-
if (!this.transport.isConnected()) {
|
|
2507
|
-
this.dappClient.once(
|
|
2508
|
-
"session_request",
|
|
2509
|
-
(sessionRequest) => {
|
|
2510
|
-
var _a;
|
|
2511
|
-
const connectionRequest = {
|
|
2512
|
-
sessionRequest,
|
|
2513
|
-
metadata: {
|
|
2514
|
-
dapp: this.options.dapp,
|
|
2515
|
-
sdk: { version: getVersion(), platform: getPlatformType() }
|
|
2516
|
-
}
|
|
2517
|
-
};
|
|
2518
|
-
const deeplink = this.options.ui.factory.createConnectionDeeplink(connectionRequest);
|
|
2519
|
-
const universalLink = this.options.ui.factory.createConnectionUniversalLink(connectionRequest);
|
|
2520
|
-
if ((_a = this.options.mobile) == null ? void 0 : _a.preferredOpenLink) {
|
|
2521
|
-
this.options.mobile.preferredOpenLink(deeplink, "_self");
|
|
2522
|
-
} else {
|
|
2523
|
-
openDeeplink(this.options, deeplink, universalLink);
|
|
2524
|
-
}
|
|
2525
|
-
}
|
|
2526
|
-
);
|
|
2527
|
-
}
|
|
2528
|
-
this.transport.connect({ scopes, caipAccountIds }).then(resolve).catch((error) => {
|
|
2529
|
-
this.storage.removeTransport();
|
|
2530
|
-
reject(error);
|
|
2531
|
-
}).finally(() => {
|
|
2532
|
-
if (timeout) {
|
|
2533
|
-
clearTimeout(timeout);
|
|
2534
|
-
}
|
|
2535
|
-
});
|
|
2536
|
-
}));
|
|
2537
|
-
});
|
|
2538
|
-
}
|
|
2539
|
-
handleConnection(promise, scopes, transportType) {
|
|
2540
|
-
return __async(this, null, function* () {
|
|
2541
|
-
this.state = "connecting";
|
|
2542
|
-
return promise.then(() => __async(this, null, function* () {
|
|
2543
|
-
var _a;
|
|
2544
|
-
this.state = "connected";
|
|
2545
|
-
if ((_a = this.options.analytics) == null ? void 0 : _a.enabled) {
|
|
2546
|
-
try {
|
|
2547
|
-
const baseProps = yield getBaseAnalyticsProperties(
|
|
2548
|
-
this.options,
|
|
2549
|
-
this.storage
|
|
2550
|
-
);
|
|
2551
|
-
analytics2.track("mmconnect_connection_established", __spreadProps(__spreadValues({}, baseProps), {
|
|
2552
|
-
transport_type: transportType,
|
|
2553
|
-
user_permissioned_chains: scopes
|
|
2554
|
-
}));
|
|
2555
|
-
} catch (error) {
|
|
2556
|
-
logger2("Error tracking connection_established event", error);
|
|
2557
|
-
}
|
|
2558
|
-
}
|
|
2559
|
-
})).catch((error) => __async(this, null, function* () {
|
|
2560
|
-
var _a;
|
|
2561
|
-
this.state = "disconnected";
|
|
2562
|
-
if ((_a = this.options.analytics) == null ? void 0 : _a.enabled) {
|
|
2563
|
-
try {
|
|
2564
|
-
const baseProps = yield getBaseAnalyticsProperties(
|
|
2565
|
-
this.options,
|
|
2566
|
-
this.storage
|
|
2567
|
-
);
|
|
2568
|
-
const isRejection = isRejectionError(error);
|
|
2569
|
-
if (isRejection) {
|
|
2570
|
-
analytics2.track("mmconnect_connection_rejected", __spreadProps(__spreadValues({}, baseProps), {
|
|
2571
|
-
transport_type: transportType
|
|
2572
|
-
}));
|
|
2573
|
-
} else {
|
|
2574
|
-
analytics2.track("mmconnect_connection_failed", __spreadProps(__spreadValues({}, baseProps), {
|
|
2575
|
-
transport_type: transportType
|
|
2576
|
-
}));
|
|
2577
|
-
}
|
|
2578
|
-
} catch (e) {
|
|
2579
|
-
logger2("Error tracking connection failed/rejected event", error);
|
|
2580
|
-
}
|
|
2581
|
-
}
|
|
2582
|
-
return Promise.reject(error);
|
|
2583
|
-
}));
|
|
2584
|
-
});
|
|
2585
|
-
}
|
|
2586
|
-
connect(scopes, caipAccountIds, forceRequest) {
|
|
2587
|
-
return __async(this, null, function* () {
|
|
2588
|
-
var _a, _b;
|
|
2589
2467
|
const { ui } = this.options;
|
|
2590
2468
|
const platformType = getPlatformType();
|
|
2591
2469
|
const isWeb = platformType === "in-app-browser" /* MetaMaskMobileWebview */ || platformType === "web-desktop" /* DesktopWeb */;
|
|
@@ -2598,96 +2476,70 @@ var MultichainSDK = class _MultichainSDK extends MultichainCore {
|
|
|
2598
2476
|
} else {
|
|
2599
2477
|
transportType = "mwp" /* MWP */;
|
|
2600
2478
|
}
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
this.options.api.supportedNetworks
|
|
2609
|
-
);
|
|
2610
|
-
analytics2.track("mmconnect_connection_initiated", __spreadProps(__spreadValues({}, baseProps), {
|
|
2611
|
-
transport_type: transportType,
|
|
2612
|
-
dapp_configured_chains: dappConfiguredChains,
|
|
2613
|
-
dapp_requested_chains: scopes
|
|
2614
|
-
}));
|
|
2615
|
-
} catch (error) {
|
|
2616
|
-
logger2("Error tracking connection_initiated event", error);
|
|
2617
|
-
}
|
|
2618
|
-
}
|
|
2619
|
-
if (((_b = this.__transport) == null ? void 0 : _b.isConnected()) && !secure) {
|
|
2620
|
-
return this.handleConnection(
|
|
2621
|
-
this.__transport.connect({ scopes, caipAccountIds, forceRequest }).then(() => {
|
|
2622
|
-
if (this.__transport instanceof MWPTransport) {
|
|
2623
|
-
return this.storage.setTransport("mwp" /* MWP */);
|
|
2624
|
-
} else {
|
|
2625
|
-
return this.storage.setTransport("browser" /* Browser */);
|
|
2626
|
-
}
|
|
2627
|
-
}),
|
|
2628
|
-
scopes,
|
|
2629
|
-
transportType
|
|
2479
|
+
try {
|
|
2480
|
+
const baseProps = yield getBaseAnalyticsProperties(
|
|
2481
|
+
this.options,
|
|
2482
|
+
this.storage
|
|
2483
|
+
);
|
|
2484
|
+
const dappConfiguredChains = Object.keys(
|
|
2485
|
+
this.options.api.supportedNetworks
|
|
2630
2486
|
);
|
|
2487
|
+
analytics2.track("mmconnect_connection_initiated", __spreadProps(__spreadValues({}, baseProps), {
|
|
2488
|
+
transport_type: transportType,
|
|
2489
|
+
dapp_configured_chains: dappConfiguredChains,
|
|
2490
|
+
dapp_requested_chains: scopes
|
|
2491
|
+
}));
|
|
2492
|
+
} catch (error) {
|
|
2493
|
+
logger2("Error tracking connection_initiated event", error);
|
|
2494
|
+
}
|
|
2495
|
+
if (((_a2 = __privateGet(this, _transport2)) == null ? void 0 : _a2.isConnected()) && !secure) {
|
|
2496
|
+
return __privateMethod(this, _MultichainSDK_instances, handleConnection_fn).call(this, __privateGet(this, _transport2).connect({ scopes, caipAccountIds, sessionProperties, forceRequest }).then(() => __async(this, null, function* () {
|
|
2497
|
+
if (__privateGet(this, _transport2) instanceof MWPTransport) {
|
|
2498
|
+
return this.storage.setTransport("mwp" /* MWP */);
|
|
2499
|
+
}
|
|
2500
|
+
return this.storage.setTransport("browser" /* Browser */);
|
|
2501
|
+
})), scopes, transportType);
|
|
2631
2502
|
}
|
|
2632
2503
|
if (platformType === "in-app-browser" /* MetaMaskMobileWebview */) {
|
|
2633
|
-
const defaultTransport = yield this.
|
|
2634
|
-
return this.
|
|
2635
|
-
defaultTransport.connect({ scopes, caipAccountIds, forceRequest }),
|
|
2636
|
-
scopes,
|
|
2637
|
-
transportType
|
|
2638
|
-
);
|
|
2504
|
+
const defaultTransport = yield __privateMethod(this, _MultichainSDK_instances, setupDefaultTransport_fn).call(this);
|
|
2505
|
+
return __privateMethod(this, _MultichainSDK_instances, handleConnection_fn).call(this, defaultTransport.connect({ scopes, caipAccountIds, sessionProperties, forceRequest }), scopes, transportType);
|
|
2639
2506
|
}
|
|
2640
2507
|
if (isWeb && hasExtensionInstalled && preferExtension) {
|
|
2641
|
-
const defaultTransport = yield this.
|
|
2642
|
-
return this.
|
|
2643
|
-
defaultTransport.connect({ scopes, caipAccountIds, forceRequest }),
|
|
2644
|
-
scopes,
|
|
2645
|
-
transportType
|
|
2646
|
-
);
|
|
2508
|
+
const defaultTransport = yield __privateMethod(this, _MultichainSDK_instances, setupDefaultTransport_fn).call(this);
|
|
2509
|
+
return __privateMethod(this, _MultichainSDK_instances, handleConnection_fn).call(this, defaultTransport.connect({ scopes, caipAccountIds, sessionProperties, forceRequest }), scopes, transportType);
|
|
2647
2510
|
}
|
|
2648
|
-
yield this.
|
|
2511
|
+
yield __privateMethod(this, _MultichainSDK_instances, setupMWP_fn).call(this);
|
|
2649
2512
|
const shouldShowInstallModal = hasExtensionInstalled ? showInstallModal : !preferExtension || showInstallModal;
|
|
2650
2513
|
if (secure && !shouldShowInstallModal) {
|
|
2651
|
-
return this.
|
|
2652
|
-
this.deeplinkConnect(scopes, caipAccountIds),
|
|
2653
|
-
scopes,
|
|
2654
|
-
transportType
|
|
2655
|
-
);
|
|
2514
|
+
return __privateMethod(this, _MultichainSDK_instances, handleConnection_fn).call(this, __privateMethod(this, _MultichainSDK_instances, deeplinkConnect_fn).call(this, scopes, caipAccountIds, sessionProperties), scopes, transportType);
|
|
2656
2515
|
}
|
|
2657
|
-
return this.
|
|
2658
|
-
this.showInstallModal(shouldShowInstallModal, scopes, caipAccountIds),
|
|
2659
|
-
scopes,
|
|
2660
|
-
transportType
|
|
2661
|
-
);
|
|
2516
|
+
return __privateMethod(this, _MultichainSDK_instances, handleConnection_fn).call(this, __privateMethod(this, _MultichainSDK_instances, showInstallModal_fn).call(this, shouldShowInstallModal, scopes, caipAccountIds, sessionProperties), scopes, transportType);
|
|
2662
2517
|
});
|
|
2663
2518
|
}
|
|
2664
2519
|
emit(event, args) {
|
|
2665
|
-
var
|
|
2666
|
-
(_b = (
|
|
2520
|
+
var _a2, _b;
|
|
2521
|
+
(_b = (_a2 = this.options.transport) == null ? void 0 : _a2.onNotification) == null ? void 0 : _b.call(_a2, { method: event, params: args });
|
|
2667
2522
|
super.emit(event, args);
|
|
2668
2523
|
}
|
|
2669
2524
|
disconnect() {
|
|
2670
2525
|
return __async(this, null, function* () {
|
|
2671
|
-
var
|
|
2672
|
-
(
|
|
2673
|
-
(_b = this
|
|
2674
|
-
yield (_c = this
|
|
2526
|
+
var _a2, _b, _c;
|
|
2527
|
+
yield (_a2 = __privateGet(this, _listener)) == null ? void 0 : _a2.call(this);
|
|
2528
|
+
(_b = __privateGet(this, _beforeUnloadListener)) == null ? void 0 : _b.call(this);
|
|
2529
|
+
yield (_c = __privateGet(this, _transport2)) == null ? void 0 : _c.disconnect();
|
|
2675
2530
|
yield this.storage.removeTransport();
|
|
2676
|
-
this.emit("wallet_sessionChanged", void 0);
|
|
2677
2531
|
this.emit("stateChanged", "disconnected");
|
|
2678
|
-
this
|
|
2679
|
-
this
|
|
2680
|
-
this
|
|
2681
|
-
this.
|
|
2682
|
-
this
|
|
2532
|
+
__privateSet(this, _listener, void 0);
|
|
2533
|
+
__privateSet(this, _beforeUnloadListener, void 0);
|
|
2534
|
+
__privateSet(this, _transport2, void 0);
|
|
2535
|
+
__privateGet(this, _providerTransportWrapper).clearNotificationCallbacks();
|
|
2536
|
+
__privateSet(this, _dappClient, void 0);
|
|
2683
2537
|
});
|
|
2684
2538
|
}
|
|
2685
2539
|
invokeMethod(request) {
|
|
2686
2540
|
return __async(this, null, function* () {
|
|
2687
|
-
|
|
2688
|
-
const
|
|
2689
|
-
(_a = this.__provider) != null ? _a : this.__provider = getMultichainClient({ transport });
|
|
2690
|
-
const rpcClient = new RpcClient(options, sdkInfo);
|
|
2541
|
+
const { transport, options } = this;
|
|
2542
|
+
const rpcClient = new RpcClient(options, __privateGet(this, _sdkInfo));
|
|
2691
2543
|
const requestRouter = new RequestRouter(transport, rpcClient, options);
|
|
2692
2544
|
return requestRouter.invokeMethod(request);
|
|
2693
2545
|
});
|
|
@@ -2708,16 +2560,427 @@ var MultichainSDK = class _MultichainSDK extends MultichainCore {
|
|
|
2708
2560
|
if (mobile == null ? void 0 : mobile.preferredOpenLink) {
|
|
2709
2561
|
mobile.preferredOpenLink(url, "_self");
|
|
2710
2562
|
} else {
|
|
2711
|
-
openDeeplink(
|
|
2712
|
-
this.options,
|
|
2713
|
-
url,
|
|
2714
|
-
METAMASK_CONNECT_BASE_URL
|
|
2715
|
-
);
|
|
2563
|
+
openDeeplink(this.options, url, METAMASK_CONNECT_BASE_URL);
|
|
2716
2564
|
}
|
|
2717
2565
|
}), 10);
|
|
2718
2566
|
}
|
|
2719
2567
|
}
|
|
2720
2568
|
};
|
|
2569
|
+
_provider = new WeakMap();
|
|
2570
|
+
_providerTransportWrapper = new WeakMap();
|
|
2571
|
+
_transport2 = new WeakMap();
|
|
2572
|
+
_dappClient = new WeakMap();
|
|
2573
|
+
_beforeUnloadListener = new WeakMap();
|
|
2574
|
+
_listener = new WeakMap();
|
|
2575
|
+
_sdkInfo = new WeakMap();
|
|
2576
|
+
_MultichainSDK_instances = new WeakSet();
|
|
2577
|
+
setupAnalytics_fn = function() {
|
|
2578
|
+
return __async(this, null, function* () {
|
|
2579
|
+
var _a2;
|
|
2580
|
+
const platform = getPlatformType();
|
|
2581
|
+
const isBrowser = platform === "in-app-browser" /* MetaMaskMobileWebview */ || platform === "web-desktop" /* DesktopWeb */ || platform === "web-mobile" /* MobileWeb */;
|
|
2582
|
+
const isReactNative2 = platform === "react-native" /* ReactNative */;
|
|
2583
|
+
if (!isBrowser && !isReactNative2) {
|
|
2584
|
+
return;
|
|
2585
|
+
}
|
|
2586
|
+
const version = getVersion();
|
|
2587
|
+
const dappId = getDappId(this.options.dapp);
|
|
2588
|
+
const anonId = yield this.storage.getAnonId();
|
|
2589
|
+
const { integrationType } = (_a2 = this.options.analytics) != null ? _a2 : {
|
|
2590
|
+
integrationType: ""
|
|
2591
|
+
};
|
|
2592
|
+
analytics2.setGlobalProperty("mmconnect_version", version);
|
|
2593
|
+
analytics2.setGlobalProperty("dapp_id", dappId);
|
|
2594
|
+
analytics2.setGlobalProperty("anon_id", anonId);
|
|
2595
|
+
analytics2.setGlobalProperty("platform", platform);
|
|
2596
|
+
analytics2.setGlobalProperty("integration_type", integrationType);
|
|
2597
|
+
analytics2.enable();
|
|
2598
|
+
});
|
|
2599
|
+
};
|
|
2600
|
+
onTransportNotification_fn = function(payload) {
|
|
2601
|
+
return __async(this, null, function* () {
|
|
2602
|
+
var _a2;
|
|
2603
|
+
if (typeof payload === "object" && payload !== null && "method" in payload) {
|
|
2604
|
+
this.emit(payload.method, (_a2 = payload.params) != null ? _a2 : payload.result);
|
|
2605
|
+
}
|
|
2606
|
+
});
|
|
2607
|
+
};
|
|
2608
|
+
getStoredTransport_fn = function() {
|
|
2609
|
+
return __async(this, null, function* () {
|
|
2610
|
+
const transportType = yield this.storage.getTransport();
|
|
2611
|
+
const hasExtensionInstalled = yield hasExtension();
|
|
2612
|
+
if (transportType) {
|
|
2613
|
+
if (transportType === "browser" /* Browser */) {
|
|
2614
|
+
if (hasExtensionInstalled) {
|
|
2615
|
+
const apiTransport = new DefaultTransport();
|
|
2616
|
+
__privateSet(this, _transport2, apiTransport);
|
|
2617
|
+
__privateGet(this, _providerTransportWrapper).setupNotifcationListener();
|
|
2618
|
+
__privateSet(this, _listener, apiTransport.onNotification(
|
|
2619
|
+
__privateMethod(this, _MultichainSDK_instances, onTransportNotification_fn).bind(this)
|
|
2620
|
+
));
|
|
2621
|
+
return apiTransport;
|
|
2622
|
+
}
|
|
2623
|
+
} else if (transportType === "mwp" /* MWP */) {
|
|
2624
|
+
const { adapter: kvstore } = this.options.storage;
|
|
2625
|
+
const dappClient = yield __privateMethod(this, _MultichainSDK_instances, createDappClient_fn).call(this);
|
|
2626
|
+
const apiTransport = new MWPTransport(dappClient, kvstore);
|
|
2627
|
+
__privateSet(this, _dappClient, dappClient);
|
|
2628
|
+
__privateSet(this, _transport2, apiTransport);
|
|
2629
|
+
__privateGet(this, _providerTransportWrapper).setupNotifcationListener();
|
|
2630
|
+
__privateSet(this, _listener, apiTransport.onNotification(
|
|
2631
|
+
__privateMethod(this, _MultichainSDK_instances, onTransportNotification_fn).bind(this)
|
|
2632
|
+
));
|
|
2633
|
+
return apiTransport;
|
|
2634
|
+
}
|
|
2635
|
+
yield this.storage.removeTransport();
|
|
2636
|
+
}
|
|
2637
|
+
return void 0;
|
|
2638
|
+
});
|
|
2639
|
+
};
|
|
2640
|
+
setupTransport_fn = function() {
|
|
2641
|
+
return __async(this, null, function* () {
|
|
2642
|
+
const transport = yield __privateMethod(this, _MultichainSDK_instances, getStoredTransport_fn).call(this);
|
|
2643
|
+
if (transport) {
|
|
2644
|
+
if (!this.transport.isConnected()) {
|
|
2645
|
+
this.status = "connecting";
|
|
2646
|
+
yield this.transport.connect();
|
|
2647
|
+
}
|
|
2648
|
+
this.status = "connected";
|
|
2649
|
+
if (this.transport instanceof MWPTransport) {
|
|
2650
|
+
yield this.storage.setTransport("mwp" /* MWP */);
|
|
2651
|
+
} else {
|
|
2652
|
+
yield this.storage.setTransport("browser" /* Browser */);
|
|
2653
|
+
}
|
|
2654
|
+
} else {
|
|
2655
|
+
this.status = "loaded";
|
|
2656
|
+
}
|
|
2657
|
+
});
|
|
2658
|
+
};
|
|
2659
|
+
init_fn = function() {
|
|
2660
|
+
return __async(this, null, function* () {
|
|
2661
|
+
var _a2;
|
|
2662
|
+
try {
|
|
2663
|
+
if (typeof window !== "undefined" && ((_a2 = window.mmsdk) == null ? void 0 : _a2.isInitialized)) {
|
|
2664
|
+
logger2("MetaMaskSDK: init already initialized");
|
|
2665
|
+
} else {
|
|
2666
|
+
yield __privateMethod(this, _MultichainSDK_instances, setupAnalytics_fn).call(this);
|
|
2667
|
+
yield __privateMethod(this, _MultichainSDK_instances, setupTransport_fn).call(this);
|
|
2668
|
+
try {
|
|
2669
|
+
const baseProps = yield getBaseAnalyticsProperties(
|
|
2670
|
+
this.options,
|
|
2671
|
+
this.storage
|
|
2672
|
+
);
|
|
2673
|
+
analytics2.track("mmconnect_initialized", baseProps);
|
|
2674
|
+
} catch (error) {
|
|
2675
|
+
logger2("Error tracking initialized event", error);
|
|
2676
|
+
}
|
|
2677
|
+
if (typeof window !== "undefined") {
|
|
2678
|
+
window.mmsdk = this;
|
|
2679
|
+
}
|
|
2680
|
+
}
|
|
2681
|
+
} catch (error) {
|
|
2682
|
+
yield this.storage.removeTransport();
|
|
2683
|
+
this.status = "pending";
|
|
2684
|
+
logger2("MetaMaskSDK error during initialization", error);
|
|
2685
|
+
}
|
|
2686
|
+
});
|
|
2687
|
+
};
|
|
2688
|
+
createDappClient_fn = function() {
|
|
2689
|
+
return __async(this, null, function* () {
|
|
2690
|
+
const { adapter: kvstore } = this.options.storage;
|
|
2691
|
+
const sessionstore = new SessionStore2(kvstore);
|
|
2692
|
+
const websocket = (
|
|
2693
|
+
// eslint-disable-next-line no-negated-condition
|
|
2694
|
+
typeof window !== "undefined" ? WebSocket : (yield import("ws")).WebSocket
|
|
2695
|
+
);
|
|
2696
|
+
const transport = yield WebSocketTransport.create({
|
|
2697
|
+
url: MWP_RELAY_URL,
|
|
2698
|
+
kvstore,
|
|
2699
|
+
websocket
|
|
2700
|
+
});
|
|
2701
|
+
const dappClient = new DappClient({ transport, sessionstore, keymanager });
|
|
2702
|
+
return dappClient;
|
|
2703
|
+
});
|
|
2704
|
+
};
|
|
2705
|
+
setupMWP_fn = function() {
|
|
2706
|
+
return __async(this, null, function* () {
|
|
2707
|
+
if (__privateGet(this, _transport2) instanceof MWPTransport) {
|
|
2708
|
+
return;
|
|
2709
|
+
}
|
|
2710
|
+
const { adapter: kvstore } = this.options.storage;
|
|
2711
|
+
const dappClient = yield __privateMethod(this, _MultichainSDK_instances, createDappClient_fn).call(this);
|
|
2712
|
+
__privateSet(this, _dappClient, dappClient);
|
|
2713
|
+
const apiTransport = new MWPTransport(dappClient, kvstore);
|
|
2714
|
+
__privateSet(this, _transport2, apiTransport);
|
|
2715
|
+
__privateGet(this, _providerTransportWrapper).setupNotifcationListener();
|
|
2716
|
+
__privateSet(this, _listener, this.transport.onNotification(
|
|
2717
|
+
__privateMethod(this, _MultichainSDK_instances, onTransportNotification_fn).bind(this)
|
|
2718
|
+
));
|
|
2719
|
+
yield this.storage.setTransport("mwp" /* MWP */);
|
|
2720
|
+
});
|
|
2721
|
+
};
|
|
2722
|
+
onBeforeUnload_fn = function() {
|
|
2723
|
+
return __async(this, null, function* () {
|
|
2724
|
+
var _a2;
|
|
2725
|
+
if ((_a2 = this.options.ui.factory.modal) == null ? void 0 : _a2.isMounted) {
|
|
2726
|
+
yield this.storage.removeTransport();
|
|
2727
|
+
}
|
|
2728
|
+
});
|
|
2729
|
+
};
|
|
2730
|
+
createBeforeUnloadListener_fn = function() {
|
|
2731
|
+
if (typeof window !== "undefined" && typeof window.addEventListener !== "undefined") {
|
|
2732
|
+
window.addEventListener("beforeunload", __privateMethod(this, _MultichainSDK_instances, onBeforeUnload_fn).bind(this));
|
|
2733
|
+
}
|
|
2734
|
+
return () => {
|
|
2735
|
+
if (typeof window !== "undefined" && typeof window.removeEventListener !== "undefined") {
|
|
2736
|
+
window.removeEventListener(
|
|
2737
|
+
"beforeunload",
|
|
2738
|
+
__privateMethod(this, _MultichainSDK_instances, onBeforeUnload_fn).bind(this)
|
|
2739
|
+
);
|
|
2740
|
+
}
|
|
2741
|
+
};
|
|
2742
|
+
};
|
|
2743
|
+
renderInstallModalAsync_fn = function(desktopPreferred, scopes, caipAccountIds, sessionProperties) {
|
|
2744
|
+
return __async(this, null, function* () {
|
|
2745
|
+
return new Promise((resolve, reject) => {
|
|
2746
|
+
this.options.ui.factory.renderInstallModal(
|
|
2747
|
+
desktopPreferred,
|
|
2748
|
+
() => __async(this, null, function* () {
|
|
2749
|
+
if (this.dappClient.state === "CONNECTED" || this.dappClient.state === "CONNECTING") {
|
|
2750
|
+
yield this.dappClient.disconnect();
|
|
2751
|
+
}
|
|
2752
|
+
return new Promise((_resolve) => {
|
|
2753
|
+
this.dappClient.on(
|
|
2754
|
+
"session_request",
|
|
2755
|
+
(sessionRequest) => {
|
|
2756
|
+
_resolve({
|
|
2757
|
+
sessionRequest,
|
|
2758
|
+
metadata: {
|
|
2759
|
+
dapp: this.options.dapp,
|
|
2760
|
+
sdk: {
|
|
2761
|
+
version: getVersion(),
|
|
2762
|
+
platform: getPlatformType()
|
|
2763
|
+
}
|
|
2764
|
+
}
|
|
2765
|
+
});
|
|
2766
|
+
}
|
|
2767
|
+
);
|
|
2768
|
+
(() => __async(this, null, function* () {
|
|
2769
|
+
var _a2;
|
|
2770
|
+
try {
|
|
2771
|
+
yield this.transport.connect({ scopes, caipAccountIds, sessionProperties });
|
|
2772
|
+
yield this.options.ui.factory.unload();
|
|
2773
|
+
(_a2 = this.options.ui.factory.modal) == null ? void 0 : _a2.unmount();
|
|
2774
|
+
this.status = "connected";
|
|
2775
|
+
yield this.storage.setTransport("mwp" /* MWP */);
|
|
2776
|
+
} catch (error) {
|
|
2777
|
+
if (error instanceof ProtocolError) {
|
|
2778
|
+
if (error.code !== ErrorCode.REQUEST_EXPIRED) {
|
|
2779
|
+
this.status = "disconnected";
|
|
2780
|
+
reject(error);
|
|
2781
|
+
}
|
|
2782
|
+
} else {
|
|
2783
|
+
this.status = "disconnected";
|
|
2784
|
+
reject(
|
|
2785
|
+
error instanceof Error ? error : new Error(String(error))
|
|
2786
|
+
);
|
|
2787
|
+
}
|
|
2788
|
+
}
|
|
2789
|
+
}))().catch(() => {
|
|
2790
|
+
});
|
|
2791
|
+
});
|
|
2792
|
+
}),
|
|
2793
|
+
(error) => __async(this, null, function* () {
|
|
2794
|
+
if (error) {
|
|
2795
|
+
yield this.storage.removeTransport();
|
|
2796
|
+
reject(error);
|
|
2797
|
+
} else {
|
|
2798
|
+
yield this.storage.setTransport("mwp" /* MWP */);
|
|
2799
|
+
resolve();
|
|
2800
|
+
}
|
|
2801
|
+
}),
|
|
2802
|
+
(uri) => {
|
|
2803
|
+
this.emit("display_uri", uri);
|
|
2804
|
+
}
|
|
2805
|
+
).catch((error) => {
|
|
2806
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
2807
|
+
});
|
|
2808
|
+
});
|
|
2809
|
+
});
|
|
2810
|
+
};
|
|
2811
|
+
showInstallModal_fn = function(desktopPreferred, scopes, caipAccountIds, sessionProperties) {
|
|
2812
|
+
return __async(this, null, function* () {
|
|
2813
|
+
var _a2;
|
|
2814
|
+
(_a2 = __privateGet(this, _beforeUnloadListener)) != null ? _a2 : __privateSet(this, _beforeUnloadListener, __privateMethod(this, _MultichainSDK_instances, createBeforeUnloadListener_fn).call(this));
|
|
2815
|
+
if (this.options.ui.headless) {
|
|
2816
|
+
yield __privateMethod(this, _MultichainSDK_instances, headlessConnect_fn).call(this, scopes, caipAccountIds, sessionProperties);
|
|
2817
|
+
} else {
|
|
2818
|
+
yield __privateMethod(this, _MultichainSDK_instances, renderInstallModalAsync_fn).call(this, desktopPreferred, scopes, caipAccountIds, sessionProperties);
|
|
2819
|
+
}
|
|
2820
|
+
});
|
|
2821
|
+
};
|
|
2822
|
+
headlessConnect_fn = function(scopes, caipAccountIds, sessionProperties) {
|
|
2823
|
+
return __async(this, null, function* () {
|
|
2824
|
+
return new Promise((resolve, reject) => {
|
|
2825
|
+
if (this.dappClient.state === "CONNECTED" || this.dappClient.state === "CONNECTING") {
|
|
2826
|
+
this.dappClient.disconnect().catch(() => {
|
|
2827
|
+
});
|
|
2828
|
+
}
|
|
2829
|
+
this.dappClient.on(
|
|
2830
|
+
"session_request",
|
|
2831
|
+
(sessionRequest) => {
|
|
2832
|
+
const connectionRequest = {
|
|
2833
|
+
sessionRequest,
|
|
2834
|
+
metadata: {
|
|
2835
|
+
dapp: this.options.dapp,
|
|
2836
|
+
sdk: {
|
|
2837
|
+
version: getVersion(),
|
|
2838
|
+
platform: getPlatformType()
|
|
2839
|
+
}
|
|
2840
|
+
}
|
|
2841
|
+
};
|
|
2842
|
+
const deeplink = this.options.ui.factory.createConnectionDeeplink(connectionRequest);
|
|
2843
|
+
this.emit("display_uri", deeplink);
|
|
2844
|
+
}
|
|
2845
|
+
);
|
|
2846
|
+
this.transport.connect({ scopes, caipAccountIds, sessionProperties }).then(() => __async(this, null, function* () {
|
|
2847
|
+
this.status = "connected";
|
|
2848
|
+
yield this.storage.setTransport("mwp" /* MWP */);
|
|
2849
|
+
resolve();
|
|
2850
|
+
})).catch((error) => __async(this, null, function* () {
|
|
2851
|
+
if (error instanceof ProtocolError) {
|
|
2852
|
+
this.status = "disconnected";
|
|
2853
|
+
yield this.storage.removeTransport();
|
|
2854
|
+
reject(error);
|
|
2855
|
+
} else {
|
|
2856
|
+
this.status = "disconnected";
|
|
2857
|
+
yield this.storage.removeTransport();
|
|
2858
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
2859
|
+
}
|
|
2860
|
+
}));
|
|
2861
|
+
});
|
|
2862
|
+
});
|
|
2863
|
+
};
|
|
2864
|
+
setupDefaultTransport_fn = function() {
|
|
2865
|
+
return __async(this, null, function* () {
|
|
2866
|
+
this.status = "connecting";
|
|
2867
|
+
yield this.storage.setTransport("browser" /* Browser */);
|
|
2868
|
+
const transport = new DefaultTransport();
|
|
2869
|
+
__privateSet(this, _listener, transport.onNotification(
|
|
2870
|
+
__privateMethod(this, _MultichainSDK_instances, onTransportNotification_fn).bind(this)
|
|
2871
|
+
));
|
|
2872
|
+
__privateSet(this, _transport2, transport);
|
|
2873
|
+
__privateGet(this, _providerTransportWrapper).setupNotifcationListener();
|
|
2874
|
+
return transport;
|
|
2875
|
+
});
|
|
2876
|
+
};
|
|
2877
|
+
deeplinkConnect_fn = function(scopes, caipAccountIds, sessionProperties) {
|
|
2878
|
+
return __async(this, null, function* () {
|
|
2879
|
+
return new Promise((resolve, reject) => {
|
|
2880
|
+
const dappClientMessageHandler = (payload) => {
|
|
2881
|
+
var _a2;
|
|
2882
|
+
if (typeof payload !== "object" || payload === null || !("data" in payload)) {
|
|
2883
|
+
return;
|
|
2884
|
+
}
|
|
2885
|
+
const data = payload.data;
|
|
2886
|
+
if (typeof data === "object" && data !== null) {
|
|
2887
|
+
if (data.error) {
|
|
2888
|
+
this.dappClient.off("message", dappClientMessageHandler);
|
|
2889
|
+
reject(data.error);
|
|
2890
|
+
}
|
|
2891
|
+
if ((_a2 = data == null ? void 0 : data.result) == null ? void 0 : _a2.sessionScopes) {
|
|
2892
|
+
this.dappClient.off("message", dappClientMessageHandler);
|
|
2893
|
+
}
|
|
2894
|
+
}
|
|
2895
|
+
};
|
|
2896
|
+
this.dappClient.on("message", dappClientMessageHandler);
|
|
2897
|
+
let timeout;
|
|
2898
|
+
if (this.transport.isConnected()) {
|
|
2899
|
+
timeout = setTimeout(() => {
|
|
2900
|
+
this.openDeeplinkIfNeeded();
|
|
2901
|
+
}, 250);
|
|
2902
|
+
} else {
|
|
2903
|
+
this.dappClient.once(
|
|
2904
|
+
"session_request",
|
|
2905
|
+
(sessionRequest) => {
|
|
2906
|
+
var _a2;
|
|
2907
|
+
const connectionRequest = {
|
|
2908
|
+
sessionRequest,
|
|
2909
|
+
metadata: {
|
|
2910
|
+
dapp: this.options.dapp,
|
|
2911
|
+
sdk: { version: getVersion(), platform: getPlatformType() }
|
|
2912
|
+
}
|
|
2913
|
+
};
|
|
2914
|
+
const deeplink = this.options.ui.factory.createConnectionDeeplink(
|
|
2915
|
+
connectionRequest
|
|
2916
|
+
);
|
|
2917
|
+
const universalLink = this.options.ui.factory.createConnectionUniversalLink(
|
|
2918
|
+
connectionRequest
|
|
2919
|
+
);
|
|
2920
|
+
this.emit("display_uri", deeplink);
|
|
2921
|
+
if ((_a2 = this.options.mobile) == null ? void 0 : _a2.preferredOpenLink) {
|
|
2922
|
+
this.options.mobile.preferredOpenLink(deeplink, "_self");
|
|
2923
|
+
} else {
|
|
2924
|
+
openDeeplink(this.options, deeplink, universalLink);
|
|
2925
|
+
}
|
|
2926
|
+
}
|
|
2927
|
+
);
|
|
2928
|
+
}
|
|
2929
|
+
return this.transport.connect({ scopes, caipAccountIds, sessionProperties }).then(resolve).catch((error) => __async(this, null, function* () {
|
|
2930
|
+
yield this.storage.removeTransport();
|
|
2931
|
+
this.dappClient.off("message", dappClientMessageHandler);
|
|
2932
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
2933
|
+
})).finally(() => {
|
|
2934
|
+
if (timeout) {
|
|
2935
|
+
clearTimeout(timeout);
|
|
2936
|
+
}
|
|
2937
|
+
});
|
|
2938
|
+
});
|
|
2939
|
+
});
|
|
2940
|
+
};
|
|
2941
|
+
handleConnection_fn = function(promise, scopes, transportType) {
|
|
2942
|
+
return __async(this, null, function* () {
|
|
2943
|
+
this.status = "connecting";
|
|
2944
|
+
return promise.then(() => __async(this, null, function* () {
|
|
2945
|
+
this.status = "connected";
|
|
2946
|
+
try {
|
|
2947
|
+
const baseProps = yield getBaseAnalyticsProperties(
|
|
2948
|
+
this.options,
|
|
2949
|
+
this.storage
|
|
2950
|
+
);
|
|
2951
|
+
analytics2.track("mmconnect_connection_established", __spreadProps(__spreadValues({}, baseProps), {
|
|
2952
|
+
transport_type: transportType,
|
|
2953
|
+
user_permissioned_chains: scopes
|
|
2954
|
+
}));
|
|
2955
|
+
} catch (error) {
|
|
2956
|
+
logger2("Error tracking connection_established event", error);
|
|
2957
|
+
}
|
|
2958
|
+
return void 0;
|
|
2959
|
+
})).catch((error) => __async(this, null, function* () {
|
|
2960
|
+
this.status = "disconnected";
|
|
2961
|
+
try {
|
|
2962
|
+
const baseProps = yield getBaseAnalyticsProperties(
|
|
2963
|
+
this.options,
|
|
2964
|
+
this.storage
|
|
2965
|
+
);
|
|
2966
|
+
const isRejection = isRejectionError(error);
|
|
2967
|
+
if (isRejection) {
|
|
2968
|
+
analytics2.track("mmconnect_connection_rejected", __spreadProps(__spreadValues({}, baseProps), {
|
|
2969
|
+
transport_type: transportType
|
|
2970
|
+
}));
|
|
2971
|
+
} else {
|
|
2972
|
+
analytics2.track("mmconnect_connection_failed", __spreadProps(__spreadValues({}, baseProps), {
|
|
2973
|
+
transport_type: transportType
|
|
2974
|
+
}));
|
|
2975
|
+
}
|
|
2976
|
+
} catch (e) {
|
|
2977
|
+
logger2("Error tracking connection failed/rejected event", error);
|
|
2978
|
+
}
|
|
2979
|
+
throw error;
|
|
2980
|
+
}));
|
|
2981
|
+
});
|
|
2982
|
+
};
|
|
2983
|
+
var MultichainSDK = _MultichainSDK;
|
|
2721
2984
|
|
|
2722
2985
|
// src/store/index.ts
|
|
2723
2986
|
import * as uuid from "uuid";
|
|
@@ -2898,54 +3161,11 @@ var Store = class extends StoreClient {
|
|
|
2898
3161
|
}
|
|
2899
3162
|
};
|
|
2900
3163
|
|
|
2901
|
-
// src/ui/
|
|
3164
|
+
// src/ui/ModalFactory.ts
|
|
2902
3165
|
import MetaMaskOnboarding from "@metamask/onboarding";
|
|
2903
3166
|
init_domain();
|
|
2904
|
-
|
|
2905
|
-
// src/ui/qr.ts
|
|
2906
|
-
var encodeQRImpl = null;
|
|
2907
|
-
function preloadQR() {
|
|
2908
|
-
return __async(this, null, function* () {
|
|
2909
|
-
if (encodeQRImpl) {
|
|
2910
|
-
return;
|
|
2911
|
-
}
|
|
2912
|
-
const mod = yield import("@paulmillr/qr");
|
|
2913
|
-
encodeQRImpl = mod.default;
|
|
2914
|
-
});
|
|
2915
|
-
}
|
|
2916
|
-
|
|
2917
|
-
// src/ui/index.ts
|
|
2918
3167
|
init_utils();
|
|
2919
|
-
var
|
|
2920
|
-
function preload() {
|
|
2921
|
-
return __async(this, null, function* () {
|
|
2922
|
-
if (true) {
|
|
2923
|
-
__instance != null ? __instance : __instance = yield import("@metamask/multichain-ui/dist/loader/index.js").then((loader) => __async(null, null, function* () {
|
|
2924
|
-
if (typeof (loader == null ? void 0 : loader.defineCustomElements) === "function") {
|
|
2925
|
-
loader.defineCustomElements();
|
|
2926
|
-
}
|
|
2927
|
-
return Promise.resolve(loader);
|
|
2928
|
-
})).catch((error) => __async(null, null, function* () {
|
|
2929
|
-
console.error(`Gracefully Failed to load modal customElements:`, error);
|
|
2930
|
-
return Promise.resolve(void 0);
|
|
2931
|
-
}));
|
|
2932
|
-
} else {
|
|
2933
|
-
const dynamicImport = (0, eval)("import");
|
|
2934
|
-
__instance != null ? __instance : __instance = yield dynamicImport(
|
|
2935
|
-
"@metamask/multichain-ui/dist/loader/index.js"
|
|
2936
|
-
).then((loader) => __async(null, null, function* () {
|
|
2937
|
-
if (typeof (loader == null ? void 0 : loader.defineCustomElements) === "function") {
|
|
2938
|
-
loader.defineCustomElements();
|
|
2939
|
-
}
|
|
2940
|
-
return Promise.resolve(loader);
|
|
2941
|
-
})).catch((error) => __async(null, null, function* () {
|
|
2942
|
-
console.error(`Gracefully Failed to load modal customElements:`, error);
|
|
2943
|
-
return Promise.resolve(void 0);
|
|
2944
|
-
}));
|
|
2945
|
-
}
|
|
2946
|
-
});
|
|
2947
|
-
}
|
|
2948
|
-
var ModalFactory = class {
|
|
3168
|
+
var BaseModalFactory = class {
|
|
2949
3169
|
/**
|
|
2950
3170
|
* Creates a new modal factory instance.
|
|
2951
3171
|
*
|
|
@@ -2967,8 +3187,8 @@ var ModalFactory = class {
|
|
|
2967
3187
|
}
|
|
2968
3188
|
unload(error) {
|
|
2969
3189
|
return __async(this, null, function* () {
|
|
2970
|
-
var
|
|
2971
|
-
(
|
|
3190
|
+
var _a2, _b;
|
|
3191
|
+
(_a2 = this.modal) == null ? void 0 : _a2.unmount();
|
|
2972
3192
|
yield (_b = this.successCallback) == null ? void 0 : _b.call(this, error);
|
|
2973
3193
|
});
|
|
2974
3194
|
}
|
|
@@ -3034,15 +3254,17 @@ var ModalFactory = class {
|
|
|
3034
3254
|
onStartDesktopOnboarding() {
|
|
3035
3255
|
new MetaMaskOnboarding().startOnboarding();
|
|
3036
3256
|
}
|
|
3037
|
-
renderInstallModal(showInstallModal, createConnectionRequest, successCallback) {
|
|
3257
|
+
renderInstallModal(showInstallModal, createConnectionRequest, successCallback, onDisplayUri) {
|
|
3038
3258
|
return __async(this, null, function* () {
|
|
3039
|
-
var
|
|
3040
|
-
(
|
|
3041
|
-
yield
|
|
3259
|
+
var _a2, _b;
|
|
3260
|
+
(_a2 = this.modal) == null ? void 0 : _a2.unmount();
|
|
3261
|
+
yield this.preload();
|
|
3042
3262
|
this.successCallback = successCallback;
|
|
3263
|
+
this.displayUriCallback = onDisplayUri;
|
|
3043
3264
|
const parentElement = this.getMountedContainer();
|
|
3044
3265
|
const connectionRequest = yield createConnectionRequest();
|
|
3045
3266
|
const qrCodeLink = this.createConnectionDeeplink(connectionRequest);
|
|
3267
|
+
(_b = this.displayUriCallback) == null ? void 0 : _b.call(this, qrCodeLink);
|
|
3046
3268
|
const modal = new this.options.InstallModal({
|
|
3047
3269
|
expiresIn: (connectionRequest.sessionRequest.expiresAt - Date.now()) / 1e3,
|
|
3048
3270
|
connectionRequest,
|
|
@@ -3051,11 +3273,15 @@ var ModalFactory = class {
|
|
|
3051
3273
|
link: qrCodeLink,
|
|
3052
3274
|
sdkVersion: getVersion(),
|
|
3053
3275
|
generateQRCode: (request) => __async(this, null, function* () {
|
|
3054
|
-
|
|
3276
|
+
var _a3;
|
|
3277
|
+
const newLink = this.createConnectionDeeplink(request);
|
|
3278
|
+
(_a3 = this.displayUriCallback) == null ? void 0 : _a3.call(this, newLink);
|
|
3279
|
+
return newLink;
|
|
3055
3280
|
}),
|
|
3056
3281
|
onClose: this.onCloseModal.bind(this),
|
|
3057
3282
|
startDesktopOnboarding: this.onStartDesktopOnboarding.bind(this),
|
|
3058
|
-
createConnectionRequest
|
|
3283
|
+
createConnectionRequest,
|
|
3284
|
+
onDisplayUri: this.displayUriCallback
|
|
3059
3285
|
});
|
|
3060
3286
|
this.modal = modal;
|
|
3061
3287
|
modal.mount();
|
|
@@ -3063,9 +3289,9 @@ var ModalFactory = class {
|
|
|
3063
3289
|
}
|
|
3064
3290
|
renderOTPCodeModal(createOTPCode, successCallback, updateOTPCode) {
|
|
3065
3291
|
return __async(this, null, function* () {
|
|
3066
|
-
var
|
|
3067
|
-
(
|
|
3068
|
-
yield
|
|
3292
|
+
var _a2;
|
|
3293
|
+
(_a2 = this.modal) == null ? void 0 : _a2.unmount();
|
|
3294
|
+
yield this.preload();
|
|
3069
3295
|
this.successCallback = successCallback;
|
|
3070
3296
|
const container = this.getMountedContainer();
|
|
3071
3297
|
const otpCode = yield createOTPCode();
|
|
@@ -3083,9 +3309,31 @@ var ModalFactory = class {
|
|
|
3083
3309
|
}
|
|
3084
3310
|
};
|
|
3085
3311
|
|
|
3312
|
+
// src/ui/index.ts
|
|
3313
|
+
function preload() {
|
|
3314
|
+
return __async(this, null, function* () {
|
|
3315
|
+
if (typeof document === "undefined") {
|
|
3316
|
+
return;
|
|
3317
|
+
}
|
|
3318
|
+
try {
|
|
3319
|
+
const { defineCustomElements } = yield import("@metamask/multichain-ui/loader");
|
|
3320
|
+
yield defineCustomElements();
|
|
3321
|
+
} catch (error) {
|
|
3322
|
+
console.error("Failed to load customElements:", error);
|
|
3323
|
+
}
|
|
3324
|
+
});
|
|
3325
|
+
}
|
|
3326
|
+
var ModalFactory = class extends BaseModalFactory {
|
|
3327
|
+
preload() {
|
|
3328
|
+
return __async(this, null, function* () {
|
|
3329
|
+
return preload();
|
|
3330
|
+
});
|
|
3331
|
+
}
|
|
3332
|
+
};
|
|
3333
|
+
|
|
3086
3334
|
// src/index.browser.ts
|
|
3087
3335
|
init_domain();
|
|
3088
|
-
var
|
|
3336
|
+
var createMultichainClient = (options) => __async(null, null, function* () {
|
|
3089
3337
|
const uiModules = yield Promise.resolve().then(() => (init_web(), web_exports));
|
|
3090
3338
|
let storage;
|
|
3091
3339
|
if (!options.storage) {
|
|
@@ -3118,7 +3366,7 @@ export {
|
|
|
3118
3366
|
StoreClient,
|
|
3119
3367
|
TransportType,
|
|
3120
3368
|
createLogger,
|
|
3121
|
-
|
|
3369
|
+
createMultichainClient,
|
|
3122
3370
|
enableDebug,
|
|
3123
3371
|
getInfuraRpcUrls,
|
|
3124
3372
|
getPlatformType,
|