@subwallet/extension-base 1.0.2-3 → 1.0.4-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/background/KoniTypes.d.ts +10 -2
- package/background/KoniTypes.js +3 -1
- package/cjs/background/KoniTypes.js +3 -1
- package/cjs/koni/background/handlers/Extension.js +9 -0
- package/cjs/koni/background/handlers/State.js +8 -1
- package/cjs/koni/background/subscription.js +24 -2
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/base/types.js +20 -0
- package/cjs/services/chain-service/constants.js +17 -2
- package/cjs/services/chain-service/index.js +57 -18
- package/cjs/services/history-service/index.js +84 -39
- package/cjs/services/migration-service/scripts/MigrateImportedToken.js +2 -1
- package/cjs/services/price-service/index.js +71 -23
- package/cjs/services/storage-service/DatabaseService.js +10 -0
- package/cjs/services/storage-service/db-stores/Transaction.js +6 -10
- package/cjs/services/transaction-service/index.js +78 -33
- package/cjs/services/transaction-service/utils.js +10 -8
- package/cjs/utils/promise.js +26 -0
- package/koni/background/handlers/Extension.d.ts +1 -0
- package/koni/background/handlers/Extension.js +9 -0
- package/koni/background/handlers/State.js +8 -1
- package/koni/background/subscription.d.ts +2 -0
- package/koni/background/subscription.js +23 -2
- package/package.json +22 -12
- package/packageInfo.js +1 -1
- package/services/base/types.d.ts +34 -0
- package/services/base/types.js +15 -0
- package/services/chain-service/constants.d.ts +6 -0
- package/services/chain-service/constants.js +10 -1
- package/services/chain-service/index.d.ts +3 -0
- package/services/chain-service/index.js +59 -20
- package/services/history-service/index.d.ts +24 -5
- package/services/history-service/index.js +84 -39
- package/services/migration-service/scripts/MigrateImportedToken.js +2 -1
- package/services/price-service/index.d.ts +22 -1
- package/services/price-service/index.js +71 -23
- package/services/storage-service/DatabaseService.d.ts +1 -0
- package/services/storage-service/DatabaseService.js +10 -0
- package/services/storage-service/db-stores/Transaction.d.ts +2 -0
- package/services/storage-service/db-stores/Transaction.js +6 -10
- package/services/transaction-service/index.d.ts +2 -0
- package/services/transaction-service/index.js +60 -17
- package/services/transaction-service/types.d.ts +2 -0
- package/services/transaction-service/utils.js +10 -8
- package/utils/promise.d.ts +6 -0
- package/utils/promise.js +20 -0
- /package/cjs/services/chain-service/{heath-check → health-check}/index.js +0 -0
- /package/services/chain-service/{heath-check → health-check}/index.d.ts +0 -0
- /package/services/chain-service/{heath-check → health-check}/index.js +0 -0
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { CRON_REFRESH_PRICE_INTERVAL } from '@subwallet/extension-base/constants';
|
|
5
|
+
import { ServiceStatus } from '@subwallet/extension-base/services/base/types';
|
|
5
6
|
import { getTokenPrice } from '@subwallet/extension-base/services/price-service/coingecko';
|
|
7
|
+
import { createPromiseHandler } from '@subwallet/extension-base/utils/promise';
|
|
6
8
|
import { BehaviorSubject } from 'rxjs';
|
|
7
9
|
const DEFAULT_PRICE_SUBJECT = {
|
|
8
10
|
ready: false,
|
|
@@ -14,34 +16,14 @@ export class PriceService {
|
|
|
14
16
|
priceSubject = new BehaviorSubject(DEFAULT_PRICE_SUBJECT);
|
|
15
17
|
priceIds = new Set();
|
|
16
18
|
constructor(dbService, eventService, chainService) {
|
|
19
|
+
this.status = ServiceStatus.NOT_INITIALIZED;
|
|
17
20
|
this.dbService = dbService;
|
|
18
21
|
this.eventService = eventService;
|
|
19
22
|
this.chainService = chainService;
|
|
20
|
-
|
|
21
|
-
// Fetch data from storage
|
|
22
|
-
this.getPrice().catch(console.error);
|
|
23
|
-
const eventHandler = () => {
|
|
24
|
-
const newPriceIds = this.getPriceIds();
|
|
25
|
-
|
|
26
|
-
// Compare two set newPriceIds and this.priceIds
|
|
27
|
-
if (newPriceIds.size !== this.priceIds.size || !Array.from(newPriceIds).every(v => this.priceIds.has(v))) {
|
|
28
|
-
this.priceIds = newPriceIds;
|
|
29
|
-
this.refreshPriceData(this.priceIds);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
this.eventService.waitAssetReady.then(() => {
|
|
33
|
-
this.refreshPriceData();
|
|
34
|
-
this.eventService.on('asset.updateState', eventHandler);
|
|
35
|
-
this.eventService.on('asset.updateState', eventHandler);
|
|
36
|
-
}).catch(console.error);
|
|
23
|
+
this.init().catch(console.error);
|
|
37
24
|
}
|
|
38
25
|
async getPrice() {
|
|
39
|
-
|
|
40
|
-
if (!isReady) {
|
|
41
|
-
const data = await this.dbService.getPriceStore();
|
|
42
|
-
this.priceSubject.next(data || DEFAULT_PRICE_SUBJECT);
|
|
43
|
-
}
|
|
44
|
-
return this.priceSubject.value;
|
|
26
|
+
return Promise.resolve(this.priceSubject.value);
|
|
45
27
|
}
|
|
46
28
|
getPriceSubject() {
|
|
47
29
|
return this.priceSubject;
|
|
@@ -65,4 +47,70 @@ export class PriceService {
|
|
|
65
47
|
}).catch(console.error);
|
|
66
48
|
this.refreshTimeout = setTimeout(this.refreshPriceData.bind(this), CRON_REFRESH_PRICE_INTERVAL);
|
|
67
49
|
}
|
|
50
|
+
async init() {
|
|
51
|
+
this.status = ServiceStatus.INITIALIZING;
|
|
52
|
+
// Fetch data from storage
|
|
53
|
+
await this.loadData();
|
|
54
|
+
const eventHandler = () => {
|
|
55
|
+
const newPriceIds = this.getPriceIds();
|
|
56
|
+
|
|
57
|
+
// Compare two set newPriceIds and this.priceIds
|
|
58
|
+
if (newPriceIds.size !== this.priceIds.size || !Array.from(newPriceIds).every(v => this.priceIds.has(v))) {
|
|
59
|
+
this.priceIds = newPriceIds;
|
|
60
|
+
this.refreshPriceData(this.priceIds);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
await this.eventService.waitAssetReady;
|
|
64
|
+
this.status = ServiceStatus.INITIALIZED;
|
|
65
|
+
this.eventService.on('asset.updateState', eventHandler);
|
|
66
|
+
this.eventService.on('asset.updateState', eventHandler);
|
|
67
|
+
}
|
|
68
|
+
async loadData() {
|
|
69
|
+
const data = await this.dbService.getPriceStore();
|
|
70
|
+
this.priceSubject.next(data || DEFAULT_PRICE_SUBJECT);
|
|
71
|
+
}
|
|
72
|
+
async persistData() {
|
|
73
|
+
await this.dbService.updatePriceStore(this.priceSubject.value).catch(console.error);
|
|
74
|
+
}
|
|
75
|
+
startPromiseHandler = createPromiseHandler();
|
|
76
|
+
async start() {
|
|
77
|
+
console.debug('Start price service');
|
|
78
|
+
try {
|
|
79
|
+
this.startPromiseHandler = createPromiseHandler();
|
|
80
|
+
this.status = ServiceStatus.STARTING;
|
|
81
|
+
await this.startCron();
|
|
82
|
+
this.status = ServiceStatus.STARTED;
|
|
83
|
+
this.startPromiseHandler.resolve();
|
|
84
|
+
} catch (e) {
|
|
85
|
+
this.startPromiseHandler.reject(e);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
async startCron() {
|
|
89
|
+
this.refreshPriceData();
|
|
90
|
+
return Promise.resolve();
|
|
91
|
+
}
|
|
92
|
+
stopPromiseHandler = createPromiseHandler();
|
|
93
|
+
async stop() {
|
|
94
|
+
console.debug('Stop price service');
|
|
95
|
+
try {
|
|
96
|
+
this.status = ServiceStatus.STOPPING;
|
|
97
|
+
this.stopPromiseHandler = createPromiseHandler();
|
|
98
|
+
await this.stopCron();
|
|
99
|
+
await this.persistData();
|
|
100
|
+
this.status = ServiceStatus.STOPPED;
|
|
101
|
+
this.stopPromiseHandler.resolve();
|
|
102
|
+
} catch (e) {
|
|
103
|
+
this.stopPromiseHandler.reject(e);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
stopCron() {
|
|
107
|
+
clearTimeout(this.refreshTimeout);
|
|
108
|
+
return Promise.resolve(undefined);
|
|
109
|
+
}
|
|
110
|
+
waitForStarted() {
|
|
111
|
+
return this.startPromiseHandler.promise;
|
|
112
|
+
}
|
|
113
|
+
waitForStopped() {
|
|
114
|
+
return this.stopPromiseHandler.promise;
|
|
115
|
+
}
|
|
68
116
|
}
|
|
@@ -41,6 +41,7 @@ export default class DatabaseService {
|
|
|
41
41
|
subscribeNominatorMetadata(callback: (data: NominatorMetadata[]) => void): void;
|
|
42
42
|
getHistories(query?: HistoryQuery): Promise<import("@subwallet/extension-base/services/storage-service/databases").ITransactionHistoryItem[]>;
|
|
43
43
|
upsertHistory(histories: TransactionHistoryItem[]): Promise<unknown>;
|
|
44
|
+
updateHistoryByNewExtrinsicHash(extrinsicHash: string, updateData: Partial<TransactionHistoryItem>): Promise<unknown>;
|
|
44
45
|
addNftCollection(collection: NftCollection): Promise<unknown>;
|
|
45
46
|
deleteNftCollection(chain: string, collectionId: string): Promise<void>;
|
|
46
47
|
getAllNftCollection(chainHashes?: string[]): import("dexie").PromiseExtended<NftCollection[]>;
|
|
@@ -126,6 +126,16 @@ export default class DatabaseService {
|
|
|
126
126
|
const cleanedHistory = histories.filter(x => x && x.address && x.chain && x.extrinsicHash);
|
|
127
127
|
return this.stores.transaction.bulkUpsert(cleanedHistory);
|
|
128
128
|
}
|
|
129
|
+
async updateHistoryByNewExtrinsicHash(extrinsicHash, updateData) {
|
|
130
|
+
// this.logger.log('Updating transaction histories');
|
|
131
|
+
const canUpdate = updateData && extrinsicHash;
|
|
132
|
+
if (!canUpdate) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
return this.stores.transaction.updateWithQuery({
|
|
136
|
+
extrinsicHash
|
|
137
|
+
}, updateData);
|
|
138
|
+
}
|
|
129
139
|
|
|
130
140
|
// NFT Collection
|
|
131
141
|
async addNftCollection(collection) {
|
|
@@ -4,9 +4,11 @@ export interface HistoryQuery {
|
|
|
4
4
|
chain?: string;
|
|
5
5
|
address?: string;
|
|
6
6
|
extrinsicHash?: string;
|
|
7
|
+
transactionId?: string;
|
|
7
8
|
}
|
|
8
9
|
export default class TransactionStore extends BaseStoreWithAddressAndChain<ITransactionHistoryItem> {
|
|
9
10
|
getHistoryByAddressAsObject(address: string): Promise<ITransactionHistoryItem[]>;
|
|
10
11
|
queryHistory(query?: HistoryQuery): Promise<ITransactionHistoryItem[]>;
|
|
11
12
|
bulkUpsert(records: ITransactionHistoryItem[]): Promise<unknown>;
|
|
13
|
+
updateWithQuery(query: HistoryQuery, update: Partial<ITransactionHistoryItem>): Promise<unknown>;
|
|
12
14
|
}
|
|
@@ -29,16 +29,12 @@ export default class TransactionStore extends BaseStoreWithAddressAndChain {
|
|
|
29
29
|
}
|
|
30
30
|
async bulkUpsert(records) {
|
|
31
31
|
await this.table.bulkPut(records);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
// }).filter((item) => (item.origin === 'app' && record.origin !== 'app'))
|
|
39
|
-
// .delete();
|
|
40
|
-
// }));
|
|
41
|
-
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
async updateWithQuery(query, update) {
|
|
35
|
+
await this.table.where(query).modify(record => {
|
|
36
|
+
return Object.assign(record, update);
|
|
37
|
+
});
|
|
42
38
|
return true;
|
|
43
39
|
}
|
|
44
40
|
}
|
|
@@ -36,6 +36,8 @@ export default class TransactionService {
|
|
|
36
36
|
private updateTransaction;
|
|
37
37
|
private getTransactionLink;
|
|
38
38
|
private transactionToHistories;
|
|
39
|
+
private onSigned;
|
|
40
|
+
private onSend;
|
|
39
41
|
private onHasTransactionHash;
|
|
40
42
|
private handlePostProcessing;
|
|
41
43
|
private onSuccess;
|
|
@@ -37,7 +37,7 @@ export default class TransactionService {
|
|
|
37
37
|
return Object.values(this.transactions);
|
|
38
38
|
}
|
|
39
39
|
get processingTransactions() {
|
|
40
|
-
return this.allTransactions.filter(t => t.status === ExtrinsicStatus.
|
|
40
|
+
return this.allTransactions.filter(t => t.status === ExtrinsicStatus.QUEUED || t.status === ExtrinsicStatus.PROCESSING);
|
|
41
41
|
}
|
|
42
42
|
getTransaction(id) {
|
|
43
43
|
return this.transactions[id];
|
|
@@ -157,6 +157,7 @@ export default class TransactionService {
|
|
|
157
157
|
}
|
|
158
158
|
fillTransactionDefaultInfo(transaction) {
|
|
159
159
|
const isInternal = !transaction.url;
|
|
160
|
+
const transactionId = getTransactionId(transaction.chainType, transaction.chain, isInternal);
|
|
160
161
|
return {
|
|
161
162
|
...transaction,
|
|
162
163
|
createdAt: new Date(),
|
|
@@ -164,10 +165,10 @@ export default class TransactionService {
|
|
|
164
165
|
errors: transaction.errors || [],
|
|
165
166
|
warnings: transaction.warnings || [],
|
|
166
167
|
url: transaction.url || EXTENSION_REQUEST_URL,
|
|
167
|
-
status: ExtrinsicStatus.
|
|
168
|
+
status: ExtrinsicStatus.QUEUED,
|
|
168
169
|
isInternal,
|
|
169
|
-
id:
|
|
170
|
-
extrinsicHash:
|
|
170
|
+
id: transactionId,
|
|
171
|
+
extrinsicHash: transactionId
|
|
171
172
|
};
|
|
172
173
|
}
|
|
173
174
|
async addTransaction(inputTransaction) {
|
|
@@ -180,8 +181,6 @@ export default class TransactionService {
|
|
|
180
181
|
this.transactionSubject.next({
|
|
181
182
|
...transactions
|
|
182
183
|
});
|
|
183
|
-
|
|
184
|
-
// Send transaction
|
|
185
184
|
return await this.sendTransaction(transaction);
|
|
186
185
|
}
|
|
187
186
|
generateBeforeHandleResponseErrors(errors) {
|
|
@@ -208,7 +207,8 @@ export default class TransactionService {
|
|
|
208
207
|
validatedTransaction.warnings = [];
|
|
209
208
|
const emitter = await this.addTransaction(validatedTransaction);
|
|
210
209
|
await new Promise(resolve => {
|
|
211
|
-
emitter.on('
|
|
210
|
+
emitter.on('signed', data => {
|
|
211
|
+
validatedTransaction.id = data.id;
|
|
212
212
|
validatedTransaction.extrinsicHash = data.extrinsicHash;
|
|
213
213
|
resolve();
|
|
214
214
|
});
|
|
@@ -224,6 +224,12 @@ export default class TransactionService {
|
|
|
224
224
|
async sendTransaction(transaction) {
|
|
225
225
|
// Send Transaction
|
|
226
226
|
const emitter = transaction.chainType === 'substrate' ? this.signAndSendSubstrateTransaction(transaction) : await this.signAndSendEvmTransaction(transaction);
|
|
227
|
+
emitter.on('signed', data => {
|
|
228
|
+
this.onSigned(data);
|
|
229
|
+
});
|
|
230
|
+
emitter.on('send', data => {
|
|
231
|
+
this.onSend(data);
|
|
232
|
+
});
|
|
227
233
|
emitter.on('extrinsicHash', data => {
|
|
228
234
|
this.onHasTransactionHash(data);
|
|
229
235
|
});
|
|
@@ -276,7 +282,8 @@ export default class TransactionService {
|
|
|
276
282
|
to: '',
|
|
277
283
|
chainType: transaction.chainType,
|
|
278
284
|
address: transaction.address,
|
|
279
|
-
status:
|
|
285
|
+
status: transaction.status,
|
|
286
|
+
transactionId: transaction.id,
|
|
280
287
|
extrinsicHash: transaction.extrinsicHash,
|
|
281
288
|
time: transaction.createdAt.getTime(),
|
|
282
289
|
fee: transaction.estimateFee,
|
|
@@ -419,8 +426,14 @@ export default class TransactionService {
|
|
|
419
426
|
break;
|
|
420
427
|
}
|
|
421
428
|
case ExtrinsicType.EVM_EXECUTE:
|
|
422
|
-
|
|
423
|
-
|
|
429
|
+
{
|
|
430
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
431
|
+
const data = parseTransactionData(transaction.data);
|
|
432
|
+
|
|
433
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access
|
|
434
|
+
historyItem.to = (data === null || data === void 0 ? void 0 : data.to) || '';
|
|
435
|
+
break;
|
|
436
|
+
}
|
|
424
437
|
case ExtrinsicType.UNKNOWN:
|
|
425
438
|
break;
|
|
426
439
|
}
|
|
@@ -439,17 +452,36 @@ export default class TransactionService {
|
|
|
439
452
|
}
|
|
440
453
|
return [historyItem];
|
|
441
454
|
}
|
|
455
|
+
onSigned({
|
|
456
|
+
id
|
|
457
|
+
}) {
|
|
458
|
+
console.log(`Transaction "${id}" is signed`);
|
|
459
|
+
}
|
|
460
|
+
onSend({
|
|
461
|
+
id
|
|
462
|
+
}) {
|
|
463
|
+
// Update transaction status
|
|
464
|
+
this.updateTransaction(id, {
|
|
465
|
+
status: ExtrinsicStatus.SUBMITTING
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
// Create Input History Transaction History
|
|
469
|
+
this.historyService.insertHistories(this.transactionToHistories(id)).catch(console.error);
|
|
470
|
+
console.log(`Transaction "${id}" is sent`);
|
|
471
|
+
}
|
|
442
472
|
onHasTransactionHash({
|
|
443
|
-
eventLogs,
|
|
444
473
|
extrinsicHash,
|
|
445
474
|
id
|
|
446
475
|
}) {
|
|
447
476
|
// Write processing transaction history
|
|
448
|
-
|
|
477
|
+
const updateData = {
|
|
449
478
|
extrinsicHash,
|
|
450
479
|
status: ExtrinsicStatus.PROCESSING
|
|
451
|
-
}
|
|
452
|
-
this.
|
|
480
|
+
};
|
|
481
|
+
this.updateTransaction(id, updateData);
|
|
482
|
+
|
|
483
|
+
// In this case transaction id is the same as extrinsic hash and will change after below update
|
|
484
|
+
this.historyService.updateHistoryByExtrinsicHash(id, updateData).catch(console.error);
|
|
453
485
|
console.log(`Transaction "${id}" is submitted with hash ${extrinsicHash || ''}`);
|
|
454
486
|
}
|
|
455
487
|
handlePostProcessing(id) {
|
|
@@ -513,16 +545,17 @@ export default class TransactionService {
|
|
|
513
545
|
id
|
|
514
546
|
}) {
|
|
515
547
|
const transaction = this.getTransaction(id);
|
|
548
|
+
const nextStatus = ExtrinsicStatus.FAIL;
|
|
516
549
|
if (transaction) {
|
|
517
550
|
this.updateTransaction(id, {
|
|
518
|
-
status:
|
|
551
|
+
status: nextStatus,
|
|
519
552
|
errors
|
|
520
553
|
});
|
|
521
554
|
console.log('Transaction failed', id, transaction.extrinsicHash);
|
|
522
555
|
|
|
523
556
|
// Write failed transaction history
|
|
524
557
|
this.historyService.updateHistories(transaction.chain, transaction.extrinsicHash, {
|
|
525
|
-
status:
|
|
558
|
+
status: nextStatus,
|
|
526
559
|
blockNumber: blockNumber || 0,
|
|
527
560
|
blockHash: blockHash || ''
|
|
528
561
|
}).catch(console.error);
|
|
@@ -642,6 +675,12 @@ export default class TransactionService {
|
|
|
642
675
|
}
|
|
643
676
|
signedTransaction = signed;
|
|
644
677
|
}
|
|
678
|
+
|
|
679
|
+
// Emit signed event
|
|
680
|
+
emitter.emit('signed', eventData);
|
|
681
|
+
|
|
682
|
+
// Send transaction
|
|
683
|
+
emitter.emit('send', eventData); // This event is needed after sending transaction with queue
|
|
645
684
|
signedTransaction && web3Api.eth.sendSignedTransaction(signedTransaction).once('transactionHash', hash => {
|
|
646
685
|
eventData.extrinsicHash = hash;
|
|
647
686
|
emitter.emit('extrinsicHash', eventData);
|
|
@@ -680,7 +719,6 @@ export default class TransactionService {
|
|
|
680
719
|
errors: [],
|
|
681
720
|
warnings: []
|
|
682
721
|
};
|
|
683
|
-
console.debug(address, transaction);
|
|
684
722
|
transaction.signAsync(address, {
|
|
685
723
|
signer: {
|
|
686
724
|
signPayload: async payload => {
|
|
@@ -692,6 +730,11 @@ export default class TransactionService {
|
|
|
692
730
|
}
|
|
693
731
|
}
|
|
694
732
|
}).then(rs => {
|
|
733
|
+
// Emit signed event
|
|
734
|
+
emitter.emit('signed', eventData);
|
|
735
|
+
|
|
736
|
+
// Send transaction
|
|
737
|
+
emitter.emit('send', eventData); // This event is needed after sending transaction with queue
|
|
695
738
|
rs.send(txState => {
|
|
696
739
|
// handle events, logs, history
|
|
697
740
|
if (!txState || !txState.status) {
|
|
@@ -41,6 +41,8 @@ export interface TransactionEventResponse extends ValidateTransactionResponse {
|
|
|
41
41
|
eventLogs?: EventRecord[];
|
|
42
42
|
}
|
|
43
43
|
export interface TransactionEventMap {
|
|
44
|
+
send: (response: TransactionEventResponse) => void;
|
|
45
|
+
signed: (response: TransactionEventResponse) => void;
|
|
44
46
|
extrinsicHash: (response: TransactionEventResponse) => void;
|
|
45
47
|
error: (response: TransactionEventResponse) => void;
|
|
46
48
|
success: (response: TransactionEventResponse) => void;
|
|
@@ -9,15 +9,17 @@ export function parseTransactionData(data) {
|
|
|
9
9
|
return data;
|
|
10
10
|
}
|
|
11
11
|
export function getTransactionLink(chainInfo, extrinsicHash) {
|
|
12
|
-
|
|
13
|
-
if (_isPureEvmChain(chainInfo)) {
|
|
14
|
-
if (explorerLink) {
|
|
15
|
-
return `${explorerLink}${explorerLink.endsWith('/') ? '' : '/'}tx/${extrinsicHash}`;
|
|
16
|
-
}
|
|
17
|
-
} else {
|
|
12
|
+
if (extrinsicHash.startsWith('0x')) {
|
|
18
13
|
const explorerLink = _getBlockExplorerFromChain(chainInfo);
|
|
19
|
-
if (
|
|
20
|
-
|
|
14
|
+
if (_isPureEvmChain(chainInfo)) {
|
|
15
|
+
if (explorerLink) {
|
|
16
|
+
return `${explorerLink}${explorerLink.endsWith('/') ? '' : '/'}tx/${extrinsicHash}`;
|
|
17
|
+
}
|
|
18
|
+
} else {
|
|
19
|
+
const explorerLink = _getBlockExplorerFromChain(chainInfo);
|
|
20
|
+
if (explorerLink) {
|
|
21
|
+
return `${explorerLink}${explorerLink.endsWith('/') ? '' : '/'}extrinsic/${extrinsicHash}`;
|
|
22
|
+
}
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
25
|
return undefined;
|
package/utils/promise.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export function createPromiseHandler() {
|
|
5
|
+
let _resolve = () => {
|
|
6
|
+
console.warn('This promise handler is not implemented');
|
|
7
|
+
};
|
|
8
|
+
let _reject = () => {
|
|
9
|
+
console.warn('This promise handler is not implemented');
|
|
10
|
+
};
|
|
11
|
+
const promise = new Promise((resolve, reject) => {
|
|
12
|
+
_resolve = resolve;
|
|
13
|
+
_reject = reject;
|
|
14
|
+
});
|
|
15
|
+
return {
|
|
16
|
+
resolve: _resolve,
|
|
17
|
+
reject: _reject,
|
|
18
|
+
promise
|
|
19
|
+
};
|
|
20
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|