@tronweb3/tronwallet-adapter-tokenpocket 1.0.8 → 1.1.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/README.md +20 -1
- package/lib/cjs/adapter.js +71 -51
- package/lib/cjs/adapter.js.map +1 -1
- package/lib/cjs/tsconfig.cjs.tsbuildinfo +1 -0
- package/lib/esm/adapter.js +72 -52
- package/lib/esm/adapter.js.map +1 -1
- package/lib/esm/tsconfig.esm.tsbuildinfo +1 -0
- package/lib/types/adapter.d.ts +16 -18
- package/lib/types/adapter.d.ts.map +1 -1
- package/lib/umd/index.js +746 -349
- package/lib/umd/index.min.js +1 -1
- package/package.json +9 -9
- package/src/adapter.ts +70 -63
package/lib/umd/index.js
CHANGED
|
@@ -363,82 +363,7 @@
|
|
|
363
363
|
return eventemitter3.exports;
|
|
364
364
|
}
|
|
365
365
|
|
|
366
|
-
var
|
|
367
|
-
|
|
368
|
-
function requireAdapter$2 () {
|
|
369
|
-
if (hasRequiredAdapter$2) return adapter$1;
|
|
370
|
-
hasRequiredAdapter$2 = 1;
|
|
371
|
-
var __importDefault = (adapter$1 && adapter$1.__importDefault) || function (mod) {
|
|
372
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
373
|
-
};
|
|
374
|
-
Object.defineProperty(adapter$1, "__esModule", { value: true });
|
|
375
|
-
adapter$1.Adapter = adapter$1.AdapterState = adapter$1.WalletReadyState = adapter$1.EventEmitter = void 0;
|
|
376
|
-
const eventemitter3_1 = __importDefault(requireEventemitter3());
|
|
377
|
-
adapter$1.EventEmitter = eventemitter3_1.default;
|
|
378
|
-
/**
|
|
379
|
-
* Wallet ready state.
|
|
380
|
-
*/
|
|
381
|
-
var WalletReadyState;
|
|
382
|
-
(function (WalletReadyState) {
|
|
383
|
-
/**
|
|
384
|
-
* Adapter will start to check if wallet exists after adapter instance is created.
|
|
385
|
-
*/
|
|
386
|
-
WalletReadyState["Loading"] = "Loading";
|
|
387
|
-
/**
|
|
388
|
-
* When checking ends and wallet is not found, readyState will be NotFound.
|
|
389
|
-
*/
|
|
390
|
-
WalletReadyState["NotFound"] = "NotFound";
|
|
391
|
-
/**
|
|
392
|
-
* When checking ends and wallet is found, readyState will be Found.
|
|
393
|
-
*/
|
|
394
|
-
WalletReadyState["Found"] = "Found";
|
|
395
|
-
})(WalletReadyState || (adapter$1.WalletReadyState = WalletReadyState = {}));
|
|
396
|
-
/**
|
|
397
|
-
* Adapter state
|
|
398
|
-
*/
|
|
399
|
-
var AdapterState;
|
|
400
|
-
(function (AdapterState) {
|
|
401
|
-
/**
|
|
402
|
-
* If adapter is checking the wallet, the state is Loading.
|
|
403
|
-
*/
|
|
404
|
-
AdapterState["Loading"] = "Loading";
|
|
405
|
-
/**
|
|
406
|
-
* If wallet is not installed, the state is NotFound.
|
|
407
|
-
*/
|
|
408
|
-
AdapterState["NotFound"] = "NotFound";
|
|
409
|
-
/**
|
|
410
|
-
* If wallet is installed but is not connected to current Dapp, the state is Disconnected.
|
|
411
|
-
*/
|
|
412
|
-
AdapterState["Disconnect"] = "Disconnected";
|
|
413
|
-
/**
|
|
414
|
-
* Wallet is connected to current Dapp.
|
|
415
|
-
*/
|
|
416
|
-
AdapterState["Connected"] = "Connected";
|
|
417
|
-
})(AdapterState || (adapter$1.AdapterState = AdapterState = {}));
|
|
418
|
-
class Adapter extends eventemitter3_1.default {
|
|
419
|
-
get connected() {
|
|
420
|
-
return this.state === AdapterState.Connected;
|
|
421
|
-
}
|
|
422
|
-
/**
|
|
423
|
-
* Some wallets such as TronLink don't support disconnect() method.
|
|
424
|
-
*/
|
|
425
|
-
disconnect() {
|
|
426
|
-
console.info("The current adapter doesn't support disconnect by DApp.");
|
|
427
|
-
return Promise.resolve();
|
|
428
|
-
}
|
|
429
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
430
|
-
multiSign(...args) {
|
|
431
|
-
return Promise.reject("The current wallet doesn't support multiSign.");
|
|
432
|
-
}
|
|
433
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
434
|
-
switchChain(_chainId) {
|
|
435
|
-
return Promise.reject("The current wallet doesn't support switch chain.");
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
adapter$1.Adapter = Adapter;
|
|
439
|
-
|
|
440
|
-
return adapter$1;
|
|
441
|
-
}
|
|
366
|
+
var typedData = {};
|
|
442
367
|
|
|
443
368
|
var errors = {};
|
|
444
369
|
|
|
@@ -448,7 +373,7 @@
|
|
|
448
373
|
if (hasRequiredErrors) return errors;
|
|
449
374
|
hasRequiredErrors = 1;
|
|
450
375
|
Object.defineProperty(errors, "__esModule", { value: true });
|
|
451
|
-
errors.WalletGetNetworkError = errors.WalletSwitchChainError = errors.WalletWindowClosedError = errors.WalletWalletLoadError = errors.WalletSignTransactionError = errors.WalletSignMessageError = errors.WalletDisconnectionError = errors.WalletConnectionError = errors.WalletDisconnectedError = errors.WalletNotSelectedError = errors.WalletNotFoundError = errors.WalletError = void 0;
|
|
376
|
+
errors.WalletSignTypedDataError = errors.WalletGetNetworkError = errors.WalletSwitchChainError = errors.WalletWindowClosedError = errors.WalletWalletLoadError = errors.WalletSignTransactionError = errors.WalletSignMessageError = errors.WalletDisconnectionError = errors.WalletConnectionError = errors.WalletDisconnectedError = errors.WalletNotSelectedError = errors.WalletNotFoundError = errors.WalletError = void 0;
|
|
452
377
|
class WalletError extends Error {
|
|
453
378
|
constructor(message, error) {
|
|
454
379
|
super(message);
|
|
@@ -460,10 +385,9 @@
|
|
|
460
385
|
* Occurs when wallet is not installed.
|
|
461
386
|
*/
|
|
462
387
|
class WalletNotFoundError extends WalletError {
|
|
463
|
-
constructor() {
|
|
464
|
-
super(
|
|
388
|
+
constructor(message, error) {
|
|
389
|
+
super(message || 'The wallet is not found.', error);
|
|
465
390
|
this.name = 'WalletNotFoundError';
|
|
466
|
-
this.message = 'The wallet is not found.';
|
|
467
391
|
}
|
|
468
392
|
}
|
|
469
393
|
errors.WalletNotFoundError = WalletNotFoundError;
|
|
@@ -544,10 +468,9 @@
|
|
|
544
468
|
* Occurs when walletconnect QR window is closed.
|
|
545
469
|
*/
|
|
546
470
|
class WalletWindowClosedError extends WalletError {
|
|
547
|
-
constructor() {
|
|
548
|
-
super(
|
|
471
|
+
constructor(message, error) {
|
|
472
|
+
super(message || 'The QR window is closed.', error);
|
|
549
473
|
this.name = 'WalletWindowClosedError';
|
|
550
|
-
this.message = 'The QR window is closed.';
|
|
551
474
|
}
|
|
552
475
|
}
|
|
553
476
|
errors.WalletWindowClosedError = WalletWindowClosedError;
|
|
@@ -571,10 +494,66 @@
|
|
|
571
494
|
}
|
|
572
495
|
}
|
|
573
496
|
errors.WalletGetNetworkError = WalletGetNetworkError;
|
|
497
|
+
/**
|
|
498
|
+
* Occurs when call `signTypedData()`.
|
|
499
|
+
*/
|
|
500
|
+
class WalletSignTypedDataError extends WalletError {
|
|
501
|
+
constructor() {
|
|
502
|
+
super(...arguments);
|
|
503
|
+
this.name = 'WalletSignTypedDataError';
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
errors.WalletSignTypedDataError = WalletSignTypedDataError;
|
|
574
507
|
|
|
575
508
|
return errors;
|
|
576
509
|
}
|
|
577
510
|
|
|
511
|
+
var hasRequiredTypedData;
|
|
512
|
+
|
|
513
|
+
function requireTypedData () {
|
|
514
|
+
if (hasRequiredTypedData) return typedData;
|
|
515
|
+
hasRequiredTypedData = 1;
|
|
516
|
+
Object.defineProperty(typedData, "__esModule", { value: true });
|
|
517
|
+
typedData.normalizeAndValidateTypedData = normalizeAndValidateTypedData;
|
|
518
|
+
const errors_js_1 = requireErrors();
|
|
519
|
+
function isPlainObject(value) {
|
|
520
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* Validate a TypedData payload and return a normalized copy safe to pass to wallets.
|
|
524
|
+
*
|
|
525
|
+
* Current normalization: convert `domain.chainId` from string to number (some wallets,
|
|
526
|
+
* e.g. TronLink, require a numeric chainId).
|
|
527
|
+
*
|
|
528
|
+
* Throws {@link WalletSignTypedDataError} if the payload is not a valid TypedData object.
|
|
529
|
+
*/
|
|
530
|
+
function normalizeAndValidateTypedData(typedData) {
|
|
531
|
+
if (!isPlainObject(typedData)) {
|
|
532
|
+
throw new errors_js_1.WalletSignTypedDataError('typedData must be an object.');
|
|
533
|
+
}
|
|
534
|
+
if (!isPlainObject(typedData.domain)) {
|
|
535
|
+
throw new errors_js_1.WalletSignTypedDataError('typedData.domain must be an object.');
|
|
536
|
+
}
|
|
537
|
+
if (!isPlainObject(typedData.types)) {
|
|
538
|
+
throw new errors_js_1.WalletSignTypedDataError('typedData.types must be an object.');
|
|
539
|
+
}
|
|
540
|
+
if (!isPlainObject(typedData.message)) {
|
|
541
|
+
throw new errors_js_1.WalletSignTypedDataError('typedData.message must be an object.');
|
|
542
|
+
}
|
|
543
|
+
const { chainId } = typedData.domain;
|
|
544
|
+
if (typeof chainId === 'string') {
|
|
545
|
+
const parsed = Number(chainId);
|
|
546
|
+
if (!Number.isFinite(parsed)) {
|
|
547
|
+
throw new errors_js_1.WalletSignTypedDataError(`Invalid domain.chainId: ${chainId}.`);
|
|
548
|
+
}
|
|
549
|
+
return Object.assign(Object.assign({}, typedData), { domain: Object.assign(Object.assign({}, typedData.domain), { chainId: parsed }) });
|
|
550
|
+
}
|
|
551
|
+
return typedData;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
return typedData;
|
|
555
|
+
}
|
|
556
|
+
|
|
578
557
|
var types$1 = {};
|
|
579
558
|
|
|
580
559
|
var hasRequiredTypes$1;
|
|
@@ -583,7 +562,47 @@
|
|
|
583
562
|
if (hasRequiredTypes$1) return types$1;
|
|
584
563
|
hasRequiredTypes$1 = 1;
|
|
585
564
|
Object.defineProperty(types$1, "__esModule", { value: true });
|
|
586
|
-
types$1.TIP6963RequestProviderEventName = types$1.TIP6963AnnounceProviderEventName = types$1.ChainNetwork = types$1.NetworkType = void 0;
|
|
565
|
+
types$1.TIP6963RequestProviderEventName = types$1.TIP6963AnnounceProviderEventName = types$1.ChainNetwork = types$1.NetworkType = types$1.AdapterState = types$1.WalletReadyState = void 0;
|
|
566
|
+
/**
|
|
567
|
+
* Wallet ready state.
|
|
568
|
+
*/
|
|
569
|
+
var WalletReadyState;
|
|
570
|
+
(function (WalletReadyState) {
|
|
571
|
+
/**
|
|
572
|
+
* Adapter will start to check if wallet exists after adapter instance is created.
|
|
573
|
+
*/
|
|
574
|
+
WalletReadyState["Loading"] = "Loading";
|
|
575
|
+
/**
|
|
576
|
+
* When checking ends and wallet is not found, readyState will be NotFound.
|
|
577
|
+
*/
|
|
578
|
+
WalletReadyState["NotFound"] = "NotFound";
|
|
579
|
+
/**
|
|
580
|
+
* When checking ends and wallet is found, readyState will be Found.
|
|
581
|
+
*/
|
|
582
|
+
WalletReadyState["Found"] = "Found";
|
|
583
|
+
})(WalletReadyState || (types$1.WalletReadyState = WalletReadyState = {}));
|
|
584
|
+
/**
|
|
585
|
+
* Adapter state
|
|
586
|
+
*/
|
|
587
|
+
var AdapterState;
|
|
588
|
+
(function (AdapterState) {
|
|
589
|
+
/**
|
|
590
|
+
* If adapter is checking the wallet, the state is Loading.
|
|
591
|
+
*/
|
|
592
|
+
AdapterState["Loading"] = "Loading";
|
|
593
|
+
/**
|
|
594
|
+
* If wallet is not installed, the state is NotFound.
|
|
595
|
+
*/
|
|
596
|
+
AdapterState["NotFound"] = "NotFound";
|
|
597
|
+
/**
|
|
598
|
+
* If wallet is installed but is not connected to current Dapp, the state is Disconnected.
|
|
599
|
+
*/
|
|
600
|
+
AdapterState["Disconnect"] = "Disconnected";
|
|
601
|
+
/**
|
|
602
|
+
* Wallet is connected to current Dapp.
|
|
603
|
+
*/
|
|
604
|
+
AdapterState["Connected"] = "Connected";
|
|
605
|
+
})(AdapterState || (types$1.AdapterState = AdapterState = {}));
|
|
587
606
|
var NetworkType;
|
|
588
607
|
(function (NetworkType) {
|
|
589
608
|
NetworkType["Mainnet"] = "Mainnet";
|
|
@@ -606,6 +625,59 @@
|
|
|
606
625
|
return types$1;
|
|
607
626
|
}
|
|
608
627
|
|
|
628
|
+
var hasRequiredAdapter$2;
|
|
629
|
+
|
|
630
|
+
function requireAdapter$2 () {
|
|
631
|
+
if (hasRequiredAdapter$2) return adapter$1;
|
|
632
|
+
hasRequiredAdapter$2 = 1;
|
|
633
|
+
var __importDefault = (adapter$1 && adapter$1.__importDefault) || function (mod) {
|
|
634
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
635
|
+
};
|
|
636
|
+
Object.defineProperty(adapter$1, "__esModule", { value: true });
|
|
637
|
+
adapter$1.Adapter = adapter$1.EventEmitter = void 0;
|
|
638
|
+
const eventemitter3_1 = __importDefault(requireEventemitter3());
|
|
639
|
+
adapter$1.EventEmitter = eventemitter3_1.default;
|
|
640
|
+
const typedData_js_1 = requireTypedData();
|
|
641
|
+
const types_js_1 = requireTypes$1();
|
|
642
|
+
class Adapter extends eventemitter3_1.default {
|
|
643
|
+
get connected() {
|
|
644
|
+
return this.state === types_js_1.AdapterState.Connected;
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* Some wallets such as TronLink don't support disconnect() method.
|
|
648
|
+
*/
|
|
649
|
+
disconnect() {
|
|
650
|
+
console.info("The current adapter doesn't support disconnect by DApp.");
|
|
651
|
+
return Promise.resolve();
|
|
652
|
+
}
|
|
653
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
654
|
+
multiSign(transaction, options = {}) {
|
|
655
|
+
return Promise.reject("The current wallet doesn't support multiSign.");
|
|
656
|
+
}
|
|
657
|
+
signTypedData(typedData) {
|
|
658
|
+
let normalized;
|
|
659
|
+
try {
|
|
660
|
+
normalized = (0, typedData_js_1.normalizeAndValidateTypedData)(typedData);
|
|
661
|
+
}
|
|
662
|
+
catch (error) {
|
|
663
|
+
return Promise.reject(error);
|
|
664
|
+
}
|
|
665
|
+
return this._signTypedData(normalized);
|
|
666
|
+
}
|
|
667
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
668
|
+
_signTypedData(_typedData) {
|
|
669
|
+
return Promise.reject("The current wallet doesn't support signTypedData.");
|
|
670
|
+
}
|
|
671
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
672
|
+
switchChain(_chainId) {
|
|
673
|
+
return Promise.reject("The current wallet doesn't support switch chain.");
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
adapter$1.Adapter = Adapter;
|
|
677
|
+
|
|
678
|
+
return adapter$1;
|
|
679
|
+
}
|
|
680
|
+
|
|
609
681
|
var utils$2 = {};
|
|
610
682
|
|
|
611
683
|
var hasRequiredUtils$2;
|
|
@@ -668,12 +740,312 @@
|
|
|
668
740
|
return utils$2;
|
|
669
741
|
}
|
|
670
742
|
|
|
743
|
+
var addonAdapter = {};
|
|
744
|
+
|
|
745
|
+
var security = {};
|
|
746
|
+
|
|
747
|
+
var hasRequiredSecurity;
|
|
748
|
+
|
|
749
|
+
function requireSecurity () {
|
|
750
|
+
if (hasRequiredSecurity) return security;
|
|
751
|
+
hasRequiredSecurity = 1;
|
|
752
|
+
(function (exports$1) {
|
|
753
|
+
var __awaiter = (security && security.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
754
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
755
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
756
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
757
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
758
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
759
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
760
|
+
});
|
|
761
|
+
};
|
|
762
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
763
|
+
exports$1.defaultSecurityOptions = void 0;
|
|
764
|
+
exports$1.clearCache = clearCache;
|
|
765
|
+
exports$1.fetchJsonWithCache = fetchJsonWithCache;
|
|
766
|
+
exports$1.defaultSecurityOptions = {
|
|
767
|
+
onRiskDetected: (result) => __awaiter(void 0, void 0, void 0, function* () {
|
|
768
|
+
console.log(`[WalletAdapter] Risk detected:`, result);
|
|
769
|
+
}),
|
|
770
|
+
configUrls: [],
|
|
771
|
+
enabled: false,
|
|
772
|
+
timeout: 2000,
|
|
773
|
+
retries: 0,
|
|
774
|
+
cacheTTL: 10 * 60 * 1000,
|
|
775
|
+
};
|
|
776
|
+
function isValidRisk(risk) {
|
|
777
|
+
return (!!risk &&
|
|
778
|
+
typeof risk === 'object' &&
|
|
779
|
+
typeof risk.title === 'string' &&
|
|
780
|
+
risk.title.length > 0 &&
|
|
781
|
+
(risk.noticeType === 1 || risk.noticeType === 2 || risk.noticeType === 3));
|
|
782
|
+
}
|
|
783
|
+
function sanitizeRisk(risk) {
|
|
784
|
+
const clean = { title: risk.title, noticeType: risk.noticeType };
|
|
785
|
+
if (typeof risk.ext === 'string')
|
|
786
|
+
clean.ext = risk.ext;
|
|
787
|
+
if (typeof risk.ios === 'string')
|
|
788
|
+
clean.ios = risk.ios;
|
|
789
|
+
if (typeof risk.and === 'string')
|
|
790
|
+
clean.and = risk.and;
|
|
791
|
+
return clean;
|
|
792
|
+
}
|
|
793
|
+
/**
|
|
794
|
+
* Defensively coerce an arbitrary remote payload into a well-formed RiskConfig.
|
|
795
|
+
*
|
|
796
|
+
* The config comes from a remote URL, so a bad release (or a tampered response)
|
|
797
|
+
* must never break the connect flow. Anything malformed is dropped with a
|
|
798
|
+
* warning rather than thrown: `wallets` must be a record whose values are
|
|
799
|
+
* arrays, and each risk must have a non-empty string `title` and a `noticeType`
|
|
800
|
+
* of 1/2/3. Invalid entries are discarded so downstream merging/consumption
|
|
801
|
+
* only ever sees clean `Risk[]`.
|
|
802
|
+
*/
|
|
803
|
+
function normalizeRiskConfig(data) {
|
|
804
|
+
const source = data && typeof data === 'object' ? data : {};
|
|
805
|
+
const wallets = {};
|
|
806
|
+
if (source.wallets && typeof source.wallets === 'object') {
|
|
807
|
+
for (const [walletName, rawRisks] of Object.entries(source.wallets)) {
|
|
808
|
+
if (!Array.isArray(rawRisks)) {
|
|
809
|
+
console.warn(`[WalletAdapter] Ignoring malformed risks for "${walletName}": expected an array, got ${typeof rawRisks}.`);
|
|
810
|
+
continue;
|
|
811
|
+
}
|
|
812
|
+
const validRisks = [];
|
|
813
|
+
for (const risk of rawRisks) {
|
|
814
|
+
if (isValidRisk(risk)) {
|
|
815
|
+
validRisks.push(sanitizeRisk(risk));
|
|
816
|
+
}
|
|
817
|
+
else {
|
|
818
|
+
console.warn(`[WalletAdapter] Dropping malformed risk entry for "${walletName}":`, risk);
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
if (validRisks.length > 0) {
|
|
822
|
+
wallets[walletName] = validRisks;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
return {
|
|
827
|
+
v: typeof source.v === 'string' ? source.v : '',
|
|
828
|
+
ts: typeof source.ts === 'number' ? source.ts : 0,
|
|
829
|
+
wallets,
|
|
830
|
+
};
|
|
831
|
+
}
|
|
832
|
+
const _jsonCache = {};
|
|
833
|
+
function clearCache() {
|
|
834
|
+
Object.keys(_jsonCache).forEach((key) => {
|
|
835
|
+
Reflect.deleteProperty(_jsonCache, key);
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
function fetchJsonWithCache(options) {
|
|
839
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
840
|
+
const { configUrls = exports$1.defaultSecurityOptions.configUrls, timeout = exports$1.defaultSecurityOptions.timeout, retries = exports$1.defaultSecurityOptions.retries, onConfigFallback, cacheTTL = exports$1.defaultSecurityOptions.cacheTTL, } = options;
|
|
841
|
+
const now = Date.now();
|
|
842
|
+
function fetchOneUrl(url) {
|
|
843
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
844
|
+
const cache = _jsonCache[url];
|
|
845
|
+
if (cache && now - cache.timestamp < cacheTTL) {
|
|
846
|
+
return cache.data;
|
|
847
|
+
}
|
|
848
|
+
function fetchWithTimeout() {
|
|
849
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
850
|
+
return new Promise((resolve, reject) => {
|
|
851
|
+
const controller = new AbortController();
|
|
852
|
+
const timer = setTimeout(() => controller.abort(), timeout);
|
|
853
|
+
fetch(url, { signal: controller.signal })
|
|
854
|
+
.then((resp) => {
|
|
855
|
+
clearTimeout(timer);
|
|
856
|
+
if (!resp.ok)
|
|
857
|
+
reject(new Error('Fetch failed with code: ' + resp.status));
|
|
858
|
+
else
|
|
859
|
+
resp.json().then((data) => resolve(normalizeRiskConfig(data)), reject);
|
|
860
|
+
})
|
|
861
|
+
.catch((err) => {
|
|
862
|
+
clearTimeout(timer);
|
|
863
|
+
reject(err);
|
|
864
|
+
});
|
|
865
|
+
});
|
|
866
|
+
});
|
|
867
|
+
}
|
|
868
|
+
for (let i = 0; i <= retries; i++) {
|
|
869
|
+
try {
|
|
870
|
+
const data = yield fetchWithTimeout();
|
|
871
|
+
_jsonCache[url] = { data, timestamp: Date.now() };
|
|
872
|
+
return data;
|
|
873
|
+
}
|
|
874
|
+
catch (e) {
|
|
875
|
+
console.warn(`[WalletAdapter] Fetch attempt ${i + 1} for ${url} failed:`, e);
|
|
876
|
+
// continue to next retry
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
// All retries failed — let the outer caller decide (onConfigFallback or safe empty config)
|
|
880
|
+
return null;
|
|
881
|
+
});
|
|
882
|
+
}
|
|
883
|
+
const results = yield Promise.all(configUrls.map(fetchOneUrl));
|
|
884
|
+
const configs = results.filter((r) => r !== null);
|
|
885
|
+
if (configs.length > 0) {
|
|
886
|
+
return configs.reduce((merged, config) => {
|
|
887
|
+
var _a;
|
|
888
|
+
if (config.ts > merged.ts) {
|
|
889
|
+
merged.v = config.v;
|
|
890
|
+
merged.ts = config.ts;
|
|
891
|
+
}
|
|
892
|
+
// Pass every risk from every source through to the DApp without
|
|
893
|
+
// deduplication. Conflict resolution (highest severity wins, source
|
|
894
|
+
// weighting, etc.) is the DApp's responsibility — the adapter just
|
|
895
|
+
// delivers the union.
|
|
896
|
+
for (const [wallet, risks] of Object.entries(config.wallets)) {
|
|
897
|
+
merged.wallets[wallet] = [...((_a = merged.wallets[wallet]) !== null && _a !== void 0 ? _a : []), ...risks];
|
|
898
|
+
}
|
|
899
|
+
return merged;
|
|
900
|
+
}, { v: '', ts: 0, wallets: {} });
|
|
901
|
+
}
|
|
902
|
+
// All URLs failed with no cache — call custom fallback or default to safe (allow connection)
|
|
903
|
+
if (onConfigFallback) {
|
|
904
|
+
return normalizeRiskConfig(yield onConfigFallback());
|
|
905
|
+
}
|
|
906
|
+
return { v: '', ts: 0, wallets: {} };
|
|
907
|
+
});
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
} (security));
|
|
911
|
+
return security;
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
var hasRequiredAddonAdapter;
|
|
915
|
+
|
|
916
|
+
function requireAddonAdapter () {
|
|
917
|
+
if (hasRequiredAddonAdapter) return addonAdapter;
|
|
918
|
+
hasRequiredAddonAdapter = 1;
|
|
919
|
+
var __awaiter = (addonAdapter && addonAdapter.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
920
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
921
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
922
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
923
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
924
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
925
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
926
|
+
});
|
|
927
|
+
};
|
|
928
|
+
Object.defineProperty(addonAdapter, "__esModule", { value: true });
|
|
929
|
+
addonAdapter.AddonAdapter = void 0;
|
|
930
|
+
const adapter_js_1 = requireAdapter$2();
|
|
931
|
+
const errors_js_1 = requireErrors();
|
|
932
|
+
const security_js_1 = requireSecurity();
|
|
933
|
+
const types_js_1 = requireTypes$1();
|
|
934
|
+
const utils_js_1 = requireUtils$2();
|
|
935
|
+
/**
|
|
936
|
+
* Class to provide security check for wallets.
|
|
937
|
+
*/
|
|
938
|
+
class AddonAdapter extends adapter_js_1.Adapter {
|
|
939
|
+
constructor(params) {
|
|
940
|
+
super();
|
|
941
|
+
this.commonConfig = {
|
|
942
|
+
checkTimeout: 2 * 1000,
|
|
943
|
+
openAppWithDeeplink: true,
|
|
944
|
+
openUrlWhenWalletNotFound: true,
|
|
945
|
+
securityOptions: security_js_1.defaultSecurityOptions,
|
|
946
|
+
};
|
|
947
|
+
this._securityCheckCache = null;
|
|
948
|
+
this.commonConfig = Object.assign(Object.assign({}, this.commonConfig), params);
|
|
949
|
+
if (typeof this.commonConfig.checkTimeout !== 'number') {
|
|
950
|
+
throw new Error(`[WalletAdapter] config.checkTimeout should be a number`);
|
|
951
|
+
}
|
|
952
|
+
AddonAdapter._validateSecurityOptions(this.commonConfig.securityOptions);
|
|
953
|
+
}
|
|
954
|
+
static _validateSecurityOptions(securityOptions) {
|
|
955
|
+
const { enabled, configUrls } = securityOptions;
|
|
956
|
+
if (enabled && (!configUrls || configUrls.length === 0)) {
|
|
957
|
+
throw new Error(`[WalletAdapter] config.securityOptions.configUrls is required when securityOptions.enabled is true`);
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* Update the security options at runtime. The given options are merged into
|
|
962
|
+
* the existing config, validated, and the cached security check result is
|
|
963
|
+
* cleared so the next connect runs a fresh check with the new configuration.
|
|
964
|
+
*/
|
|
965
|
+
updateSecurityOptions(securityOptions) {
|
|
966
|
+
const merged = Object.assign(Object.assign({}, this.commonConfig.securityOptions), securityOptions);
|
|
967
|
+
AddonAdapter._validateSecurityOptions(merged);
|
|
968
|
+
this.commonConfig.securityOptions = merged;
|
|
969
|
+
this._securityCheckCache = null;
|
|
970
|
+
}
|
|
971
|
+
/**
|
|
972
|
+
* Run the pre-connect pipeline (wallet discovery, deeplink/url fallback,
|
|
973
|
+
* security check).
|
|
974
|
+
*
|
|
975
|
+
* @returns `true` when the caller should continue with the actual connect
|
|
976
|
+
* flow, `false` when the adapter is already connected/connecting and the
|
|
977
|
+
* caller should bail out. Throws `WalletNotFoundError` when the wallet
|
|
978
|
+
* cannot be found.
|
|
979
|
+
*/
|
|
980
|
+
_beforeConnect() {
|
|
981
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
982
|
+
if (this.connected || this.connecting)
|
|
983
|
+
return false;
|
|
984
|
+
yield this._checkWallet();
|
|
985
|
+
if (this.readyState === types_js_1.WalletReadyState.NotFound) {
|
|
986
|
+
if ((0, utils_js_1.isInBrowser)() &&
|
|
987
|
+
!this._openAppByDeepLinkIfNeed() &&
|
|
988
|
+
this.commonConfig.openUrlWhenWalletNotFound !== false) {
|
|
989
|
+
window.open(this.url, '_blank');
|
|
990
|
+
}
|
|
991
|
+
throw new errors_js_1.WalletNotFoundError();
|
|
992
|
+
}
|
|
993
|
+
yield this.checkSecurity();
|
|
994
|
+
return true;
|
|
995
|
+
});
|
|
996
|
+
}
|
|
997
|
+
/**
|
|
998
|
+
* Fetch remote config and do risk check.
|
|
999
|
+
* In-flight calls share the same promise (so `onRiskDetected` fires at most
|
|
1000
|
+
* once even on a slow network). After the promise settles, the result is
|
|
1001
|
+
* cached for SECURITY_CHECK_CACHE_TTL; the next call after that window
|
|
1002
|
+
* runs a fresh check.
|
|
1003
|
+
*/
|
|
1004
|
+
checkSecurity() {
|
|
1005
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1006
|
+
if (!this.commonConfig.securityOptions.enabled)
|
|
1007
|
+
return;
|
|
1008
|
+
const cache = this._securityCheckCache;
|
|
1009
|
+
if (cache &&
|
|
1010
|
+
(cache.settledAt === null || Date.now() - cache.settledAt < AddonAdapter.SECURITY_CHECK_CACHE_TTL)) {
|
|
1011
|
+
return cache.promise;
|
|
1012
|
+
}
|
|
1013
|
+
const promise = (() => __awaiter(this, void 0, void 0, function* () {
|
|
1014
|
+
const result = yield (0, security_js_1.fetchJsonWithCache)(this.commonConfig.securityOptions);
|
|
1015
|
+
const risks = result.wallets[this.name];
|
|
1016
|
+
if (risks && risks.length > 0) {
|
|
1017
|
+
const callback = this.commonConfig.securityOptions.onRiskDetected || security_js_1.defaultSecurityOptions.onRiskDetected;
|
|
1018
|
+
yield callback({ risks });
|
|
1019
|
+
}
|
|
1020
|
+
}))();
|
|
1021
|
+
const entry = { promise, settledAt: null };
|
|
1022
|
+
this._securityCheckCache = entry;
|
|
1023
|
+
// The `.finally` chain returns a new promise that mirrors `promise`'s rejection.
|
|
1024
|
+
// Attach a noop `.catch` to avoid an unhandled rejection on that chain — the
|
|
1025
|
+
// original `promise` is still surfaced to callers via the return below.
|
|
1026
|
+
promise
|
|
1027
|
+
.finally(() => {
|
|
1028
|
+
if (this._securityCheckCache === entry) {
|
|
1029
|
+
entry.settledAt = Date.now();
|
|
1030
|
+
}
|
|
1031
|
+
})
|
|
1032
|
+
.catch(() => { });
|
|
1033
|
+
return promise;
|
|
1034
|
+
});
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
addonAdapter.AddonAdapter = AddonAdapter;
|
|
1038
|
+
AddonAdapter.SECURITY_CHECK_CACHE_TTL = 5 * 1000;
|
|
1039
|
+
|
|
1040
|
+
return addonAdapter;
|
|
1041
|
+
}
|
|
1042
|
+
|
|
671
1043
|
var hasRequiredCjs$2;
|
|
672
1044
|
|
|
673
1045
|
function requireCjs$2 () {
|
|
674
1046
|
if (hasRequiredCjs$2) return cjs$1;
|
|
675
1047
|
hasRequiredCjs$2 = 1;
|
|
676
|
-
(function (exports) {
|
|
1048
|
+
(function (exports$1) {
|
|
677
1049
|
var __createBinding = (cjs$1 && cjs$1.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
678
1050
|
if (k2 === undefined) k2 = k;
|
|
679
1051
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -685,14 +1057,17 @@
|
|
|
685
1057
|
if (k2 === undefined) k2 = k;
|
|
686
1058
|
o[k2] = m[k];
|
|
687
1059
|
}));
|
|
688
|
-
var __exportStar = (cjs$1 && cjs$1.__exportStar) || function(m, exports) {
|
|
689
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
1060
|
+
var __exportStar = (cjs$1 && cjs$1.__exportStar) || function(m, exports$1) {
|
|
1061
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$1, p)) __createBinding(exports$1, m, p);
|
|
690
1062
|
};
|
|
691
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
692
|
-
__exportStar(
|
|
693
|
-
__exportStar(
|
|
694
|
-
__exportStar(
|
|
695
|
-
__exportStar(
|
|
1063
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
1064
|
+
__exportStar(requireAdapter$2(), exports$1);
|
|
1065
|
+
__exportStar(requireErrors(), exports$1);
|
|
1066
|
+
__exportStar(requireTypes$1(), exports$1);
|
|
1067
|
+
__exportStar(requireTypedData(), exports$1);
|
|
1068
|
+
__exportStar(requireUtils$2(), exports$1);
|
|
1069
|
+
__exportStar(requireAddonAdapter(), exports$1);
|
|
1070
|
+
__exportStar(requireSecurity(), exports$1);
|
|
696
1071
|
|
|
697
1072
|
} (cjs$1));
|
|
698
1073
|
return cjs$1;
|
|
@@ -726,10 +1101,10 @@
|
|
|
726
1101
|
utils$1.waitTronwebReady = waitTronwebReady;
|
|
727
1102
|
const tronwallet_abstract_adapter_1 = /*@__PURE__*/ requireCjs$2();
|
|
728
1103
|
function supportTron() {
|
|
729
|
-
return !!(window.tron && window.tron.isTronLink);
|
|
1104
|
+
return (0, tronwallet_abstract_adapter_1.isInBrowser)() && !!(window.tron && window.tron.isTronLink);
|
|
730
1105
|
}
|
|
731
1106
|
function supportTronLink() {
|
|
732
|
-
return !!(supportTron() || window.tronLink || window.tronWeb);
|
|
1107
|
+
return (0, tronwallet_abstract_adapter_1.isInBrowser)() && !!(supportTron() || window.tronLink || window.tronWeb);
|
|
733
1108
|
}
|
|
734
1109
|
/**
|
|
735
1110
|
* Detect if in TronLinkApp
|
|
@@ -749,7 +1124,7 @@
|
|
|
749
1124
|
defaultDappIcon = new URL(link.getAttribute('href') || '', location.href).toString();
|
|
750
1125
|
}
|
|
751
1126
|
}
|
|
752
|
-
catch (
|
|
1127
|
+
catch (_a) {
|
|
753
1128
|
// console.error(e);
|
|
754
1129
|
}
|
|
755
1130
|
const { origin, pathname, search, hash } = window.location;
|
|
@@ -796,7 +1171,7 @@
|
|
|
796
1171
|
function requireAdapter$1 () {
|
|
797
1172
|
if (hasRequiredAdapter$1) return adapter;
|
|
798
1173
|
hasRequiredAdapter$1 = 1;
|
|
799
|
-
(function (exports) {
|
|
1174
|
+
(function (exports$1) {
|
|
800
1175
|
var __awaiter = (adapter && adapter.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
801
1176
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
802
1177
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -806,12 +1181,12 @@
|
|
|
806
1181
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
807
1182
|
});
|
|
808
1183
|
};
|
|
809
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
810
|
-
exports.TronLinkAdapter = exports.TronLinkAdapterName = exports.chainIdNetworkMap = void 0;
|
|
811
|
-
exports.getNetworkInfoByTronWeb = getNetworkInfoByTronWeb;
|
|
1184
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
1185
|
+
exports$1.TronLinkAdapter = exports$1.TronLinkAdapterName = exports$1.chainIdNetworkMap = void 0;
|
|
1186
|
+
exports$1.getNetworkInfoByTronWeb = getNetworkInfoByTronWeb;
|
|
812
1187
|
const tronwallet_abstract_adapter_1 = /*@__PURE__*/ requireCjs$2();
|
|
813
|
-
const utils_js_1 =
|
|
814
|
-
exports.chainIdNetworkMap = {
|
|
1188
|
+
const utils_js_1 = requireUtils$1();
|
|
1189
|
+
exports$1.chainIdNetworkMap = {
|
|
815
1190
|
'0x2b6653dc': tronwallet_abstract_adapter_1.NetworkType.Mainnet,
|
|
816
1191
|
'0x94a9059e': tronwallet_abstract_adapter_1.NetworkType.Shasta,
|
|
817
1192
|
'0xcd8690dc': tronwallet_abstract_adapter_1.NetworkType.Nile,
|
|
@@ -822,7 +1197,7 @@
|
|
|
822
1197
|
const { blockID = '' } = yield tronWeb.trx.getBlockByNumber(0);
|
|
823
1198
|
const chainId = `0x${blockID.slice(-8)}`;
|
|
824
1199
|
return {
|
|
825
|
-
networkType: exports.chainIdNetworkMap[chainId] || tronwallet_abstract_adapter_1.NetworkType.Unknown,
|
|
1200
|
+
networkType: exports$1.chainIdNetworkMap[chainId] || tronwallet_abstract_adapter_1.NetworkType.Unknown,
|
|
826
1201
|
chainId,
|
|
827
1202
|
fullNode: ((_a = tronWeb.fullNode) === null || _a === void 0 ? void 0 : _a.host) || '',
|
|
828
1203
|
solidityNode: ((_b = tronWeb.solidityNode) === null || _b === void 0 ? void 0 : _b.host) || '',
|
|
@@ -830,61 +1205,18 @@
|
|
|
830
1205
|
};
|
|
831
1206
|
});
|
|
832
1207
|
}
|
|
833
|
-
exports.TronLinkAdapterName = 'TronLink';
|
|
834
|
-
class TronLinkAdapter extends tronwallet_abstract_adapter_1.
|
|
1208
|
+
exports$1.TronLinkAdapterName = 'TronLink';
|
|
1209
|
+
class TronLinkAdapter extends tronwallet_abstract_adapter_1.AddonAdapter {
|
|
835
1210
|
// record if first connect event has emitted or not
|
|
836
1211
|
constructor(config = {}) {
|
|
837
|
-
super();
|
|
838
|
-
this.name = exports.TronLinkAdapterName;
|
|
1212
|
+
super(config);
|
|
1213
|
+
this.name = exports$1.TronLinkAdapterName;
|
|
839
1214
|
this.url = 'https://www.tronlink.org/';
|
|
840
1215
|
this.icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAF0AAABdCAYAAADHcWrDAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAUGVYSWZNTQAqAAAACAACARIAAwAAAAEAAQAAh2kABAAAAAEAAAAmAAAAAAADoAEAAwAAAAEAAQAAoAIABAAAAAEAAABdoAMABAAAAAEAAABdAAAAAMkTBfIAAAFZaVRYdFhNTDpjb20uYWRvYmUueG1wAAAAAAA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJYTVAgQ29yZSA2LjAuMCI+CiAgIDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+CiAgICAgIDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiCiAgICAgICAgICAgIHhtbG5zOnRpZmY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vdGlmZi8xLjAvIj4KICAgICAgICAgPHRpZmY6T3JpZW50YXRpb24+MTwvdGlmZjpPcmllbnRhdGlvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Chle4QcAABZhSURBVHgB7V0JlBTVuf6runtWllkA2QeYQQRBZHNFxZjw4jFqMEFxCWIS1yOaTeJ76nk5Lyc5CUZNfCoa0BgUxRh3QD2CJs8lELaIgOCw78sszN4z0131vu/W1NDTfbtneqa7Zx5v/nN6prrq1q2q77//ev9bbUgcNHjm/sya7PIiIxA43TCNUbYEcw3bsOLo4v98U9sWAxSwbbvYI7LDCDZ+dezl847G82BGWxrnzVl/nmF5bhCxviG2FBoen0+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ueMXyxK5XcE5P9n17MBqQFGIjoiNUCPTJQkJSgwa4CI2Q7+WJmHTEvE7dqwS/x2kH/Pgn65oX22Qw6d5p1mfPwc46r+MuxnU18QL5F4x0kwXQ0Fq+QmjAC1QIJUjHkXTaYyFdh6ehweUN8oKu3uliVhhW8uWzJ+AOhfbYA/firZ1Y3NFqzwJ0PDS+TTp2rahhKc/4xtBzCvXlOHnCymO/2SgTRXeQLf3RTdzx2HKnn0EXGMa9Jwyn2CSMYuKHkxSl/C2/bAnQerHp5cgl+6niGHax7Tsitpl8KDz8xFd8Z9fGF93x5so4un9Rb5Uno6nWU2AdfH5KVHjnSObdZjmBNBZWxLoQGSkvYwS3A8IqSF6GyNRQBOtuULTmvsnTxxB9YVuB6VG1sxW9O4zc1wb24lZrminHsopzRH482lTccc6eszEpEWoDLbmhEdbEPk1p8U5NTxqF5AAxORyUbVWI1PNbQEJhW9uI5n2laql36zE5T6/IXJi7Nu3H1CsO0r4OmmY2M5CT8oGmmw3IMjURZsWh3h/3pGbas3OKXE5hJy4lMs8s1WESwbAMOejwdUoaIVaR/nt6JKK1GoVAQDEF61lG4+Ks2GPRgQbId3InZl7cxQBeWLJ70ZYzHUYdigs4WHPX4txA9L8qfs34UfM7J2B6NFVmDxLB6i92q0KkLtfcPhX0vSqq3H6geC/98RHg/VwL0MW8e/hjvVy/Xim34CVG+21h+ePawjAk4HDG1byFN4q+r/dQH74aaDGOtFvnw4wC+2BJzo8db/XnJc1Njr7EMua7DuJAdXXXTrq8fI2lpUyPvz8LSjjXLjCEXHIw8Ft8eu65sqmTkjok4K+AvNnyZH0Xsb+eO/wWrg46Do/7gYAAAAABJRU5ErkJggg==';
|
|
841
1216
|
this._readyState = (0, tronwallet_abstract_adapter_1.isInBrowser)() ? tronwallet_abstract_adapter_1.WalletReadyState.Loading : tronwallet_abstract_adapter_1.WalletReadyState.NotFound;
|
|
842
|
-
this._state = tronwallet_abstract_adapter_1.AdapterState.Loading;
|
|
1217
|
+
this._state = (0, tronwallet_abstract_adapter_1.isInBrowser)() ? tronwallet_abstract_adapter_1.AdapterState.Loading : tronwallet_abstract_adapter_1.AdapterState.NotFound;
|
|
843
1218
|
// https://github.com/tronprotocol/tips/blob/master/tip-1193.md
|
|
844
1219
|
this._supportNewTronProtocol = false;
|
|
845
|
-
this._tronLinkMessageHandler = (e) => {
|
|
846
|
-
var _a, _b, _c, _d, _e;
|
|
847
|
-
const message = (_a = e.data) === null || _a === void 0 ? void 0 : _a.message;
|
|
848
|
-
if (!message) {
|
|
849
|
-
return;
|
|
850
|
-
}
|
|
851
|
-
if (message.action === 'accountsChanged') {
|
|
852
|
-
setTimeout(() => {
|
|
853
|
-
var _a;
|
|
854
|
-
const preAddr = this.address || '';
|
|
855
|
-
if ((_a = this._wallet) === null || _a === void 0 ? void 0 : _a.ready) {
|
|
856
|
-
const address = message.data.address;
|
|
857
|
-
this.setAddress(address);
|
|
858
|
-
this.setState(tronwallet_abstract_adapter_1.AdapterState.Connected);
|
|
859
|
-
}
|
|
860
|
-
else {
|
|
861
|
-
this.setAddress(null);
|
|
862
|
-
this.setState(tronwallet_abstract_adapter_1.AdapterState.Disconnect);
|
|
863
|
-
}
|
|
864
|
-
this.emit('accountsChanged', this.address || '', preAddr);
|
|
865
|
-
if (!preAddr && this.address) {
|
|
866
|
-
this.emit('connect', this.address);
|
|
867
|
-
}
|
|
868
|
-
else if (preAddr && !this.address) {
|
|
869
|
-
this.emit('disconnect');
|
|
870
|
-
}
|
|
871
|
-
}, 200);
|
|
872
|
-
}
|
|
873
|
-
else if (message.action === 'setNode') {
|
|
874
|
-
this.emit('chainChanged', { chainId: ((_c = (_b = message.data) === null || _b === void 0 ? void 0 : _b.node) === null || _c === void 0 ? void 0 : _c.chainId) || '' });
|
|
875
|
-
}
|
|
876
|
-
else if (message.action === 'connect') {
|
|
877
|
-
const address = ((_e = (_d = this._wallet.tronWeb) === null || _d === void 0 ? void 0 : _d.defaultAddress) === null || _e === void 0 ? void 0 : _e.base58) || '';
|
|
878
|
-
this.setAddress(address);
|
|
879
|
-
this.setState(tronwallet_abstract_adapter_1.AdapterState.Connected);
|
|
880
|
-
this.emit('connect', address);
|
|
881
|
-
}
|
|
882
|
-
else if (message.action === 'disconnect') {
|
|
883
|
-
this.setAddress(null);
|
|
884
|
-
this.setState(tronwallet_abstract_adapter_1.AdapterState.Disconnect);
|
|
885
|
-
this.emit('disconnect');
|
|
886
|
-
}
|
|
887
|
-
};
|
|
888
1220
|
this._onChainChanged = (data) => {
|
|
889
1221
|
this.emit('chainChanged', data);
|
|
890
1222
|
};
|
|
@@ -892,17 +1224,8 @@
|
|
|
892
1224
|
var _a, _b, _c;
|
|
893
1225
|
const preAddr = this.address || '';
|
|
894
1226
|
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)) || '';
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
// tronlink will emit accountsChanged many times, only process when connected
|
|
898
|
-
this.setAddress(null);
|
|
899
|
-
this.setState(tronwallet_abstract_adapter_1.AdapterState.Disconnect);
|
|
900
|
-
}
|
|
901
|
-
else {
|
|
902
|
-
const address = curAddr;
|
|
903
|
-
this.setAddress(address);
|
|
904
|
-
this.setState(tronwallet_abstract_adapter_1.AdapterState.Connected);
|
|
905
|
-
}
|
|
1227
|
+
this.setAddress(curAddr ? curAddr : null);
|
|
1228
|
+
this.setState(this.address ? tronwallet_abstract_adapter_1.AdapterState.Connected : tronwallet_abstract_adapter_1.AdapterState.Disconnect);
|
|
906
1229
|
this.emit('accountsChanged', this.address || '', preAddr);
|
|
907
1230
|
if (!preAddr && this.address) {
|
|
908
1231
|
this.emit('connect', this.address);
|
|
@@ -912,8 +1235,9 @@
|
|
|
912
1235
|
}
|
|
913
1236
|
};
|
|
914
1237
|
this._checkPromise = null;
|
|
915
|
-
this._updateWallet = () => {
|
|
916
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
1238
|
+
this._updateWallet = () => __awaiter(this, void 0, void 0, function* () {
|
|
1239
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1240
|
+
this._supportNewTronProtocol = false;
|
|
917
1241
|
let state = this.state;
|
|
918
1242
|
let address = this.address;
|
|
919
1243
|
if ((0, tronwallet_abstract_adapter_1.isInMobileBrowser)()) {
|
|
@@ -928,9 +1252,23 @@
|
|
|
928
1252
|
};
|
|
929
1253
|
}
|
|
930
1254
|
address = ((_c = (_b = this._wallet.tronWeb) === null || _b === void 0 ? void 0 : _b.defaultAddress) === null || _c === void 0 ? void 0 : _c.base58) || null;
|
|
931
|
-
|
|
1255
|
+
if (address) {
|
|
1256
|
+
// Only run the security check once the wallet is actually connected.
|
|
1257
|
+
try {
|
|
1258
|
+
yield this.checkSecurity();
|
|
1259
|
+
}
|
|
1260
|
+
catch (_j) {
|
|
1261
|
+
this.setAddress(null);
|
|
1262
|
+
this.setState(tronwallet_abstract_adapter_1.AdapterState.Disconnect);
|
|
1263
|
+
return;
|
|
1264
|
+
}
|
|
1265
|
+
state = tronwallet_abstract_adapter_1.AdapterState.Connected;
|
|
1266
|
+
}
|
|
1267
|
+
else {
|
|
1268
|
+
state = tronwallet_abstract_adapter_1.AdapterState.Disconnect;
|
|
1269
|
+
}
|
|
932
1270
|
}
|
|
933
|
-
else if (
|
|
1271
|
+
else if (this.isLegacyTronLinkProvider(window.tron)) {
|
|
934
1272
|
this._supportNewTronProtocol = true;
|
|
935
1273
|
this._wallet = window.tron;
|
|
936
1274
|
this._listenTronEvent();
|
|
@@ -939,7 +1277,7 @@
|
|
|
939
1277
|
state = address ? tronwallet_abstract_adapter_1.AdapterState.Connected : tronwallet_abstract_adapter_1.AdapterState.Disconnect;
|
|
940
1278
|
}
|
|
941
1279
|
catch (e) {
|
|
942
|
-
console.error('
|
|
1280
|
+
console.error('Unknown error: ' + e, ' Please install TronLink extension wallet.');
|
|
943
1281
|
address = null;
|
|
944
1282
|
state = tronwallet_abstract_adapter_1.AdapterState.Disconnect;
|
|
945
1283
|
this._readyState = tronwallet_abstract_adapter_1.WalletReadyState.NotFound;
|
|
@@ -949,20 +1287,9 @@
|
|
|
949
1287
|
}
|
|
950
1288
|
else if (window.tronLink) {
|
|
951
1289
|
this._wallet = window.tronLink;
|
|
952
|
-
this._listenTronLinkEvent();
|
|
953
1290
|
address = ((_h = (_g = this._wallet.tronWeb) === null || _g === void 0 ? void 0 : _g.defaultAddress) === null || _h === void 0 ? void 0 : _h.base58) || null;
|
|
954
1291
|
state = this._wallet.ready ? tronwallet_abstract_adapter_1.AdapterState.Connected : tronwallet_abstract_adapter_1.AdapterState.Disconnect;
|
|
955
1292
|
}
|
|
956
|
-
else if (window.tronWeb) {
|
|
957
|
-
// fake tronLink
|
|
958
|
-
this._wallet = {
|
|
959
|
-
ready: window.tronWeb.ready,
|
|
960
|
-
tronWeb: window.tronWeb,
|
|
961
|
-
request: () => Promise.resolve(true),
|
|
962
|
-
};
|
|
963
|
-
address = ((_j = this._wallet.tronWeb.defaultAddress) === null || _j === void 0 ? void 0 : _j.base58) || null;
|
|
964
|
-
state = this._wallet.ready ? tronwallet_abstract_adapter_1.AdapterState.Connected : tronwallet_abstract_adapter_1.AdapterState.Disconnect;
|
|
965
|
-
}
|
|
966
1293
|
else {
|
|
967
1294
|
// no tronlink support
|
|
968
1295
|
this._wallet = null;
|
|
@@ -975,19 +1302,18 @@
|
|
|
975
1302
|
}
|
|
976
1303
|
this.setAddress(address);
|
|
977
1304
|
this.setState(state);
|
|
978
|
-
};
|
|
1305
|
+
});
|
|
979
1306
|
this.checkReadyInterval = null;
|
|
980
|
-
const { checkTimeout =
|
|
1307
|
+
const { checkTimeout = 5 * 1000, dappIcon = '', dappName = '', openUrlWhenWalletNotFound = true, openTronLinkAppOnMobile = true, openAppWithDeeplink = true, } = config;
|
|
981
1308
|
if (typeof checkTimeout !== 'number') {
|
|
982
1309
|
throw new Error('[TronLinkAdapter] config.checkTimeout should be a number');
|
|
983
1310
|
}
|
|
984
|
-
this.config = {
|
|
985
|
-
checkTimeout,
|
|
1311
|
+
this.config = Object.assign(Object.assign({}, this.commonConfig), { checkTimeout,
|
|
986
1312
|
openTronLinkAppOnMobile,
|
|
1313
|
+
openAppWithDeeplink,
|
|
987
1314
|
openUrlWhenWalletNotFound,
|
|
988
1315
|
dappIcon,
|
|
989
|
-
dappName
|
|
990
|
-
};
|
|
1316
|
+
dappName });
|
|
991
1317
|
this._connecting = false;
|
|
992
1318
|
this._wallet = null;
|
|
993
1319
|
this._address = null;
|
|
@@ -996,9 +1322,20 @@
|
|
|
996
1322
|
this.setState(tronwallet_abstract_adapter_1.AdapterState.NotFound);
|
|
997
1323
|
return;
|
|
998
1324
|
}
|
|
999
|
-
if ((0,
|
|
1325
|
+
if (!(0, tronwallet_abstract_adapter_1.isInMobileBrowser)()) {
|
|
1326
|
+
this._checkWallet().then(() => {
|
|
1327
|
+
if (this.connected) {
|
|
1328
|
+
this.emit('connect', this.address || '');
|
|
1329
|
+
}
|
|
1330
|
+
});
|
|
1331
|
+
}
|
|
1332
|
+
else if ((0, utils_js_1.supportTron)() || ((0, tronwallet_abstract_adapter_1.isInMobileBrowser)() && (window.tronLink || window.tronWeb))) {
|
|
1000
1333
|
this._readyState = tronwallet_abstract_adapter_1.WalletReadyState.Found;
|
|
1001
|
-
this._updateWallet()
|
|
1334
|
+
this._updateWallet().then(() => {
|
|
1335
|
+
if (this.connected) {
|
|
1336
|
+
this.emit('connect', this.address || '');
|
|
1337
|
+
}
|
|
1338
|
+
});
|
|
1002
1339
|
}
|
|
1003
1340
|
else {
|
|
1004
1341
|
this._checkWallet().then(() => {
|
|
@@ -1051,16 +1388,8 @@
|
|
|
1051
1388
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1052
1389
|
var _a, _b;
|
|
1053
1390
|
try {
|
|
1054
|
-
this.
|
|
1055
|
-
if (this.connected || this.connecting)
|
|
1391
|
+
if (!(yield this._beforeConnect()))
|
|
1056
1392
|
return;
|
|
1057
|
-
yield this._checkWallet();
|
|
1058
|
-
if (this.state === tronwallet_abstract_adapter_1.AdapterState.NotFound) {
|
|
1059
|
-
if (this.config.openUrlWhenWalletNotFound !== false && (0, tronwallet_abstract_adapter_1.isInBrowser)()) {
|
|
1060
|
-
window.open(this.url, '_blank');
|
|
1061
|
-
}
|
|
1062
|
-
throw new tronwallet_abstract_adapter_1.WalletNotFoundError();
|
|
1063
|
-
}
|
|
1064
1393
|
// lower version only support window.tronWeb, no window.tronLink
|
|
1065
1394
|
if (!this._wallet)
|
|
1066
1395
|
return;
|
|
@@ -1091,27 +1420,21 @@
|
|
|
1091
1420
|
}
|
|
1092
1421
|
else if (window.tronLink) {
|
|
1093
1422
|
const wallet = this._wallet;
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
throw new tronwallet_abstract_adapter_1.WalletConnectionError('TronLink wallet is locked or no wallet account is avaliable.');
|
|
1100
|
-
}
|
|
1101
|
-
if (res.code === 4000) {
|
|
1102
|
-
throw new tronwallet_abstract_adapter_1.WalletConnectionError('The same DApp has already initiated a request to connect to TronLink wallet, and the pop-up window has not been closed.');
|
|
1103
|
-
}
|
|
1104
|
-
if (res.code === 4001) {
|
|
1105
|
-
throw new tronwallet_abstract_adapter_1.WalletConnectionError('The user rejected connection.');
|
|
1106
|
-
}
|
|
1423
|
+
const res = yield wallet.request({ method: 'tron_requestAccounts' });
|
|
1424
|
+
if (!res) {
|
|
1425
|
+
// 1. wallet is locked
|
|
1426
|
+
// 2. tronlink is first installed and there is no wallet account
|
|
1427
|
+
throw new tronwallet_abstract_adapter_1.WalletConnectionError('TronLink wallet is locked or no wallet account is avaliable.');
|
|
1107
1428
|
}
|
|
1108
|
-
|
|
1109
|
-
throw new tronwallet_abstract_adapter_1.WalletConnectionError(
|
|
1429
|
+
if (res.code === 4000) {
|
|
1430
|
+
throw new tronwallet_abstract_adapter_1.WalletConnectionError('The same DApp has already initiated a request to connect to TronLink wallet, and the pop-up window has not been closed.');
|
|
1431
|
+
}
|
|
1432
|
+
if (res.code === 4001) {
|
|
1433
|
+
throw new tronwallet_abstract_adapter_1.WalletConnectionError('The user rejected connection.');
|
|
1110
1434
|
}
|
|
1111
1435
|
const address = ((_a = wallet.tronWeb.defaultAddress) === null || _a === void 0 ? void 0 : _a.base58) || '';
|
|
1112
1436
|
this.setAddress(address);
|
|
1113
1437
|
this.setState(tronwallet_abstract_adapter_1.AdapterState.Connected);
|
|
1114
|
-
this._listenTronLinkEvent();
|
|
1115
1438
|
}
|
|
1116
1439
|
else if (window.tronWeb) {
|
|
1117
1440
|
const wallet = this._wallet;
|
|
@@ -1125,8 +1448,9 @@
|
|
|
1125
1448
|
this.connected && this.emit('connect', this.address || '');
|
|
1126
1449
|
}
|
|
1127
1450
|
catch (error) {
|
|
1128
|
-
|
|
1129
|
-
|
|
1451
|
+
const err = error instanceof tronwallet_abstract_adapter_1.WalletError ? error : new tronwallet_abstract_adapter_1.WalletConnectionError(error === null || error === void 0 ? void 0 : error.message, error);
|
|
1452
|
+
this.emit('error', err);
|
|
1453
|
+
throw err;
|
|
1130
1454
|
}
|
|
1131
1455
|
finally {
|
|
1132
1456
|
this._connecting = false;
|
|
@@ -1138,9 +1462,6 @@
|
|
|
1138
1462
|
if (this._supportNewTronProtocol) {
|
|
1139
1463
|
this._stopListenTronEvent();
|
|
1140
1464
|
}
|
|
1141
|
-
else {
|
|
1142
|
-
this._stopListenTronLinkEvent();
|
|
1143
|
-
}
|
|
1144
1465
|
if (this.state !== tronwallet_abstract_adapter_1.AdapterState.Connected) {
|
|
1145
1466
|
return;
|
|
1146
1467
|
}
|
|
@@ -1149,19 +1470,22 @@
|
|
|
1149
1470
|
this.emit('disconnect');
|
|
1150
1471
|
});
|
|
1151
1472
|
}
|
|
1152
|
-
|
|
1473
|
+
_checkAndSign(action, ErrorConstructor) {
|
|
1153
1474
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1154
1475
|
try {
|
|
1155
1476
|
const wallet = yield this.checkAndGetWallet();
|
|
1156
1477
|
try {
|
|
1157
|
-
return yield wallet
|
|
1478
|
+
return yield action(wallet);
|
|
1158
1479
|
}
|
|
1159
1480
|
catch (error) {
|
|
1160
|
-
if (error instanceof Error) {
|
|
1161
|
-
throw new
|
|
1481
|
+
if (error instanceof Error || (typeof error === 'object' && error.message)) {
|
|
1482
|
+
throw new ErrorConstructor(error.message, error);
|
|
1483
|
+
}
|
|
1484
|
+
else if (typeof error === 'string') {
|
|
1485
|
+
throw new ErrorConstructor(error, new Error(error));
|
|
1162
1486
|
}
|
|
1163
1487
|
else {
|
|
1164
|
-
throw new
|
|
1488
|
+
throw new ErrorConstructor('Unknown error', error);
|
|
1165
1489
|
}
|
|
1166
1490
|
}
|
|
1167
1491
|
}
|
|
@@ -1171,48 +1495,32 @@
|
|
|
1171
1495
|
}
|
|
1172
1496
|
});
|
|
1173
1497
|
}
|
|
1174
|
-
|
|
1498
|
+
signTransaction(transaction) {
|
|
1175
1499
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1176
|
-
|
|
1177
|
-
const wallet = yield this.checkAndGetWallet();
|
|
1178
|
-
try {
|
|
1179
|
-
return yield wallet.tronWeb.trx.multiSign(transaction, privateKey, permissionId);
|
|
1180
|
-
}
|
|
1181
|
-
catch (error) {
|
|
1182
|
-
if (error instanceof Error) {
|
|
1183
|
-
throw new tronwallet_abstract_adapter_1.WalletSignTransactionError(error.message, error);
|
|
1184
|
-
}
|
|
1185
|
-
else {
|
|
1186
|
-
throw new tronwallet_abstract_adapter_1.WalletSignTransactionError(error, new Error(error));
|
|
1187
|
-
}
|
|
1188
|
-
}
|
|
1189
|
-
}
|
|
1190
|
-
catch (error) {
|
|
1191
|
-
this.emit('error', error);
|
|
1192
|
-
throw error;
|
|
1193
|
-
}
|
|
1500
|
+
return this._checkAndSign((wallet) => wallet.tronWeb.trx.sign(transaction), tronwallet_abstract_adapter_1.WalletSignTransactionError);
|
|
1194
1501
|
});
|
|
1195
1502
|
}
|
|
1196
|
-
|
|
1503
|
+
/**
|
|
1504
|
+
*
|
|
1505
|
+
* @param transaction transaction to be signed
|
|
1506
|
+
* @param _, false to use tronWeb.trx.multiSign
|
|
1507
|
+
* @param permissionId permissionId for multiSign
|
|
1508
|
+
* @returns
|
|
1509
|
+
*/
|
|
1510
|
+
multiSign(transaction_1) {
|
|
1511
|
+
return __awaiter(this, arguments, void 0, function* (transaction, options = {}) {
|
|
1512
|
+
// multiSign is a transaction signing operation, so it uses WalletSignTransactionError
|
|
1513
|
+
return this._checkAndSign((wallet) => wallet.tronWeb.trx.multiSign(transaction, undefined, options.permissionId), tronwallet_abstract_adapter_1.WalletSignTransactionError);
|
|
1514
|
+
});
|
|
1515
|
+
}
|
|
1516
|
+
signMessage(message) {
|
|
1197
1517
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
if (error instanceof Error) {
|
|
1205
|
-
throw new tronwallet_abstract_adapter_1.WalletSignMessageError(error.message, error);
|
|
1206
|
-
}
|
|
1207
|
-
else {
|
|
1208
|
-
throw new tronwallet_abstract_adapter_1.WalletSignMessageError(error, new Error(error));
|
|
1209
|
-
}
|
|
1210
|
-
}
|
|
1211
|
-
}
|
|
1212
|
-
catch (error) {
|
|
1213
|
-
this.emit('error', error);
|
|
1214
|
-
throw error;
|
|
1215
|
-
}
|
|
1518
|
+
return this._checkAndSign((wallet) => __awaiter(this, void 0, void 0, function* () { return wallet.tronWeb.trx.signMessageV2(message); }), tronwallet_abstract_adapter_1.WalletSignMessageError);
|
|
1519
|
+
});
|
|
1520
|
+
}
|
|
1521
|
+
_signTypedData(typedData) {
|
|
1522
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1523
|
+
return this._checkAndSign((wallet) => __awaiter(this, void 0, void 0, function* () { return wallet.tronWeb.trx._signTypedData(typedData.domain, typedData.types, typedData.message); }), tronwallet_abstract_adapter_1.WalletSignTypedDataError);
|
|
1216
1524
|
});
|
|
1217
1525
|
}
|
|
1218
1526
|
/**
|
|
@@ -1255,7 +1563,9 @@
|
|
|
1255
1563
|
}
|
|
1256
1564
|
checkAndGetWallet() {
|
|
1257
1565
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1258
|
-
this.
|
|
1566
|
+
if (this._openAppByDeepLinkIfNeed()) {
|
|
1567
|
+
throw new tronwallet_abstract_adapter_1.WalletNotFoundError();
|
|
1568
|
+
}
|
|
1259
1569
|
yield this._checkWallet();
|
|
1260
1570
|
if (this.state !== tronwallet_abstract_adapter_1.AdapterState.Connected)
|
|
1261
1571
|
throw new tronwallet_abstract_adapter_1.WalletDisconnectedError();
|
|
@@ -1265,27 +1575,17 @@
|
|
|
1265
1575
|
return wallet;
|
|
1266
1576
|
});
|
|
1267
1577
|
}
|
|
1268
|
-
|
|
1269
|
-
this.
|
|
1270
|
-
|
|
1271
|
-
}
|
|
1272
|
-
_stopListenTronLinkEvent() {
|
|
1273
|
-
window.removeEventListener('message', this._tronLinkMessageHandler);
|
|
1274
|
-
}
|
|
1275
|
-
checkIfOpenTronLink() {
|
|
1276
|
-
const { dappName = '', dappIcon = '' } = this.config;
|
|
1277
|
-
if (this.config.openTronLinkAppOnMobile === false) {
|
|
1278
|
-
return;
|
|
1279
|
-
}
|
|
1280
|
-
if ((0, utils_js_1.openTronLink)({ dappIcon, dappName })) {
|
|
1281
|
-
throw new tronwallet_abstract_adapter_1.WalletNotFoundError();
|
|
1578
|
+
_openAppByDeepLinkIfNeed() {
|
|
1579
|
+
if (this.config.openAppWithDeeplink === false || this.config.openTronLinkAppOnMobile === false) {
|
|
1580
|
+
return false;
|
|
1282
1581
|
}
|
|
1582
|
+
const { dappName = '', dappIcon = '' } = this.config;
|
|
1583
|
+
return (0, utils_js_1.openTronLink)({ dappIcon, dappName });
|
|
1283
1584
|
}
|
|
1284
1585
|
// following code is for TIP-1193
|
|
1285
1586
|
_listenTronEvent() {
|
|
1286
1587
|
var _a, _b;
|
|
1287
1588
|
this._stopListenTronEvent();
|
|
1288
|
-
this._stopListenTronLinkEvent();
|
|
1289
1589
|
const wallet = this._wallet;
|
|
1290
1590
|
(_a = wallet.on) === null || _a === void 0 ? void 0 : _a.call(wallet, 'chainChanged', this._onChainChanged);
|
|
1291
1591
|
(_b = wallet.on) === null || _b === void 0 ? void 0 : _b.call(wallet, 'accountsChanged', this._onAccountsChanged);
|
|
@@ -1296,6 +1596,12 @@
|
|
|
1296
1596
|
(_a = wallet.removeListener) === null || _a === void 0 ? void 0 : _a.call(wallet, 'chainChanged', this._onChainChanged);
|
|
1297
1597
|
(_b = wallet.removeListener) === null || _b === void 0 ? void 0 : _b.call(wallet, 'accountsChanged', this._onAccountsChanged);
|
|
1298
1598
|
}
|
|
1599
|
+
isLegacyTronLinkProvider(provider) {
|
|
1600
|
+
return !!(provider === null || provider === void 0 ? void 0 : provider.isTronLink);
|
|
1601
|
+
}
|
|
1602
|
+
hasDesktopLegacyTronLinkProvider() {
|
|
1603
|
+
return this.isLegacyTronLinkProvider(window.tron) || !!window.tronLink;
|
|
1604
|
+
}
|
|
1299
1605
|
/**
|
|
1300
1606
|
* check if wallet exists by interval, the promise only resolve when wallet detected or timeout
|
|
1301
1607
|
* @returns if wallet exists
|
|
@@ -1307,18 +1613,89 @@
|
|
|
1307
1613
|
if (this._checkPromise) {
|
|
1308
1614
|
return this._checkPromise;
|
|
1309
1615
|
}
|
|
1616
|
+
if ((0, tronwallet_abstract_adapter_1.isInBrowser)() && !(0, tronwallet_abstract_adapter_1.isInMobileBrowser)()) {
|
|
1617
|
+
// Desktop: use TIP-6963 event-based discovery with fallback
|
|
1618
|
+
this._checkPromise = new Promise((resolve) => {
|
|
1619
|
+
let handled = false;
|
|
1620
|
+
let timer = null;
|
|
1621
|
+
let handler = null;
|
|
1622
|
+
const cleanupDesktopDetection = () => {
|
|
1623
|
+
if (timer) {
|
|
1624
|
+
clearTimeout(timer);
|
|
1625
|
+
timer = null;
|
|
1626
|
+
}
|
|
1627
|
+
if (typeof window !== 'undefined' && handler) {
|
|
1628
|
+
window.removeEventListener(tronwallet_abstract_adapter_1.TIP6963AnnounceProviderEventName, handler);
|
|
1629
|
+
}
|
|
1630
|
+
};
|
|
1631
|
+
const finishWithLegacyDetection = () => {
|
|
1632
|
+
if (handled) {
|
|
1633
|
+
return;
|
|
1634
|
+
}
|
|
1635
|
+
handled = true;
|
|
1636
|
+
cleanupDesktopDetection();
|
|
1637
|
+
if (typeof window === 'undefined') {
|
|
1638
|
+
resolve(false);
|
|
1639
|
+
return;
|
|
1640
|
+
}
|
|
1641
|
+
// Fallback to legacy detection
|
|
1642
|
+
this._updateWallet();
|
|
1643
|
+
const isSupport = this.state !== tronwallet_abstract_adapter_1.AdapterState.NotFound;
|
|
1644
|
+
this._readyState = isSupport ? tronwallet_abstract_adapter_1.WalletReadyState.Found : tronwallet_abstract_adapter_1.WalletReadyState.NotFound;
|
|
1645
|
+
this.emit('readyStateChanged', this._readyState);
|
|
1646
|
+
resolve(isSupport);
|
|
1647
|
+
};
|
|
1648
|
+
timer = setTimeout(finishWithLegacyDetection, this.config.checkTimeout);
|
|
1649
|
+
handler = (event) => __awaiter(this, void 0, void 0, function* () {
|
|
1650
|
+
var _a, _b;
|
|
1651
|
+
if (handled) {
|
|
1652
|
+
return;
|
|
1653
|
+
}
|
|
1654
|
+
const { info, provider } = event.detail;
|
|
1655
|
+
const isTronLinkProvider = info.name === 'TronLink';
|
|
1656
|
+
if (isTronLinkProvider) {
|
|
1657
|
+
handled = true;
|
|
1658
|
+
this._supportNewTronProtocol = true;
|
|
1659
|
+
this._wallet = provider;
|
|
1660
|
+
try {
|
|
1661
|
+
yield this.checkSecurity();
|
|
1662
|
+
}
|
|
1663
|
+
catch (_c) {
|
|
1664
|
+
this.setAddress(null);
|
|
1665
|
+
this.setState(tronwallet_abstract_adapter_1.AdapterState.Disconnect);
|
|
1666
|
+
this._readyState = tronwallet_abstract_adapter_1.WalletReadyState.Found;
|
|
1667
|
+
this.emit('readyStateChanged', this.readyState);
|
|
1668
|
+
resolve(true);
|
|
1669
|
+
return;
|
|
1670
|
+
}
|
|
1671
|
+
this._listenTronEvent();
|
|
1672
|
+
this._readyState = tronwallet_abstract_adapter_1.WalletReadyState.Found;
|
|
1673
|
+
const address = (((_a = this._wallet) === null || _a === void 0 ? void 0 : _a.tronWeb) && ((_b = this._wallet.tronWeb.defaultAddress) === null || _b === void 0 ? void 0 : _b.base58)) || null;
|
|
1674
|
+
const state = address ? tronwallet_abstract_adapter_1.AdapterState.Connected : tronwallet_abstract_adapter_1.AdapterState.Disconnect;
|
|
1675
|
+
this.setAddress(address);
|
|
1676
|
+
this.setState(state);
|
|
1677
|
+
this.emit('readyStateChanged', this.readyState);
|
|
1678
|
+
cleanupDesktopDetection();
|
|
1679
|
+
resolve(true);
|
|
1680
|
+
}
|
|
1681
|
+
});
|
|
1682
|
+
window.addEventListener(tronwallet_abstract_adapter_1.TIP6963AnnounceProviderEventName, handler);
|
|
1683
|
+
window.dispatchEvent(new Event(tronwallet_abstract_adapter_1.TIP6963RequestProviderEventName));
|
|
1684
|
+
});
|
|
1685
|
+
return this._checkPromise;
|
|
1686
|
+
}
|
|
1687
|
+
// Mobile: use legacy polling detection
|
|
1310
1688
|
const interval = 100;
|
|
1311
|
-
const checkTronTimes = Math.floor(2000 / interval);
|
|
1312
1689
|
const maxTimes = Math.floor(this.config.checkTimeout / interval);
|
|
1313
1690
|
let times = 0, timer;
|
|
1314
1691
|
this._checkPromise = new Promise((resolve) => {
|
|
1315
1692
|
const check = () => {
|
|
1316
1693
|
times++;
|
|
1317
|
-
|
|
1694
|
+
this._updateWallet();
|
|
1695
|
+
const isSupport = !!((0, tronwallet_abstract_adapter_1.isInMobileBrowser)() && (window.tronLink || window.tronWeb));
|
|
1318
1696
|
if (isSupport || times > maxTimes) {
|
|
1319
1697
|
timer && clearInterval(timer);
|
|
1320
1698
|
this._readyState = isSupport ? tronwallet_abstract_adapter_1.WalletReadyState.Found : tronwallet_abstract_adapter_1.WalletReadyState.NotFound;
|
|
1321
|
-
this._updateWallet();
|
|
1322
1699
|
this.emit('readyStateChanged', this.readyState);
|
|
1323
1700
|
resolve(isSupport);
|
|
1324
1701
|
}
|
|
@@ -1363,7 +1740,7 @@
|
|
|
1363
1740
|
}
|
|
1364
1741
|
}
|
|
1365
1742
|
}
|
|
1366
|
-
exports.TronLinkAdapter = TronLinkAdapter;
|
|
1743
|
+
exports$1.TronLinkAdapter = TronLinkAdapter;
|
|
1367
1744
|
|
|
1368
1745
|
} (adapter));
|
|
1369
1746
|
return adapter;
|
|
@@ -1386,7 +1763,7 @@
|
|
|
1386
1763
|
function requireCjs$1 () {
|
|
1387
1764
|
if (hasRequiredCjs$1) return cjs;
|
|
1388
1765
|
hasRequiredCjs$1 = 1;
|
|
1389
|
-
(function (exports) {
|
|
1766
|
+
(function (exports$1) {
|
|
1390
1767
|
var __createBinding = (cjs && cjs.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
1391
1768
|
if (k2 === undefined) k2 = k;
|
|
1392
1769
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -1398,13 +1775,13 @@
|
|
|
1398
1775
|
if (k2 === undefined) k2 = k;
|
|
1399
1776
|
o[k2] = m[k];
|
|
1400
1777
|
}));
|
|
1401
|
-
var __exportStar = (cjs && cjs.__exportStar) || function(m, exports) {
|
|
1402
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
1778
|
+
var __exportStar = (cjs && cjs.__exportStar) || function(m, exports$1) {
|
|
1779
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$1, p)) __createBinding(exports$1, m, p);
|
|
1403
1780
|
};
|
|
1404
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1405
|
-
__exportStar(
|
|
1406
|
-
__exportStar(
|
|
1407
|
-
__exportStar(
|
|
1781
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
1782
|
+
__exportStar(requireAdapter$1(), exports$1);
|
|
1783
|
+
__exportStar(requireTypes(), exports$1);
|
|
1784
|
+
__exportStar(requireUtils$1(), exports$1);
|
|
1408
1785
|
|
|
1409
1786
|
} (cjs));
|
|
1410
1787
|
return cjs;
|
|
@@ -1460,7 +1837,7 @@
|
|
|
1460
1837
|
function requireAdapter () {
|
|
1461
1838
|
if (hasRequiredAdapter) return adapter$2;
|
|
1462
1839
|
hasRequiredAdapter = 1;
|
|
1463
|
-
(function (exports) {
|
|
1840
|
+
(function (exports$1) {
|
|
1464
1841
|
var __awaiter = (adapter$2 && adapter$2.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
1465
1842
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
1466
1843
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -1470,22 +1847,31 @@
|
|
|
1470
1847
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1471
1848
|
});
|
|
1472
1849
|
};
|
|
1473
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1474
|
-
exports.TokenPocketAdapter = exports.TokenPocketAdapterName = void 0;
|
|
1850
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
1851
|
+
exports$1.TokenPocketAdapter = exports$1.TokenPocketAdapterName = void 0;
|
|
1475
1852
|
const tronwallet_abstract_adapter_1 = /*@__PURE__*/ requireCjs$2();
|
|
1476
1853
|
const tronwallet_adapter_tronlink_1 = /*@__PURE__*/ requireCjs$1();
|
|
1477
|
-
const utils_js_1 =
|
|
1854
|
+
const utils_js_1 = requireUtils();
|
|
1478
1855
|
const tronwallet_abstract_adapter_2 = /*@__PURE__*/ requireCjs$2();
|
|
1479
|
-
exports.TokenPocketAdapterName = 'TokenPocket';
|
|
1480
|
-
class TokenPocketAdapter extends tronwallet_abstract_adapter_1.
|
|
1856
|
+
exports$1.TokenPocketAdapterName = 'TokenPocket';
|
|
1857
|
+
class TokenPocketAdapter extends tronwallet_abstract_adapter_1.AddonAdapter {
|
|
1481
1858
|
constructor(config = {}) {
|
|
1482
|
-
super();
|
|
1483
|
-
this.name = exports.TokenPocketAdapterName;
|
|
1859
|
+
super(config);
|
|
1860
|
+
this.name = exports$1.TokenPocketAdapterName;
|
|
1484
1861
|
this.url = 'https://tokenpocket.pro/';
|
|
1485
1862
|
this.icon = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIwIiBoZWlnaHQ9IjEyMCIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGc+CjxwYXRoIGQ9Ik0xMDQxLjUyIDBILTI3VjEwMjRIMTA0MS41MlYwWiIgZmlsbD0iIzI5ODBGRSIvPgo8ZyBjbGlwLXBhdGg9InVybCgjY2xpcDBfNDA4XzIyNSkiPgo8cGF0aCBkPSJNNDA2Ljc5NiA0MzguNjQzSDQwNi45MjdDNDA2Ljc5NiA0MzcuODU3IDQwNi43OTYgNDM2Ljk0IDQwNi43OTYgNDM2LjE1NFY0MzguNjQzWiIgZmlsbD0iIzI5QUVGRiIvPgo8cGF0aCBkPSJNNjY3LjYwMiA0NjMuNTMzSDUyMy4yNDlWNzI0LjA3NkM1MjMuMjQ5IDczNi4zODkgNTMzLjIwNCA3NDYuMzQ1IDU0NS41MTcgNzQ2LjM0NUg2NDUuMzMzQzY1Ny42NDcgNzQ2LjM0NSA2NjcuNjAyIDczNi4zODkgNjY3LjYwMiA3MjQuMDc2VjQ2My41MzNaIiBmaWxsPSJ3aGl0ZSIvPgo8cGF0aCBkPSJNNDUzLjU2MyAyNzdINDQ4LjcxNkgxOTAuMjY5QzE3Ny45NTUgMjc3IDE2OCAyODYuOTU1IDE2OCAyOTkuMjY5VjM4OS42NTNDMTY4IDQwMS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jcyOC40NDgiIGhlaWdodD0iNDcwIiBmaWxsPSJ3aGl0ZSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMTY4IDI3NykiLz4KPC9jbGlwUGF0aD4KPC9kZWZzPgo8L3N2Zz4K';
|
|
1486
1863
|
this._readyState = (0, tronwallet_abstract_adapter_1.isInBrowser)() ? tronwallet_abstract_adapter_1.WalletReadyState.Loading : tronwallet_abstract_adapter_1.WalletReadyState.NotFound;
|
|
1487
1864
|
this._state = tronwallet_abstract_adapter_1.AdapterState.Loading;
|
|
1865
|
+
/**
|
|
1866
|
+
* Whether the most recent security check passed. Gates the auto-connect
|
|
1867
|
+
* paths (e.g. `onAccountsChanged`) so a wallet that failed the security
|
|
1868
|
+
* check cannot silently connect when the extension emits account events.
|
|
1869
|
+
*/
|
|
1870
|
+
this._securityPassed = false;
|
|
1488
1871
|
this.onAccountsChanged = (accounts) => {
|
|
1872
|
+
// Do not auto-connect via account events when the security check has not passed.
|
|
1873
|
+
if (!this._securityPassed)
|
|
1874
|
+
return;
|
|
1489
1875
|
const preAddr = this.address || '';
|
|
1490
1876
|
const curAddr = (accounts === null || accounts === void 0 ? void 0 : accounts[0]) || '';
|
|
1491
1877
|
if (!curAddr) {
|
|
@@ -1507,11 +1893,22 @@
|
|
|
1507
1893
|
};
|
|
1508
1894
|
this.checkReadyInterval = null;
|
|
1509
1895
|
this._checkPromise = null;
|
|
1510
|
-
this._updateWallet = () => {
|
|
1896
|
+
this._updateWallet = () => __awaiter(this, void 0, void 0, function* () {
|
|
1511
1897
|
var _a, _b, _c, _d, _e;
|
|
1512
1898
|
let state = this.state;
|
|
1513
1899
|
let address = this.address;
|
|
1514
1900
|
if ((0, utils_js_1.supportTokenPocket)()) {
|
|
1901
|
+
try {
|
|
1902
|
+
yield this.checkSecurity();
|
|
1903
|
+
this._securityPassed = true;
|
|
1904
|
+
}
|
|
1905
|
+
catch (_f) {
|
|
1906
|
+
this._securityPassed = false;
|
|
1907
|
+
this.stopListenTronEvent();
|
|
1908
|
+
this.setAddress(null);
|
|
1909
|
+
this.setState(tronwallet_abstract_adapter_1.AdapterState.Disconnect);
|
|
1910
|
+
return;
|
|
1911
|
+
}
|
|
1515
1912
|
const tron = (_a = window.tokenpocket) === null || _a === void 0 ? void 0 : _a.tron;
|
|
1516
1913
|
this._wallet = (0, tronwallet_abstract_adapter_1.isInMobileBrowser)()
|
|
1517
1914
|
? {
|
|
@@ -1537,22 +1934,18 @@
|
|
|
1537
1934
|
}
|
|
1538
1935
|
this.setAddress(address);
|
|
1539
1936
|
this.setState(state);
|
|
1540
|
-
};
|
|
1541
|
-
|
|
1542
|
-
if (typeof checkTimeout !== 'number') {
|
|
1543
|
-
throw new Error('[TokenPocketAdapter] config.checkTimeout should be a number');
|
|
1544
|
-
}
|
|
1545
|
-
this.config = {
|
|
1546
|
-
checkTimeout,
|
|
1547
|
-
openAppWithDeeplink,
|
|
1548
|
-
openUrlWhenWalletNotFound,
|
|
1549
|
-
};
|
|
1937
|
+
});
|
|
1938
|
+
this.config = Object.assign({}, this.commonConfig);
|
|
1550
1939
|
this._connecting = false;
|
|
1551
1940
|
this._wallet = null;
|
|
1552
1941
|
this._address = null;
|
|
1553
1942
|
if ((0, tronwallet_abstract_adapter_1.isInMobileBrowser)() && (0, utils_js_1.supportTokenPocket)()) {
|
|
1554
1943
|
this._readyState = tronwallet_abstract_adapter_1.WalletReadyState.Found;
|
|
1555
|
-
this._updateWallet()
|
|
1944
|
+
this._updateWallet().then(() => {
|
|
1945
|
+
if (this.connected) {
|
|
1946
|
+
this.emit('connect', this.address || '');
|
|
1947
|
+
}
|
|
1948
|
+
});
|
|
1556
1949
|
}
|
|
1557
1950
|
else {
|
|
1558
1951
|
this._checkWallet().then(() => {
|
|
@@ -1603,42 +1996,26 @@
|
|
|
1603
1996
|
connect() {
|
|
1604
1997
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1605
1998
|
try {
|
|
1606
|
-
this.
|
|
1607
|
-
if (this.connected || this.connecting)
|
|
1999
|
+
if (!(yield this._beforeConnect()))
|
|
1608
2000
|
return;
|
|
1609
|
-
|
|
1610
|
-
if (this.readyState === tronwallet_abstract_adapter_1.WalletReadyState.NotFound) {
|
|
1611
|
-
if (this.config.openUrlWhenWalletNotFound !== false && (0, tronwallet_abstract_adapter_1.isInBrowser)()) {
|
|
1612
|
-
window.open(this.url, '_blank');
|
|
1613
|
-
}
|
|
1614
|
-
throw new tronwallet_abstract_adapter_1.WalletNotFoundError();
|
|
1615
|
-
}
|
|
2001
|
+
this._securityPassed = true;
|
|
1616
2002
|
if (!this._wallet)
|
|
1617
2003
|
return;
|
|
1618
2004
|
this._connecting = true;
|
|
1619
2005
|
const wallet = this._wallet;
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
throw new tronwallet_abstract_adapter_1.WalletConnectionError('Request connect error.');
|
|
1624
|
-
}
|
|
1625
|
-
const address = res[0];
|
|
1626
|
-
this.setAddress(address);
|
|
1627
|
-
this.setState(tronwallet_abstract_adapter_1.AdapterState.Connected);
|
|
1628
|
-
this.emit('connect', this.address || '');
|
|
1629
|
-
}
|
|
1630
|
-
catch (e) {
|
|
1631
|
-
if (e instanceof tronwallet_abstract_adapter_1.WalletError) {
|
|
1632
|
-
throw e;
|
|
1633
|
-
}
|
|
1634
|
-
else {
|
|
1635
|
-
throw new tronwallet_abstract_adapter_1.WalletConnectionError(e === null || e === void 0 ? void 0 : e.message, e);
|
|
1636
|
-
}
|
|
2006
|
+
const res = yield wallet.tron.request({ method: 'eth_requestAccounts' });
|
|
2007
|
+
if (!(res === null || res === void 0 ? void 0 : res[0])) {
|
|
2008
|
+
throw new tronwallet_abstract_adapter_1.WalletConnectionError('Request connect error.');
|
|
1637
2009
|
}
|
|
2010
|
+
const address = res[0];
|
|
2011
|
+
this.setAddress(address);
|
|
2012
|
+
this.setState(tronwallet_abstract_adapter_1.AdapterState.Connected);
|
|
2013
|
+
this.emit('connect', this.address || '');
|
|
1638
2014
|
}
|
|
1639
2015
|
catch (error) {
|
|
1640
|
-
|
|
1641
|
-
|
|
2016
|
+
const err = error instanceof tronwallet_abstract_adapter_1.WalletError ? error : new tronwallet_abstract_adapter_1.WalletConnectionError(error === null || error === void 0 ? void 0 : error.message, error);
|
|
2017
|
+
this.emit('error', err);
|
|
2018
|
+
throw err;
|
|
1642
2019
|
}
|
|
1643
2020
|
finally {
|
|
1644
2021
|
this._connecting = false;
|
|
@@ -1650,17 +2027,18 @@
|
|
|
1650
2027
|
if (this.state !== tronwallet_abstract_adapter_1.AdapterState.Connected) {
|
|
1651
2028
|
return;
|
|
1652
2029
|
}
|
|
2030
|
+
this._securityPassed = false;
|
|
1653
2031
|
this.setAddress(null);
|
|
1654
2032
|
this.setState(tronwallet_abstract_adapter_1.AdapterState.Disconnect);
|
|
1655
2033
|
this.emit('disconnect');
|
|
1656
2034
|
});
|
|
1657
2035
|
}
|
|
1658
|
-
signTransaction(transaction
|
|
2036
|
+
signTransaction(transaction) {
|
|
1659
2037
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1660
2038
|
try {
|
|
1661
2039
|
const wallet = yield this.checkAndGetWallet();
|
|
1662
2040
|
try {
|
|
1663
|
-
return yield wallet.tronWeb.trx.sign(transaction
|
|
2041
|
+
return yield wallet.tronWeb.trx.sign(transaction);
|
|
1664
2042
|
}
|
|
1665
2043
|
catch (error) {
|
|
1666
2044
|
if (error instanceof Error || (typeof error === 'object' && error.message)) {
|
|
@@ -1680,12 +2058,12 @@
|
|
|
1680
2058
|
}
|
|
1681
2059
|
});
|
|
1682
2060
|
}
|
|
1683
|
-
multiSign(
|
|
1684
|
-
return __awaiter(this,
|
|
2061
|
+
multiSign(transaction_1) {
|
|
2062
|
+
return __awaiter(this, arguments, void 0, function* (transaction, options = {}) {
|
|
1685
2063
|
try {
|
|
1686
2064
|
const wallet = yield this.checkAndGetWallet();
|
|
1687
2065
|
try {
|
|
1688
|
-
return yield wallet.tronWeb.trx.multiSign(transaction,
|
|
2066
|
+
return yield wallet.tronWeb.trx.multiSign(transaction, undefined, options.permissionId);
|
|
1689
2067
|
}
|
|
1690
2068
|
catch (error) {
|
|
1691
2069
|
if (error instanceof Error || (typeof error === 'object' && error.message)) {
|
|
@@ -1705,12 +2083,12 @@
|
|
|
1705
2083
|
}
|
|
1706
2084
|
});
|
|
1707
2085
|
}
|
|
1708
|
-
signMessage(message
|
|
2086
|
+
signMessage(message) {
|
|
1709
2087
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1710
2088
|
try {
|
|
1711
2089
|
const wallet = yield this.checkAndGetWallet();
|
|
1712
2090
|
try {
|
|
1713
|
-
return yield wallet.tronWeb.trx.signMessageV2(message
|
|
2091
|
+
return yield wallet.tronWeb.trx.signMessageV2(message);
|
|
1714
2092
|
}
|
|
1715
2093
|
catch (error) {
|
|
1716
2094
|
if (error instanceof Error || (typeof error === 'object' && error.message)) {
|
|
@@ -1769,6 +2147,12 @@
|
|
|
1769
2147
|
throw new tronwallet_abstract_adapter_1.WalletNotFoundError();
|
|
1770
2148
|
}
|
|
1771
2149
|
}
|
|
2150
|
+
_openAppByDeepLinkIfNeed() {
|
|
2151
|
+
if (this.config.openAppWithDeeplink === false) {
|
|
2152
|
+
return false;
|
|
2153
|
+
}
|
|
2154
|
+
return (0, utils_js_1.openTokenPocket)();
|
|
2155
|
+
}
|
|
1772
2156
|
checkForWalletReady() {
|
|
1773
2157
|
if (this.checkReadyInterval) {
|
|
1774
2158
|
return;
|
|
@@ -1829,7 +2213,7 @@
|
|
|
1829
2213
|
}
|
|
1830
2214
|
this.emit('readyStateChanged', this._readyState);
|
|
1831
2215
|
}, this.config.checkTimeout);
|
|
1832
|
-
const handler = (event) => {
|
|
2216
|
+
const handler = (event) => __awaiter(this, void 0, void 0, function* () {
|
|
1833
2217
|
var _a, _b, _c;
|
|
1834
2218
|
const { info, provider } = event.detail;
|
|
1835
2219
|
if (info.name === 'TokenPocket') {
|
|
@@ -1842,6 +2226,19 @@
|
|
|
1842
2226
|
this._readyState = tronwallet_abstract_adapter_1.WalletReadyState.Found;
|
|
1843
2227
|
const address = ((_c = this._wallet.tronWeb.defaultAddress) === null || _c === void 0 ? void 0 : _c.base58) || null;
|
|
1844
2228
|
const state = address ? tronwallet_abstract_adapter_1.AdapterState.Connected : tronwallet_abstract_adapter_1.AdapterState.Disconnect;
|
|
2229
|
+
try {
|
|
2230
|
+
yield this.checkSecurity();
|
|
2231
|
+
this._securityPassed = true;
|
|
2232
|
+
}
|
|
2233
|
+
catch (_d) {
|
|
2234
|
+
this._securityPassed = false;
|
|
2235
|
+
this.stopListenTronEvent();
|
|
2236
|
+
this.setAddress(null);
|
|
2237
|
+
this.setState(tronwallet_abstract_adapter_1.AdapterState.Disconnect);
|
|
2238
|
+
clearTimeout(timer);
|
|
2239
|
+
resolve(true);
|
|
2240
|
+
return;
|
|
2241
|
+
}
|
|
1845
2242
|
this.setState(state);
|
|
1846
2243
|
this.setAddress(address);
|
|
1847
2244
|
this.emit('readyStateChanged', this.readyState);
|
|
@@ -1852,7 +2249,7 @@
|
|
|
1852
2249
|
this.checkForWalletReady();
|
|
1853
2250
|
}
|
|
1854
2251
|
}
|
|
1855
|
-
};
|
|
2252
|
+
});
|
|
1856
2253
|
window.addEventListener(tronwallet_abstract_adapter_2.TIP6963AnnounceProviderEventName, handler);
|
|
1857
2254
|
window.dispatchEvent(new Event(tronwallet_abstract_adapter_2.TIP6963RequestProviderEventName));
|
|
1858
2255
|
});
|
|
@@ -1890,7 +2287,7 @@
|
|
|
1890
2287
|
}
|
|
1891
2288
|
}
|
|
1892
2289
|
}
|
|
1893
|
-
exports.TokenPocketAdapter = TokenPocketAdapter;
|
|
2290
|
+
exports$1.TokenPocketAdapter = TokenPocketAdapter;
|
|
1894
2291
|
|
|
1895
2292
|
} (adapter$2));
|
|
1896
2293
|
return adapter$2;
|
|
@@ -1901,7 +2298,7 @@
|
|
|
1901
2298
|
function requireCjs () {
|
|
1902
2299
|
if (hasRequiredCjs) return cjs$2;
|
|
1903
2300
|
hasRequiredCjs = 1;
|
|
1904
|
-
(function (exports) {
|
|
2301
|
+
(function (exports$1) {
|
|
1905
2302
|
var __createBinding = (cjs$2 && cjs$2.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
1906
2303
|
if (k2 === undefined) k2 = k;
|
|
1907
2304
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -1913,12 +2310,12 @@
|
|
|
1913
2310
|
if (k2 === undefined) k2 = k;
|
|
1914
2311
|
o[k2] = m[k];
|
|
1915
2312
|
}));
|
|
1916
|
-
var __exportStar = (cjs$2 && cjs$2.__exportStar) || function(m, exports) {
|
|
1917
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
2313
|
+
var __exportStar = (cjs$2 && cjs$2.__exportStar) || function(m, exports$1) {
|
|
2314
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$1, p)) __createBinding(exports$1, m, p);
|
|
1918
2315
|
};
|
|
1919
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1920
|
-
__exportStar(
|
|
1921
|
-
__exportStar(
|
|
2316
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
2317
|
+
__exportStar(requireAdapter(), exports$1);
|
|
2318
|
+
__exportStar(requireUtils(), exports$1);
|
|
1922
2319
|
|
|
1923
2320
|
} (cjs$2));
|
|
1924
2321
|
return cjs$2;
|