@tronweb3/tronwallet-adapter-trust 1.0.1 → 1.0.3
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/LICENSE +1 -1
- package/README.md +1 -1
- package/lib/cjs/adapter.js +22 -14
- package/lib/cjs/adapter.js.map +1 -1
- package/lib/cjs/tsconfig.cjs.tsbuildinfo +1 -0
- package/lib/esm/adapter.js +22 -14
- package/lib/esm/adapter.js.map +1 -1
- package/lib/esm/tsconfig.esm.tsbuildinfo +1 -0
- package/lib/types/adapter.d.ts +5 -3
- package/lib/types/adapter.d.ts.map +1 -1
- package/lib/umd/index.js +131 -197
- package/lib/umd/index.min.js +1 -1
- package/package.json +8 -8
- package/src/adapter.ts +18 -17
package/lib/umd/index.js
CHANGED
|
@@ -427,7 +427,7 @@
|
|
|
427
427
|
return Promise.resolve();
|
|
428
428
|
}
|
|
429
429
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
430
|
-
multiSign(
|
|
430
|
+
multiSign(transaction, options = {}) {
|
|
431
431
|
return Promise.reject("The current wallet doesn't support multiSign.");
|
|
432
432
|
}
|
|
433
433
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -460,10 +460,9 @@
|
|
|
460
460
|
* Occurs when wallet is not installed.
|
|
461
461
|
*/
|
|
462
462
|
class WalletNotFoundError extends WalletError {
|
|
463
|
-
constructor() {
|
|
464
|
-
super(
|
|
463
|
+
constructor(message, error) {
|
|
464
|
+
super(message || 'The wallet is not found.', error);
|
|
465
465
|
this.name = 'WalletNotFoundError';
|
|
466
|
-
this.message = 'The wallet is not found.';
|
|
467
466
|
}
|
|
468
467
|
}
|
|
469
468
|
errors.WalletNotFoundError = WalletNotFoundError;
|
|
@@ -544,10 +543,9 @@
|
|
|
544
543
|
* Occurs when walletconnect QR window is closed.
|
|
545
544
|
*/
|
|
546
545
|
class WalletWindowClosedError extends WalletError {
|
|
547
|
-
constructor() {
|
|
548
|
-
super(
|
|
546
|
+
constructor(message, error) {
|
|
547
|
+
super(message || 'The QR window is closed.', error);
|
|
549
548
|
this.name = 'WalletWindowClosedError';
|
|
550
|
-
this.message = 'The QR window is closed.';
|
|
551
549
|
}
|
|
552
550
|
}
|
|
553
551
|
errors.WalletWindowClosedError = WalletWindowClosedError;
|
|
@@ -583,7 +581,7 @@
|
|
|
583
581
|
if (hasRequiredTypes$1) return types$1;
|
|
584
582
|
hasRequiredTypes$1 = 1;
|
|
585
583
|
Object.defineProperty(types$1, "__esModule", { value: true });
|
|
586
|
-
types$1.ChainNetwork = types$1.NetworkType = void 0;
|
|
584
|
+
types$1.TIP6963RequestProviderEventName = types$1.TIP6963AnnounceProviderEventName = types$1.ChainNetwork = types$1.NetworkType = void 0;
|
|
587
585
|
var NetworkType;
|
|
588
586
|
(function (NetworkType) {
|
|
589
587
|
NetworkType["Mainnet"] = "Mainnet";
|
|
@@ -600,6 +598,8 @@
|
|
|
600
598
|
ChainNetwork["Shasta"] = "Shasta";
|
|
601
599
|
ChainNetwork["Nile"] = "Nile";
|
|
602
600
|
})(ChainNetwork || (types$1.ChainNetwork = ChainNetwork = {}));
|
|
601
|
+
types$1.TIP6963AnnounceProviderEventName = 'TIP6963:announceProvider';
|
|
602
|
+
types$1.TIP6963RequestProviderEventName = 'TIP6963:requestProvider';
|
|
603
603
|
|
|
604
604
|
return types$1;
|
|
605
605
|
}
|
|
@@ -671,7 +671,7 @@
|
|
|
671
671
|
function requireCjs$2 () {
|
|
672
672
|
if (hasRequiredCjs$2) return cjs$1;
|
|
673
673
|
hasRequiredCjs$2 = 1;
|
|
674
|
-
(function (exports) {
|
|
674
|
+
(function (exports$1) {
|
|
675
675
|
var __createBinding = (cjs$1 && cjs$1.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
676
676
|
if (k2 === undefined) k2 = k;
|
|
677
677
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -683,14 +683,14 @@
|
|
|
683
683
|
if (k2 === undefined) k2 = k;
|
|
684
684
|
o[k2] = m[k];
|
|
685
685
|
}));
|
|
686
|
-
var __exportStar = (cjs$1 && cjs$1.__exportStar) || function(m, exports) {
|
|
687
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
686
|
+
var __exportStar = (cjs$1 && cjs$1.__exportStar) || function(m, exports$1) {
|
|
687
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$1, p)) __createBinding(exports$1, m, p);
|
|
688
688
|
};
|
|
689
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
690
|
-
__exportStar(
|
|
691
|
-
__exportStar(
|
|
692
|
-
__exportStar(
|
|
693
|
-
__exportStar(
|
|
689
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
690
|
+
__exportStar(requireAdapter$2(), exports$1);
|
|
691
|
+
__exportStar(requireErrors(), exports$1);
|
|
692
|
+
__exportStar(requireTypes$1(), exports$1);
|
|
693
|
+
__exportStar(requireUtils$2(), exports$1);
|
|
694
694
|
|
|
695
695
|
} (cjs$1));
|
|
696
696
|
return cjs$1;
|
|
@@ -724,10 +724,10 @@
|
|
|
724
724
|
utils$1.waitTronwebReady = waitTronwebReady;
|
|
725
725
|
const tronwallet_abstract_adapter_1 = /*@__PURE__*/ requireCjs$2();
|
|
726
726
|
function supportTron() {
|
|
727
|
-
return !!(window.tron && window.tron.isTronLink);
|
|
727
|
+
return (0, tronwallet_abstract_adapter_1.isInBrowser)() && !!(window.tron && window.tron.isTronLink);
|
|
728
728
|
}
|
|
729
729
|
function supportTronLink() {
|
|
730
|
-
return !!(supportTron() || window.tronLink || window.tronWeb);
|
|
730
|
+
return (0, tronwallet_abstract_adapter_1.isInBrowser)() && !!(supportTron() || window.tronLink || window.tronWeb);
|
|
731
731
|
}
|
|
732
732
|
/**
|
|
733
733
|
* Detect if in TronLinkApp
|
|
@@ -747,7 +747,7 @@
|
|
|
747
747
|
defaultDappIcon = new URL(link.getAttribute('href') || '', location.href).toString();
|
|
748
748
|
}
|
|
749
749
|
}
|
|
750
|
-
catch (
|
|
750
|
+
catch (_a) {
|
|
751
751
|
// console.error(e);
|
|
752
752
|
}
|
|
753
753
|
const { origin, pathname, search, hash } = window.location;
|
|
@@ -794,7 +794,7 @@
|
|
|
794
794
|
function requireAdapter$1 () {
|
|
795
795
|
if (hasRequiredAdapter$1) return adapter;
|
|
796
796
|
hasRequiredAdapter$1 = 1;
|
|
797
|
-
(function (exports) {
|
|
797
|
+
(function (exports$1) {
|
|
798
798
|
var __awaiter = (adapter && adapter.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
799
799
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
800
800
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -804,12 +804,12 @@
|
|
|
804
804
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
805
805
|
});
|
|
806
806
|
};
|
|
807
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
808
|
-
exports.TronLinkAdapter = exports.TronLinkAdapterName = exports.chainIdNetworkMap = void 0;
|
|
809
|
-
exports.getNetworkInfoByTronWeb = getNetworkInfoByTronWeb;
|
|
807
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
808
|
+
exports$1.TronLinkAdapter = exports$1.TronLinkAdapterName = exports$1.chainIdNetworkMap = void 0;
|
|
809
|
+
exports$1.getNetworkInfoByTronWeb = getNetworkInfoByTronWeb;
|
|
810
810
|
const tronwallet_abstract_adapter_1 = /*@__PURE__*/ requireCjs$2();
|
|
811
|
-
const utils_js_1 =
|
|
812
|
-
exports.chainIdNetworkMap = {
|
|
811
|
+
const utils_js_1 = requireUtils$1();
|
|
812
|
+
exports$1.chainIdNetworkMap = {
|
|
813
813
|
'0x2b6653dc': tronwallet_abstract_adapter_1.NetworkType.Mainnet,
|
|
814
814
|
'0x94a9059e': tronwallet_abstract_adapter_1.NetworkType.Shasta,
|
|
815
815
|
'0xcd8690dc': tronwallet_abstract_adapter_1.NetworkType.Nile,
|
|
@@ -820,7 +820,7 @@
|
|
|
820
820
|
const { blockID = '' } = yield tronWeb.trx.getBlockByNumber(0);
|
|
821
821
|
const chainId = `0x${blockID.slice(-8)}`;
|
|
822
822
|
return {
|
|
823
|
-
networkType: exports.chainIdNetworkMap[chainId] || tronwallet_abstract_adapter_1.NetworkType.Unknown,
|
|
823
|
+
networkType: exports$1.chainIdNetworkMap[chainId] || tronwallet_abstract_adapter_1.NetworkType.Unknown,
|
|
824
824
|
chainId,
|
|
825
825
|
fullNode: ((_a = tronWeb.fullNode) === null || _a === void 0 ? void 0 : _a.host) || '',
|
|
826
826
|
solidityNode: ((_b = tronWeb.solidityNode) === null || _b === void 0 ? void 0 : _b.host) || '',
|
|
@@ -828,61 +828,18 @@
|
|
|
828
828
|
};
|
|
829
829
|
});
|
|
830
830
|
}
|
|
831
|
-
exports.TronLinkAdapterName = 'TronLink';
|
|
831
|
+
exports$1.TronLinkAdapterName = 'TronLink';
|
|
832
832
|
class TronLinkAdapter extends tronwallet_abstract_adapter_1.Adapter {
|
|
833
833
|
// record if first connect event has emitted or not
|
|
834
834
|
constructor(config = {}) {
|
|
835
835
|
super();
|
|
836
|
-
this.name = exports.TronLinkAdapterName;
|
|
836
|
+
this.name = exports$1.TronLinkAdapterName;
|
|
837
837
|
this.url = 'https://www.tronlink.org/';
|
|
838
838
|
this.icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAF0AAABdCAYAAADHcWrDAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAUGVYSWZNTQAqAAAACAACARIAAwAAAAEAAQAAh2kABAAAAAEAAAAmAAAAAAADoAEAAwAAAAEAAQAAoAIABAAAAAEAAABdoAMABAAAAAEAAABdAAAAAMkTBfIAAAFZaVRYdFhNTDpjb20uYWRvYmUueG1wAAAAAAA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nTxxB9YVuB6VG1sxW9O4zc1wb24lZrminHsopzRH482lTccc6eszEpEWoDLbmhEdbEPk1p8U5NTxqF5AAxORyUbVWI1PNbQEJhW9uI5n2laql36zE5T6/IXJi7Nu3H1CsO0r4OmmY2M5CT8oGmmw3IMjURZsWh3h/3pGbas3OKXE5hJy4lMs8s1WESwbAMOejwdUoaIVaR/nt6JKK1GoVAQDEF61lG4+Ks2GPRgQbId3InZl7cxQBeWLJ70ZYzHUYdigs4WHPX4txA9L8qfs34UfM7J2B6NFVmDxLB6i92q0KkLtfcPhX0vSqq3H6geC/98RHg/VwL0MW8e/hjvVy/Xim34CVG+21h+ePawjAk4HDG1byFN4q+r/dQH74aaDGOtFvnw4wC+2BJzo8db/XnJc1Njr7EMua7DuJAdXXXTrq8fI2lpUyPvz8LSjjXLjCEXHIw8Ft8eu65sqmTkjok4K+AvNnyZH0Xsb+eO/wWrg46Do/7gYAAAAABJRU5ErkJggg==';
|
|
839
839
|
this._readyState = (0, tronwallet_abstract_adapter_1.isInBrowser)() ? tronwallet_abstract_adapter_1.WalletReadyState.Loading : tronwallet_abstract_adapter_1.WalletReadyState.NotFound;
|
|
840
|
-
this._state = tronwallet_abstract_adapter_1.AdapterState.Loading;
|
|
840
|
+
this._state = (0, tronwallet_abstract_adapter_1.isInBrowser)() ? tronwallet_abstract_adapter_1.AdapterState.Loading : tronwallet_abstract_adapter_1.AdapterState.NotFound;
|
|
841
841
|
// https://github.com/tronprotocol/tips/blob/master/tip-1193.md
|
|
842
842
|
this._supportNewTronProtocol = false;
|
|
843
|
-
this._tronLinkMessageHandler = (e) => {
|
|
844
|
-
var _a, _b, _c, _d, _e;
|
|
845
|
-
const message = (_a = e.data) === null || _a === void 0 ? void 0 : _a.message;
|
|
846
|
-
if (!message) {
|
|
847
|
-
return;
|
|
848
|
-
}
|
|
849
|
-
if (message.action === 'accountsChanged') {
|
|
850
|
-
setTimeout(() => {
|
|
851
|
-
var _a;
|
|
852
|
-
const preAddr = this.address || '';
|
|
853
|
-
if ((_a = this._wallet) === null || _a === void 0 ? void 0 : _a.ready) {
|
|
854
|
-
const address = message.data.address;
|
|
855
|
-
this.setAddress(address);
|
|
856
|
-
this.setState(tronwallet_abstract_adapter_1.AdapterState.Connected);
|
|
857
|
-
}
|
|
858
|
-
else {
|
|
859
|
-
this.setAddress(null);
|
|
860
|
-
this.setState(tronwallet_abstract_adapter_1.AdapterState.Disconnect);
|
|
861
|
-
}
|
|
862
|
-
this.emit('accountsChanged', this.address || '', preAddr);
|
|
863
|
-
if (!preAddr && this.address) {
|
|
864
|
-
this.emit('connect', this.address);
|
|
865
|
-
}
|
|
866
|
-
else if (preAddr && !this.address) {
|
|
867
|
-
this.emit('disconnect');
|
|
868
|
-
}
|
|
869
|
-
}, 200);
|
|
870
|
-
}
|
|
871
|
-
else if (message.action === 'setNode') {
|
|
872
|
-
this.emit('chainChanged', { chainId: ((_c = (_b = message.data) === null || _b === void 0 ? void 0 : _b.node) === null || _c === void 0 ? void 0 : _c.chainId) || '' });
|
|
873
|
-
}
|
|
874
|
-
else if (message.action === 'connect') {
|
|
875
|
-
const address = ((_e = (_d = this._wallet.tronWeb) === null || _d === void 0 ? void 0 : _d.defaultAddress) === null || _e === void 0 ? void 0 : _e.base58) || '';
|
|
876
|
-
this.setAddress(address);
|
|
877
|
-
this.setState(tronwallet_abstract_adapter_1.AdapterState.Connected);
|
|
878
|
-
this.emit('connect', address);
|
|
879
|
-
}
|
|
880
|
-
else if (message.action === 'disconnect') {
|
|
881
|
-
this.setAddress(null);
|
|
882
|
-
this.setState(tronwallet_abstract_adapter_1.AdapterState.Disconnect);
|
|
883
|
-
this.emit('disconnect');
|
|
884
|
-
}
|
|
885
|
-
};
|
|
886
843
|
this._onChainChanged = (data) => {
|
|
887
844
|
this.emit('chainChanged', data);
|
|
888
845
|
};
|
|
@@ -890,17 +847,8 @@
|
|
|
890
847
|
var _a, _b, _c;
|
|
891
848
|
const preAddr = this.address || '';
|
|
892
849
|
const curAddr = (((_a = this._wallet) === null || _a === void 0 ? void 0 : _a.tronWeb) && ((_c = (_b = this._wallet) === null || _b === void 0 ? void 0 : _b.tronWeb.defaultAddress) === null || _c === void 0 ? void 0 : _c.base58)) || '';
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
// tronlink will emit accountsChanged many times, only process when connected
|
|
896
|
-
this.setAddress(null);
|
|
897
|
-
this.setState(tronwallet_abstract_adapter_1.AdapterState.Disconnect);
|
|
898
|
-
}
|
|
899
|
-
else {
|
|
900
|
-
const address = curAddr;
|
|
901
|
-
this.setAddress(address);
|
|
902
|
-
this.setState(tronwallet_abstract_adapter_1.AdapterState.Connected);
|
|
903
|
-
}
|
|
850
|
+
this.setAddress(curAddr ? curAddr : null);
|
|
851
|
+
this.setState(this.address ? tronwallet_abstract_adapter_1.AdapterState.Connected : tronwallet_abstract_adapter_1.AdapterState.Disconnect);
|
|
904
852
|
this.emit('accountsChanged', this.address || '', preAddr);
|
|
905
853
|
if (!preAddr && this.address) {
|
|
906
854
|
this.emit('connect', this.address);
|
|
@@ -911,7 +859,8 @@
|
|
|
911
859
|
};
|
|
912
860
|
this._checkPromise = null;
|
|
913
861
|
this._updateWallet = () => {
|
|
914
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
862
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
863
|
+
this._supportNewTronProtocol = false;
|
|
915
864
|
let state = this.state;
|
|
916
865
|
let address = this.address;
|
|
917
866
|
if ((0, tronwallet_abstract_adapter_1.isInMobileBrowser)()) {
|
|
@@ -932,13 +881,22 @@
|
|
|
932
881
|
this._supportNewTronProtocol = true;
|
|
933
882
|
this._wallet = window.tron;
|
|
934
883
|
this._listenTronEvent();
|
|
935
|
-
|
|
936
|
-
|
|
884
|
+
try {
|
|
885
|
+
address = (((_d = this._wallet) === null || _d === void 0 ? void 0 : _d.tronWeb) && ((_f = (_e = this._wallet.tronWeb) === null || _e === void 0 ? void 0 : _e.defaultAddress) === null || _f === void 0 ? void 0 : _f.base58)) || null;
|
|
886
|
+
state = address ? tronwallet_abstract_adapter_1.AdapterState.Connected : tronwallet_abstract_adapter_1.AdapterState.Disconnect;
|
|
887
|
+
}
|
|
888
|
+
catch (e) {
|
|
889
|
+
console.error('Unknown error: ' + e, ' Please install TronLink extension wallet.');
|
|
890
|
+
address = null;
|
|
891
|
+
state = tronwallet_abstract_adapter_1.AdapterState.Disconnect;
|
|
892
|
+
this._readyState = tronwallet_abstract_adapter_1.WalletReadyState.NotFound;
|
|
893
|
+
this.emit('readyStateChanged', this.readyState);
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
937
896
|
}
|
|
938
897
|
else if (window.tronLink) {
|
|
939
898
|
this._wallet = window.tronLink;
|
|
940
|
-
this.
|
|
941
|
-
address = ((_g = (_f = this._wallet.tronWeb) === null || _f === void 0 ? void 0 : _f.defaultAddress) === null || _g === void 0 ? void 0 : _g.base58) || null;
|
|
899
|
+
address = ((_h = (_g = this._wallet.tronWeb) === null || _g === void 0 ? void 0 : _g.defaultAddress) === null || _h === void 0 ? void 0 : _h.base58) || null;
|
|
942
900
|
state = this._wallet.ready ? tronwallet_abstract_adapter_1.AdapterState.Connected : tronwallet_abstract_adapter_1.AdapterState.Disconnect;
|
|
943
901
|
}
|
|
944
902
|
else if (window.tronWeb) {
|
|
@@ -948,7 +906,7 @@
|
|
|
948
906
|
tronWeb: window.tronWeb,
|
|
949
907
|
request: () => Promise.resolve(true),
|
|
950
908
|
};
|
|
951
|
-
address = ((
|
|
909
|
+
address = ((_j = this._wallet.tronWeb.defaultAddress) === null || _j === void 0 ? void 0 : _j.base58) || null;
|
|
952
910
|
state = this._wallet.ready ? tronwallet_abstract_adapter_1.AdapterState.Connected : tronwallet_abstract_adapter_1.AdapterState.Disconnect;
|
|
953
911
|
}
|
|
954
912
|
else {
|
|
@@ -965,13 +923,14 @@
|
|
|
965
923
|
this.setState(state);
|
|
966
924
|
};
|
|
967
925
|
this.checkReadyInterval = null;
|
|
968
|
-
const { checkTimeout = 30 * 1000, dappIcon = '', dappName = '', openUrlWhenWalletNotFound = true, openTronLinkAppOnMobile = true, } = config;
|
|
926
|
+
const { checkTimeout = 30 * 1000, dappIcon = '', dappName = '', openUrlWhenWalletNotFound = true, openTronLinkAppOnMobile = true, openAppWithDeeplink = true, } = config;
|
|
969
927
|
if (typeof checkTimeout !== 'number') {
|
|
970
928
|
throw new Error('[TronLinkAdapter] config.checkTimeout should be a number');
|
|
971
929
|
}
|
|
972
930
|
this.config = {
|
|
973
931
|
checkTimeout,
|
|
974
932
|
openTronLinkAppOnMobile,
|
|
933
|
+
openAppWithDeeplink,
|
|
975
934
|
openUrlWhenWalletNotFound,
|
|
976
935
|
dappIcon,
|
|
977
936
|
dappName,
|
|
@@ -979,11 +938,6 @@
|
|
|
979
938
|
this._connecting = false;
|
|
980
939
|
this._wallet = null;
|
|
981
940
|
this._address = null;
|
|
982
|
-
if (!(0, tronwallet_abstract_adapter_1.isInBrowser)()) {
|
|
983
|
-
this._readyState = tronwallet_abstract_adapter_1.WalletReadyState.NotFound;
|
|
984
|
-
this.setState(tronwallet_abstract_adapter_1.AdapterState.NotFound);
|
|
985
|
-
return;
|
|
986
|
-
}
|
|
987
941
|
if ((0, utils_js_1.supportTron)() || ((0, tronwallet_abstract_adapter_1.isInMobileBrowser)() && (window.tronLink || window.tronWeb))) {
|
|
988
942
|
this._readyState = tronwallet_abstract_adapter_1.WalletReadyState.Found;
|
|
989
943
|
this._updateWallet();
|
|
@@ -1099,7 +1053,6 @@
|
|
|
1099
1053
|
const address = ((_a = wallet.tronWeb.defaultAddress) === null || _a === void 0 ? void 0 : _a.base58) || '';
|
|
1100
1054
|
this.setAddress(address);
|
|
1101
1055
|
this.setState(tronwallet_abstract_adapter_1.AdapterState.Connected);
|
|
1102
|
-
this._listenTronLinkEvent();
|
|
1103
1056
|
}
|
|
1104
1057
|
else if (window.tronWeb) {
|
|
1105
1058
|
const wallet = this._wallet;
|
|
@@ -1126,9 +1079,6 @@
|
|
|
1126
1079
|
if (this._supportNewTronProtocol) {
|
|
1127
1080
|
this._stopListenTronEvent();
|
|
1128
1081
|
}
|
|
1129
|
-
else {
|
|
1130
|
-
this._stopListenTronLinkEvent();
|
|
1131
|
-
}
|
|
1132
1082
|
if (this.state !== tronwallet_abstract_adapter_1.AdapterState.Connected) {
|
|
1133
1083
|
return;
|
|
1134
1084
|
}
|
|
@@ -1137,19 +1087,22 @@
|
|
|
1137
1087
|
this.emit('disconnect');
|
|
1138
1088
|
});
|
|
1139
1089
|
}
|
|
1140
|
-
|
|
1090
|
+
_checkAndSign(action, ErrorConstructor) {
|
|
1141
1091
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1142
1092
|
try {
|
|
1143
1093
|
const wallet = yield this.checkAndGetWallet();
|
|
1144
1094
|
try {
|
|
1145
|
-
return yield wallet
|
|
1095
|
+
return yield action(wallet);
|
|
1146
1096
|
}
|
|
1147
1097
|
catch (error) {
|
|
1148
|
-
if (error instanceof Error) {
|
|
1149
|
-
throw new
|
|
1098
|
+
if (error instanceof Error || (typeof error === 'object' && error.message)) {
|
|
1099
|
+
throw new ErrorConstructor(error.message, error);
|
|
1100
|
+
}
|
|
1101
|
+
else if (typeof error === 'string') {
|
|
1102
|
+
throw new ErrorConstructor(error, new Error(error));
|
|
1150
1103
|
}
|
|
1151
1104
|
else {
|
|
1152
|
-
throw new
|
|
1105
|
+
throw new ErrorConstructor('Unknown error', error);
|
|
1153
1106
|
}
|
|
1154
1107
|
}
|
|
1155
1108
|
}
|
|
@@ -1159,48 +1112,27 @@
|
|
|
1159
1112
|
}
|
|
1160
1113
|
});
|
|
1161
1114
|
}
|
|
1162
|
-
|
|
1115
|
+
signTransaction(transaction) {
|
|
1163
1116
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
catch (error) {
|
|
1179
|
-
this.emit('error', error);
|
|
1180
|
-
throw error;
|
|
1181
|
-
}
|
|
1117
|
+
return this._checkAndSign((wallet) => wallet.tronWeb.trx.sign(transaction), tronwallet_abstract_adapter_1.WalletSignTransactionError);
|
|
1118
|
+
});
|
|
1119
|
+
}
|
|
1120
|
+
/**
|
|
1121
|
+
*
|
|
1122
|
+
* @param transaction transaction to be signed
|
|
1123
|
+
* @param _, false to use tronWeb.trx.multiSign
|
|
1124
|
+
* @param permissionId permissionId for multiSign
|
|
1125
|
+
* @returns
|
|
1126
|
+
*/
|
|
1127
|
+
multiSign(transaction_1) {
|
|
1128
|
+
return __awaiter(this, arguments, void 0, function* (transaction, options = {}) {
|
|
1129
|
+
// multiSign is a transaction signing operation, so it uses WalletSignTransactionError
|
|
1130
|
+
return this._checkAndSign((wallet) => wallet.tronWeb.trx.multiSign(transaction, undefined, options.permissionId), tronwallet_abstract_adapter_1.WalletSignTransactionError);
|
|
1182
1131
|
});
|
|
1183
1132
|
}
|
|
1184
|
-
signMessage(message
|
|
1133
|
+
signMessage(message) {
|
|
1185
1134
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1186
|
-
|
|
1187
|
-
const wallet = yield this.checkAndGetWallet();
|
|
1188
|
-
try {
|
|
1189
|
-
return yield wallet.tronWeb.trx.signMessageV2(message, privateKey);
|
|
1190
|
-
}
|
|
1191
|
-
catch (error) {
|
|
1192
|
-
if (error instanceof Error) {
|
|
1193
|
-
throw new tronwallet_abstract_adapter_1.WalletSignMessageError(error.message, error);
|
|
1194
|
-
}
|
|
1195
|
-
else {
|
|
1196
|
-
throw new tronwallet_abstract_adapter_1.WalletSignMessageError(error, new Error(error));
|
|
1197
|
-
}
|
|
1198
|
-
}
|
|
1199
|
-
}
|
|
1200
|
-
catch (error) {
|
|
1201
|
-
this.emit('error', error);
|
|
1202
|
-
throw error;
|
|
1203
|
-
}
|
|
1135
|
+
return this._checkAndSign((wallet) => __awaiter(this, void 0, void 0, function* () { return wallet.tronWeb.trx.signMessageV2(message); }), tronwallet_abstract_adapter_1.WalletSignMessageError);
|
|
1204
1136
|
});
|
|
1205
1137
|
}
|
|
1206
1138
|
/**
|
|
@@ -1253,16 +1185,9 @@
|
|
|
1253
1185
|
return wallet;
|
|
1254
1186
|
});
|
|
1255
1187
|
}
|
|
1256
|
-
_listenTronLinkEvent() {
|
|
1257
|
-
this._stopListenTronLinkEvent();
|
|
1258
|
-
window.addEventListener('message', this._tronLinkMessageHandler);
|
|
1259
|
-
}
|
|
1260
|
-
_stopListenTronLinkEvent() {
|
|
1261
|
-
window.removeEventListener('message', this._tronLinkMessageHandler);
|
|
1262
|
-
}
|
|
1263
1188
|
checkIfOpenTronLink() {
|
|
1264
1189
|
const { dappName = '', dappIcon = '' } = this.config;
|
|
1265
|
-
if (this.config.openTronLinkAppOnMobile === false) {
|
|
1190
|
+
if (this.config.openTronLinkAppOnMobile === false || this.config.openAppWithDeeplink === false) {
|
|
1266
1191
|
return;
|
|
1267
1192
|
}
|
|
1268
1193
|
if ((0, utils_js_1.openTronLink)({ dappIcon, dappName })) {
|
|
@@ -1271,16 +1196,17 @@
|
|
|
1271
1196
|
}
|
|
1272
1197
|
// following code is for TIP-1193
|
|
1273
1198
|
_listenTronEvent() {
|
|
1199
|
+
var _a, _b;
|
|
1274
1200
|
this._stopListenTronEvent();
|
|
1275
|
-
this._stopListenTronLinkEvent();
|
|
1276
1201
|
const wallet = this._wallet;
|
|
1277
|
-
wallet.on('chainChanged', this._onChainChanged);
|
|
1278
|
-
wallet.on('accountsChanged', this._onAccountsChanged);
|
|
1202
|
+
(_a = wallet.on) === null || _a === void 0 ? void 0 : _a.call(wallet, 'chainChanged', this._onChainChanged);
|
|
1203
|
+
(_b = wallet.on) === null || _b === void 0 ? void 0 : _b.call(wallet, 'accountsChanged', this._onAccountsChanged);
|
|
1279
1204
|
}
|
|
1280
1205
|
_stopListenTronEvent() {
|
|
1206
|
+
var _a, _b;
|
|
1281
1207
|
const wallet = this._wallet;
|
|
1282
|
-
wallet.removeListener('chainChanged', this._onChainChanged);
|
|
1283
|
-
wallet.removeListener('accountsChanged', this._onAccountsChanged);
|
|
1208
|
+
(_a = wallet.removeListener) === null || _a === void 0 ? void 0 : _a.call(wallet, 'chainChanged', this._onChainChanged);
|
|
1209
|
+
(_b = wallet.removeListener) === null || _b === void 0 ? void 0 : _b.call(wallet, 'accountsChanged', this._onAccountsChanged);
|
|
1284
1210
|
}
|
|
1285
1211
|
/**
|
|
1286
1212
|
* check if wallet exists by interval, the promise only resolve when wallet detected or timeout
|
|
@@ -1349,7 +1275,7 @@
|
|
|
1349
1275
|
}
|
|
1350
1276
|
}
|
|
1351
1277
|
}
|
|
1352
|
-
exports.TronLinkAdapter = TronLinkAdapter;
|
|
1278
|
+
exports$1.TronLinkAdapter = TronLinkAdapter;
|
|
1353
1279
|
|
|
1354
1280
|
} (adapter));
|
|
1355
1281
|
return adapter;
|
|
@@ -1372,7 +1298,7 @@
|
|
|
1372
1298
|
function requireCjs$1 () {
|
|
1373
1299
|
if (hasRequiredCjs$1) return cjs;
|
|
1374
1300
|
hasRequiredCjs$1 = 1;
|
|
1375
|
-
(function (exports) {
|
|
1301
|
+
(function (exports$1) {
|
|
1376
1302
|
var __createBinding = (cjs && cjs.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
1377
1303
|
if (k2 === undefined) k2 = k;
|
|
1378
1304
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -1384,13 +1310,13 @@
|
|
|
1384
1310
|
if (k2 === undefined) k2 = k;
|
|
1385
1311
|
o[k2] = m[k];
|
|
1386
1312
|
}));
|
|
1387
|
-
var __exportStar = (cjs && cjs.__exportStar) || function(m, exports) {
|
|
1388
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
1313
|
+
var __exportStar = (cjs && cjs.__exportStar) || function(m, exports$1) {
|
|
1314
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$1, p)) __createBinding(exports$1, m, p);
|
|
1389
1315
|
};
|
|
1390
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1391
|
-
__exportStar(
|
|
1392
|
-
__exportStar(
|
|
1393
|
-
__exportStar(
|
|
1316
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
1317
|
+
__exportStar(requireAdapter$1(), exports$1);
|
|
1318
|
+
__exportStar(requireTypes(), exports$1);
|
|
1319
|
+
__exportStar(requireUtils$1(), exports$1);
|
|
1394
1320
|
|
|
1395
1321
|
} (cjs));
|
|
1396
1322
|
return cjs;
|
|
@@ -1403,11 +1329,11 @@
|
|
|
1403
1329
|
function requireUtils () {
|
|
1404
1330
|
if (hasRequiredUtils) return utils;
|
|
1405
1331
|
hasRequiredUtils = 1;
|
|
1406
|
-
(function (exports) {
|
|
1407
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1408
|
-
exports.isTrustApp = void 0;
|
|
1409
|
-
exports.supportTrust = supportTrust;
|
|
1410
|
-
exports.openTrustWallet = openTrustWallet;
|
|
1332
|
+
(function (exports$1) {
|
|
1333
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
1334
|
+
exports$1.isTrustApp = void 0;
|
|
1335
|
+
exports$1.supportTrust = supportTrust;
|
|
1336
|
+
exports$1.openTrustWallet = openTrustWallet;
|
|
1411
1337
|
const tronwallet_abstract_adapter_1 = /*@__PURE__*/ requireCjs$2();
|
|
1412
1338
|
function supportTrust() {
|
|
1413
1339
|
return typeof window !== 'undefined' && !!(window.trustwallet && window.trustwallet.tronLink);
|
|
@@ -1418,9 +1344,9 @@
|
|
|
1418
1344
|
}
|
|
1419
1345
|
return false;
|
|
1420
1346
|
};
|
|
1421
|
-
exports.isTrustApp = isTrustApp;
|
|
1347
|
+
exports$1.isTrustApp = isTrustApp;
|
|
1422
1348
|
function openTrustWallet() {
|
|
1423
|
-
if (!(0, exports.isTrustApp)() && (0, tronwallet_abstract_adapter_1.isInMobileBrowser)()) {
|
|
1349
|
+
if (!(0, exports$1.isTrustApp)() && (0, tronwallet_abstract_adapter_1.isInMobileBrowser)()) {
|
|
1424
1350
|
window.location.href = 'https://link.trustwallet.com/open_url?url=' + encodeURIComponent(window.location.href);
|
|
1425
1351
|
return true;
|
|
1426
1352
|
}
|
|
@@ -1436,7 +1362,7 @@
|
|
|
1436
1362
|
function requireAdapter () {
|
|
1437
1363
|
if (hasRequiredAdapter) return adapter$2;
|
|
1438
1364
|
hasRequiredAdapter = 1;
|
|
1439
|
-
(function (exports) {
|
|
1365
|
+
(function (exports$1) {
|
|
1440
1366
|
var __awaiter = (adapter$2 && adapter$2.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
1441
1367
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
1442
1368
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -1446,16 +1372,16 @@
|
|
|
1446
1372
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1447
1373
|
});
|
|
1448
1374
|
};
|
|
1449
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1450
|
-
exports.TrustAdapter = exports.TrustAdapterName = void 0;
|
|
1375
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
1376
|
+
exports$1.TrustAdapter = exports$1.TrustAdapterName = void 0;
|
|
1451
1377
|
const tronwallet_abstract_adapter_1 = /*@__PURE__*/ requireCjs$2();
|
|
1452
1378
|
const tronwallet_adapter_tronlink_1 = /*@__PURE__*/ requireCjs$1();
|
|
1453
|
-
const utils_js_1 =
|
|
1454
|
-
exports.TrustAdapterName = 'Trust';
|
|
1379
|
+
const utils_js_1 = requireUtils();
|
|
1380
|
+
exports$1.TrustAdapterName = 'Trust';
|
|
1455
1381
|
class TrustAdapter extends tronwallet_abstract_adapter_1.Adapter {
|
|
1456
1382
|
constructor(config = {}) {
|
|
1457
1383
|
super();
|
|
1458
|
-
this.name = exports.TrustAdapterName;
|
|
1384
|
+
this.name = exports$1.TrustAdapterName;
|
|
1459
1385
|
this.url = 'https://trustwallet.com';
|
|
1460
1386
|
this.icon = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTgiIGhlaWdodD0iNjUiIHZpZXdCb3g9IjAgMCA1OCA2NSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTAgOS4zODk0OUwyOC44OTA3IDBWNjUuMDA0MkM4LjI1NDUgNTYuMzM2OSAwIDM5LjcyNDggMCAzMC4zMzUzVjkuMzg5NDlaIiBmaWxsPSIjMDUwMEZGIi8+CjxwYXRoIGQ9Ik01Ny43ODIyIDkuMzg5NDlMMjguODkxNSAwVjY1LjAwNDJDNDkuNTI3NyA1Ni4zMzY5IDU3Ljc4MjIgMzkuNzI0OCA1Ny43ODIyIDMwLjMzNTNWOS4zODk0OVoiIGZpbGw9InVybCgjcGFpbnQwX2xpbmVhcl8yMjAxXzY5NDIpIi8+CjxkZWZzPgo8bGluZWFyR3JhZGllbnQgaWQ9InBhaW50MF9saW5lYXJfMjIwMV82OTQyIiB4MT0iNTEuMzYxNSIgeTE9Ii00LjE1MjkzIiB4Mj0iMjkuNTM4NCIgeTI9IjY0LjUxNDciIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIj4KPHN0b3Agb2Zmc2V0PSIwLjAyMTEyIiBzdG9wLWNvbG9yPSIjMDAwMEZGIi8+CjxzdG9wIG9mZnNldD0iMC4wNzYyNDIzIiBzdG9wLWNvbG9yPSIjMDA5NEZGIi8+CjxzdG9wIG9mZnNldD0iMC4xNjMwODkiIHN0b3AtY29sb3I9IiM0OEZGOTEiLz4KPHN0b3Agb2Zmc2V0PSIwLjQyMDA0OSIgc3RvcC1jb2xvcj0iIzAwOTRGRiIvPgo8c3RvcCBvZmZzZXQ9IjAuNjgyODg2IiBzdG9wLWNvbG9yPSIjMDAzOEZGIi8+CjxzdG9wIG9mZnNldD0iMC45MDI0NjUiIHN0b3AtY29sb3I9IiMwNTAwRkYiLz4KPC9saW5lYXJHcmFkaWVudD4KPC9kZWZzPgo8L3N2Zz4K';
|
|
1461
1387
|
this._readyState = (0, tronwallet_abstract_adapter_1.isInBrowser)() ? tronwallet_abstract_adapter_1.WalletReadyState.Loading : tronwallet_abstract_adapter_1.WalletReadyState.NotFound;
|
|
@@ -1516,7 +1442,6 @@
|
|
|
1516
1442
|
let state = this.state;
|
|
1517
1443
|
let address = this.address;
|
|
1518
1444
|
if ((0, utils_js_1.supportTrust)()) {
|
|
1519
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
1520
1445
|
this._wallet = window.trustwallet.tronLink;
|
|
1521
1446
|
this._listenEvent();
|
|
1522
1447
|
address = ((_b = (_a = this._wallet.tronWeb) === null || _a === void 0 ? void 0 : _a.defaultAddress) === null || _b === void 0 ? void 0 : _b.base58) || null;
|
|
@@ -1656,20 +1581,23 @@
|
|
|
1656
1581
|
this.emit('disconnect');
|
|
1657
1582
|
});
|
|
1658
1583
|
}
|
|
1659
|
-
signTransaction(transaction
|
|
1584
|
+
signTransaction(transaction) {
|
|
1660
1585
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1661
1586
|
try {
|
|
1662
1587
|
const wallet = yield this.checkAndGetWallet();
|
|
1663
1588
|
try {
|
|
1664
|
-
return yield wallet.tronWeb.trx.sign(transaction
|
|
1589
|
+
return yield wallet.tronWeb.trx.sign(transaction);
|
|
1665
1590
|
}
|
|
1666
1591
|
catch (error) {
|
|
1667
|
-
if (error instanceof Error) {
|
|
1592
|
+
if (error instanceof Error || (typeof error === 'object' && error.message)) {
|
|
1668
1593
|
throw new tronwallet_abstract_adapter_1.WalletSignTransactionError(error.message, error);
|
|
1669
1594
|
}
|
|
1670
|
-
else {
|
|
1595
|
+
else if (typeof error === 'string') {
|
|
1671
1596
|
throw new tronwallet_abstract_adapter_1.WalletSignTransactionError(error, new Error(error));
|
|
1672
1597
|
}
|
|
1598
|
+
else {
|
|
1599
|
+
throw new tronwallet_abstract_adapter_1.WalletSignTransactionError('Unknown error', error);
|
|
1600
|
+
}
|
|
1673
1601
|
}
|
|
1674
1602
|
}
|
|
1675
1603
|
catch (error) {
|
|
@@ -1678,20 +1606,23 @@
|
|
|
1678
1606
|
}
|
|
1679
1607
|
});
|
|
1680
1608
|
}
|
|
1681
|
-
multiSign(
|
|
1682
|
-
return __awaiter(this,
|
|
1609
|
+
multiSign(transaction_1) {
|
|
1610
|
+
return __awaiter(this, arguments, void 0, function* (transaction, options = {}) {
|
|
1683
1611
|
try {
|
|
1684
1612
|
const wallet = yield this.checkAndGetWallet();
|
|
1685
1613
|
try {
|
|
1686
|
-
return yield wallet.tronWeb.trx.multiSign(transaction,
|
|
1614
|
+
return yield wallet.tronWeb.trx.multiSign(transaction, undefined, options.permissionId);
|
|
1687
1615
|
}
|
|
1688
1616
|
catch (error) {
|
|
1689
|
-
if (error instanceof Error) {
|
|
1617
|
+
if (error instanceof Error || (typeof error === 'object' && error.message)) {
|
|
1690
1618
|
throw new tronwallet_abstract_adapter_1.WalletSignTransactionError(error.message, error);
|
|
1691
1619
|
}
|
|
1692
|
-
else {
|
|
1620
|
+
else if (typeof error === 'string') {
|
|
1693
1621
|
throw new tronwallet_abstract_adapter_1.WalletSignTransactionError(error, new Error(error));
|
|
1694
1622
|
}
|
|
1623
|
+
else {
|
|
1624
|
+
throw new tronwallet_abstract_adapter_1.WalletSignTransactionError('Unknown error', error);
|
|
1625
|
+
}
|
|
1695
1626
|
}
|
|
1696
1627
|
}
|
|
1697
1628
|
catch (error) {
|
|
@@ -1700,20 +1631,23 @@
|
|
|
1700
1631
|
}
|
|
1701
1632
|
});
|
|
1702
1633
|
}
|
|
1703
|
-
signMessage(message
|
|
1634
|
+
signMessage(message) {
|
|
1704
1635
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1705
1636
|
try {
|
|
1706
1637
|
const wallet = yield this.checkAndGetWallet();
|
|
1707
1638
|
try {
|
|
1708
|
-
return yield wallet.tronWeb.trx.signMessageV2(message
|
|
1639
|
+
return yield wallet.tronWeb.trx.signMessageV2(message);
|
|
1709
1640
|
}
|
|
1710
1641
|
catch (error) {
|
|
1711
|
-
if (error instanceof Error) {
|
|
1642
|
+
if (error instanceof Error || (typeof error === 'object' && error.message)) {
|
|
1712
1643
|
throw new tronwallet_abstract_adapter_1.WalletSignMessageError(error.message, error);
|
|
1713
1644
|
}
|
|
1714
|
-
else {
|
|
1645
|
+
else if (typeof error === 'string') {
|
|
1715
1646
|
throw new tronwallet_abstract_adapter_1.WalletSignMessageError(error, new Error(error));
|
|
1716
1647
|
}
|
|
1648
|
+
else {
|
|
1649
|
+
throw new tronwallet_abstract_adapter_1.WalletSignMessageError('Unknown error', error);
|
|
1650
|
+
}
|
|
1717
1651
|
}
|
|
1718
1652
|
}
|
|
1719
1653
|
catch (error) {
|
|
@@ -1791,7 +1725,7 @@
|
|
|
1791
1725
|
}
|
|
1792
1726
|
}
|
|
1793
1727
|
}
|
|
1794
|
-
exports.TrustAdapter = TrustAdapter;
|
|
1728
|
+
exports$1.TrustAdapter = TrustAdapter;
|
|
1795
1729
|
|
|
1796
1730
|
} (adapter$2));
|
|
1797
1731
|
return adapter$2;
|
|
@@ -1802,7 +1736,7 @@
|
|
|
1802
1736
|
function requireCjs () {
|
|
1803
1737
|
if (hasRequiredCjs) return cjs$2;
|
|
1804
1738
|
hasRequiredCjs = 1;
|
|
1805
|
-
(function (exports) {
|
|
1739
|
+
(function (exports$1) {
|
|
1806
1740
|
var __createBinding = (cjs$2 && cjs$2.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
1807
1741
|
if (k2 === undefined) k2 = k;
|
|
1808
1742
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -1814,12 +1748,12 @@
|
|
|
1814
1748
|
if (k2 === undefined) k2 = k;
|
|
1815
1749
|
o[k2] = m[k];
|
|
1816
1750
|
}));
|
|
1817
|
-
var __exportStar = (cjs$2 && cjs$2.__exportStar) || function(m, exports) {
|
|
1818
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
1751
|
+
var __exportStar = (cjs$2 && cjs$2.__exportStar) || function(m, exports$1) {
|
|
1752
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$1, p)) __createBinding(exports$1, m, p);
|
|
1819
1753
|
};
|
|
1820
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1821
|
-
__exportStar(
|
|
1822
|
-
__exportStar(
|
|
1754
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
1755
|
+
__exportStar(requireAdapter(), exports$1);
|
|
1756
|
+
__exportStar(requireUtils(), exports$1);
|
|
1823
1757
|
|
|
1824
1758
|
} (cjs$2));
|
|
1825
1759
|
return cjs$2;
|