@subwallet/extension-base 1.0.5-2 → 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.
@@ -1075,7 +1075,6 @@ export interface ChainStakingMetadata {
1075
1075
  minJoinNominationPool?: string;
1076
1076
  minStake: string;
1077
1077
  nominatorCount?: number;
1078
- minPoolBonding?: string;
1079
1078
  maxValidatorPerNominator: number;
1080
1079
  maxWithdrawalRequestPerValidator: number;
1081
1080
  allowCancelUnstaking: boolean;
@@ -34,7 +34,7 @@ function validateRelayUnbondingCondition(amount, chainStakingMetadata, nominator
34
34
  const errors = [];
35
35
  const bnActiveStake = new _util.BN(nominatorMetadata.activeStake);
36
36
  const bnRemainingStake = bnActiveStake.sub(new _util.BN(amount));
37
- const minStake = new _util.BN(chainStakingMetadata.minPoolBonding || '0');
37
+ const minStake = new _util.BN(chainStakingMetadata.minJoinNominationPool || '0');
38
38
  if (!(bnRemainingStake.isZero() || bnRemainingStake.gte(minStake))) {
39
39
  errors.push(new _TransactionError.TransactionError(_KoniTypes.StakingTxErrorType.INVALID_ACTIVE_STAKE));
40
40
  }
@@ -48,7 +48,7 @@ function validatePoolBondingCondition(chainInfo, amount, selectedPool, address,
48
48
  // amount >= min stake
49
49
  const errors = [];
50
50
  let bnTotalStake = new _util.BN(amount);
51
- const bnMinStake = new _util.BN(chainStakingMetadata.minPoolBonding || '0');
51
+ const bnMinStake = new _util.BN(chainStakingMetadata.minJoinNominationPool || '0');
52
52
  if (selectedPool.state !== 'Open') {
53
53
  errors.push(new _TransactionError.TransactionError(_KoniTypes.StakingTxErrorType.INACTIVE_NOMINATION_POOL));
54
54
  }
@@ -90,9 +90,6 @@ function validateRelayBondingCondition(chainInfo, amount, selectedValidators, ad
90
90
  async function getRelayChainStakingMetadata(chainInfo, substrateApi) {
91
91
  var _chainApi$api$query$a, _chainApi$api$query, _chainApi$api$query$s, _chainApi$api$query2, _chainApi$api$query2$, _chainApi$api$query3, _chainApi$api$query3$;
92
92
  const chain = chainInfo.slug;
93
- const {
94
- decimals
95
- } = (0, _utils2._getChainNativeTokenBasicInfo)(chainInfo);
96
93
  const chainApi = await substrateApi.isReady;
97
94
  const _era = await chainApi.api.query.staking.currentEra();
98
95
  const currentEra = _era.toString();
@@ -136,8 +133,6 @@ async function getRelayChainStakingMetadata(chainInfo, substrateApi) {
136
133
  // in %, annually
137
134
  inflation,
138
135
  minStake: minStake.toString(),
139
- minPoolBonding: (10 ** decimals).toString(),
140
- // default is 1
141
136
  maxValidatorPerNominator: parseInt(maxNominations),
142
137
  maxWithdrawalRequestPerValidator: parseInt(maxUnlockingChunks),
143
138
  allowCancelUnstaking: true,
@@ -17,6 +17,7 @@ exports.getParaCurrentInflation = getParaCurrentInflation;
17
17
  exports.getStakingAvailableActionsByChain = getStakingAvailableActionsByChain;
18
18
  exports.getStakingAvailableActionsByNominator = getStakingAvailableActionsByNominator;
19
19
  exports.getStakingStatusByNominations = getStakingStatusByNominations;
20
+ exports.getValidatorLabel = getValidatorLabel;
20
21
  exports.getWithdrawalInfo = getWithdrawalInfo;
21
22
  exports.isActionFromValidator = isActionFromValidator;
22
23
  exports.isShowNominationByValidator = isShowNominationByValidator;
@@ -268,4 +269,12 @@ function getStakingStatusByNominations(bnTotalActiveStake, nominationList) {
268
269
  }
269
270
  }
270
271
  return stakingStatus;
272
+ }
273
+ function getValidatorLabel(chain) {
274
+ if (_constants._STAKING_CHAIN_GROUP.astar.includes(chain)) {
275
+ return 'dApp';
276
+ } else if (_constants._STAKING_CHAIN_GROUP.relay.includes(chain)) {
277
+ return 'Validator';
278
+ }
279
+ return 'Collator';
271
280
  }
@@ -1446,7 +1446,8 @@ class KoniExtension {
1446
1446
 
1447
1447
  // Get native token amount
1448
1448
  const freeBalance = await this.#koniState.balanceService.getTokenFreeBalance(from, networkKey, tokenSlug);
1449
- if ((0, _utilCrypto.isEthereumAddress)(from) && (0, _utilCrypto.isEthereumAddress)(to)) {
1449
+ if ((0, _utilCrypto.isEthereumAddress)(from) && (0, _utilCrypto.isEthereumAddress)(to) && (0, _utils._isTokenTransferredByEvm)(tokenInfo)) {
1450
+ // TODO: review this
1450
1451
  chainType = _KoniTypes.ChainType.EVM;
1451
1452
  const txVal = transferAll ? freeBalance.value : value || '0';
1452
1453
 
@@ -2917,6 +2918,7 @@ class KoniExtension {
2917
2918
  return Object.fromEntries(Object.entries(rs).map(_ref70 => {
2918
2919
  let [key, value] = _ref70;
2919
2920
  const {
2921
+ additionalValidator,
2920
2922
  transaction,
2921
2923
  ...transactionResult
2922
2924
  } = value;
@@ -445,35 +445,36 @@ class KoniTabs {
445
445
  const chainIdNum = parseInt(chainId, 16);
446
446
  const [existedNetworkSlug, existedChainInfo] = this.#koniState.findNetworkKeyByChainId(chainIdNum);
447
447
  if (existedNetworkSlug && existedChainInfo && existedChainInfo !== null && existedChainInfo !== void 0 && existedChainInfo.evmInfo) {
448
- const evmInfo = existedChainInfo.evmInfo;
449
- const substrateInfo = existedChainInfo.substrateInfo;
450
- const chainState = this.#koniState.getChainStateByKey(existedNetworkSlug);
451
- await this.#koniState.addNetworkConfirm(id, url, {
452
- mode: 'update',
453
- chainSpec: {
454
- evmChainId: evmInfo.evmChainId,
455
- decimals: evmInfo.decimals,
456
- existentialDeposit: evmInfo.existentialDeposit,
457
- genesisHash: (substrateInfo === null || substrateInfo === void 0 ? void 0 : substrateInfo.genesisHash) || '',
458
- paraId: (substrateInfo === null || substrateInfo === void 0 ? void 0 : substrateInfo.paraId) || null,
459
- addressPrefix: (substrateInfo === null || substrateInfo === void 0 ? void 0 : substrateInfo.addressPrefix) || 0
460
- },
461
- chainEditInfo: {
462
- blockExplorer: blockExplorerUrls === null || blockExplorerUrls === void 0 ? void 0 : blockExplorerUrls[0],
463
- slug: existedNetworkSlug,
464
- currentProvider: chainState.currentProvider,
465
- providers: existedChainInfo.providers,
466
- symbol: evmInfo.symbol,
467
- chainType: 'EVM',
468
- name: existedChainInfo.name
469
- }
470
- });
471
448
  return await this.switchEvmChain(id, url, {
472
449
  method: 'wallet_switchEthereumChain',
473
450
  params: [{
474
451
  chainId
475
452
  }]
476
453
  });
454
+ // const evmInfo = existedChainInfo.evmInfo;
455
+ // const substrateInfo = existedChainInfo.substrateInfo;
456
+ // const chainState = this.#koniState.getChainStateByKey(existedNetworkSlug);
457
+ //
458
+ // return await this.#koniState.addNetworkConfirm(id, url, {
459
+ // mode: 'update',
460
+ // chainSpec: {
461
+ // evmChainId: evmInfo.evmChainId,
462
+ // decimals: evmInfo.decimals,
463
+ // existentialDeposit: evmInfo.existentialDeposit,
464
+ // genesisHash: substrateInfo?.genesisHash || '',
465
+ // paraId: substrateInfo?.paraId || null,
466
+ // addressPrefix: substrateInfo?.addressPrefix || 0
467
+ // },
468
+ // chainEditInfo: {
469
+ // blockExplorer: blockExplorerUrls?.[0],
470
+ // slug: existedNetworkSlug,
471
+ // currentProvider: chainState.currentProvider,
472
+ // providers: existedChainInfo.providers,
473
+ // symbol: evmInfo.symbol,
474
+ // chainType: 'EVM',
475
+ // name: existedChainInfo.name
476
+ // }
477
+ // });
477
478
  } else if (rpcUrls && chainName) {
478
479
  const filteredUrls = rpcUrls.filter(targetString => {
479
480
  let url;
@@ -13,6 +13,6 @@ const packageInfo = {
13
13
  name: '@subwallet/extension-base',
14
14
  path: typeof __dirname === 'string' ? __dirname : 'auto',
15
15
  type: 'cjs',
16
- version: '1.0.5-2'
16
+ version: '1.0.5-3'
17
17
  };
18
18
  exports.packageInfo = packageInfo;
@@ -36,7 +36,7 @@ const _BALANCE_CHAIN_GROUP = {
36
36
  genshiro: ['genshiro_testnet', 'genshiro'],
37
37
  equilibrium_parachain: ['equilibrium_parachain'],
38
38
  bifrost: ['bifrost', 'acala', 'karura', 'acala_testnet', 'pioneer', 'bitcountry'],
39
- statemine: ['statemine', 'astar', 'shiden', 'statemint', 'moonbeam', 'moonbase', 'moonriver', 'crabParachain'],
39
+ statemine: ['statemine', 'astar', 'shiden', 'statemint', 'moonbeam', 'moonbase', 'moonriver', 'crabParachain', 'darwinia2'],
40
40
  kusama: ['kusama', 'kintsugi', 'kintsugi_test', 'interlay', 'acala', 'statemint', 'karura', 'bifrost'] // perhaps there are some runtime updates
41
41
  };
42
42
  exports._BALANCE_CHAIN_GROUP = _BALANCE_CHAIN_GROUP;
@@ -194,7 +194,7 @@ const _TRANSFER_CHAIN_GROUP = {
194
194
  genshiro: ['genshiro_testnet', 'genshiro', 'equilibrium_parachain'],
195
195
  crab: ['crab', 'pangolin'],
196
196
  bitcountry: ['pioneer', 'bitcountry'],
197
- statemine: ['statemint', 'statemine']
197
+ statemine: ['statemint', 'statemine', 'darwinia2']
198
198
  };
199
199
  exports._TRANSFER_CHAIN_GROUP = _TRANSFER_CHAIN_GROUP;
200
200
  const _BALANCE_PARSING_CHAIN_GROUP = {
@@ -720,6 +720,11 @@ class ChainService {
720
720
  targetChainInfo.substrateInfo.crowdloanUrl = params.chainEditInfo.crowdloanUrl;
721
721
  }
722
722
  }
723
+ if (targetChainInfo.evmInfo) {
724
+ if (params.chainEditInfo.blockExplorer !== undefined) {
725
+ targetChainInfo.evmInfo.blockExplorer = params.chainEditInfo.blockExplorer;
726
+ }
727
+ }
723
728
  this.updateChainInfoMapSubscription();
724
729
  this.dbService.updateChainStore({
725
730
  ...targetChainInfo,
@@ -61,6 +61,7 @@ exports._isSubstrateParaChain = _isSubstrateParaChain;
61
61
  exports._isSubstrateParachain = _isSubstrateParachain;
62
62
  exports._isSubstrateRelayChain = _isSubstrateRelayChain;
63
63
  exports._isTokenEvmSmartContract = _isTokenEvmSmartContract;
64
+ exports._isTokenTransferredByEvm = _isTokenTransferredByEvm;
64
65
  exports._isTokenWasmSmartContract = _isTokenWasmSmartContract;
65
66
  exports._isXcmPathSupported = _isXcmPathSupported;
66
67
  exports._parseAssetRefKey = _parseAssetRefKey;
@@ -128,6 +129,10 @@ function _getContractAddressOfToken(tokenInfo) {
128
129
  var _tokenInfo$metadata;
129
130
  return ((_tokenInfo$metadata = tokenInfo.metadata) === null || _tokenInfo$metadata === void 0 ? void 0 : _tokenInfo$metadata.contractAddress) || '';
130
131
  }
132
+ function _isTokenTransferredByEvm(tokenInfo) {
133
+ var _tokenInfo$metadata2;
134
+ return !!((_tokenInfo$metadata2 = tokenInfo.metadata) !== null && _tokenInfo$metadata2 !== void 0 && _tokenInfo$metadata2.contractAddress) || _isNativeToken(tokenInfo);
135
+ }
131
136
  function _checkSmartContractSupportByChain(chainInfo, contractType) {
132
137
  // EVM chains support smart contract by default so just checking Substrate chains
133
138
  if (chainInfo.substrateInfo === null || chainInfo.substrateInfo && chainInfo.substrateInfo.supportSmartContract === null) {
@@ -138,12 +143,12 @@ function _checkSmartContractSupportByChain(chainInfo, contractType) {
138
143
 
139
144
  // Utils for balance functions
140
145
  function _getTokenOnChainAssetId(tokenInfo) {
141
- var _tokenInfo$metadata2;
142
- return ((_tokenInfo$metadata2 = tokenInfo.metadata) === null || _tokenInfo$metadata2 === void 0 ? void 0 : _tokenInfo$metadata2.assetId) || '-1';
146
+ var _tokenInfo$metadata3;
147
+ return ((_tokenInfo$metadata3 = tokenInfo.metadata) === null || _tokenInfo$metadata3 === void 0 ? void 0 : _tokenInfo$metadata3.assetId) || '-1';
143
148
  }
144
149
  function _getTokenOnChainInfo(tokenInfo) {
145
- var _tokenInfo$metadata3;
146
- return (_tokenInfo$metadata3 = tokenInfo.metadata) === null || _tokenInfo$metadata3 === void 0 ? void 0 : _tokenInfo$metadata3.onChainInfo;
150
+ var _tokenInfo$metadata4;
151
+ return (_tokenInfo$metadata4 = tokenInfo.metadata) === null || _tokenInfo$metadata4 === void 0 ? void 0 : _tokenInfo$metadata4.onChainInfo;
147
152
  }
148
153
  function _getTokenMinAmount(tokenInfo) {
149
154
  return tokenInfo.minAmount || '0';
@@ -296,16 +301,16 @@ function _isXcmPathSupported(originTokenSlug, destinationTokenSlug, assetRefMap)
296
301
  return assetRef.path === _types._AssetRefPath.XCM;
297
302
  }
298
303
  function _getXcmAssetType(tokenInfo) {
299
- var _tokenInfo$metadata4;
300
- return ((_tokenInfo$metadata4 = tokenInfo.metadata) === null || _tokenInfo$metadata4 === void 0 ? void 0 : _tokenInfo$metadata4.assetType) || '';
304
+ var _tokenInfo$metadata5;
305
+ return ((_tokenInfo$metadata5 = tokenInfo.metadata) === null || _tokenInfo$metadata5 === void 0 ? void 0 : _tokenInfo$metadata5.assetType) || '';
301
306
  }
302
307
  function _getXcmAssetId(tokenInfo) {
303
- var _tokenInfo$metadata5;
304
- return ((_tokenInfo$metadata5 = tokenInfo.metadata) === null || _tokenInfo$metadata5 === void 0 ? void 0 : _tokenInfo$metadata5.assetId) || '-1';
308
+ var _tokenInfo$metadata6;
309
+ return ((_tokenInfo$metadata6 = tokenInfo.metadata) === null || _tokenInfo$metadata6 === void 0 ? void 0 : _tokenInfo$metadata6.assetId) || '-1';
305
310
  }
306
311
  function _getXcmAssetMultilocation(tokenInfo) {
307
- var _tokenInfo$metadata6;
308
- return (_tokenInfo$metadata6 = tokenInfo.metadata) === null || _tokenInfo$metadata6 === void 0 ? void 0 : _tokenInfo$metadata6.multilocation;
312
+ var _tokenInfo$metadata7;
313
+ return (_tokenInfo$metadata7 = tokenInfo.metadata) === null || _tokenInfo$metadata7 === void 0 ? void 0 : _tokenInfo$metadata7.multilocation;
309
314
  }
310
315
  function _getXcmTransferType(originChainInfo, destinationChainInfo) {
311
316
  var _originChainInfo$subs, _destinationChainInfo;
@@ -255,7 +255,7 @@ async function fetchMultiChainHistories(addresses, chainMap) {
255
255
  const usedAddresses = relatedAddresses.filter(a => lowerAddresses.includes(a.toLowerCase()));
256
256
  const chainInfo = chainMap[chainId];
257
257
  if (chainInfo === undefined) {
258
- console.warn(`Not found chain info for chain id: ${chainId}`); // TODO: resolve conflicting chainId
258
+ console.debug(`Not found chain info for chain id: ${chainId}`); // TODO: resolve conflicting chainId
259
259
 
260
260
  return;
261
261
  }
@@ -264,7 +264,7 @@ async function fetchMultiChainHistories(addresses, chainMap) {
264
264
  const transactionData = parseSubsquidTransactionData(address, name, historyItem, chainInfo, parseData(args), parseData(_data));
265
265
  histories.push(transactionData);
266
266
  } catch (e) {
267
- console.warn('Parse transaction data failed', address, e);
267
+ console.debug('Parse transaction data failed', address, e);
268
268
  }
269
269
  });
270
270
  });
@@ -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) {
@@ -293,7 +300,7 @@ class TransactionService {
293
300
  status: transaction.status,
294
301
  transactionId: transaction.id,
295
302
  extrinsicHash: transaction.extrinsicHash,
296
- time: transaction.createdAt.getTime(),
303
+ time: transaction.createdAt,
297
304
  fee: transaction.estimateFee,
298
305
  blockNumber: 0,
299
306
  // Will be added in next step
@@ -302,7 +309,6 @@ class TransactionService {
302
309
  nonce: nonce || 0,
303
310
  startBlock: startBlock || 0
304
311
  };
305
- console.log('historyItem', historyItem);
306
312
  const chainInfo = this.chainService.getChainInfoByKey(transaction.chain);
307
313
  const nativeAsset = (0, _utils._getChainNativeTokenBasicInfo)(chainInfo);
308
314
  const baseNativeAmount = {
@@ -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) {
@@ -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 { _getChainNativeTokenBasicInfo, _getChainSubstrateAddressPrefix } from '@subwallet/extension-base/services/chain-service/utils';
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.minPoolBonding || '0');
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.minPoolBonding || '0');
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';
@@ -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-2",
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.2",
1696
- "@subwallet/extension-base": "^1.0.5-2",
1697
- "@subwallet/extension-chains": "^1.0.5-2",
1698
- "@subwallet/extension-dapp": "^1.0.5-2",
1699
- "@subwallet/extension-inject": "^1.0.5-2",
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-2'
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$metadata2;
75
- return ((_tokenInfo$metadata2 = tokenInfo.metadata) === null || _tokenInfo$metadata2 === void 0 ? void 0 : _tokenInfo$metadata2.assetId) || '-1';
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$metadata3;
79
- return (_tokenInfo$metadata3 = tokenInfo.metadata) === null || _tokenInfo$metadata3 === void 0 ? void 0 : _tokenInfo$metadata3.onChainInfo;
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$metadata4;
233
- return ((_tokenInfo$metadata4 = tokenInfo.metadata) === null || _tokenInfo$metadata4 === void 0 ? void 0 : _tokenInfo$metadata4.assetType) || '';
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$metadata5;
237
- return ((_tokenInfo$metadata5 = tokenInfo.metadata) === null || _tokenInfo$metadata5 === void 0 ? void 0 : _tokenInfo$metadata5.assetId) || '-1';
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$metadata6;
241
- return (_tokenInfo$metadata6 = tokenInfo.metadata) === null || _tokenInfo$metadata6 === void 0 ? void 0 : _tokenInfo$metadata6.multilocation;
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;
@@ -244,7 +244,7 @@ export async function fetchMultiChainHistories(addresses, chainMap, maxPage = 25
244
244
  const usedAddresses = relatedAddresses.filter(a => lowerAddresses.includes(a.toLowerCase()));
245
245
  const chainInfo = chainMap[chainId];
246
246
  if (chainInfo === undefined) {
247
- console.warn(`Not found chain info for chain id: ${chainId}`); // TODO: resolve conflicting chainId
247
+ console.debug(`Not found chain info for chain id: ${chainId}`); // TODO: resolve conflicting chainId
248
248
 
249
249
  return;
250
250
  }
@@ -253,7 +253,7 @@ export async function fetchMultiChainHistories(addresses, chainMap, maxPage = 25
253
253
  const transactionData = parseSubsquidTransactionData(address, name, historyItem, chainInfo, parseData(args), parseData(_data));
254
254
  histories.push(transactionData);
255
255
  } catch (e) {
256
- console.warn('Parse transaction data failed', address, e);
256
+ console.debug('Parse transaction data failed', address, e);
257
257
  }
258
258
  });
259
259
  });
@@ -161,8 +161,8 @@ export default class TransactionService {
161
161
  const transactionId = getTransactionId(transaction.chainType, transaction.chain, isInternal);
162
162
  return {
163
163
  ...transaction,
164
- createdAt: new Date(),
165
- updatedAt: new Date(),
164
+ createdAt: new Date().getTime(),
165
+ updatedAt: new Date().getTime(),
166
166
  errors: transaction.errors || [],
167
167
  warnings: transaction.warnings || [],
168
168
  url: transaction.url || EXTENSION_REQUEST_URL,
@@ -203,6 +203,9 @@ export default class TransactionService {
203
203
  const stopByErrors = validatedTransaction.errors.length > 0;
204
204
  const stopByWarnings = validatedTransaction.warnings.length > 0 && !validatedTransaction.ignoreWarnings;
205
205
  if (stopByErrors || stopByWarnings) {
206
+ // @ts-ignore
207
+ 'transaction' in validatedTransaction && delete validatedTransaction.transaction;
208
+ 'additionalValidator' in validatedTransaction && delete validatedTransaction.additionalValidator;
206
209
  return validatedTransaction;
207
210
  }
208
211
  validatedTransaction.warnings = [];
@@ -220,6 +223,10 @@ export default class TransactionService {
220
223
  }
221
224
  });
222
225
  });
226
+
227
+ // @ts-ignore
228
+ 'transaction' in validatedTransaction && delete validatedTransaction.transaction;
229
+ 'additionalValidator' in validatedTransaction && delete validatedTransaction.additionalValidator;
223
230
  return validatedTransaction;
224
231
  }
225
232
  async sendTransaction(transaction) {
@@ -286,7 +293,7 @@ export default class TransactionService {
286
293
  status: transaction.status,
287
294
  transactionId: transaction.id,
288
295
  extrinsicHash: transaction.extrinsicHash,
289
- time: transaction.createdAt.getTime(),
296
+ time: transaction.createdAt,
290
297
  fee: transaction.estimateFee,
291
298
  blockNumber: 0,
292
299
  // Will be added in next step
@@ -295,7 +302,6 @@ export default class TransactionService {
295
302
  nonce: nonce || 0,
296
303
  startBlock: startBlock || 0
297
304
  };
298
- console.log('historyItem', historyItem);
299
305
  const chainInfo = this.chainService.getChainInfoByKey(transaction.chain);
300
306
  const nativeAsset = _getChainNativeTokenBasicInfo(chainInfo);
301
307
  const baseNativeAmount = {
@@ -14,14 +14,14 @@ export interface SWTransaction extends ValidateTransactionResponse, Partial<Pick
14
14
  status: ExtrinsicStatus;
15
15
  extrinsicHash: string;
16
16
  extrinsicType: ExtrinsicType;
17
- createdAt: Date;
18
- updatedAt: Date;
17
+ createdAt: number;
18
+ updatedAt: number;
19
19
  estimateFee?: AmountData;
20
20
  transaction: SubmittableExtrinsic | TransactionConfig;
21
21
  additionalValidator?: (inputTransaction: SWTransactionResponse) => Promise<void>;
22
22
  eventsHandler?: (eventEmitter: TransactionEmitter) => void;
23
23
  }
24
- export declare type SWTransactionResult = Omit<SWTransaction, 'transaction'>;
24
+ export declare type SWTransactionResult = Omit<SWTransaction, 'transaction' | 'additionalValidator'>;
25
25
  declare type SwInputBase = Pick<SWTransaction, 'address' | 'url' | 'data' | 'extrinsicType' | 'chain' | 'chainType' | 'ignoreWarnings' | 'transferNativeAmount'> & Partial<Pick<SWTransaction, 'additionalValidator'>>;
26
26
  export interface SWTransactionInput extends SwInputBase {
27
27
  transaction?: SWTransaction['transaction'] | null;
@@ -21,6 +21,9 @@ function getBlockExplorerTxRoute(chainInfo) {
21
21
  if (_isPureEvmChain(chainInfo)) {
22
22
  return 'tx';
23
23
  }
24
+ if (['aventus'].includes(chainInfo.slug)) {
25
+ return 'transaction';
26
+ }
24
27
  return 'extrinsic';
25
28
  }
26
29
  export function getExplorerLink(chainInfo, value, type) {