@subwallet/extension-base 1.0.1 → 1.0.2-1b
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 +25 -36
- package/background/KoniTypes.js +12 -7
- package/background/errors/TransactionError.js +21 -1
- package/cjs/background/KoniTypes.js +14 -8
- package/cjs/background/errors/TransactionError.js +20 -0
- package/cjs/constants/index.js +13 -28
- package/cjs/koni/api/dotsama/balance.js +60 -224
- package/cjs/koni/api/dotsama/transfer.js +30 -29
- package/cjs/koni/api/nft/acala_nft/index.js +4 -1
- package/cjs/koni/api/nft/bit.country/index.js +4 -1
- package/cjs/koni/api/nft/evm_nft/index.js +7 -3
- package/cjs/koni/api/nft/index.js +3 -6
- package/cjs/koni/api/nft/karura_nft/index.js +4 -1
- package/cjs/koni/api/nft/rmrk_nft/index.js +8 -1
- package/cjs/koni/api/nft/statemine_nft/index.js +4 -1
- package/cjs/koni/api/nft/unique_nft/index.js +6 -1
- package/cjs/koni/api/nft/wasm_nft/index.js +169 -111
- package/cjs/koni/api/nft/wasm_nft/utils.js +11 -7
- package/cjs/koni/api/staking/bonding/amplitude.js +18 -10
- package/cjs/koni/api/staking/bonding/astar.js +37 -238
- package/cjs/koni/api/staking/bonding/index.js +26 -14
- package/cjs/koni/api/staking/bonding/paraChain.js +100 -11
- package/cjs/koni/api/staking/bonding/relayChain.js +174 -16
- package/cjs/koni/api/staking/bonding/utils.js +55 -10
- package/cjs/koni/api/tokens/wasm/index.js +5 -4
- package/cjs/koni/api/tokens/wasm/utils.js +63 -0
- package/cjs/koni/api/xcm/index.js +0 -111
- package/cjs/koni/api/xcm/polkadotXcm.js +2 -2
- package/cjs/koni/api/xcm/utils.js +18 -13
- package/cjs/koni/api/xcm/xTokens.js +3 -5
- package/cjs/koni/api/xcm/xcmPallet.js +9 -6
- package/cjs/koni/background/cron.js +179 -77
- package/cjs/koni/background/handlers/Extension.js +231 -195
- package/cjs/koni/background/handlers/State.js +147 -111
- package/cjs/koni/background/handlers/Tabs.js +48 -39
- package/cjs/koni/background/subscription.js +64 -56
- package/cjs/packageInfo.js +1 -1
- package/cjs/page/index.js +5 -0
- package/cjs/services/chain-service/constants.js +1 -11
- package/cjs/services/chain-service/handler/SubstrateChainHandler.js +13 -8
- package/cjs/services/chain-service/handler/light-client/index.js +2 -0
- package/cjs/services/chain-service/index.js +39 -6
- package/cjs/services/chain-service/utils.js +4 -0
- package/cjs/services/event-service/index.js +75 -0
- package/cjs/services/event-service/types.js +11 -0
- package/cjs/services/history-service/index.js +46 -21
- package/cjs/services/history-service/subsquid-multi-chain-history.js +19 -11
- package/cjs/services/keyring-service/index.js +101 -0
- package/cjs/services/migration-service/index.js +13 -10
- package/cjs/{koni/migration/scripts/RemoveWrongCrowdloan.js → services/migration-service/scripts/AutoEnableChainsTokens.js} +11 -6
- package/cjs/services/migration-service/scripts/MigrateNetworkSettings.js +39 -19
- package/cjs/services/migration-service/scripts/MigrateSettings.js +31 -0
- package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +72 -0
- package/cjs/services/migration-service/scripts/index.js +13 -4
- package/cjs/services/price-service/coingecko.js +15 -3
- package/cjs/services/price-service/index.js +15 -18
- package/cjs/services/request-service/constants.js +8 -2
- package/cjs/services/request-service/handler/AuthRequestHandler.js +43 -12
- package/cjs/services/request-service/index.js +3 -0
- package/cjs/services/storage-service/DatabaseService.js +53 -34
- package/cjs/services/storage-service/databases/index.js +1 -1
- package/cjs/services/storage-service/db-stores/BaseStoreWithAddressAndChain.js +2 -8
- package/cjs/services/storage-service/db-stores/Nft.js +8 -18
- package/cjs/services/storage-service/db-stores/Transaction.js +10 -7
- package/cjs/services/subscan-service/index.js +107 -0
- package/cjs/services/subscan-service/subscan-chain-map.js +74 -0
- package/cjs/services/subscan-service/types.js +1 -0
- package/cjs/services/transaction-service/event-parser/index.js +20 -48
- package/cjs/services/transaction-service/index.js +66 -22
- package/cjs/services/transaction-service/utils.js +4 -6
- package/cjs/utils/address.js +9 -1
- package/cjs/utils/index.js +30 -26
- package/constants/index.d.ts +8 -13
- package/constants/index.js +8 -13
- package/koni/api/dotsama/balance.d.ts +0 -1
- package/koni/api/dotsama/balance.js +33 -197
- package/koni/api/dotsama/transfer.js +5 -4
- package/koni/api/nft/acala_nft/index.js +3 -1
- package/koni/api/nft/bit.country/index.js +3 -1
- package/koni/api/nft/evm_nft/index.js +6 -3
- package/koni/api/nft/index.d.ts +1 -2
- package/koni/api/nft/index.js +3 -6
- package/koni/api/nft/karura_nft/index.js +3 -1
- package/koni/api/nft/nft.d.ts +1 -0
- package/koni/api/nft/rmrk_nft/index.js +8 -1
- package/koni/api/nft/statemine_nft/index.js +3 -1
- package/koni/api/nft/unique_nft/index.js +5 -1
- package/koni/api/nft/wasm_nft/index.d.ts +0 -2
- package/koni/api/nft/wasm_nft/index.js +167 -109
- package/koni/api/nft/wasm_nft/utils.d.ts +7 -5
- package/koni/api/nft/wasm_nft/utils.js +7 -5
- package/koni/api/staking/bonding/amplitude.d.ts +1 -2
- package/koni/api/staking/bonding/amplitude.js +22 -13
- package/koni/api/staking/bonding/astar.d.ts +2 -11
- package/koni/api/staking/bonding/astar.js +39 -231
- package/koni/api/staking/bonding/index.d.ts +5 -2
- package/koni/api/staking/bonding/index.js +27 -17
- package/koni/api/staking/bonding/paraChain.d.ts +4 -1
- package/koni/api/staking/bonding/paraChain.js +101 -14
- package/koni/api/staking/bonding/relayChain.d.ts +6 -2
- package/koni/api/staking/bonding/relayChain.js +172 -17
- package/koni/api/staking/bonding/utils.d.ts +15 -2
- package/koni/api/staking/bonding/utils.js +53 -11
- package/koni/api/tokens/wasm/index.js +5 -4
- package/koni/api/tokens/wasm/utils.d.ts +6 -0
- package/koni/api/tokens/wasm/utils.js +54 -0
- package/koni/api/xcm/index.js +1 -112
- package/koni/api/xcm/polkadotXcm.js +3 -3
- package/koni/api/xcm/utils.d.ts +5 -6
- package/koni/api/xcm/utils.js +15 -10
- package/koni/api/xcm/xTokens.js +5 -7
- package/koni/api/xcm/xcmPallet.js +10 -9
- package/koni/background/cron.d.ts +6 -1
- package/koni/background/cron.js +179 -76
- package/koni/background/handlers/Extension.d.ts +2 -2
- package/koni/background/handlers/Extension.js +161 -125
- package/koni/background/handlers/State.d.ts +21 -20
- package/koni/background/handlers/State.js +144 -111
- package/koni/background/handlers/Tabs.js +30 -20
- package/koni/background/subscription.d.ts +1 -1
- package/koni/background/subscription.js +64 -58
- package/package.json +63 -18
- package/packageInfo.js +1 -1
- package/page/index.d.ts +2 -0
- package/page/index.js +4 -0
- package/services/chain-service/constants.d.ts +0 -1
- package/services/chain-service/constants.js +0 -9
- package/services/chain-service/handler/SubstrateChainHandler.js +14 -9
- package/services/chain-service/handler/light-client/index.d.ts +17 -1
- package/services/chain-service/handler/light-client/index.js +1 -1
- package/services/chain-service/helper/psp22_abi.json +1041 -881
- package/services/chain-service/helper/psp34_abi.json +2963 -1807
- package/services/chain-service/index.d.ts +6 -4
- package/services/chain-service/index.js +40 -9
- package/services/chain-service/utils.d.ts +1 -0
- package/services/chain-service/utils.js +3 -0
- package/services/event-service/index.d.ts +22 -0
- package/services/event-service/index.js +63 -0
- package/services/event-service/types.d.ts +28 -0
- package/services/event-service/types.js +4 -0
- package/services/history-service/index.d.ts +5 -3
- package/services/history-service/index.js +46 -21
- package/services/history-service/subsquid-multi-chain-history.js +22 -13
- package/services/keyring-service/index.d.ts +19 -0
- package/services/keyring-service/index.js +93 -0
- package/services/migration-service/index.js +11 -9
- package/services/migration-service/scripts/AutoEnableChainsTokens.d.ts +4 -0
- package/services/migration-service/scripts/AutoEnableChainsTokens.js +13 -0
- package/services/migration-service/scripts/MigrateNetworkSettings.js +37 -18
- package/services/migration-service/scripts/MigrateSettings.d.ts +4 -0
- package/services/migration-service/scripts/MigrateSettings.js +23 -0
- package/services/migration-service/scripts/MigrateTransactionHistory.d.ts +4 -0
- package/services/migration-service/scripts/MigrateTransactionHistory.js +64 -0
- package/services/migration-service/scripts/index.d.ts +1 -0
- package/services/migration-service/scripts/index.js +10 -3
- package/services/price-service/coingecko.js +15 -3
- package/services/price-service/index.d.ts +5 -3
- package/services/price-service/index.js +15 -18
- package/services/request-service/constants.d.ts +1 -0
- package/services/request-service/constants.js +6 -1
- package/services/request-service/handler/AuthRequestHandler.d.ts +8 -1
- package/services/request-service/handler/AuthRequestHandler.js +44 -13
- package/services/request-service/index.d.ts +7 -1
- package/services/request-service/index.js +3 -0
- package/services/storage-service/DatabaseService.d.ts +1 -0
- package/services/storage-service/DatabaseService.js +53 -34
- package/services/storage-service/databases/index.js +1 -1
- package/services/storage-service/db-stores/BaseStoreWithAddressAndChain.d.ts +1 -1
- package/services/storage-service/db-stores/BaseStoreWithAddressAndChain.js +2 -8
- package/services/storage-service/db-stores/Nft.d.ts +3 -3
- package/services/storage-service/db-stores/Nft.js +8 -17
- package/services/storage-service/db-stores/Transaction.js +10 -7
- package/services/subscan-service/index.d.ts +20 -0
- package/services/subscan-service/index.js +99 -0
- package/services/subscan-service/subscan-chain-map.d.ts +5 -0
- package/services/subscan-service/subscan-chain-map.js +63 -0
- package/services/subscan-service/types.d.ts +27 -0
- package/services/subscan-service/types.js +1 -0
- package/services/transaction-service/event-parser/index.d.ts +2 -2
- package/services/transaction-service/event-parser/index.js +21 -49
- package/services/transaction-service/index.d.ts +4 -2
- package/services/transaction-service/index.js +66 -22
- package/services/transaction-service/utils.js +5 -6
- package/utils/address.d.ts +1 -0
- package/utils/address.js +9 -2
- package/utils/index.d.ts +2 -1
- package/utils/index.js +26 -23
- package/cjs/background/errors/EvmRpcError.js +0 -21
- package/cjs/background/errors/SubWalletProviderError.js +0 -17
- package/cjs/constants/ethereum.js +0 -19
- package/cjs/errors/SubWalletProviderError.js +0 -17
- package/cjs/koni/api/xcm/astar.js +0 -160
- package/cjs/koni/api/xcm/moonbeamXcm.js +0 -80
- package/cjs/koni/api/xcm/statemintXcm.js +0 -197
- package/cjs/koni/api/xcm/substrateXcm.js +0 -213
- package/cjs/koni/migration/Base.js +0 -20
- package/cjs/koni/migration/index.js +0 -45
- package/cjs/koni/migration/scripts/ChangeRouteToHome.js +0 -22
- package/cjs/koni/migration/scripts/ClearOldStorage.js +0 -24
- package/cjs/koni/migration/scripts/RemoveWrongTransactionHistoriesFromStore.js +0 -36
- package/cjs/koni/migration/scripts/ResetTransactionHistoryEventIdx.js +0 -21
- package/cjs/koni/migration/scripts/index.js +0 -22
- package/cjs/koni/page/index.js +0 -16
- package/cjs/services/asset-service/index.js +0 -91
- package/cjs/services/storage-service/db-stores/ExtraDelegationInfo.js +0 -17
- package/cjs/stores/Balance.js +0 -18
- package/cjs/stores/Crowdloan.js +0 -18
- package/cjs/stores/CustomEvmToken.js +0 -18
- package/cjs/stores/NetworkMap.js +0 -18
- package/cjs/stores/Nft.js +0 -18
- package/cjs/stores/NftCollection.js +0 -18
- package/cjs/stores/Price.js +0 -18
- package/cjs/stores/Staking.js +0 -18
- package/cjs/stores/StakingReward.js +0 -18
- package/cjs/utils/eth/parseTransactionData.js +0 -284
- package/koni/page/index.d.ts +0 -2
- package/koni/page/index.js +0 -9
- /package/cjs/{koni/page → page}/SubWalleEvmProvider.js +0 -0
- /package/{koni/page → page}/SubWalleEvmProvider.d.ts +0 -0
- /package/{koni/page → page}/SubWalleEvmProvider.js +0 -0
|
@@ -6,19 +6,19 @@ import { TransactionError } from '@subwallet/extension-base/background/errors/Tr
|
|
|
6
6
|
import { isJsonPayload, SEED_DEFAULT_LENGTH, SEED_LENGTHS } from '@subwallet/extension-base/background/handlers/Extension';
|
|
7
7
|
import { withErrorLog } from '@subwallet/extension-base/background/handlers/helpers';
|
|
8
8
|
import { createSubscription } from '@subwallet/extension-base/background/handlers/subscriptions';
|
|
9
|
-
import { AccountExternalErrorCode, BasicTxErrorType, ChainType, ExternalRequestPromiseStatus, ExtrinsicType, TransferTxErrorType } from '@subwallet/extension-base/background/KoniTypes';
|
|
10
|
-
import { ALL_ACCOUNT_KEY, ALL_GENESIS_HASH } from '@subwallet/extension-base/constants';
|
|
9
|
+
import { AccountExternalErrorCode, BasicTxErrorType, ChainType, ExternalRequestPromiseStatus, ExtrinsicType, StakingType, TransferTxErrorType } from '@subwallet/extension-base/background/KoniTypes';
|
|
10
|
+
import { ALL_ACCOUNT_KEY, ALL_GENESIS_HASH, DEFAULT_TIME_AUTO_LOCK } from '@subwallet/extension-base/constants';
|
|
11
11
|
import { ALLOWED_PATH } from '@subwallet/extension-base/defaults';
|
|
12
12
|
import { parseSubstrateTransaction } from '@subwallet/extension-base/koni/api/dotsama/parseTransaction';
|
|
13
13
|
import { checkReferenceCount, checkSupportTransfer, createTransferExtrinsic } from '@subwallet/extension-base/koni/api/dotsama/transfer';
|
|
14
14
|
import { getNftTransferExtrinsic, isRecipientSelf } from '@subwallet/extension-base/koni/api/nft/transfer';
|
|
15
|
-
import { getBondingExtrinsic, getCancelWithdrawalExtrinsic, getClaimRewardExtrinsic, getNominationPoolsInfo, getUnbondingExtrinsic, getValidatorsInfo, getWithdrawalExtrinsic } from '@subwallet/extension-base/koni/api/staking/bonding';
|
|
15
|
+
import { getBondingExtrinsic, getCancelWithdrawalExtrinsic, getClaimRewardExtrinsic, getNominationPoolsInfo, getUnbondingExtrinsic, getValidatorsInfo, getWithdrawalExtrinsic, validateBondingCondition, validateUnbondingCondition } from '@subwallet/extension-base/koni/api/staking/bonding';
|
|
16
16
|
import { getTuringCancelCompoundingExtrinsic, getTuringCompoundExtrinsic } from '@subwallet/extension-base/koni/api/staking/bonding/paraChain';
|
|
17
|
-
import { getPoolingBondingExtrinsic, getPoolingUnbondingExtrinsic } from '@subwallet/extension-base/koni/api/staking/bonding/relayChain';
|
|
17
|
+
import { getPoolingBondingExtrinsic, getPoolingUnbondingExtrinsic, validatePoolBondingCondition, validateRelayUnbondingCondition } from '@subwallet/extension-base/koni/api/staking/bonding/relayChain';
|
|
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, _isNativeToken, _isTokenEvmSmartContract } from '@subwallet/extension-base/services/chain-service/utils';
|
|
21
|
+
import { _getChainNativeTokenBasicInfo, _getContractAddressOfToken, _getEvmChainId, _getSubstrateGenesisHash, _getTokenMinAmount, _isAssetSmartContractNft, _isChainEvmCompatible, _isCustomAsset, _isLocalToken, _isNativeToken, _isTokenEvmSmartContract } 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 { createTransactionFromRLP, signatureToHex } from '@subwallet/extension-base/utils/eth';
|
|
24
24
|
import { parseContractInput, parseEvmRlp } from '@subwallet/extension-base/utils/eth/parseTransaction';
|
|
@@ -52,6 +52,7 @@ const ACCOUNT_ALL_JSON = {
|
|
|
52
52
|
name: 'All'
|
|
53
53
|
};
|
|
54
54
|
export default class KoniExtension {
|
|
55
|
+
#lockTimeOut = undefined;
|
|
55
56
|
#koniState;
|
|
56
57
|
constructor(state) {
|
|
57
58
|
this.#koniState = state;
|
|
@@ -400,36 +401,38 @@ export default class KoniExtension {
|
|
|
400
401
|
}
|
|
401
402
|
async accountsGetAllWithCurrentAddress(id, port) {
|
|
402
403
|
const cb = createSubscription(id, port);
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
404
|
+
const keyringService = this.#koniState.keyringService;
|
|
405
|
+
await this.#koniState.eventService.waitAccountReady;
|
|
406
|
+
const currentAccount = keyringService.currentAccount;
|
|
407
|
+
const accountsSubject = keyring.accounts.subject;
|
|
408
|
+
const transformedAccounts = transformAccounts(accountsSubject.value);
|
|
409
|
+
const responseData = {
|
|
410
|
+
accounts: transformedAccounts !== null && transformedAccounts !== void 0 && transformedAccounts.length ? [{
|
|
411
|
+
...ACCOUNT_ALL_JSON
|
|
412
|
+
}, ...transformedAccounts] : [],
|
|
413
|
+
currentAddress: currentAccount === null || currentAccount === void 0 ? void 0 : currentAccount.address,
|
|
414
|
+
currentGenesisHash: currentAccount === null || currentAccount === void 0 ? void 0 : currentAccount.currentGenesisHash
|
|
415
|
+
};
|
|
416
|
+
const subscriptionAccounts = accountsSubject.subscribe(storedAccounts => {
|
|
417
|
+
const transformedAccounts = transformAccounts(storedAccounts);
|
|
418
|
+
responseData.accounts = transformedAccounts !== null && transformedAccounts !== void 0 && transformedAccounts.length ? [{
|
|
419
|
+
...ACCOUNT_ALL_JSON
|
|
420
|
+
}, ...transformedAccounts] : [];
|
|
421
|
+
cb(responseData);
|
|
422
|
+
});
|
|
423
|
+
const subscriptionCurrentAccount = keyringService.currentAccountSubject.subscribe(currentAccountData => {
|
|
424
|
+
responseData.currentAddress = currentAccountData.address;
|
|
425
|
+
responseData.currentGenesisHash = currentAccountData.currentGenesisHash;
|
|
426
|
+
cb(responseData);
|
|
427
|
+
});
|
|
428
|
+
this.createUnsubscriptionHandle(id, () => {
|
|
429
|
+
subscriptionAccounts.unsubscribe();
|
|
430
|
+
subscriptionCurrentAccount.unsubscribe();
|
|
431
|
+
});
|
|
432
|
+
port.onDisconnect.addListener(() => {
|
|
433
|
+
this.cancelSubscription(id);
|
|
432
434
|
});
|
|
435
|
+
return responseData;
|
|
433
436
|
}
|
|
434
437
|
accountsGetAll(id, port) {
|
|
435
438
|
const cb = createSubscription(id, port);
|
|
@@ -450,11 +453,15 @@ export default class KoniExtension {
|
|
|
450
453
|
}) {
|
|
451
454
|
return keyring.saveRecent(accountId);
|
|
452
455
|
}
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
456
|
+
|
|
457
|
+
// private triggerAccountsSubscription (): boolean {
|
|
458
|
+
// const accountsSubject = accountsObservable.subject;
|
|
459
|
+
//
|
|
460
|
+
// accountsSubject.next(accountsSubject.getValue());
|
|
461
|
+
//
|
|
462
|
+
// return true;
|
|
463
|
+
// }
|
|
464
|
+
|
|
458
465
|
_getAuthListV2() {
|
|
459
466
|
return new Promise((resolve, reject) => {
|
|
460
467
|
this.#koniState.getAuthorize(rs => {
|
|
@@ -796,40 +803,40 @@ export default class KoniExtension {
|
|
|
796
803
|
return await this.#koniState.getAuthList();
|
|
797
804
|
}
|
|
798
805
|
_saveCurrentAccountAddress(address, callback) {
|
|
799
|
-
this.#koniState.
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
806
|
+
let accountInfo = this.#koniState.keyringService.currentAccount;
|
|
807
|
+
if (!accountInfo) {
|
|
808
|
+
accountInfo = {
|
|
809
|
+
address,
|
|
810
|
+
currentGenesisHash: ALL_GENESIS_HASH,
|
|
811
|
+
allGenesisHash: ALL_GENESIS_HASH || undefined
|
|
812
|
+
};
|
|
813
|
+
} else {
|
|
814
|
+
accountInfo.address = address;
|
|
815
|
+
if (address !== ALL_ACCOUNT_KEY) {
|
|
816
|
+
try {
|
|
817
|
+
const currentKeyPair = keyring.getPair(address);
|
|
810
818
|
accountInfo.currentGenesisHash = (currentKeyPair === null || currentKeyPair === void 0 ? void 0 : currentKeyPair.meta.genesisHash) || ALL_GENESIS_HASH;
|
|
811
|
-
}
|
|
812
|
-
accountInfo.currentGenesisHash =
|
|
819
|
+
} catch {
|
|
820
|
+
accountInfo.currentGenesisHash = ALL_GENESIS_HASH;
|
|
813
821
|
}
|
|
822
|
+
} else {
|
|
823
|
+
accountInfo.currentGenesisHash = accountInfo.allGenesisHash || ALL_GENESIS_HASH;
|
|
814
824
|
}
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
825
|
+
}
|
|
826
|
+
this.#koniState.setCurrentAccount(accountInfo, () => {
|
|
827
|
+
callback && callback(accountInfo);
|
|
818
828
|
});
|
|
819
829
|
}
|
|
820
830
|
updateCurrentAccountAddress(address) {
|
|
821
|
-
this._saveCurrentAccountAddress(address
|
|
822
|
-
this.triggerAccountsSubscription();
|
|
823
|
-
});
|
|
831
|
+
this._saveCurrentAccountAddress(address);
|
|
824
832
|
return true;
|
|
825
833
|
}
|
|
826
|
-
saveCurrentAccountAddress(data
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
834
|
+
async saveCurrentAccountAddress(data) {
|
|
835
|
+
return new Promise(resolve => {
|
|
836
|
+
this._saveCurrentAccountAddress(data.address, currentInfo => {
|
|
837
|
+
resolve(currentInfo);
|
|
838
|
+
});
|
|
831
839
|
});
|
|
832
|
-
return true;
|
|
833
840
|
}
|
|
834
841
|
async getAssetSetting() {
|
|
835
842
|
return this.#koniState.chainService.getAssetSettings();
|
|
@@ -846,6 +853,7 @@ export default class KoniExtension {
|
|
|
846
853
|
async updateAssetSetting(params) {
|
|
847
854
|
try {
|
|
848
855
|
await this.#koniState.chainService.updateAssetSetting(params.tokenSlug, params.assetSetting);
|
|
856
|
+
this.#koniState.eventService.emit('asset.updateState', params.tokenSlug);
|
|
849
857
|
return true;
|
|
850
858
|
} catch (e) {
|
|
851
859
|
console.error('Error updating asset setting', e);
|
|
@@ -969,16 +977,10 @@ export default class KoniExtension {
|
|
|
969
977
|
throw Error('Require password to set up master password');
|
|
970
978
|
} else {
|
|
971
979
|
keyring.changeMasterPassword(password);
|
|
972
|
-
this.#koniState.
|
|
973
|
-
hasMasterPassword: true,
|
|
974
|
-
isLocked: false,
|
|
975
|
-
isReady: true
|
|
976
|
-
});
|
|
980
|
+
this.#koniState.updateKeyringState();
|
|
977
981
|
}
|
|
978
982
|
}
|
|
979
|
-
const currentAccount =
|
|
980
|
-
this.#koniState.getCurrentAccount(resolve);
|
|
981
|
-
});
|
|
983
|
+
const currentAccount = this.#koniState.keyringService.currentAccount;
|
|
982
984
|
const allGenesisHash = (currentAccount === null || currentAccount === void 0 ? void 0 : currentAccount.allGenesisHash) || undefined;
|
|
983
985
|
types === null || types === void 0 ? void 0 : types.forEach(type => {
|
|
984
986
|
const suri = getSuri(_suri, type);
|
|
@@ -1038,19 +1040,13 @@ export default class KoniExtension {
|
|
|
1038
1040
|
});
|
|
1039
1041
|
});
|
|
1040
1042
|
|
|
1041
|
-
// Remove history
|
|
1042
|
-
await this.#koniState.historyService.removeHistoryByAddress(address);
|
|
1043
|
-
|
|
1044
1043
|
// Set current account to all account
|
|
1045
1044
|
await new Promise(resolve => {
|
|
1046
|
-
this.#koniState.
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
address: ALL_ACCOUNT_KEY
|
|
1052
|
-
}, resolve);
|
|
1053
|
-
});
|
|
1045
|
+
const currentAccountInfo = this.#koniState.keyringService.currentAccount;
|
|
1046
|
+
this.#koniState.setCurrentAccount({
|
|
1047
|
+
currentGenesisHash: (currentAccountInfo === null || currentAccountInfo === void 0 ? void 0 : currentAccountInfo.allGenesisHash) || null,
|
|
1048
|
+
address: ALL_ACCOUNT_KEY
|
|
1049
|
+
}, resolve);
|
|
1054
1050
|
});
|
|
1055
1051
|
return true;
|
|
1056
1052
|
}
|
|
@@ -1301,7 +1297,7 @@ export default class KoniExtension {
|
|
|
1301
1297
|
if (!tokenInfo) {
|
|
1302
1298
|
errors.push(new TransactionError(BasicTxErrorType.INVALID_PARAMS, 'Not found token from registry'));
|
|
1303
1299
|
}
|
|
1304
|
-
if (isEthereumAddress(from) && isEthereumAddress(to) &&
|
|
1300
|
+
if (isEthereumAddress(from) && isEthereumAddress(to) && _isTokenEvmSmartContract(tokenInfo) && _getContractAddressOfToken(tokenInfo).length === 0) {
|
|
1305
1301
|
errors.push(new TransactionError(BasicTxErrorType.INVALID_PARAMS, 'Not found ERC20 address for this token'));
|
|
1306
1302
|
}
|
|
1307
1303
|
return [errors, keypair, transferValue, tokenInfo];
|
|
@@ -1335,17 +1331,15 @@ export default class KoniExtension {
|
|
|
1335
1331
|
|
|
1336
1332
|
// Get native token amount
|
|
1337
1333
|
const freeBalance = await this.#koniState.balanceService.getTokenFreeBalance(from, networkKey, tokenSlug);
|
|
1338
|
-
let edAsWarning = false;
|
|
1339
1334
|
if (isEthereumAddress(from) && isEthereumAddress(to)) {
|
|
1340
1335
|
chainType = ChainType.EVM;
|
|
1341
1336
|
const txVal = transferAll ? freeBalance.value : value || '0';
|
|
1342
1337
|
|
|
1343
1338
|
// Estimate with EVM API
|
|
1344
|
-
if (_isTokenEvmSmartContract(tokenInfo)) {
|
|
1339
|
+
if (_isTokenEvmSmartContract(tokenInfo) || _isLocalToken(tokenInfo)) {
|
|
1345
1340
|
[transaction, transferAmount.value] = await getERC20TransactionObject(_getContractAddressOfToken(tokenInfo), chainInfo, from, to, txVal, !!transferAll, evmApiMap);
|
|
1346
1341
|
} else {
|
|
1347
1342
|
[transaction, transferAmount.value] = await getEVMTransactionObject(chainInfo, to, txVal, !!transferAll, evmApiMap);
|
|
1348
|
-
edAsWarning = true;
|
|
1349
1343
|
}
|
|
1350
1344
|
} else {
|
|
1351
1345
|
const substrateApi = this.#koniState.getSubstrateApi(networkKey);
|
|
@@ -1358,7 +1352,6 @@ export default class KoniExtension {
|
|
|
1358
1352
|
to: to,
|
|
1359
1353
|
substrateApi
|
|
1360
1354
|
});
|
|
1361
|
-
edAsWarning = true;
|
|
1362
1355
|
}
|
|
1363
1356
|
const transferNativeAmount = isTransferNativeToken ? transferAmount.value : '0';
|
|
1364
1357
|
return this.#koniState.transactionService.handleTransaction({
|
|
@@ -1373,7 +1366,7 @@ export default class KoniExtension {
|
|
|
1373
1366
|
extrinsicType: isTransferNativeToken ? ExtrinsicType.TRANSFER_BALANCE : ExtrinsicType.TRANSFER_TOKEN,
|
|
1374
1367
|
ignoreWarnings: transferAll,
|
|
1375
1368
|
isTransferAll: transferAll,
|
|
1376
|
-
edAsWarning:
|
|
1369
|
+
edAsWarning: isTransferNativeToken
|
|
1377
1370
|
});
|
|
1378
1371
|
}
|
|
1379
1372
|
validateCrossChainTransfer(destinationNetworkKey, sendingTokenSlug, sender, sendingValue) {
|
|
@@ -1740,9 +1733,7 @@ export default class KoniExtension {
|
|
|
1740
1733
|
resolve();
|
|
1741
1734
|
});
|
|
1742
1735
|
}
|
|
1743
|
-
const currentAccount =
|
|
1744
|
-
this.#koniState.getCurrentAccount(resolve);
|
|
1745
|
-
});
|
|
1736
|
+
const currentAccount = this.#koniState.keyringService.currentAccount;
|
|
1746
1737
|
const allGenesisHash = (currentAccount === null || currentAccount === void 0 ? void 0 : currentAccount.allGenesisHash) || undefined;
|
|
1747
1738
|
if (addresses.length <= 1) {
|
|
1748
1739
|
this.#koniState.setCurrentAccount({
|
|
@@ -2053,31 +2044,38 @@ export default class KoniExtension {
|
|
|
2053
2044
|
}
|
|
2054
2045
|
async getNominationPoolOptions(chain) {
|
|
2055
2046
|
const substrateApi = this.#koniState.getSubstrateApi(chain);
|
|
2047
|
+
console.log('chain', chain);
|
|
2056
2048
|
return await getNominationPoolsInfo(chain, substrateApi);
|
|
2057
2049
|
}
|
|
2058
2050
|
async submitBonding(inputData) {
|
|
2059
2051
|
const {
|
|
2052
|
+
address,
|
|
2060
2053
|
amount,
|
|
2061
2054
|
chain,
|
|
2062
2055
|
nominatorMetadata,
|
|
2063
2056
|
selectedValidators
|
|
2064
2057
|
} = inputData;
|
|
2065
|
-
if (!amount || !nominatorMetadata || !selectedValidators) {
|
|
2066
|
-
// Todo: Check and return error here
|
|
2067
|
-
|
|
2068
|
-
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new TransactionError(BasicTxErrorType.INVALID_PARAMS)]);
|
|
2069
|
-
}
|
|
2070
2058
|
const chainInfo = this.#koniState.getChainInfo(chain);
|
|
2059
|
+
const chainStakingMetadata = await this.#koniState.getStakingMetadataByChain(chain, StakingType.NOMINATED);
|
|
2060
|
+
if (!chainStakingMetadata) {
|
|
2061
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new TransactionError(BasicTxErrorType.INTERNAL_ERROR)]);
|
|
2062
|
+
}
|
|
2063
|
+
const bondingValidation = validateBondingCondition(chainInfo, amount, selectedValidators, address, chainStakingMetadata, nominatorMetadata);
|
|
2064
|
+
if (!amount || !selectedValidators || bondingValidation.length > 0) {
|
|
2065
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors(bondingValidation);
|
|
2066
|
+
}
|
|
2071
2067
|
const substrateApi = this.#koniState.getSubstrateApi(chain);
|
|
2072
|
-
const extrinsic = await getBondingExtrinsic(chainInfo, amount,
|
|
2068
|
+
const extrinsic = await getBondingExtrinsic(chainInfo, amount, selectedValidators, substrateApi, address, nominatorMetadata);
|
|
2069
|
+
console.log('Bonding extrinsic: ', chain, extrinsic.toHex());
|
|
2073
2070
|
return await this.#koniState.transactionService.handleTransaction({
|
|
2074
|
-
address
|
|
2071
|
+
address,
|
|
2075
2072
|
chain: chain,
|
|
2076
2073
|
chainType: ChainType.SUBSTRATE,
|
|
2077
2074
|
data: inputData,
|
|
2078
2075
|
extrinsicType: ExtrinsicType.STAKING_BOND,
|
|
2079
2076
|
transaction: extrinsic,
|
|
2080
|
-
url: EXTENSION_REQUEST_URL
|
|
2077
|
+
url: EXTENSION_REQUEST_URL,
|
|
2078
|
+
transferNativeAmount: amount
|
|
2081
2079
|
});
|
|
2082
2080
|
}
|
|
2083
2081
|
async submitUnbonding(inputData) {
|
|
@@ -2087,11 +2085,17 @@ export default class KoniExtension {
|
|
|
2087
2085
|
nominatorMetadata,
|
|
2088
2086
|
validatorAddress
|
|
2089
2087
|
} = inputData;
|
|
2090
|
-
|
|
2091
|
-
|
|
2088
|
+
const chainStakingMetadata = await this.#koniState.getStakingMetadataByChain(chain, StakingType.NOMINATED);
|
|
2089
|
+
if (!chainStakingMetadata || !nominatorMetadata) {
|
|
2090
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new TransactionError(BasicTxErrorType.INTERNAL_ERROR)]);
|
|
2091
|
+
}
|
|
2092
|
+
const unbondingValidation = validateUnbondingCondition(nominatorMetadata, amount, chain, chainStakingMetadata, validatorAddress);
|
|
2093
|
+
if (!amount || unbondingValidation.length > 0) {
|
|
2094
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors(unbondingValidation);
|
|
2092
2095
|
}
|
|
2093
2096
|
const substrateApi = this.#koniState.getSubstrateApi(chain);
|
|
2094
2097
|
const extrinsic = await getUnbondingExtrinsic(nominatorMetadata, amount, chain, substrateApi, validatorAddress);
|
|
2098
|
+
console.log('Unbonding extrinsic: ', extrinsic.toHex());
|
|
2095
2099
|
return await this.#koniState.transactionService.handleTransaction({
|
|
2096
2100
|
address: nominatorMetadata.address,
|
|
2097
2101
|
chain: chain,
|
|
@@ -2112,6 +2116,7 @@ export default class KoniExtension {
|
|
|
2112
2116
|
}
|
|
2113
2117
|
const dotSamaApi = this.#koniState.getSubstrateApi(chain);
|
|
2114
2118
|
const extrinsic = await getWithdrawalExtrinsic(dotSamaApi, chain, nominatorMetadata, validatorAddress);
|
|
2119
|
+
console.log('Stake withdrawal extrinsic: ', extrinsic.toHex());
|
|
2115
2120
|
return await this.#koniState.transactionService.handleTransaction({
|
|
2116
2121
|
address: nominatorMetadata.address,
|
|
2117
2122
|
chain: chain,
|
|
@@ -2133,6 +2138,7 @@ export default class KoniExtension {
|
|
|
2133
2138
|
}
|
|
2134
2139
|
const substrateApi = this.#koniState.getSubstrateApi(chain);
|
|
2135
2140
|
const extrinsic = await getClaimRewardExtrinsic(substrateApi, chain, address, stakingType, bondReward);
|
|
2141
|
+
console.log('Staking claim reward extrinsic: ', extrinsic.toHex());
|
|
2136
2142
|
return await this.#koniState.transactionService.handleTransaction({
|
|
2137
2143
|
address,
|
|
2138
2144
|
chain: chain,
|
|
@@ -2153,6 +2159,7 @@ export default class KoniExtension {
|
|
|
2153
2159
|
}
|
|
2154
2160
|
const substrateApi = this.#koniState.getSubstrateApi(chain);
|
|
2155
2161
|
const extrinsic = await getCancelWithdrawalExtrinsic(substrateApi, chain, selectedUnstaking);
|
|
2162
|
+
console.log('Cancel stake withdrawal extrinsic', extrinsic.toHex());
|
|
2156
2163
|
return await this.#koniState.transactionService.handleTransaction({
|
|
2157
2164
|
address,
|
|
2158
2165
|
chain,
|
|
@@ -2162,7 +2169,7 @@ export default class KoniExtension {
|
|
|
2162
2169
|
chainType: ChainType.SUBSTRATE
|
|
2163
2170
|
});
|
|
2164
2171
|
}
|
|
2165
|
-
async
|
|
2172
|
+
async submitPoolBonding(inputData) {
|
|
2166
2173
|
const {
|
|
2167
2174
|
address,
|
|
2168
2175
|
amount,
|
|
@@ -2170,8 +2177,18 @@ export default class KoniExtension {
|
|
|
2170
2177
|
nominatorMetadata,
|
|
2171
2178
|
selectedPool
|
|
2172
2179
|
} = inputData;
|
|
2180
|
+
const chainInfo = this.#koniState.getChainInfo(chain);
|
|
2181
|
+
const chainStakingMetadata = await this.#koniState.getStakingMetadataByChain(chain, StakingType.NOMINATED);
|
|
2182
|
+
if (!chainStakingMetadata) {
|
|
2183
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new TransactionError(BasicTxErrorType.INTERNAL_ERROR)]);
|
|
2184
|
+
}
|
|
2185
|
+
const bondingValidation = validatePoolBondingCondition(chainInfo, amount, selectedPool, address, chainStakingMetadata, nominatorMetadata);
|
|
2186
|
+
if (!amount || bondingValidation.length > 0) {
|
|
2187
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors(bondingValidation);
|
|
2188
|
+
}
|
|
2173
2189
|
const substrateApi = this.#koniState.getSubstrateApi(chain);
|
|
2174
2190
|
const extrinsic = await getPoolingBondingExtrinsic(substrateApi, amount, selectedPool.id, nominatorMetadata);
|
|
2191
|
+
console.log('Join nomination pool extrinsic', extrinsic.toHex());
|
|
2175
2192
|
return await this.#koniState.transactionService.handleTransaction({
|
|
2176
2193
|
address,
|
|
2177
2194
|
chain,
|
|
@@ -2187,8 +2204,17 @@ export default class KoniExtension {
|
|
|
2187
2204
|
chain,
|
|
2188
2205
|
nominatorMetadata
|
|
2189
2206
|
} = inputData;
|
|
2207
|
+
const chainStakingMetadata = await this.#koniState.getStakingMetadataByChain(chain, StakingType.NOMINATED);
|
|
2208
|
+
if (!chainStakingMetadata || !nominatorMetadata) {
|
|
2209
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors([new TransactionError(BasicTxErrorType.INTERNAL_ERROR)]);
|
|
2210
|
+
}
|
|
2211
|
+
const unbondingValidation = validateRelayUnbondingCondition(amount, chainStakingMetadata, nominatorMetadata);
|
|
2212
|
+
if (!amount || unbondingValidation.length > 0) {
|
|
2213
|
+
return this.#koniState.transactionService.generateBeforeHandleResponseErrors(unbondingValidation);
|
|
2214
|
+
}
|
|
2190
2215
|
const substrateApi = this.#koniState.getSubstrateApi(chain);
|
|
2191
2216
|
const extrinsic = await getPoolingUnbondingExtrinsic(substrateApi, amount, nominatorMetadata);
|
|
2217
|
+
console.log('Nomination pool unbond extrinsic', extrinsic.toHex());
|
|
2192
2218
|
return await this.#koniState.transactionService.handleTransaction({
|
|
2193
2219
|
address: nominatorMetadata.address,
|
|
2194
2220
|
chain,
|
|
@@ -2259,12 +2285,13 @@ export default class KoniExtension {
|
|
|
2259
2285
|
}
|
|
2260
2286
|
keyringStateSubscribe(id, port) {
|
|
2261
2287
|
const cb = createSubscription(id, port);
|
|
2262
|
-
const
|
|
2288
|
+
const keyringStateSubject = this.#koniState.keyringService.keyringStateSubject;
|
|
2289
|
+
const subscription = keyringStateSubject.subscribe(value => cb(value));
|
|
2263
2290
|
this.createUnsubscriptionHandle(id, subscription.unsubscribe);
|
|
2264
2291
|
port.onDisconnect.addListener(() => {
|
|
2265
2292
|
this.cancelSubscription(id);
|
|
2266
2293
|
});
|
|
2267
|
-
return this.#koniState.
|
|
2294
|
+
return this.#koniState.keyringService.keyringState;
|
|
2268
2295
|
}
|
|
2269
2296
|
keyringChangeMasterPassword({
|
|
2270
2297
|
createNew,
|
|
@@ -2295,11 +2322,7 @@ export default class KoniExtension {
|
|
|
2295
2322
|
status: false
|
|
2296
2323
|
};
|
|
2297
2324
|
}
|
|
2298
|
-
this.#koniState.
|
|
2299
|
-
hasMasterPassword: true,
|
|
2300
|
-
isLocked: false,
|
|
2301
|
-
isReady: true
|
|
2302
|
-
});
|
|
2325
|
+
this.#koniState.updateKeyringState();
|
|
2303
2326
|
return {
|
|
2304
2327
|
status: true,
|
|
2305
2328
|
errors: []
|
|
@@ -2334,11 +2357,7 @@ export default class KoniExtension {
|
|
|
2334
2357
|
status: false
|
|
2335
2358
|
};
|
|
2336
2359
|
}
|
|
2337
|
-
this.#koniState.
|
|
2338
|
-
isReady: true,
|
|
2339
|
-
hasMasterPassword: true,
|
|
2340
|
-
isLocked: false
|
|
2341
|
-
});
|
|
2360
|
+
this.#koniState.updateKeyringState();
|
|
2342
2361
|
return {
|
|
2343
2362
|
status: true,
|
|
2344
2363
|
errors: []
|
|
@@ -2346,11 +2365,8 @@ export default class KoniExtension {
|
|
|
2346
2365
|
}
|
|
2347
2366
|
keyringLock() {
|
|
2348
2367
|
keyring.lockAll();
|
|
2349
|
-
this.#koniState.
|
|
2350
|
-
|
|
2351
|
-
hasMasterPassword: true,
|
|
2352
|
-
isLocked: true
|
|
2353
|
-
});
|
|
2368
|
+
this.#koniState.updateKeyringState();
|
|
2369
|
+
clearTimeout(this.#lockTimeOut);
|
|
2354
2370
|
}
|
|
2355
2371
|
keyringExportMnemonic({
|
|
2356
2372
|
address,
|
|
@@ -2393,6 +2409,7 @@ export default class KoniExtension {
|
|
|
2393
2409
|
payload
|
|
2394
2410
|
} = request;
|
|
2395
2411
|
const registry = new TypeRegistry();
|
|
2412
|
+
let isEvm = false;
|
|
2396
2413
|
if (isJsonPayload(payload)) {
|
|
2397
2414
|
// Get the metadata for the genesisHash
|
|
2398
2415
|
const currentMetadata = this.#koniState.knownMetadata.find(meta => meta.genesisHash === payload.genesisHash);
|
|
@@ -2402,11 +2419,16 @@ export default class KoniExtension {
|
|
|
2402
2419
|
if (currentMetadata) {
|
|
2403
2420
|
registry.register(currentMetadata === null || currentMetadata === void 0 ? void 0 : currentMetadata.types);
|
|
2404
2421
|
}
|
|
2422
|
+
const [, chainInfo] = this.#koniState.findNetworkKeyByGenesisHash(payload.genesisHash);
|
|
2423
|
+
if (chainInfo) {
|
|
2424
|
+
isEvm = _isChainEvmCompatible(chainInfo);
|
|
2425
|
+
}
|
|
2405
2426
|
}
|
|
2406
2427
|
const result = request.sign(registry, pair);
|
|
2407
2428
|
resolve({
|
|
2408
2429
|
id,
|
|
2409
|
-
|
|
2430
|
+
// In case evm chain, must be cut 2 character after 0x
|
|
2431
|
+
signature: isEvm ? `0x${result.signature.slice(4)}` : result.signature
|
|
2410
2432
|
});
|
|
2411
2433
|
return true;
|
|
2412
2434
|
}
|
|
@@ -2679,10 +2701,24 @@ export default class KoniExtension {
|
|
|
2679
2701
|
});
|
|
2680
2702
|
return notificationSubject.value;
|
|
2681
2703
|
}
|
|
2704
|
+
async reloadCron({
|
|
2705
|
+
data
|
|
2706
|
+
}) {
|
|
2707
|
+
if (data === 'nft') {
|
|
2708
|
+
return await this.#koniState.reloadNft();
|
|
2709
|
+
} else if (data === 'staking') {
|
|
2710
|
+
return await this.#koniState.reloadStaking();
|
|
2711
|
+
}
|
|
2712
|
+
return Promise.resolve(false);
|
|
2713
|
+
}
|
|
2682
2714
|
|
|
2683
2715
|
// --------------------------------------------------------------
|
|
2684
2716
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
2685
2717
|
async handle(id, type, request, port) {
|
|
2718
|
+
clearTimeout(this.#lockTimeOut);
|
|
2719
|
+
this.#lockTimeOut = setTimeout(() => {
|
|
2720
|
+
this.keyringLock();
|
|
2721
|
+
}, DEFAULT_TIME_AUTO_LOCK);
|
|
2686
2722
|
switch (type) {
|
|
2687
2723
|
/// Clone from PolkadotJs
|
|
2688
2724
|
case 'pri(accounts.create.external)':
|
|
@@ -2791,10 +2827,8 @@ export default class KoniExtension {
|
|
|
2791
2827
|
return this.accountsGetAll(id, port);
|
|
2792
2828
|
case 'pri(accounts.saveRecent)':
|
|
2793
2829
|
return this.saveRecentAccountId(request);
|
|
2794
|
-
case 'pri(accounts.triggerSubscription)':
|
|
2795
|
-
return this.triggerAccountsSubscription();
|
|
2796
2830
|
case 'pri(currentAccount.saveAddress)':
|
|
2797
|
-
return this.saveCurrentAccountAddress(request
|
|
2831
|
+
return await this.saveCurrentAccountAddress(request);
|
|
2798
2832
|
case 'pri(accounts.updateCurrentAddress)':
|
|
2799
2833
|
return this.updateCurrentAccountAddress(request);
|
|
2800
2834
|
case 'pri(settings.changeBalancesVisibility)':
|
|
@@ -2958,7 +2992,7 @@ export default class KoniExtension {
|
|
|
2958
2992
|
case 'pri(staking.submitTuringCancelCompound)':
|
|
2959
2993
|
return await this.submitTuringCancelStakeCompound(request);
|
|
2960
2994
|
case 'pri(bonding.nominationPool.submitBonding)':
|
|
2961
|
-
return await this.
|
|
2995
|
+
return await this.submitPoolBonding(request);
|
|
2962
2996
|
case 'pri(bonding.nominationPool.submitUnbonding)':
|
|
2963
2997
|
return await this.submitPoolingUnbonding(request);
|
|
2964
2998
|
|
|
@@ -3007,6 +3041,8 @@ export default class KoniExtension {
|
|
|
3007
3041
|
// Notification
|
|
3008
3042
|
case 'pri(notifications.subscribe)':
|
|
3009
3043
|
return this.subscribeNotifications(id, port);
|
|
3044
|
+
case 'pri(cron.reload)':
|
|
3045
|
+
return await this.reloadCron(request);
|
|
3010
3046
|
|
|
3011
3047
|
// Default
|
|
3012
3048
|
default:
|