@subwallet/extension-base 1.0.5-1 → 1.0.5-3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/background/KoniTypes.d.ts +2 -1
- package/cjs/koni/api/staking/bonding/relayChain.js +2 -7
- package/cjs/koni/api/staking/bonding/utils.js +9 -0
- package/cjs/koni/background/handlers/Extension.js +4 -2
- package/cjs/koni/background/handlers/Tabs.js +24 -23
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/chain-service/constants.js +2 -2
- package/cjs/services/chain-service/index.js +5 -0
- package/cjs/services/chain-service/utils.js +15 -10
- package/cjs/services/history-service/helpers/recoverHistoryStatus.js +157 -38
- package/cjs/services/history-service/index.js +26 -19
- package/cjs/services/history-service/subsquid-multi-chain-history.js +2 -2
- package/cjs/services/notification-service/NotificationService.js +1 -1
- package/cjs/services/storage-service/DatabaseService.js +1 -1
- package/cjs/services/transaction-service/index.js +41 -14
- package/cjs/services/transaction-service/utils.js +3 -0
- package/cjs/utils/index.js +3 -0
- package/koni/api/staking/bonding/relayChain.js +3 -8
- package/koni/api/staking/bonding/utils.d.ts +1 -0
- package/koni/api/staking/bonding/utils.js +8 -0
- package/koni/background/handlers/Extension.js +5 -3
- package/koni/background/handlers/Tabs.js +24 -23
- package/package.json +6 -6
- package/packageInfo.js +1 -1
- package/services/chain-service/constants.js +2 -2
- package/services/chain-service/index.js +5 -0
- package/services/chain-service/utils.d.ts +1 -0
- package/services/chain-service/utils.js +14 -10
- package/services/history-service/helpers/recoverHistoryStatus.d.ts +7 -1
- package/services/history-service/helpers/recoverHistoryStatus.js +151 -35
- package/services/history-service/index.d.ts +1 -1
- package/services/history-service/index.js +26 -19
- package/services/history-service/subsquid-multi-chain-history.js +2 -2
- package/services/notification-service/NotificationService.js +1 -1
- package/services/storage-service/DatabaseService.d.ts +1 -1
- package/services/storage-service/DatabaseService.js +1 -1
- package/services/transaction-service/index.js +41 -14
- package/services/transaction-service/types.d.ts +5 -3
- package/services/transaction-service/utils.js +3 -0
- package/utils/index.js +3 -0
|
@@ -168,8 +168,8 @@ class TransactionService {
|
|
|
168
168
|
const transactionId = (0, _helpers.getTransactionId)(transaction.chainType, transaction.chain, isInternal);
|
|
169
169
|
return {
|
|
170
170
|
...transaction,
|
|
171
|
-
createdAt: new Date(),
|
|
172
|
-
updatedAt: new Date(),
|
|
171
|
+
createdAt: new Date().getTime(),
|
|
172
|
+
updatedAt: new Date().getTime(),
|
|
173
173
|
errors: transaction.errors || [],
|
|
174
174
|
warnings: transaction.warnings || [],
|
|
175
175
|
url: transaction.url || _constants2.EXTENSION_REQUEST_URL,
|
|
@@ -210,6 +210,9 @@ class TransactionService {
|
|
|
210
210
|
const stopByErrors = validatedTransaction.errors.length > 0;
|
|
211
211
|
const stopByWarnings = validatedTransaction.warnings.length > 0 && !validatedTransaction.ignoreWarnings;
|
|
212
212
|
if (stopByErrors || stopByWarnings) {
|
|
213
|
+
// @ts-ignore
|
|
214
|
+
'transaction' in validatedTransaction && delete validatedTransaction.transaction;
|
|
215
|
+
'additionalValidator' in validatedTransaction && delete validatedTransaction.additionalValidator;
|
|
213
216
|
return validatedTransaction;
|
|
214
217
|
}
|
|
215
218
|
validatedTransaction.warnings = [];
|
|
@@ -227,6 +230,10 @@ class TransactionService {
|
|
|
227
230
|
}
|
|
228
231
|
});
|
|
229
232
|
});
|
|
233
|
+
|
|
234
|
+
// @ts-ignore
|
|
235
|
+
'transaction' in validatedTransaction && delete validatedTransaction.transaction;
|
|
236
|
+
'additionalValidator' in validatedTransaction && delete validatedTransaction.additionalValidator;
|
|
230
237
|
return validatedTransaction;
|
|
231
238
|
}
|
|
232
239
|
async sendTransaction(transaction) {
|
|
@@ -279,7 +286,7 @@ class TransactionService {
|
|
|
279
286
|
const chainInfo = this.chainService.getChainInfoByKey(transaction.chain);
|
|
280
287
|
return (0, _utils2.getExplorerLink)(chainInfo, transaction.extrinsicHash, 'tx');
|
|
281
288
|
}
|
|
282
|
-
transactionToHistories(id, eventLogs) {
|
|
289
|
+
transactionToHistories(id, startBlock, nonce, eventLogs) {
|
|
283
290
|
const transaction = this.getTransaction(id);
|
|
284
291
|
const historyItem = {
|
|
285
292
|
origin: 'app',
|
|
@@ -293,13 +300,15 @@ class TransactionService {
|
|
|
293
300
|
status: transaction.status,
|
|
294
301
|
transactionId: transaction.id,
|
|
295
302
|
extrinsicHash: transaction.extrinsicHash,
|
|
296
|
-
time: transaction.createdAt
|
|
303
|
+
time: transaction.createdAt,
|
|
297
304
|
fee: transaction.estimateFee,
|
|
298
305
|
blockNumber: 0,
|
|
299
306
|
// Will be added in next step
|
|
300
|
-
blockHash: ''
|
|
307
|
+
blockHash: '',
|
|
308
|
+
// Will be added in next step
|
|
309
|
+
nonce: nonce || 0,
|
|
310
|
+
startBlock: startBlock || 0
|
|
301
311
|
};
|
|
302
|
-
|
|
303
312
|
const chainInfo = this.chainService.getChainInfoByKey(transaction.chain);
|
|
304
313
|
const nativeAsset = (0, _utils._getChainNativeTokenBasicInfo)(chainInfo);
|
|
305
314
|
const baseNativeAmount = {
|
|
@@ -468,7 +477,9 @@ class TransactionService {
|
|
|
468
477
|
}
|
|
469
478
|
onSend(_ref2) {
|
|
470
479
|
let {
|
|
471
|
-
id
|
|
480
|
+
id,
|
|
481
|
+
nonce,
|
|
482
|
+
startBlock
|
|
472
483
|
} = _ref2;
|
|
473
484
|
// Update transaction status
|
|
474
485
|
this.updateTransaction(id, {
|
|
@@ -476,7 +487,7 @@ class TransactionService {
|
|
|
476
487
|
});
|
|
477
488
|
|
|
478
489
|
// Create Input History Transaction History
|
|
479
|
-
this.historyService.insertHistories(this.transactionToHistories(id)).catch(console.error);
|
|
490
|
+
this.historyService.insertHistories(this.transactionToHistories(id, startBlock, nonce)).catch(console.error);
|
|
480
491
|
console.debug(`Transaction "${id}" is sent`);
|
|
481
492
|
}
|
|
482
493
|
onHasTransactionHash(_ref3) {
|
|
@@ -527,15 +538,18 @@ class TransactionService {
|
|
|
527
538
|
let {
|
|
528
539
|
blockHash,
|
|
529
540
|
blockNumber,
|
|
541
|
+
extrinsicHash,
|
|
530
542
|
id
|
|
531
543
|
} = _ref4;
|
|
532
544
|
const transaction = this.getTransaction(id);
|
|
533
545
|
this.updateTransaction(id, {
|
|
534
|
-
status: _KoniTypes.ExtrinsicStatus.SUCCESS
|
|
546
|
+
status: _KoniTypes.ExtrinsicStatus.SUCCESS,
|
|
547
|
+
extrinsicHash
|
|
535
548
|
});
|
|
536
549
|
|
|
537
550
|
// Write success transaction history
|
|
538
|
-
this.historyService.
|
|
551
|
+
this.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
552
|
+
extrinsicHash,
|
|
539
553
|
status: _KoniTypes.ExtrinsicStatus.SUCCESS,
|
|
540
554
|
blockNumber: blockNumber || 0,
|
|
541
555
|
blockHash: blockHash || ''
|
|
@@ -556,6 +570,7 @@ class TransactionService {
|
|
|
556
570
|
blockHash,
|
|
557
571
|
blockNumber,
|
|
558
572
|
errors,
|
|
573
|
+
extrinsicHash,
|
|
559
574
|
id
|
|
560
575
|
} = _ref5;
|
|
561
576
|
const transaction = this.getTransaction(id);
|
|
@@ -563,11 +578,13 @@ class TransactionService {
|
|
|
563
578
|
if (transaction) {
|
|
564
579
|
this.updateTransaction(id, {
|
|
565
580
|
status: nextStatus,
|
|
566
|
-
errors
|
|
581
|
+
errors,
|
|
582
|
+
extrinsicHash
|
|
567
583
|
});
|
|
568
584
|
|
|
569
585
|
// Write failed transaction history
|
|
570
|
-
this.historyService.
|
|
586
|
+
this.historyService.updateHistoryByExtrinsicHash(transaction.extrinsicHash, {
|
|
587
|
+
extrinsicHash: extrinsicHash || transaction.extrinsicHash,
|
|
571
588
|
status: nextStatus,
|
|
572
589
|
blockNumber: blockNumber || 0,
|
|
573
590
|
blockHash: blockHash || ''
|
|
@@ -667,7 +684,7 @@ class TransactionService {
|
|
|
667
684
|
errors: [],
|
|
668
685
|
warnings: []
|
|
669
686
|
};
|
|
670
|
-
this.requestService.addConfirmation(id, url || _constants2.EXTENSION_REQUEST_URL, 'evmSendTransactionRequest', payload, {}).then(_ref7 => {
|
|
687
|
+
this.requestService.addConfirmation(id, url || _constants2.EXTENSION_REQUEST_URL, 'evmSendTransactionRequest', payload, {}).then(async _ref7 => {
|
|
671
688
|
let {
|
|
672
689
|
isApproved,
|
|
673
690
|
payload
|
|
@@ -694,11 +711,16 @@ class TransactionService {
|
|
|
694
711
|
|
|
695
712
|
// Send transaction
|
|
696
713
|
this.handleTransactionTimeout(emitter, eventData);
|
|
714
|
+
|
|
715
|
+
// Add start info
|
|
716
|
+
eventData.nonce = txObject.nonce;
|
|
717
|
+
eventData.startBlock = await web3Api.eth.getBlockNumber();
|
|
697
718
|
emitter.emit('send', eventData); // This event is needed after sending transaction with queue
|
|
698
719
|
signedTransaction && web3Api.eth.sendSignedTransaction(signedTransaction).once('transactionHash', hash => {
|
|
699
720
|
eventData.extrinsicHash = hash;
|
|
700
721
|
emitter.emit('extrinsicHash', eventData);
|
|
701
722
|
}).once('receipt', rs => {
|
|
723
|
+
eventData.extrinsicHash = rs.transactionHash;
|
|
702
724
|
eventData.blockHash = rs.blockHash;
|
|
703
725
|
eventData.blockNumber = rs.blockNumber;
|
|
704
726
|
emitter.emit('success', eventData);
|
|
@@ -724,6 +746,7 @@ class TransactionService {
|
|
|
724
746
|
signAndSendSubstrateTransaction(_ref8) {
|
|
725
747
|
let {
|
|
726
748
|
address,
|
|
749
|
+
chain,
|
|
727
750
|
id,
|
|
728
751
|
transaction,
|
|
729
752
|
url
|
|
@@ -744,11 +767,14 @@ class TransactionService {
|
|
|
744
767
|
};
|
|
745
768
|
}
|
|
746
769
|
}
|
|
747
|
-
}).then(rs => {
|
|
770
|
+
}).then(async rs => {
|
|
748
771
|
// Emit signed event
|
|
749
772
|
emitter.emit('signed', eventData);
|
|
750
773
|
|
|
751
774
|
// Send transaction
|
|
775
|
+
const api = this.chainService.getSubstrateApi(chain);
|
|
776
|
+
eventData.nonce = rs.nonce.toNumber();
|
|
777
|
+
eventData.startBlock = (await api.api.query.system.number()).toPrimitive();
|
|
752
778
|
this.handleTransactionTimeout(emitter, eventData);
|
|
753
779
|
emitter.emit('send', eventData); // This event is needed after sending transaction with queue
|
|
754
780
|
|
|
@@ -766,6 +792,7 @@ class TransactionService {
|
|
|
766
792
|
}
|
|
767
793
|
}
|
|
768
794
|
if (txState.status.isFinalized) {
|
|
795
|
+
eventData.extrinsicHash = txState.txHash.toHex();
|
|
769
796
|
eventData.eventLogs = txState.events;
|
|
770
797
|
// TODO: push block hash and block number into eventData
|
|
771
798
|
txState.events.filter(_ref9 => {
|
|
@@ -27,6 +27,9 @@ function getBlockExplorerTxRoute(chainInfo) {
|
|
|
27
27
|
if ((0, _utils._isPureEvmChain)(chainInfo)) {
|
|
28
28
|
return 'tx';
|
|
29
29
|
}
|
|
30
|
+
if (['aventus'].includes(chainInfo.slug)) {
|
|
31
|
+
return 'transaction';
|
|
32
|
+
}
|
|
30
33
|
return 'extrinsic';
|
|
31
34
|
}
|
|
32
35
|
function getExplorerLink(chainInfo, value, type) {
|
package/cjs/utils/index.js
CHANGED
|
@@ -56,6 +56,9 @@ function reformatAddress(address) {
|
|
|
56
56
|
let networkPrefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 42;
|
|
57
57
|
let isEthereum = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
58
58
|
try {
|
|
59
|
+
if (!address || address === '') {
|
|
60
|
+
return '';
|
|
61
|
+
}
|
|
59
62
|
if ((0, _utilCrypto.isEthereumAddress)(address)) {
|
|
60
63
|
return address;
|
|
61
64
|
}
|
|
@@ -5,7 +5,7 @@ import { TransactionError } from '@subwallet/extension-base/background/errors/Tr
|
|
|
5
5
|
import { StakingStatus, StakingTxErrorType, StakingType, UnstakingStatus } from '@subwallet/extension-base/background/KoniTypes';
|
|
6
6
|
import { calculateAlephZeroValidatorReturn, calculateChainStakedReturn, calculateInflation, calculateValidatorStakedReturn, getCommission, parseIdentity, parsePoolStashAddress, transformPoolName } from '@subwallet/extension-base/koni/api/staking/bonding/utils';
|
|
7
7
|
import { _STAKING_CHAIN_GROUP, _STAKING_ERA_LENGTH_MAP } from '@subwallet/extension-base/services/chain-service/constants';
|
|
8
|
-
import {
|
|
8
|
+
import { _getChainSubstrateAddressPrefix } from '@subwallet/extension-base/services/chain-service/utils';
|
|
9
9
|
import { reformatAddress } from '@subwallet/extension-base/utils';
|
|
10
10
|
import { BN, BN_ZERO } from '@polkadot/util';
|
|
11
11
|
import { isEthereumAddress } from '@polkadot/util-crypto';
|
|
@@ -13,7 +13,7 @@ export function validateRelayUnbondingCondition(amount, chainStakingMetadata, no
|
|
|
13
13
|
const errors = [];
|
|
14
14
|
const bnActiveStake = new BN(nominatorMetadata.activeStake);
|
|
15
15
|
const bnRemainingStake = bnActiveStake.sub(new BN(amount));
|
|
16
|
-
const minStake = new BN(chainStakingMetadata.
|
|
16
|
+
const minStake = new BN(chainStakingMetadata.minJoinNominationPool || '0');
|
|
17
17
|
if (!(bnRemainingStake.isZero() || bnRemainingStake.gte(minStake))) {
|
|
18
18
|
errors.push(new TransactionError(StakingTxErrorType.INVALID_ACTIVE_STAKE));
|
|
19
19
|
}
|
|
@@ -27,7 +27,7 @@ export function validatePoolBondingCondition(chainInfo, amount, selectedPool, ad
|
|
|
27
27
|
// amount >= min stake
|
|
28
28
|
const errors = [];
|
|
29
29
|
let bnTotalStake = new BN(amount);
|
|
30
|
-
const bnMinStake = new BN(chainStakingMetadata.
|
|
30
|
+
const bnMinStake = new BN(chainStakingMetadata.minJoinNominationPool || '0');
|
|
31
31
|
if (selectedPool.state !== 'Open') {
|
|
32
32
|
errors.push(new TransactionError(StakingTxErrorType.INACTIVE_NOMINATION_POOL));
|
|
33
33
|
}
|
|
@@ -69,9 +69,6 @@ export function validateRelayBondingCondition(chainInfo, amount, selectedValidat
|
|
|
69
69
|
export async function getRelayChainStakingMetadata(chainInfo, substrateApi) {
|
|
70
70
|
var _chainApi$api$query$a, _chainApi$api$query, _chainApi$api$query$s, _chainApi$api$query2, _chainApi$api$query2$, _chainApi$api$query3, _chainApi$api$query3$;
|
|
71
71
|
const chain = chainInfo.slug;
|
|
72
|
-
const {
|
|
73
|
-
decimals
|
|
74
|
-
} = _getChainNativeTokenBasicInfo(chainInfo);
|
|
75
72
|
const chainApi = await substrateApi.isReady;
|
|
76
73
|
const _era = await chainApi.api.query.staking.currentEra();
|
|
77
74
|
const currentEra = _era.toString();
|
|
@@ -115,8 +112,6 @@ export async function getRelayChainStakingMetadata(chainInfo, substrateApi) {
|
|
|
115
112
|
// in %, annually
|
|
116
113
|
inflation,
|
|
117
114
|
minStake: minStake.toString(),
|
|
118
|
-
minPoolBonding: (10 ** decimals).toString(),
|
|
119
|
-
// default is 1
|
|
120
115
|
maxValidatorPerNominator: parseInt(maxNominations),
|
|
121
116
|
maxWithdrawalRequestPerValidator: parseInt(maxUnlockingChunks),
|
|
122
117
|
allowCancelUnstaking: true,
|
|
@@ -153,3 +153,4 @@ export declare function getStakingAvailableActionsByNominator(nominatorMetadata:
|
|
|
153
153
|
export declare function isActionFromValidator(stakingType: StakingType, chain: string): boolean;
|
|
154
154
|
export declare function getWithdrawalInfo(nominatorMetadata: NominatorMetadata): UnstakingInfo | undefined;
|
|
155
155
|
export declare function getStakingStatusByNominations(bnTotalActiveStake: BN, nominationList: NominationInfo[]): StakingStatus;
|
|
156
|
+
export declare function getValidatorLabel(chain: string): "dApp" | "Validator" | "Collator";
|
|
@@ -241,4 +241,12 @@ export function getStakingStatusByNominations(bnTotalActiveStake, nominationList
|
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
243
|
return stakingStatus;
|
|
244
|
+
}
|
|
245
|
+
export function getValidatorLabel(chain) {
|
|
246
|
+
if (_STAKING_CHAIN_GROUP.astar.includes(chain)) {
|
|
247
|
+
return 'dApp';
|
|
248
|
+
} else if (_STAKING_CHAIN_GROUP.relay.includes(chain)) {
|
|
249
|
+
return 'Validator';
|
|
250
|
+
}
|
|
251
|
+
return 'Collator';
|
|
244
252
|
}
|
|
@@ -18,7 +18,7 @@ import { getPoolingBondingExtrinsic, getPoolingUnbondingExtrinsic, validatePoolB
|
|
|
18
18
|
import { getERC20TransactionObject, getERC721Transaction, getEVMTransactionObject } from '@subwallet/extension-base/koni/api/tokens/evm/transfer';
|
|
19
19
|
import { getPSP34TransferExtrinsic } from '@subwallet/extension-base/koni/api/tokens/wasm';
|
|
20
20
|
import { createXcmExtrinsic } from '@subwallet/extension-base/koni/api/xcm';
|
|
21
|
-
import { _getChainNativeTokenBasicInfo, _getContractAddressOfToken, _getEvmChainId, _getSubstrateGenesisHash, _getTokenMinAmount, _isAssetSmartContractNft, _isChainEvmCompatible, _isCustomAsset, _isLocalToken, _isNativeToken, _isTokenEvmSmartContract } from '@subwallet/extension-base/services/chain-service/utils';
|
|
21
|
+
import { _getChainNativeTokenBasicInfo, _getContractAddressOfToken, _getEvmChainId, _getSubstrateGenesisHash, _getTokenMinAmount, _isAssetSmartContractNft, _isChainEvmCompatible, _isCustomAsset, _isLocalToken, _isNativeToken, _isTokenEvmSmartContract, _isTokenTransferredByEvm } from '@subwallet/extension-base/services/chain-service/utils';
|
|
22
22
|
import { EXTENSION_REQUEST_URL } from '@subwallet/extension-base/services/request-service/constants';
|
|
23
23
|
import { DEFAULT_AUTO_LOCK_TIME } from '@subwallet/extension-base/services/setting-service/constants';
|
|
24
24
|
import { reformatAddress } from '@subwallet/extension-base/utils';
|
|
@@ -1251,7 +1251,7 @@ export default class KoniExtension {
|
|
|
1251
1251
|
const isPasswordValidated = this.validatedAccountsPassword(file, password);
|
|
1252
1252
|
if (isPasswordValidated) {
|
|
1253
1253
|
try {
|
|
1254
|
-
this._saveCurrentAccountAddress(
|
|
1254
|
+
this._saveCurrentAccountAddress(ALL_ACCOUNT_KEY, () => {
|
|
1255
1255
|
keyring.restoreAccounts(file, password);
|
|
1256
1256
|
this._addAddressesToAuthList(addressList, isAllowed);
|
|
1257
1257
|
});
|
|
@@ -1398,7 +1398,8 @@ export default class KoniExtension {
|
|
|
1398
1398
|
|
|
1399
1399
|
// Get native token amount
|
|
1400
1400
|
const freeBalance = await this.#koniState.balanceService.getTokenFreeBalance(from, networkKey, tokenSlug);
|
|
1401
|
-
if (isEthereumAddress(from) && isEthereumAddress(to)) {
|
|
1401
|
+
if (isEthereumAddress(from) && isEthereumAddress(to) && _isTokenTransferredByEvm(tokenInfo)) {
|
|
1402
|
+
// TODO: review this
|
|
1402
1403
|
chainType = ChainType.EVM;
|
|
1403
1404
|
const txVal = transferAll ? freeBalance.value : value || '0';
|
|
1404
1405
|
|
|
@@ -2837,6 +2838,7 @@ export default class KoniExtension {
|
|
|
2837
2838
|
function convertRs(rs) {
|
|
2838
2839
|
return Object.fromEntries(Object.entries(rs).map(([key, value]) => {
|
|
2839
2840
|
const {
|
|
2841
|
+
additionalValidator,
|
|
2840
2842
|
transaction,
|
|
2841
2843
|
...transactionResult
|
|
2842
2844
|
} = value;
|
|
@@ -401,35 +401,36 @@ export default class KoniTabs {
|
|
|
401
401
|
const chainIdNum = parseInt(chainId, 16);
|
|
402
402
|
const [existedNetworkSlug, existedChainInfo] = this.#koniState.findNetworkKeyByChainId(chainIdNum);
|
|
403
403
|
if (existedNetworkSlug && existedChainInfo && existedChainInfo !== null && existedChainInfo !== void 0 && existedChainInfo.evmInfo) {
|
|
404
|
-
const evmInfo = existedChainInfo.evmInfo;
|
|
405
|
-
const substrateInfo = existedChainInfo.substrateInfo;
|
|
406
|
-
const chainState = this.#koniState.getChainStateByKey(existedNetworkSlug);
|
|
407
|
-
await this.#koniState.addNetworkConfirm(id, url, {
|
|
408
|
-
mode: 'update',
|
|
409
|
-
chainSpec: {
|
|
410
|
-
evmChainId: evmInfo.evmChainId,
|
|
411
|
-
decimals: evmInfo.decimals,
|
|
412
|
-
existentialDeposit: evmInfo.existentialDeposit,
|
|
413
|
-
genesisHash: (substrateInfo === null || substrateInfo === void 0 ? void 0 : substrateInfo.genesisHash) || '',
|
|
414
|
-
paraId: (substrateInfo === null || substrateInfo === void 0 ? void 0 : substrateInfo.paraId) || null,
|
|
415
|
-
addressPrefix: (substrateInfo === null || substrateInfo === void 0 ? void 0 : substrateInfo.addressPrefix) || 0
|
|
416
|
-
},
|
|
417
|
-
chainEditInfo: {
|
|
418
|
-
blockExplorer: blockExplorerUrls === null || blockExplorerUrls === void 0 ? void 0 : blockExplorerUrls[0],
|
|
419
|
-
slug: existedNetworkSlug,
|
|
420
|
-
currentProvider: chainState.currentProvider,
|
|
421
|
-
providers: existedChainInfo.providers,
|
|
422
|
-
symbol: evmInfo.symbol,
|
|
423
|
-
chainType: 'EVM',
|
|
424
|
-
name: existedChainInfo.name
|
|
425
|
-
}
|
|
426
|
-
});
|
|
427
404
|
return await this.switchEvmChain(id, url, {
|
|
428
405
|
method: 'wallet_switchEthereumChain',
|
|
429
406
|
params: [{
|
|
430
407
|
chainId
|
|
431
408
|
}]
|
|
432
409
|
});
|
|
410
|
+
// const evmInfo = existedChainInfo.evmInfo;
|
|
411
|
+
// const substrateInfo = existedChainInfo.substrateInfo;
|
|
412
|
+
// const chainState = this.#koniState.getChainStateByKey(existedNetworkSlug);
|
|
413
|
+
//
|
|
414
|
+
// return await this.#koniState.addNetworkConfirm(id, url, {
|
|
415
|
+
// mode: 'update',
|
|
416
|
+
// chainSpec: {
|
|
417
|
+
// evmChainId: evmInfo.evmChainId,
|
|
418
|
+
// decimals: evmInfo.decimals,
|
|
419
|
+
// existentialDeposit: evmInfo.existentialDeposit,
|
|
420
|
+
// genesisHash: substrateInfo?.genesisHash || '',
|
|
421
|
+
// paraId: substrateInfo?.paraId || null,
|
|
422
|
+
// addressPrefix: substrateInfo?.addressPrefix || 0
|
|
423
|
+
// },
|
|
424
|
+
// chainEditInfo: {
|
|
425
|
+
// blockExplorer: blockExplorerUrls?.[0],
|
|
426
|
+
// slug: existedNetworkSlug,
|
|
427
|
+
// currentProvider: chainState.currentProvider,
|
|
428
|
+
// providers: existedChainInfo.providers,
|
|
429
|
+
// symbol: evmInfo.symbol,
|
|
430
|
+
// chainType: 'EVM',
|
|
431
|
+
// name: existedChainInfo.name
|
|
432
|
+
// }
|
|
433
|
+
// });
|
|
433
434
|
} else if (rpcUrls && chainName) {
|
|
434
435
|
const filteredUrls = rpcUrls.filter(targetString => {
|
|
435
436
|
let url;
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "1.0.5-
|
|
20
|
+
"version": "1.0.5-3",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -1692,11 +1692,11 @@
|
|
|
1692
1692
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
1693
1693
|
"@subsocial/types": "^0.6.8",
|
|
1694
1694
|
"@substrate/connect": "^0.7.26",
|
|
1695
|
-
"@subwallet/chain-list": "^0.1.
|
|
1696
|
-
"@subwallet/extension-base": "^1.0.5-
|
|
1697
|
-
"@subwallet/extension-chains": "^1.0.5-
|
|
1698
|
-
"@subwallet/extension-dapp": "^1.0.5-
|
|
1699
|
-
"@subwallet/extension-inject": "^1.0.5-
|
|
1695
|
+
"@subwallet/chain-list": "^0.1.7",
|
|
1696
|
+
"@subwallet/extension-base": "^1.0.5-3",
|
|
1697
|
+
"@subwallet/extension-chains": "^1.0.5-3",
|
|
1698
|
+
"@subwallet/extension-dapp": "^1.0.5-3",
|
|
1699
|
+
"@subwallet/extension-inject": "^1.0.5-3",
|
|
1700
1700
|
"@subwallet/keyring": "^0.0.9",
|
|
1701
1701
|
"@subwallet/ui-keyring": "^0.0.9",
|
|
1702
1702
|
"@unique-nft/types": "^0.6.0-4",
|
package/packageInfo.js
CHANGED
|
@@ -7,5 +7,5 @@ export const packageInfo = {
|
|
|
7
7
|
name: '@subwallet/extension-base',
|
|
8
8
|
path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
|
|
9
9
|
type: 'esm',
|
|
10
|
-
version: '1.0.5-
|
|
10
|
+
version: '1.0.5-3'
|
|
11
11
|
};
|
|
@@ -26,7 +26,7 @@ export const _BALANCE_CHAIN_GROUP = {
|
|
|
26
26
|
genshiro: ['genshiro_testnet', 'genshiro'],
|
|
27
27
|
equilibrium_parachain: ['equilibrium_parachain'],
|
|
28
28
|
bifrost: ['bifrost', 'acala', 'karura', 'acala_testnet', 'pioneer', 'bitcountry'],
|
|
29
|
-
statemine: ['statemine', 'astar', 'shiden', 'statemint', 'moonbeam', 'moonbase', 'moonriver', 'crabParachain'],
|
|
29
|
+
statemine: ['statemine', 'astar', 'shiden', 'statemint', 'moonbeam', 'moonbase', 'moonriver', 'crabParachain', 'darwinia2'],
|
|
30
30
|
kusama: ['kusama', 'kintsugi', 'kintsugi_test', 'interlay', 'acala', 'statemint', 'karura', 'bifrost'] // perhaps there are some runtime updates
|
|
31
31
|
};
|
|
32
32
|
|
|
@@ -179,7 +179,7 @@ export const _TRANSFER_CHAIN_GROUP = {
|
|
|
179
179
|
genshiro: ['genshiro_testnet', 'genshiro', 'equilibrium_parachain'],
|
|
180
180
|
crab: ['crab', 'pangolin'],
|
|
181
181
|
bitcountry: ['pioneer', 'bitcountry'],
|
|
182
|
-
statemine: ['statemint', 'statemine']
|
|
182
|
+
statemine: ['statemint', 'statemine', 'darwinia2']
|
|
183
183
|
};
|
|
184
184
|
export const _BALANCE_PARSING_CHAIN_GROUP = {
|
|
185
185
|
bobabeam: ['bobabeam', 'bobabase']
|
|
@@ -707,6 +707,11 @@ export class ChainService {
|
|
|
707
707
|
targetChainInfo.substrateInfo.crowdloanUrl = params.chainEditInfo.crowdloanUrl;
|
|
708
708
|
}
|
|
709
709
|
}
|
|
710
|
+
if (targetChainInfo.evmInfo) {
|
|
711
|
+
if (params.chainEditInfo.blockExplorer !== undefined) {
|
|
712
|
+
targetChainInfo.evmInfo.blockExplorer = params.chainEditInfo.blockExplorer;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
710
715
|
this.updateChainInfoMapSubscription();
|
|
711
716
|
this.dbService.updateChainStore({
|
|
712
717
|
...targetChainInfo,
|
|
@@ -10,6 +10,7 @@ export declare function _isPureEvmChain(chainInfo: _ChainInfo): boolean;
|
|
|
10
10
|
export declare function _isPureSubstrateChain(chainInfo: _ChainInfo): boolean;
|
|
11
11
|
export declare function _getOriginChainOfAsset(assetSlug: string): string;
|
|
12
12
|
export declare function _getContractAddressOfToken(tokenInfo: _ChainAsset): string;
|
|
13
|
+
export declare function _isTokenTransferredByEvm(tokenInfo: _ChainAsset): boolean;
|
|
13
14
|
export declare function _checkSmartContractSupportByChain(chainInfo: _ChainInfo, contractType: _AssetType): boolean;
|
|
14
15
|
export declare function _getTokenOnChainAssetId(tokenInfo: _ChainAsset): string;
|
|
15
16
|
export declare function _getTokenOnChainInfo(tokenInfo: _ChainAsset): Record<string, any>;
|
|
@@ -61,6 +61,10 @@ export function _getContractAddressOfToken(tokenInfo) {
|
|
|
61
61
|
var _tokenInfo$metadata;
|
|
62
62
|
return ((_tokenInfo$metadata = tokenInfo.metadata) === null || _tokenInfo$metadata === void 0 ? void 0 : _tokenInfo$metadata.contractAddress) || '';
|
|
63
63
|
}
|
|
64
|
+
export function _isTokenTransferredByEvm(tokenInfo) {
|
|
65
|
+
var _tokenInfo$metadata2;
|
|
66
|
+
return !!((_tokenInfo$metadata2 = tokenInfo.metadata) !== null && _tokenInfo$metadata2 !== void 0 && _tokenInfo$metadata2.contractAddress) || _isNativeToken(tokenInfo);
|
|
67
|
+
}
|
|
64
68
|
export function _checkSmartContractSupportByChain(chainInfo, contractType) {
|
|
65
69
|
// EVM chains support smart contract by default so just checking Substrate chains
|
|
66
70
|
if (chainInfo.substrateInfo === null || chainInfo.substrateInfo && chainInfo.substrateInfo.supportSmartContract === null) {
|
|
@@ -71,12 +75,12 @@ export function _checkSmartContractSupportByChain(chainInfo, contractType) {
|
|
|
71
75
|
|
|
72
76
|
// Utils for balance functions
|
|
73
77
|
export function _getTokenOnChainAssetId(tokenInfo) {
|
|
74
|
-
var _tokenInfo$
|
|
75
|
-
return ((_tokenInfo$
|
|
78
|
+
var _tokenInfo$metadata3;
|
|
79
|
+
return ((_tokenInfo$metadata3 = tokenInfo.metadata) === null || _tokenInfo$metadata3 === void 0 ? void 0 : _tokenInfo$metadata3.assetId) || '-1';
|
|
76
80
|
}
|
|
77
81
|
export function _getTokenOnChainInfo(tokenInfo) {
|
|
78
|
-
var _tokenInfo$
|
|
79
|
-
return (_tokenInfo$
|
|
82
|
+
var _tokenInfo$metadata4;
|
|
83
|
+
return (_tokenInfo$metadata4 = tokenInfo.metadata) === null || _tokenInfo$metadata4 === void 0 ? void 0 : _tokenInfo$metadata4.onChainInfo;
|
|
80
84
|
}
|
|
81
85
|
export function _getTokenMinAmount(tokenInfo) {
|
|
82
86
|
return tokenInfo.minAmount || '0';
|
|
@@ -229,16 +233,16 @@ export function _isXcmPathSupported(originTokenSlug, destinationTokenSlug, asset
|
|
|
229
233
|
return assetRef.path === _AssetRefPath.XCM;
|
|
230
234
|
}
|
|
231
235
|
export function _getXcmAssetType(tokenInfo) {
|
|
232
|
-
var _tokenInfo$
|
|
233
|
-
return ((_tokenInfo$
|
|
236
|
+
var _tokenInfo$metadata5;
|
|
237
|
+
return ((_tokenInfo$metadata5 = tokenInfo.metadata) === null || _tokenInfo$metadata5 === void 0 ? void 0 : _tokenInfo$metadata5.assetType) || '';
|
|
234
238
|
}
|
|
235
239
|
export function _getXcmAssetId(tokenInfo) {
|
|
236
|
-
var _tokenInfo$
|
|
237
|
-
return ((_tokenInfo$
|
|
240
|
+
var _tokenInfo$metadata6;
|
|
241
|
+
return ((_tokenInfo$metadata6 = tokenInfo.metadata) === null || _tokenInfo$metadata6 === void 0 ? void 0 : _tokenInfo$metadata6.assetId) || '-1';
|
|
238
242
|
}
|
|
239
243
|
export function _getXcmAssetMultilocation(tokenInfo) {
|
|
240
|
-
var _tokenInfo$
|
|
241
|
-
return (_tokenInfo$
|
|
244
|
+
var _tokenInfo$metadata7;
|
|
245
|
+
return (_tokenInfo$metadata7 = tokenInfo.metadata) === null || _tokenInfo$metadata7 === void 0 ? void 0 : _tokenInfo$metadata7.multilocation;
|
|
242
246
|
}
|
|
243
247
|
export function _getXcmTransferType(originChainInfo, destinationChainInfo) {
|
|
244
248
|
var _originChainInfo$subs, _destinationChainInfo;
|
|
@@ -8,4 +8,10 @@ export declare enum HistoryRecoverStatus {
|
|
|
8
8
|
FAIL_DETECT = "FAIL_DETECT",
|
|
9
9
|
UNKNOWN = "UNKNOWN"
|
|
10
10
|
}
|
|
11
|
-
export
|
|
11
|
+
export interface TransactionRecoverResult {
|
|
12
|
+
status: HistoryRecoverStatus;
|
|
13
|
+
extrinsicHash?: string;
|
|
14
|
+
blockHash?: string;
|
|
15
|
+
blockNumber?: number;
|
|
16
|
+
}
|
|
17
|
+
export declare const historyRecover: (history: TransactionHistoryItem, chainService: ChainService) => Promise<TransactionRecoverResult>;
|