@subwallet/extension-base 1.1.2-0 → 1.1.3-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/background/KoniTypes.d.ts +32 -4
- package/background/KoniTypes.js +2 -1
- package/cjs/background/KoniTypes.js +4 -2
- package/cjs/constants/i18n.js +10 -2
- package/cjs/koni/api/dotsama/transfer.js +6 -2
- package/cjs/koni/api/nft/acala_nft/index.js +0 -2
- package/cjs/koni/api/nft/bit.country/index.js +49 -18
- package/cjs/koni/api/nft/config.js +5 -3
- package/cjs/koni/api/nft/evm_nft/index.js +0 -5
- package/cjs/koni/api/nft/index.js +2 -3
- package/cjs/koni/api/nft/karura_nft/index.js +0 -2
- package/cjs/koni/api/nft/rmrk_nft/index.js +0 -4
- package/cjs/koni/api/nft/statemine_nft/index.js +0 -2
- package/cjs/koni/api/nft/unique_nft/index.js +0 -5
- package/cjs/koni/api/nft/wasm_nft/index.js +0 -5
- package/cjs/koni/api/staking/bonding/amplitude.js +6 -6
- package/cjs/koni/api/staking/bonding/astar.js +6 -6
- package/cjs/koni/api/staking/bonding/paraChain.js +5 -5
- package/cjs/koni/api/staking/bonding/relayChain.js +24 -14
- package/cjs/koni/api/staking/bonding/utils.js +1 -7
- package/cjs/koni/api/xcm/xTokens.js +1 -1
- package/cjs/koni/background/cron.js +2 -37
- package/cjs/koni/background/handlers/Extension.js +206 -137
- package/cjs/koni/background/handlers/State.js +72 -84
- package/cjs/koni/background/subscription.js +6 -88
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/chain-service/constants.js +8 -5
- package/cjs/services/chain-service/handler/SubstrateApi.js +8 -0
- package/cjs/services/chain-service/handler/manta/MantaPrivateHandler.js +1 -1
- package/cjs/services/chain-service/handler/manta/manta-extension-sdk-empty.js +13 -0
- package/cjs/services/chain-service/index.js +11 -6
- package/cjs/services/request-service/handler/PopupHandler.js +2 -2
- package/cjs/services/request-service/helper/index.js +2 -26
- package/cjs/services/setting-service/constants.js +16 -6
- package/cjs/services/storage-service/DatabaseService.js +3 -0
- package/cjs/services/storage-service/db-stores/Metadata.js +1 -1
- package/cjs/services/storage-service/db-stores/Nft.js +3 -0
- package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -2
- package/cjs/services/wallet-connect-service/constants.js +8 -5
- package/cjs/services/wallet-connect-service/index.js +50 -36
- package/cjs/utils/environment.js +32 -2
- package/cjs/utils/index.js +33 -5
- package/cjs/utils/registry.js +25 -0
- package/cjs/utils/translate.js +11 -0
- package/constants/i18n.d.ts +2 -1
- package/constants/i18n.js +8 -1
- package/koni/api/dotsama/transfer.js +6 -2
- package/koni/api/nft/acala_nft/index.js +0 -2
- package/koni/api/nft/bit.country/index.d.ts +1 -0
- package/koni/api/nft/bit.country/index.js +50 -19
- package/koni/api/nft/config.d.ts +2 -1
- package/koni/api/nft/config.js +2 -1
- package/koni/api/nft/evm_nft/index.js +0 -4
- package/koni/api/nft/index.d.ts +1 -1
- package/koni/api/nft/index.js +2 -3
- package/koni/api/nft/karura_nft/index.js +0 -2
- package/koni/api/nft/nft.d.ts +0 -1
- package/koni/api/nft/rmrk_nft/index.js +0 -4
- package/koni/api/nft/statemine_nft/index.js +0 -2
- package/koni/api/nft/unique_nft/index.js +0 -5
- package/koni/api/nft/wasm_nft/index.js +0 -4
- package/koni/api/staking/bonding/amplitude.js +6 -6
- package/koni/api/staking/bonding/astar.js +6 -6
- package/koni/api/staking/bonding/paraChain.js +5 -5
- package/koni/api/staking/bonding/relayChain.js +24 -14
- package/koni/api/staking/bonding/utils.js +1 -7
- package/koni/api/xcm/xTokens.js +1 -1
- package/koni/background/cron.d.ts +0 -5
- package/koni/background/cron.js +4 -39
- package/koni/background/handlers/Extension.d.ts +4 -0
- package/koni/background/handlers/Extension.js +97 -32
- package/koni/background/handlers/State.d.ts +8 -7
- package/koni/background/handlers/State.js +72 -84
- package/koni/background/subscription.d.ts +1 -4
- package/koni/background/subscription.js +9 -88
- package/package.json +22 -6
- package/packageInfo.js +1 -1
- package/services/chain-service/constants.d.ts +2 -0
- package/services/chain-service/constants.js +8 -5
- package/services/chain-service/handler/SubstrateApi.js +8 -0
- package/services/chain-service/handler/manta/MantaPrivateHandler.d.ts +1 -1
- package/services/chain-service/handler/manta/MantaPrivateHandler.js +1 -1
- package/services/chain-service/handler/manta/manta-extension-sdk-empty.d.ts +4 -0
- package/services/chain-service/handler/manta/manta-extension-sdk-empty.js +5 -0
- package/services/chain-service/index.d.ts +2 -1
- package/services/chain-service/index.js +11 -6
- package/services/request-service/handler/PopupHandler.js +1 -1
- package/services/request-service/helper/index.d.ts +0 -2
- package/services/request-service/helper/index.js +0 -23
- package/services/request-service/types.d.ts +0 -1
- package/services/setting-service/constants.d.ts +6 -1
- package/services/setting-service/constants.js +10 -5
- package/services/storage-service/DatabaseService.d.ts +1 -0
- package/services/storage-service/DatabaseService.js +3 -0
- package/services/storage-service/db-stores/Metadata.js +1 -1
- package/services/storage-service/db-stores/Nft.d.ts +1 -0
- package/services/storage-service/db-stores/Nft.js +3 -0
- package/services/storage-service/db-stores/NominatorMetadata.js +3 -2
- package/services/wallet-connect-service/constants.d.ts +2 -1
- package/services/wallet-connect-service/constants.js +5 -3
- package/services/wallet-connect-service/index.d.ts +0 -1
- package/services/wallet-connect-service/index.js +50 -36
- package/utils/environment.d.ts +4 -1
- package/utils/environment.js +28 -1
- package/utils/index.d.ts +3 -0
- package/utils/index.js +6 -2
- package/utils/registry.d.ts +4 -0
- package/utils/registry.js +18 -0
- package/utils/translate.d.ts +1 -0
- package/utils/translate.js +4 -0
package/koni/background/cron.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import { _isChainSupportEvmNft, _isChainSupportNativeNft,
|
|
4
|
+
import { CRON_REFRESH_NFT_INTERVAL, CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL, CRON_REFRESH_STAKING_REWARD_INTERVAL, CRON_SYNC_MANTA_PAY } from '@subwallet/extension-base/constants';
|
|
5
|
+
import { _isChainSupportEvmNft, _isChainSupportNativeNft, _isChainSupportWasmNft } from '@subwallet/extension-base/services/chain-service/utils';
|
|
6
6
|
import { waitTimeout } from '@subwallet/extension-base/utils';
|
|
7
7
|
import { Subject } from 'rxjs';
|
|
8
8
|
import { logger as createLogger } from '@polkadot/util';
|
|
@@ -61,7 +61,6 @@ export class KoniCron {
|
|
|
61
61
|
const serviceInfo = this.state.getServiceInfo();
|
|
62
62
|
const commonReload = eventTypes.some(eventType => commonReloadEvents.includes(eventType));
|
|
63
63
|
const chainUpdated = eventTypes.includes('chain.updateState');
|
|
64
|
-
const stakingSubmitted = eventTypes.includes('transaction.submitStaking');
|
|
65
64
|
const reloadMantaPay = eventTypes.includes('mantaPay.submitTransaction') || eventTypes.includes('mantaPay.enable');
|
|
66
65
|
const updatedChains = [];
|
|
67
66
|
if (chainUpdated) {
|
|
@@ -72,7 +71,7 @@ export class KoniCron {
|
|
|
72
71
|
}
|
|
73
72
|
});
|
|
74
73
|
}
|
|
75
|
-
if (!commonReload && !chainUpdated && !
|
|
74
|
+
if (!commonReload && !chainUpdated && !reloadMantaPay) {
|
|
76
75
|
return;
|
|
77
76
|
}
|
|
78
77
|
const address = (_serviceInfo$currentA = serviceInfo.currentAccountInfo) === null || _serviceInfo$currentA === void 0 ? void 0 : _serviceInfo$currentA.address;
|
|
@@ -81,7 +80,6 @@ export class KoniCron {
|
|
|
81
80
|
}
|
|
82
81
|
const chainInfoMap = serviceInfo.chainInfoMap;
|
|
83
82
|
const needUpdateNft = this.needUpdateNft(chainInfoMap, updatedChains);
|
|
84
|
-
const needUpdateStaking = this.needUpdateStaking(chainInfoMap, updatedChains);
|
|
85
83
|
|
|
86
84
|
// MantaPay
|
|
87
85
|
reloadMantaPay && this.removeCron('syncMantaPay');
|
|
@@ -90,19 +88,10 @@ export class KoniCron {
|
|
|
90
88
|
(commonReload || needUpdateNft) && this.resetNft(address);
|
|
91
89
|
(commonReload || needUpdateNft) && this.removeCron('refreshNft');
|
|
92
90
|
|
|
93
|
-
// Staking
|
|
94
|
-
(commonReload || needUpdateStaking || stakingSubmitted) && this.resetStakingReward();
|
|
95
|
-
(commonReload || needUpdateStaking || stakingSubmitted) && this.removeCron('refreshStakingReward');
|
|
96
|
-
(commonReload || needUpdateStaking || stakingSubmitted) && this.removeCron('refreshPoolingStakingReward');
|
|
97
|
-
needUpdateStaking && this.removeCron('updateChainStakingMetadata');
|
|
98
|
-
|
|
99
91
|
// Chains
|
|
100
92
|
if (this.checkNetworkAvailable(serviceInfo)) {
|
|
101
93
|
// only add cron job if there's at least 1 active network
|
|
102
94
|
(commonReload || needUpdateNft) && this.addCron('refreshNft', this.refreshNft(address, serviceInfo.chainApiMap, this.state.getSmartContractNfts(), this.state.getActiveChainInfoMap()), CRON_REFRESH_NFT_INTERVAL);
|
|
103
|
-
(commonReload || needUpdateStaking || stakingSubmitted) && this.addCron('refreshStakingReward', this.refreshStakingReward(address), CRON_REFRESH_STAKING_REWARD_INTERVAL);
|
|
104
|
-
(commonReload || needUpdateStaking || stakingSubmitted) && this.addCron('refreshPoolingStakingReward', this.refreshStakingRewardFastInterval(address), CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL);
|
|
105
|
-
needUpdateStaking && this.addCron('updateChainStakingMetadata', this.updateChainStakingMetadata(serviceInfo.chainInfoMap, serviceInfo.chainStateMap, serviceInfo.chainApiMap.substrate), CRON_REFRESH_CHAIN_STAKING_METADATA);
|
|
106
95
|
reloadMantaPay && this.addCron('syncMantaPay', this.syncMantaPay, CRON_SYNC_MANTA_PAY);
|
|
107
96
|
} else {
|
|
108
97
|
this.setStakingRewardReady();
|
|
@@ -117,7 +106,6 @@ export class KoniCron {
|
|
|
117
106
|
this.addCron('refreshNft', this.refreshNft(currentAccountInfo.address, this.state.getApiMap(), this.state.getSmartContractNfts(), this.state.getActiveChainInfoMap()), CRON_REFRESH_NFT_INTERVAL);
|
|
118
107
|
this.addCron('refreshStakingReward', this.refreshStakingReward(currentAccountInfo.address), CRON_REFRESH_STAKING_REWARD_INTERVAL);
|
|
119
108
|
this.addCron('refreshPoolingStakingReward', this.refreshStakingRewardFastInterval(currentAccountInfo.address), CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL);
|
|
120
|
-
this.addCron('updateChainStakingMetadata', this.updateChainStakingMetadata(this.state.getChainInfoMap(), this.state.getChainStateMap(), this.state.getSubstrateApiMap()), CRON_REFRESH_CHAIN_STAKING_METADATA);
|
|
121
109
|
this.addCron('syncMantaPay', this.syncMantaPay, CRON_SYNC_MANTA_PAY);
|
|
122
110
|
} else {
|
|
123
111
|
this.setStakingRewardReady();
|
|
@@ -155,9 +143,6 @@ export class KoniCron {
|
|
|
155
143
|
resetNft = newAddress => {
|
|
156
144
|
this.state.resetNft(newAddress);
|
|
157
145
|
};
|
|
158
|
-
resetStakingReward = () => {
|
|
159
|
-
this.state.resetStakingReward();
|
|
160
|
-
};
|
|
161
146
|
refreshStakingReward = address => {
|
|
162
147
|
return () => {
|
|
163
148
|
this.subscriptions.subscribeStakingReward(address).catch(this.logger.error);
|
|
@@ -174,16 +159,6 @@ export class KoniCron {
|
|
|
174
159
|
checkNetworkAvailable = serviceInfo => {
|
|
175
160
|
return Object.keys(serviceInfo.chainApiMap.substrate).length > 0 || Object.keys(serviceInfo.chainApiMap.evm).length > 0;
|
|
176
161
|
};
|
|
177
|
-
updateChainStakingMetadata = (chainInfoMap, chainStateMap, substrateApiMap) => {
|
|
178
|
-
return () => {
|
|
179
|
-
this.subscriptions.fetchChainStakingMetadata(chainInfoMap, chainStateMap, substrateApiMap).catch(this.logger.error);
|
|
180
|
-
};
|
|
181
|
-
};
|
|
182
|
-
updateNominatorMetadata = (address, chainInfoMap, chainStateMap, substrateApiMap) => {
|
|
183
|
-
return () => {
|
|
184
|
-
this.subscriptions.fetchNominatorMetadata(address, chainInfoMap, chainStateMap, substrateApiMap).catch(this.logger.error);
|
|
185
|
-
};
|
|
186
|
-
};
|
|
187
162
|
async reloadNft() {
|
|
188
163
|
const address = this.state.keyringService.currentAccount.address;
|
|
189
164
|
const serviceInfo = this.state.getServiceInfo();
|
|
@@ -195,11 +170,7 @@ export class KoniCron {
|
|
|
195
170
|
}
|
|
196
171
|
async reloadStaking() {
|
|
197
172
|
const address = this.state.keyringService.currentAccount.address;
|
|
198
|
-
|
|
199
|
-
this.removeCron('refreshStakingReward');
|
|
200
|
-
this.removeCron('refreshPoolingStakingReward');
|
|
201
|
-
this.addCron('refreshStakingReward', this.refreshStakingReward(address), CRON_REFRESH_STAKING_REWARD_INTERVAL);
|
|
202
|
-
this.addCron('refreshPoolingStakingReward', this.refreshStakingRewardFastInterval(address), CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL);
|
|
173
|
+
console.log('reload staking', address);
|
|
203
174
|
await waitTimeout(1800);
|
|
204
175
|
return true;
|
|
205
176
|
}
|
|
@@ -212,10 +183,4 @@ export class KoniCron {
|
|
|
212
183
|
}
|
|
213
184
|
return false;
|
|
214
185
|
}
|
|
215
|
-
needUpdateStaking(chainInfoMap, updatedChains) {
|
|
216
|
-
if (updatedChains && updatedChains.length > 0) {
|
|
217
|
-
return updatedChains.some(updatedChain => _isChainSupportSubstrateStaking(chainInfoMap[updatedChain]));
|
|
218
|
-
}
|
|
219
|
-
return false;
|
|
220
|
-
}
|
|
221
186
|
}
|
|
@@ -76,6 +76,9 @@ export default class KoniExtension {
|
|
|
76
76
|
private setAutoLockTime;
|
|
77
77
|
private subscribeSettings;
|
|
78
78
|
private setEnableChainPatrol;
|
|
79
|
+
private setShowZeroBalance;
|
|
80
|
+
private setLanguage;
|
|
81
|
+
private setShowBalance;
|
|
79
82
|
private subscribeAuthUrls;
|
|
80
83
|
private _saveCurrentAccountAddress;
|
|
81
84
|
private updateCurrentAccountAddress;
|
|
@@ -199,5 +202,6 @@ export default class KoniExtension {
|
|
|
199
202
|
private disableMantaPay;
|
|
200
203
|
private subscribeMantaPayConfig;
|
|
201
204
|
private subscribeMantaPaySyncState;
|
|
205
|
+
private findRawMetadata;
|
|
202
206
|
handle<TMessageType extends MessageTypes>(id: string, type: TMessageType, request: RequestTypes[TMessageType], port: chrome.runtime.Port): Promise<ResponseType<TMessageType>>;
|
|
203
207
|
}
|
|
@@ -20,7 +20,7 @@ import { getPoolingBondingExtrinsic, getPoolingUnbondingExtrinsic, validatePoolB
|
|
|
20
20
|
import { getERC20TransactionObject, getERC721Transaction, getEVMTransactionObject } from '@subwallet/extension-base/koni/api/tokens/evm/transfer';
|
|
21
21
|
import { getPSP34TransferExtrinsic } from '@subwallet/extension-base/koni/api/tokens/wasm';
|
|
22
22
|
import { createXcmExtrinsic } from '@subwallet/extension-base/koni/api/xcm';
|
|
23
|
-
import { _DEFAULT_MANTA_ZK_CHAIN, _MANTA_ZK_CHAIN_GROUP, _ZK_ASSET_PREFIX } from '@subwallet/extension-base/services/chain-service/constants';
|
|
23
|
+
import { _API_OPTIONS_CHAIN_GROUP, _DEFAULT_MANTA_ZK_CHAIN, _MANTA_ZK_CHAIN_GROUP, _ZK_ASSET_PREFIX } from '@subwallet/extension-base/services/chain-service/constants';
|
|
24
24
|
import { _ChainConnectionStatus } from '@subwallet/extension-base/services/chain-service/types';
|
|
25
25
|
import { _getChainNativeTokenBasicInfo, _getContractAddressOfToken, _getEvmChainId, _getSubstrateGenesisHash, _getTokenMinAmount, _isAssetSmartContractNft, _isChainEvmCompatible, _isCustomAsset, _isLocalToken, _isMantaZkAsset, _isNativeToken, _isTokenEvmSmartContract, _isTokenTransferredByEvm } from '@subwallet/extension-base/services/chain-service/utils';
|
|
26
26
|
import { EXTENSION_REQUEST_URL } from '@subwallet/extension-base/services/request-service/constants';
|
|
@@ -828,32 +828,24 @@ export default class KoniExtension {
|
|
|
828
828
|
});
|
|
829
829
|
return true;
|
|
830
830
|
}
|
|
831
|
-
saveTheme(data
|
|
832
|
-
|
|
833
|
-
this.#koniState.setTheme(data, cb);
|
|
834
|
-
port.onDisconnect.addListener(() => {
|
|
835
|
-
this.cancelSubscription(id);
|
|
836
|
-
});
|
|
831
|
+
saveTheme(data) {
|
|
832
|
+
this.#koniState.updateSetting('theme', data);
|
|
837
833
|
return true;
|
|
838
834
|
}
|
|
839
835
|
setCamera({
|
|
840
836
|
camera
|
|
841
837
|
}) {
|
|
842
|
-
this.#koniState.
|
|
838
|
+
this.#koniState.updateSetting('camera', camera);
|
|
843
839
|
return true;
|
|
844
840
|
}
|
|
845
|
-
saveBrowserConfirmationType(data
|
|
846
|
-
|
|
847
|
-
this.#koniState.setBrowserConfirmationType(data, cb);
|
|
848
|
-
port.onDisconnect.addListener(() => {
|
|
849
|
-
this.cancelSubscription(id);
|
|
850
|
-
});
|
|
841
|
+
saveBrowserConfirmationType(data) {
|
|
842
|
+
this.#koniState.updateSetting('browserConfirmationType', data);
|
|
851
843
|
return true;
|
|
852
844
|
}
|
|
853
845
|
setAutoLockTime({
|
|
854
846
|
autoLockTime
|
|
855
847
|
}) {
|
|
856
|
-
this.#koniState.
|
|
848
|
+
this.#koniState.updateSetting('timeAutoLock', autoLockTime);
|
|
857
849
|
return true;
|
|
858
850
|
}
|
|
859
851
|
async subscribeSettings(id, port) {
|
|
@@ -872,7 +864,25 @@ export default class KoniExtension {
|
|
|
872
864
|
setEnableChainPatrol({
|
|
873
865
|
enable
|
|
874
866
|
}) {
|
|
875
|
-
this.#koniState.
|
|
867
|
+
this.#koniState.updateSetting('enableChainPatrol', enable);
|
|
868
|
+
return true;
|
|
869
|
+
}
|
|
870
|
+
setShowZeroBalance({
|
|
871
|
+
show
|
|
872
|
+
}) {
|
|
873
|
+
this.#koniState.updateSetting('isShowZeroBalance', show);
|
|
874
|
+
return true;
|
|
875
|
+
}
|
|
876
|
+
setLanguage({
|
|
877
|
+
language
|
|
878
|
+
}) {
|
|
879
|
+
this.#koniState.updateSetting('language', language);
|
|
880
|
+
return true;
|
|
881
|
+
}
|
|
882
|
+
setShowBalance({
|
|
883
|
+
enable
|
|
884
|
+
}) {
|
|
885
|
+
this.#koniState.updateSetting('isShowBalance', enable);
|
|
876
886
|
return true;
|
|
877
887
|
}
|
|
878
888
|
async subscribeAuthUrls(id, port) {
|
|
@@ -1475,6 +1485,8 @@ export default class KoniExtension {
|
|
|
1475
1485
|
|
|
1476
1486
|
const additionalValidator = async inputTransaction => {
|
|
1477
1487
|
const minAmount = tokenInfo.minAmount || '0';
|
|
1488
|
+
|
|
1489
|
+
// Check ed for sender
|
|
1478
1490
|
if (!isTransferNativeToken) {
|
|
1479
1491
|
const {
|
|
1480
1492
|
value: balance
|
|
@@ -1490,10 +1502,12 @@ export default class KoniExtension {
|
|
|
1490
1502
|
const {
|
|
1491
1503
|
value: receiverBalance
|
|
1492
1504
|
} = await this.getAddressFreeBalance({
|
|
1493
|
-
address:
|
|
1505
|
+
address: to,
|
|
1494
1506
|
networkKey,
|
|
1495
1507
|
token: tokenSlug
|
|
1496
1508
|
});
|
|
1509
|
+
|
|
1510
|
+
// Check ed for receiver
|
|
1497
1511
|
if (new BigN(receiverBalance).plus(transferAmount.value).lt(minAmount)) {
|
|
1498
1512
|
const atLeast = new BigN(minAmount).minus(receiverBalance).plus((tokenInfo.decimals || 0) === 0 ? 0 : 1);
|
|
1499
1513
|
const atLeastStr = formatNumber(atLeast, tokenInfo.decimals || 0, balanceFormatter);
|
|
@@ -1557,16 +1571,24 @@ export default class KoniExtension {
|
|
|
1557
1571
|
additionalValidator = async inputTransaction => {
|
|
1558
1572
|
const destMinAmount = destinationTokenInfo.minAmount || '0';
|
|
1559
1573
|
const atLeast = new BigN(destMinAmount).multipliedBy(XCM_MIN_AMOUNT_RATIO);
|
|
1574
|
+
|
|
1575
|
+
// Check ed for receiver
|
|
1560
1576
|
if (new BigN(value).lt(atLeast)) {
|
|
1561
1577
|
const atLeastStr = formatNumber(atLeast, destinationTokenInfo.decimals || 0, balanceFormatter);
|
|
1562
1578
|
inputTransaction.errors.push(new TransactionError(TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, `You must transfer at least ${atLeastStr} ${originTokenInfo.symbol} to keep the destination account alive`));
|
|
1563
1579
|
}
|
|
1564
1580
|
const srcMinAmount = originTokenInfo.minAmount || '0';
|
|
1565
1581
|
const isTransferNativeToken = originTokenInfo.assetType === _AssetType.NATIVE;
|
|
1582
|
+
|
|
1583
|
+
// Check ed for sender
|
|
1566
1584
|
if (!isTransferNativeToken) {
|
|
1567
1585
|
const {
|
|
1568
1586
|
value: balance
|
|
1569
|
-
} = await this
|
|
1587
|
+
} = await this.getAddressFreeBalance({
|
|
1588
|
+
address: from,
|
|
1589
|
+
networkKey: originNetworkKey,
|
|
1590
|
+
token: originTokenInfo.slug
|
|
1591
|
+
});
|
|
1570
1592
|
if (new BigN(balance).minus(value).lt(srcMinAmount)) {
|
|
1571
1593
|
inputTransaction.warnings.push(new TransactionWarning(BasicTxWarningCode.NOT_ENOUGH_EXISTENTIAL_DEPOSIT, ''));
|
|
1572
1594
|
}
|
|
@@ -2743,7 +2765,7 @@ export default class KoniExtension {
|
|
|
2743
2765
|
const {
|
|
2744
2766
|
payload
|
|
2745
2767
|
} = request;
|
|
2746
|
-
|
|
2768
|
+
let registry = new TypeRegistry();
|
|
2747
2769
|
let isEvm = false;
|
|
2748
2770
|
if (isJsonPayload(payload)) {
|
|
2749
2771
|
// Get the metadata for the genesisHash
|
|
@@ -2755,6 +2777,15 @@ export default class KoniExtension {
|
|
|
2755
2777
|
registry.register(currentMetadata === null || currentMetadata === void 0 ? void 0 : currentMetadata.types);
|
|
2756
2778
|
}
|
|
2757
2779
|
const [, chainInfo] = this.#koniState.findNetworkKeyByGenesisHash(payload.genesisHash);
|
|
2780
|
+
if (chainInfo && _API_OPTIONS_CHAIN_GROUP.avail.includes(chainInfo.slug)) {
|
|
2781
|
+
const isChainActive = this.#koniState.getChainStateByKey(chainInfo.slug).active;
|
|
2782
|
+
if (!isChainActive) {
|
|
2783
|
+
reject(new Error('Unable to sign'));
|
|
2784
|
+
return false;
|
|
2785
|
+
} else {
|
|
2786
|
+
registry = this.#koniState.getSubstrateApi(chainInfo.slug).api.registry;
|
|
2787
|
+
}
|
|
2788
|
+
}
|
|
2758
2789
|
if (chainInfo) {
|
|
2759
2790
|
isEvm = _isChainEvmCompatible(chainInfo);
|
|
2760
2791
|
}
|
|
@@ -3197,6 +3228,7 @@ export default class KoniExtension {
|
|
|
3197
3228
|
return new Promise(resolve => setTimeout(resolve, 1500));
|
|
3198
3229
|
}
|
|
3199
3230
|
try {
|
|
3231
|
+
var _this$koniState$chain, _this$koniState$chain2;
|
|
3200
3232
|
await this.#koniState.chainService.enableChain(_DEFAULT_MANTA_ZK_CHAIN);
|
|
3201
3233
|
this.#koniState.chainService.setMantaZkAssetSettings(true);
|
|
3202
3234
|
const mnemonic = this.keyringExportMnemonic({
|
|
@@ -3215,16 +3247,16 @@ export default class KoniExtension {
|
|
|
3215
3247
|
await this.saveCurrentAccountAddress({
|
|
3216
3248
|
address
|
|
3217
3249
|
});
|
|
3218
|
-
const unsubSyncProgress = await this.#koniState.chainService.mantaPay.subscribeSyncProgress();
|
|
3250
|
+
const unsubSyncProgress = await ((_this$koniState$chain = this.#koniState.chainService) === null || _this$koniState$chain === void 0 ? void 0 : (_this$koniState$chain2 = _this$koniState$chain.mantaPay) === null || _this$koniState$chain2 === void 0 ? void 0 : _this$koniState$chain2.subscribeSyncProgress());
|
|
3219
3251
|
console.debug('Start initial sync for MantaPay');
|
|
3220
3252
|
this.#koniState.initialSyncMantaPay(address).then(() => {
|
|
3221
3253
|
console.debug('Finished initial sync for MantaPay');
|
|
3222
3254
|
this.#skipAutoLock = false;
|
|
3223
|
-
unsubSyncProgress();
|
|
3255
|
+
unsubSyncProgress && unsubSyncProgress();
|
|
3224
3256
|
}).catch(e => {
|
|
3225
3257
|
console.error('Error syncing MantaPay', e);
|
|
3226
3258
|
this.#skipAutoLock = false;
|
|
3227
|
-
unsubSyncProgress();
|
|
3259
|
+
unsubSyncProgress && unsubSyncProgress();
|
|
3228
3260
|
});
|
|
3229
3261
|
return {
|
|
3230
3262
|
success: !!result,
|
|
@@ -3246,29 +3278,32 @@ export default class KoniExtension {
|
|
|
3246
3278
|
}
|
|
3247
3279
|
}
|
|
3248
3280
|
async initSyncMantaPay(address) {
|
|
3249
|
-
|
|
3281
|
+
var _this$koniState$chain3, _this$koniState$chain4, _this$koniState$chain5, _this$koniState$chain6;
|
|
3282
|
+
if ((_this$koniState$chain3 = this.#koniState.chainService) !== null && _this$koniState$chain3 !== void 0 && (_this$koniState$chain4 = _this$koniState$chain3.mantaPay) !== null && _this$koniState$chain4 !== void 0 && _this$koniState$chain4.getSyncState().isSyncing) {
|
|
3250
3283
|
return;
|
|
3251
3284
|
}
|
|
3252
3285
|
this.#skipAutoLock = true;
|
|
3253
3286
|
await this.saveCurrentAccountAddress({
|
|
3254
3287
|
address
|
|
3255
3288
|
});
|
|
3256
|
-
const unsubSyncProgress = await this.#koniState.chainService.mantaPay.subscribeSyncProgress();
|
|
3289
|
+
const unsubSyncProgress = await ((_this$koniState$chain5 = this.#koniState.chainService) === null || _this$koniState$chain5 === void 0 ? void 0 : (_this$koniState$chain6 = _this$koniState$chain5.mantaPay) === null || _this$koniState$chain6 === void 0 ? void 0 : _this$koniState$chain6.subscribeSyncProgress());
|
|
3257
3290
|
console.debug('Start initial sync for MantaPay');
|
|
3258
3291
|
this.#koniState.initialSyncMantaPay(address).then(() => {
|
|
3292
|
+
var _this$koniState$chain7, _this$koniState$chain8;
|
|
3259
3293
|
console.debug('Finished initial sync for MantaPay');
|
|
3260
3294
|
this.#skipAutoLock = false;
|
|
3261
|
-
unsubSyncProgress();
|
|
3295
|
+
unsubSyncProgress && unsubSyncProgress();
|
|
3262
3296
|
// make sure the sync state is set, just in case it gets unsubscribed
|
|
3263
|
-
this.#koniState.chainService.mantaPay.setSyncState({
|
|
3297
|
+
(_this$koniState$chain7 = this.#koniState.chainService) === null || _this$koniState$chain7 === void 0 ? void 0 : (_this$koniState$chain8 = _this$koniState$chain7.mantaPay) === null || _this$koniState$chain8 === void 0 ? void 0 : _this$koniState$chain8.setSyncState({
|
|
3264
3298
|
progress: 100,
|
|
3265
3299
|
isSyncing: false
|
|
3266
3300
|
});
|
|
3267
3301
|
}).catch(e => {
|
|
3302
|
+
var _this$koniState$chain9, _this$koniState$chain10;
|
|
3268
3303
|
console.error('Error syncing MantaPay', e);
|
|
3269
3304
|
this.#skipAutoLock = false;
|
|
3270
|
-
unsubSyncProgress();
|
|
3271
|
-
this.#koniState.chainService.mantaPay.setSyncState({
|
|
3305
|
+
unsubSyncProgress && unsubSyncProgress();
|
|
3306
|
+
(_this$koniState$chain9 = this.#koniState.chainService) === null || _this$koniState$chain9 === void 0 ? void 0 : (_this$koniState$chain10 = _this$koniState$chain9.mantaPay) === null || _this$koniState$chain10 === void 0 ? void 0 : _this$koniState$chain10.setSyncState({
|
|
3272
3307
|
progress: 0,
|
|
3273
3308
|
isSyncing: false
|
|
3274
3309
|
});
|
|
@@ -3291,8 +3326,9 @@ export default class KoniExtension {
|
|
|
3291
3326
|
return this.#koniState.getMantaPayConfig('calamari');
|
|
3292
3327
|
}
|
|
3293
3328
|
subscribeMantaPaySyncState(id, port) {
|
|
3329
|
+
var _this$koniState$subsc, _this$koniState$chain11, _this$koniState$chain12;
|
|
3294
3330
|
const cb = createSubscription(id, port);
|
|
3295
|
-
const syncingStateSubscription = this.#koniState.subscribeMantaPaySyncState().subscribe({
|
|
3331
|
+
const syncingStateSubscription = (_this$koniState$subsc = this.#koniState.subscribeMantaPaySyncState()) === null || _this$koniState$subsc === void 0 ? void 0 : _this$koniState$subsc.subscribe({
|
|
3296
3332
|
next: rs => {
|
|
3297
3333
|
cb(rs);
|
|
3298
3334
|
}
|
|
@@ -3301,7 +3337,26 @@ export default class KoniExtension {
|
|
|
3301
3337
|
port.onDisconnect.addListener(() => {
|
|
3302
3338
|
this.cancelSubscription(id);
|
|
3303
3339
|
});
|
|
3304
|
-
return this.#koniState.chainService.mantaPay.getSyncState()
|
|
3340
|
+
return ((_this$koniState$chain11 = this.#koniState.chainService) === null || _this$koniState$chain11 === void 0 ? void 0 : (_this$koniState$chain12 = _this$koniState$chain11.mantaPay) === null || _this$koniState$chain12 === void 0 ? void 0 : _this$koniState$chain12.getSyncState()) || {
|
|
3341
|
+
isSyncing: false,
|
|
3342
|
+
progress: 0,
|
|
3343
|
+
needManualSync: false
|
|
3344
|
+
};
|
|
3345
|
+
}
|
|
3346
|
+
|
|
3347
|
+
/// Metadata
|
|
3348
|
+
|
|
3349
|
+
async findRawMetadata({
|
|
3350
|
+
genesisHash
|
|
3351
|
+
}) {
|
|
3352
|
+
const {
|
|
3353
|
+
metadata,
|
|
3354
|
+
specVersion
|
|
3355
|
+
} = await this.#koniState.findMetadata(genesisHash);
|
|
3356
|
+
return {
|
|
3357
|
+
rawMetadata: metadata,
|
|
3358
|
+
specVersion
|
|
3359
|
+
};
|
|
3305
3360
|
}
|
|
3306
3361
|
|
|
3307
3362
|
// --------------------------------------------------------------
|
|
@@ -3402,13 +3457,19 @@ export default class KoniExtension {
|
|
|
3402
3457
|
case 'pri(settings.saveCamera)':
|
|
3403
3458
|
return this.setCamera(request);
|
|
3404
3459
|
case 'pri(settings.saveTheme)':
|
|
3405
|
-
return this.saveTheme(request
|
|
3460
|
+
return this.saveTheme(request);
|
|
3406
3461
|
case 'pri(settings.saveBrowserConfirmationType)':
|
|
3407
|
-
return this.saveBrowserConfirmationType(request
|
|
3462
|
+
return this.saveBrowserConfirmationType(request);
|
|
3408
3463
|
case 'pri(settings.saveAutoLockTime)':
|
|
3409
3464
|
return this.setAutoLockTime(request);
|
|
3410
3465
|
case 'pri(settings.saveEnableChainPatrol)':
|
|
3411
3466
|
return this.setEnableChainPatrol(request);
|
|
3467
|
+
case 'pri(settings.saveShowZeroBalance)':
|
|
3468
|
+
return this.setShowZeroBalance(request);
|
|
3469
|
+
case 'pri(settings.saveLanguage)':
|
|
3470
|
+
return this.setLanguage(request);
|
|
3471
|
+
case 'pri(settings.saveShowBalance)':
|
|
3472
|
+
return this.setShowBalance(request);
|
|
3412
3473
|
case 'pri(price.getPrice)':
|
|
3413
3474
|
return await this.getPrice();
|
|
3414
3475
|
case 'pri(price.getSubscription)':
|
|
@@ -3702,6 +3763,10 @@ export default class KoniExtension {
|
|
|
3702
3763
|
return await this.disableMantaPay(request);
|
|
3703
3764
|
case 'pri(mantaPay.subscribeSyncingState)':
|
|
3704
3765
|
return this.subscribeMantaPaySyncState(id, port);
|
|
3766
|
+
|
|
3767
|
+
// Metadata
|
|
3768
|
+
case 'pri(metadata.find)':
|
|
3769
|
+
return this.findRawMetadata(request);
|
|
3705
3770
|
// Default
|
|
3706
3771
|
default:
|
|
3707
3772
|
throw new Error(`Unable to handle message of type ${type}`);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="chrome" />
|
|
2
2
|
import { _AssetRef, _AssetType, _ChainAsset, _ChainInfo, _MultiChainAsset } from '@subwallet/chain-list/types';
|
|
3
|
-
import { AddTokenRequestExternal, AmountData, ApiMap, AuthRequestV2, BalanceItem, BalanceJson,
|
|
3
|
+
import { AddTokenRequestExternal, AmountData, ApiMap, AuthRequestV2, BalanceItem, BalanceJson, ChainStakingMetadata, ConfirmationsQueue, CrowdloanItem, CrowdloanJson, CurrentAccountInfo, EvmSendTransactionParams, ExternalRequestPromise, MantaPayConfig, MantaPaySyncState, NftCollection, NftItem, NftJson, NominatorMetadata, RequestAccountExportPrivateKey, RequestCheckPublicAndSecretKey, RequestConfirmationComplete, RequestSettingsType, ResponseAccountExportPrivateKey, ResponseCheckPublicAndSecretKey, ServiceInfo, SingleModeJson, StakingItem, StakingJson, StakingRewardItem, StakingRewardJson, StakingType, UiSettings } from '@subwallet/extension-base/background/KoniTypes';
|
|
4
4
|
import { AccountJson, RequestAuthorizeTab, RequestRpcSend, RequestRpcSubscribe, RequestRpcUnsubscribe, RequestSign, ResponseRpcListProviders, ResponseSigning } from '@subwallet/extension-base/background/types';
|
|
5
5
|
import { BalanceService } from '@subwallet/extension-base/services/balance-service';
|
|
6
6
|
import { ChainService } from '@subwallet/extension-base/services/chain-service';
|
|
@@ -138,11 +138,8 @@ export default class KoniState {
|
|
|
138
138
|
get signSubject(): BehaviorSubject<import("@subwallet/extension-base/background/types").SigningRequest[]>;
|
|
139
139
|
getSettings(callback: (settings: UiSettings) => void): void;
|
|
140
140
|
setSettings(settings: UiSettings, callback?: () => void): void;
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
setCamera(value: boolean): void;
|
|
144
|
-
setAutoLockTime(value: number): void;
|
|
145
|
-
setEnableChainPatrol(value: boolean): void;
|
|
141
|
+
updateSetting<T extends keyof UiSettings>(key: T, value: UiSettings[T]): void;
|
|
142
|
+
setShowBalance(value: boolean): void;
|
|
146
143
|
subscribeSettingsSubject(): Subject<RequestSettingsType>;
|
|
147
144
|
getAccountAddress(): string | null;
|
|
148
145
|
getDecodedAddresses(address?: string): string[];
|
|
@@ -240,6 +237,10 @@ export default class KoniState {
|
|
|
240
237
|
subscribeMantaPayBalance(): () => void;
|
|
241
238
|
syncMantaPay(): Promise<void>;
|
|
242
239
|
getMantaPayZkBalance(address: string, tokenInfo: _ChainAsset): Promise<AmountData>;
|
|
243
|
-
subscribeMantaPaySyncState(): Subject<
|
|
240
|
+
subscribeMantaPaySyncState(): Subject<MantaPaySyncState>;
|
|
241
|
+
findMetadata(hash: string): Promise<{
|
|
242
|
+
metadata: string;
|
|
243
|
+
specVersion: number;
|
|
244
|
+
}>;
|
|
244
245
|
}
|
|
245
246
|
export {};
|