@subwallet/extension-base 1.1.24-0 → 1.1.24-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/background/KoniTypes.d.ts +2 -25
- package/cjs/constants/index.js +9 -3
- package/cjs/koni/api/staking/bonding/amplitude.js +6 -4
- package/cjs/koni/api/staking/bonding/astar.js +4 -0
- package/cjs/koni/api/staking/bonding/index.js +5 -0
- package/cjs/koni/api/staking/bonding/paraChain.js +9 -20
- package/cjs/koni/api/staking/bonding/relayChain.js +41 -23
- package/cjs/koni/api/staking/bonding/utils.js +67 -16
- package/cjs/koni/api/tokens/evm/balance.js +5 -1
- package/cjs/koni/api/tokens/evm/transfer.js +8 -4
- package/cjs/koni/background/cron.js +2 -2
- package/cjs/koni/background/handlers/Extension.js +5 -5
- package/cjs/koni/background/handlers/Mobile.js +1 -1
- package/cjs/koni/background/handlers/State.js +123 -44
- package/cjs/koni/background/subscription.js +2 -2
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/group.js +53 -0
- package/cjs/services/balance-service/helpers/subscribe/balance.js +111 -0
- package/cjs/services/balance-service/helpers/subscribe/evm.js +95 -0
- package/cjs/services/balance-service/helpers/subscribe/substrate/equilibrium.js +113 -0
- package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +324 -0
- package/cjs/services/balance-service/index.js +41 -16
- package/cjs/services/chain-service/constants.js +4 -3
- package/cjs/services/history-service/helpers/subscan-extrinsic-parser-helper.js +7 -1
- package/cjs/services/history-service/index.js +12 -8
- package/cjs/services/migration-service/scripts/MigrateProvider.js +1 -1
- package/cjs/services/storage-service/DatabaseService.js +7 -2
- package/cjs/services/storage-service/db-stores/Balance.js +9 -9
- package/cjs/services/subscan-service/index.js +66 -22
- package/cjs/services/transaction-service/index.js +4 -3
- package/cjs/types/balance.js +1 -0
- package/cjs/types/index.js +11 -0
- package/cjs/utils/{address.js → account.js} +32 -2
- package/cjs/utils/eth.js +7 -2
- package/cjs/utils/index.js +12 -0
- package/constants/index.d.ts +2 -0
- package/constants/index.js +2 -0
- package/koni/api/staking/bonding/amplitude.d.ts +3 -0
- package/koni/api/staking/bonding/amplitude.js +6 -4
- package/koni/api/staking/bonding/astar.d.ts +3 -0
- package/koni/api/staking/bonding/astar.js +4 -0
- package/koni/api/staking/bonding/index.d.ts +3 -0
- package/koni/api/staking/bonding/index.js +5 -0
- package/koni/api/staking/bonding/paraChain.d.ts +3 -0
- package/koni/api/staking/bonding/paraChain.js +9 -20
- package/koni/api/staking/bonding/relayChain.d.ts +3 -0
- package/koni/api/staking/bonding/relayChain.js +41 -24
- package/koni/api/staking/bonding/utils.d.ts +15 -2
- package/koni/api/staking/bonding/utils.js +69 -18
- package/koni/api/tokens/evm/balance.js +5 -1
- package/koni/api/tokens/evm/transfer.d.ts +1 -1
- package/koni/api/tokens/evm/transfer.js +8 -4
- package/koni/background/cron.js +3 -3
- package/koni/background/handlers/Extension.js +5 -5
- package/koni/background/handlers/Mobile.js +1 -1
- package/koni/background/handlers/State.d.ts +6 -4
- package/koni/background/handlers/State.js +111 -33
- package/koni/background/subscription.js +2 -2
- package/package.json +40 -15
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/group.d.ts +9 -0
- package/services/balance-service/helpers/group.js +46 -0
- package/services/balance-service/helpers/subscribe/balance.d.ts +4 -0
- package/services/balance-service/helpers/subscribe/balance.js +103 -0
- package/services/balance-service/helpers/subscribe/evm.d.ts +5 -0
- package/services/balance-service/helpers/subscribe/evm.js +87 -0
- package/services/balance-service/helpers/subscribe/substrate/equilibrium.d.ts +4 -0
- package/services/balance-service/helpers/subscribe/substrate/equilibrium.js +105 -0
- package/services/balance-service/helpers/subscribe/substrate/index.d.ts +4 -0
- package/services/balance-service/helpers/subscribe/substrate/index.js +316 -0
- package/services/balance-service/index.d.ts +24 -5
- package/services/balance-service/index.js +40 -14
- package/services/chain-service/constants.js +4 -3
- package/services/history-service/helpers/subscan-extrinsic-parser-helper.js +7 -1
- package/services/history-service/index.js +12 -8
- package/services/migration-service/scripts/MigrateProvider.js +1 -1
- package/services/storage-service/DatabaseService.d.ts +4 -2
- package/services/storage-service/DatabaseService.js +7 -2
- package/services/storage-service/databases/index.d.ts +2 -1
- package/services/storage-service/db-stores/Balance.d.ts +2 -2
- package/services/storage-service/db-stores/Balance.js +9 -9
- package/services/subscan-service/index.d.ts +11 -5
- package/services/subscan-service/index.js +66 -26
- package/services/subscan-service/types.d.ts +4 -0
- package/services/transaction-service/index.js +5 -4
- package/types/balance.d.ts +40 -0
- package/types/balance.js +1 -0
- package/types/index.d.ts +1 -0
- package/types/index.js +1 -0
- package/utils/account.d.ts +15 -0
- package/utils/{address.js → account.js} +28 -0
- package/utils/eth.d.ts +1 -0
- package/utils/eth.js +4 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/cjs/koni/api/dotsama/balance.js +0 -464
- package/koni/api/dotsama/balance.d.ts +0 -6
- package/koni/api/dotsama/balance.js +0 -451
- package/utils/address.d.ts +0 -5
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="bn.js" />
|
|
2
1
|
import { _AssetRef, _AssetType, _ChainAsset, _ChainInfo, _FundStatus, _MultiChainAsset } from '@subwallet/chain-list/types';
|
|
3
2
|
import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
|
|
4
3
|
import { AuthUrls, Resolver } from '@subwallet/extension-base/background/handlers/State';
|
|
@@ -7,7 +6,7 @@ import { _CHAIN_VALIDATION_ERROR } from '@subwallet/extension-base/services/chai
|
|
|
7
6
|
import { _ChainState, _EvmApi, _NetworkUpsertParams, _SubstrateApi, _ValidateCustomAssetRequest, _ValidateCustomAssetResponse, EnableChainParams, EnableMultiChainParams } from '@subwallet/extension-base/services/chain-service/types';
|
|
8
7
|
import { SWTransactionResponse, SWTransactionResult } from '@subwallet/extension-base/services/transaction-service/types';
|
|
9
8
|
import { WalletConnectNotSupportRequest, WalletConnectSessionRequest } from '@subwallet/extension-base/services/wallet-connect-service/types';
|
|
10
|
-
import { BuyServiceInfo, BuyTokenInfo } from '@subwallet/extension-base/types';
|
|
9
|
+
import { BalanceJson, BuyServiceInfo, BuyTokenInfo } from '@subwallet/extension-base/types';
|
|
11
10
|
import { InjectedAccount, InjectedAccountWithMeta, MetadataDefBase } from '@subwallet/extension-inject/types';
|
|
12
11
|
import { KeyringPair$Json, KeyringPair$Meta } from '@subwallet/keyring/types';
|
|
13
12
|
import { KeyringOptions } from '@subwallet/ui-keyring/options/types';
|
|
@@ -18,7 +17,6 @@ import Web3 from 'web3';
|
|
|
18
17
|
import { RequestArguments, TransactionConfig } from 'web3-core';
|
|
19
18
|
import { JsonRpcPayload, JsonRpcResponse } from 'web3-core-helpers';
|
|
20
19
|
import { SignerResult } from '@polkadot/types/types/extrinsic';
|
|
21
|
-
import { BN } from '@polkadot/util';
|
|
22
20
|
import { HexString } from '@polkadot/util/types';
|
|
23
21
|
import { KeypairType } from '@polkadot/util-crypto/types';
|
|
24
22
|
import { TransactionWarning } from './warnings/TransactionWarning';
|
|
@@ -196,28 +194,6 @@ export interface MetadataItem {
|
|
|
196
194
|
specVersion: string;
|
|
197
195
|
hexValue: HexString;
|
|
198
196
|
}
|
|
199
|
-
export interface TokenBalanceRaw {
|
|
200
|
-
reserved: BN;
|
|
201
|
-
frozen: BN;
|
|
202
|
-
free: BN;
|
|
203
|
-
}
|
|
204
|
-
export interface SubstrateBalance {
|
|
205
|
-
reserved?: string;
|
|
206
|
-
miscFrozen?: string;
|
|
207
|
-
feeFrozen?: string;
|
|
208
|
-
}
|
|
209
|
-
export interface BalanceItem {
|
|
210
|
-
tokenSlug: string;
|
|
211
|
-
state: APIItemState;
|
|
212
|
-
timestamp?: number;
|
|
213
|
-
free: string;
|
|
214
|
-
locked: string;
|
|
215
|
-
substrateInfo?: SubstrateBalance;
|
|
216
|
-
}
|
|
217
|
-
export interface BalanceJson {
|
|
218
|
-
reset?: boolean;
|
|
219
|
-
details: Record<string, BalanceItem>;
|
|
220
|
-
}
|
|
221
197
|
export interface CrowdloanItem {
|
|
222
198
|
state: APIItemState;
|
|
223
199
|
paraState?: CrowdloanParaState;
|
|
@@ -1182,6 +1158,7 @@ export interface NominationPoolInfo extends Pick<PalletNominationPoolsBondedPool
|
|
|
1182
1158
|
address: string;
|
|
1183
1159
|
name?: string;
|
|
1184
1160
|
bondedAmount: string;
|
|
1161
|
+
isProfitable: boolean;
|
|
1185
1162
|
}
|
|
1186
1163
|
export declare enum UnstakingStatus {
|
|
1187
1164
|
CLAIMABLE = "CLAIMABLE",
|
package/cjs/constants/index.js
CHANGED
|
@@ -25,9 +25,11 @@ var _exportNames = {
|
|
|
25
25
|
ALL_GENESIS_HASH: true,
|
|
26
26
|
IGNORE_GET_SUBSTRATE_FEATURES_LIST: true,
|
|
27
27
|
IGNORE_QR_SIGNER: true,
|
|
28
|
-
XCM_MIN_AMOUNT_RATIO: true
|
|
28
|
+
XCM_MIN_AMOUNT_RATIO: true,
|
|
29
|
+
GAS_PRICE_RATIO: true,
|
|
30
|
+
NETWORK_MULTI_GAS_FEE: true
|
|
29
31
|
};
|
|
30
|
-
exports.XCM_MIN_AMOUNT_RATIO = exports.SUB_TOKEN_REFRESH_BALANCE_INTERVAL = exports.MANTA_PAY_BALANCE_INTERVAL = exports.IGNORE_QR_SIGNER = exports.IGNORE_GET_SUBSTRATE_FEATURES_LIST = exports.CRON_SYNC_MANTA_PAY = exports.CRON_REFRESH_STAKING_REWARD_INTERVAL = exports.CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL = exports.CRON_REFRESH_PRICE_INTERVAL = exports.CRON_REFRESH_NFT_INTERVAL = exports.CRON_REFRESH_HISTORY_INTERVAL = exports.CRON_REFRESH_CHAIN_STAKING_METADATA = exports.CRON_REFRESH_CHAIN_NOMINATOR_METADATA = exports.CRON_RECOVER_HISTORY_INTERVAL = exports.CRON_GET_API_MAP_STATUS = exports.CRON_AUTO_RECOVER_WEB3_INTERVAL = exports.CRON_AUTO_RECOVER_DOTSAMA_INTERVAL = exports.ASTAR_REFRESH_BALANCE_INTERVAL = exports.ALL_NETWORK_KEY = exports.ALL_GENESIS_HASH = exports.ALL_ACCOUNT_KEY = exports.ACALA_REFRESH_CROWDLOAN_INTERVAL = void 0;
|
|
32
|
+
exports.XCM_MIN_AMOUNT_RATIO = exports.SUB_TOKEN_REFRESH_BALANCE_INTERVAL = exports.NETWORK_MULTI_GAS_FEE = exports.MANTA_PAY_BALANCE_INTERVAL = exports.IGNORE_QR_SIGNER = exports.IGNORE_GET_SUBSTRATE_FEATURES_LIST = exports.GAS_PRICE_RATIO = exports.CRON_SYNC_MANTA_PAY = exports.CRON_REFRESH_STAKING_REWARD_INTERVAL = exports.CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL = exports.CRON_REFRESH_PRICE_INTERVAL = exports.CRON_REFRESH_NFT_INTERVAL = exports.CRON_REFRESH_HISTORY_INTERVAL = exports.CRON_REFRESH_CHAIN_STAKING_METADATA = exports.CRON_REFRESH_CHAIN_NOMINATOR_METADATA = exports.CRON_RECOVER_HISTORY_INTERVAL = exports.CRON_GET_API_MAP_STATUS = exports.CRON_AUTO_RECOVER_WEB3_INTERVAL = exports.CRON_AUTO_RECOVER_DOTSAMA_INTERVAL = exports.ASTAR_REFRESH_BALANCE_INTERVAL = exports.ALL_NETWORK_KEY = exports.ALL_GENESIS_HASH = exports.ALL_ACCOUNT_KEY = exports.ACALA_REFRESH_CROWDLOAN_INTERVAL = void 0;
|
|
31
33
|
var _staking = require("./staking");
|
|
32
34
|
Object.keys(_staking).forEach(function (key) {
|
|
33
35
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -98,4 +100,8 @@ exports.IGNORE_GET_SUBSTRATE_FEATURES_LIST = IGNORE_GET_SUBSTRATE_FEATURES_LIST;
|
|
|
98
100
|
const IGNORE_QR_SIGNER = [];
|
|
99
101
|
exports.IGNORE_QR_SIGNER = IGNORE_QR_SIGNER;
|
|
100
102
|
const XCM_MIN_AMOUNT_RATIO = 1.2;
|
|
101
|
-
exports.XCM_MIN_AMOUNT_RATIO = XCM_MIN_AMOUNT_RATIO;
|
|
103
|
+
exports.XCM_MIN_AMOUNT_RATIO = XCM_MIN_AMOUNT_RATIO;
|
|
104
|
+
const GAS_PRICE_RATIO = 1.05;
|
|
105
|
+
exports.GAS_PRICE_RATIO = GAS_PRICE_RATIO;
|
|
106
|
+
const NETWORK_MULTI_GAS_FEE = ['astarEvm'];
|
|
107
|
+
exports.NETWORK_MULTI_GAS_FEE = NETWORK_MULTI_GAS_FEE;
|
|
@@ -75,8 +75,7 @@ async function subscribeAmplitudeNominatorMetadata(chainInfo, address, substrate
|
|
|
75
75
|
let activeStake = '0';
|
|
76
76
|
if (delegatorState) {
|
|
77
77
|
// delegatorState can be null while unstaking all
|
|
78
|
-
const
|
|
79
|
-
const identity = identityInfo ? (0, _utils.parseIdentity)(identityInfo) : undefined;
|
|
78
|
+
const [identity] = await (0, _utils.parseIdentity)(substrateApi, delegatorState.owner);
|
|
80
79
|
activeStake = delegatorState.amount.toString();
|
|
81
80
|
const bnActiveStake = new _util.BN(activeStake);
|
|
82
81
|
let delegationStatus = _KoniTypes.StakingStatus.NOT_EARNING;
|
|
@@ -125,6 +124,10 @@ async function subscribeAmplitudeNominatorMetadata(chainInfo, address, substrate
|
|
|
125
124
|
unstakings: unstakingList
|
|
126
125
|
};
|
|
127
126
|
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Deprecated
|
|
130
|
+
* */
|
|
128
131
|
async function getAmplitudeNominatorMetadata(chainInfo, address, substrateApi) {
|
|
129
132
|
if ((0, _utilCrypto.isEthereumAddress)(address)) {
|
|
130
133
|
return;
|
|
@@ -151,8 +154,7 @@ async function getAmplitudeNominatorMetadata(chainInfo, address, substrateApi) {
|
|
|
151
154
|
let activeStake = '0';
|
|
152
155
|
if (delegatorState) {
|
|
153
156
|
// delegatorState can be null while unstaking all
|
|
154
|
-
const
|
|
155
|
-
const identity = identityInfo ? (0, _utils.parseIdentity)(identityInfo) : undefined;
|
|
157
|
+
const [identity] = await (0, _utils.parseIdentity)(substrateApi, delegatorState.owner);
|
|
156
158
|
activeStake = delegatorState.amount.toString();
|
|
157
159
|
const bnActiveStake = new _util.BN(activeStake);
|
|
158
160
|
let delegationStatus = _KoniTypes.StakingStatus.NOT_EARNING;
|
|
@@ -164,6 +164,10 @@ async function subscribeAstarNominatorMetadata(chainInfo, address, substrateApi,
|
|
|
164
164
|
status: stakingStatus
|
|
165
165
|
};
|
|
166
166
|
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Deprecated
|
|
170
|
+
* */
|
|
167
171
|
async function getAstarNominatorMetadata(chainInfo, address, substrateApi) {
|
|
168
172
|
if ((0, _utilCrypto.isEthereumAddress)(address)) {
|
|
169
173
|
return;
|
|
@@ -48,6 +48,10 @@ async function getChainStakingMetadata(chainInfo, substrateApi) {
|
|
|
48
48
|
}
|
|
49
49
|
return (0, _relayChain.getRelayChainStakingMetadata)(chainInfo, substrateApi);
|
|
50
50
|
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Deprecated
|
|
54
|
+
* */
|
|
51
55
|
async function getNominatorMetadata(chainInfo, address, substrateApi) {
|
|
52
56
|
if (_constants._STAKING_CHAIN_GROUP.astar.includes(chainInfo.slug)) {
|
|
53
57
|
return (0, _astar.getAstarNominatorMetadata)(chainInfo, address, substrateApi);
|
|
@@ -122,6 +126,7 @@ async function getCancelWithdrawalExtrinsic(substrateApi, chain, selectedUnstaki
|
|
|
122
126
|
function subscribeEssentialChainStakingMetadata(substrateApiMap, chainInfoMap, callback) {
|
|
123
127
|
const unsubList = [];
|
|
124
128
|
|
|
129
|
+
// TODO: replace with for of to improve performance
|
|
125
130
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
126
131
|
Object.values(chainInfoMap).forEach(async chainInfo => {
|
|
127
132
|
if (!substrateApiMap[chainInfo.slug]) {
|
|
@@ -45,7 +45,7 @@ function validateParaChainUnbondingCondition(amount, nominatorMetadata, chainSta
|
|
|
45
45
|
const bnChainMinStake = new _util.BN(chainStakingMetadata.minStake || '0');
|
|
46
46
|
const bnCollatorMinStake = new _util.BN(targetNomination.validatorMinStake || '0');
|
|
47
47
|
const bnMinStake = _util.BN.max(bnCollatorMinStake, bnChainMinStake);
|
|
48
|
-
const existUnstakeErrorMessage = (0, _utils.getExistUnstakeErrorMessage)(chainStakingMetadata.chain);
|
|
48
|
+
const existUnstakeErrorMessage = (0, _utils.getExistUnstakeErrorMessage)(chainStakingMetadata.chain, nominatorMetadata === null || nominatorMetadata === void 0 ? void 0 : nominatorMetadata.type);
|
|
49
49
|
if (targetNomination.hasUnstaking) {
|
|
50
50
|
errors.push(new _TransactionError.TransactionError(_KoniTypes.StakingTxErrorType.EXIST_UNSTAKING_REQUEST, existUnstakeErrorMessage));
|
|
51
51
|
}
|
|
@@ -63,7 +63,7 @@ function validateParaChainBondingCondition(chainInfo, amount, selectedCollators,
|
|
|
63
63
|
const bnMinStake = bnCollatorMinStake > bnChainMinStake ? bnCollatorMinStake : bnChainMinStake;
|
|
64
64
|
const minStakeErrorMessage = (0, _utils.getMinStakeErrorMessage)(chainInfo, bnMinStake);
|
|
65
65
|
const maxValidatorErrorMessage = (0, _utils.getMaxValidatorErrorMessage)(chainInfo, chainStakingMetadata.maxValidatorPerNominator);
|
|
66
|
-
const existUnstakeErrorMessage = (0, _utils.getExistUnstakeErrorMessage)(chainInfo.slug, true);
|
|
66
|
+
const existUnstakeErrorMessage = (0, _utils.getExistUnstakeErrorMessage)(chainInfo.slug, nominatorMetadata === null || nominatorMetadata === void 0 ? void 0 : nominatorMetadata.type, true);
|
|
67
67
|
if (!nominatorMetadata || nominatorMetadata.status === _KoniTypes.StakingStatus.NOT_STAKING) {
|
|
68
68
|
if (!bnTotalStake.gte(bnMinStake)) {
|
|
69
69
|
errors.push(new _TransactionError.TransactionError(_KoniTypes.StakingTxErrorType.NOT_ENOUGH_MIN_STAKE, minStakeErrorMessage));
|
|
@@ -170,13 +170,10 @@ async function subscribeParaChainNominatorMetadata(chainInfo, address, substrate
|
|
|
170
170
|
const roundInfo = _roundInfo.toPrimitive();
|
|
171
171
|
const currentRound = roundInfo.current;
|
|
172
172
|
await Promise.all(delegatorState.delegations.map(async delegation => {
|
|
173
|
-
|
|
174
|
-
const [_delegationScheduledRequests, _identity, _collatorInfo] = await Promise.all([substrateApi.api.query.parachainStaking.delegationScheduledRequests(delegation.owner), (_substrateApi$api$que = substrateApi.api.query.identity) === null || _substrateApi$api$que === void 0 ? void 0 : _substrateApi$api$que.identityOf(delegation.owner), substrateApi.api.query.parachainStaking.candidateInfo(delegation.owner)]);
|
|
173
|
+
const [_delegationScheduledRequests, [identity], _collatorInfo] = await Promise.all([substrateApi.api.query.parachainStaking.delegationScheduledRequests(delegation.owner), (0, _utils.parseIdentity)(substrateApi, delegation.owner), substrateApi.api.query.parachainStaking.candidateInfo(delegation.owner)]);
|
|
175
174
|
const collatorInfo = _collatorInfo.toPrimitive();
|
|
176
175
|
const minDelegation = collatorInfo === null || collatorInfo === void 0 ? void 0 : collatorInfo.lowestTopDelegationAmount.toString();
|
|
177
|
-
const identityInfo = _identity === null || _identity === void 0 ? void 0 : _identity.toHuman();
|
|
178
176
|
const delegationScheduledRequests = _delegationScheduledRequests.toPrimitive();
|
|
179
|
-
const identity = (0, _utils.parseIdentity)(identityInfo);
|
|
180
177
|
let hasUnstaking = false;
|
|
181
178
|
let delegationStatus = _KoniTypes.StakingStatus.NOT_EARNING;
|
|
182
179
|
|
|
@@ -238,6 +235,10 @@ async function subscribeParaChainNominatorMetadata(chainInfo, address, substrate
|
|
|
238
235
|
unstakings: Object.values(unstakingMap)
|
|
239
236
|
};
|
|
240
237
|
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Deprecated
|
|
241
|
+
* */
|
|
241
242
|
async function getParaChainNominatorMetadata(chainInfo, address, substrateApi) {
|
|
242
243
|
if ((0, _utils2._isChainEvmCompatible)(chainInfo) && !(0, _utilCrypto.isEthereumAddress)(address)) {
|
|
243
244
|
return;
|
|
@@ -261,14 +262,12 @@ async function getParaChainNominatorMetadata(chainInfo, address, substrateApi) {
|
|
|
261
262
|
}
|
|
262
263
|
let bnTotalActiveStake = _util.BN_ZERO;
|
|
263
264
|
await Promise.all(delegatorState.delegations.map(async delegation => {
|
|
264
|
-
const [_delegationScheduledRequests,
|
|
265
|
+
const [_delegationScheduledRequests, [identity], _roundInfo, _collatorInfo] = await Promise.all([chainApi.api.query.parachainStaking.delegationScheduledRequests(delegation.owner), (0, _utils.parseIdentity)(substrateApi, delegation.owner), chainApi.api.query.parachainStaking.round(), chainApi.api.query.parachainStaking.candidateInfo(delegation.owner)]);
|
|
265
266
|
const rawCollatorInfo = _collatorInfo.toHuman();
|
|
266
267
|
const minDelegation = (rawCollatorInfo === null || rawCollatorInfo === void 0 ? void 0 : rawCollatorInfo.lowestTopDelegationAmount).replaceAll(',', '');
|
|
267
|
-
const identityInfo = _identity.toHuman();
|
|
268
268
|
const roundInfo = _roundInfo.toPrimitive();
|
|
269
269
|
const delegationScheduledRequests = _delegationScheduledRequests.toPrimitive();
|
|
270
270
|
const currentRound = roundInfo.current;
|
|
271
|
-
const identity = (0, _utils.parseIdentity)(identityInfo);
|
|
272
271
|
let hasUnstaking = false;
|
|
273
272
|
let delegationStatus = _KoniTypes.StakingStatus.NOT_EARNING;
|
|
274
273
|
|
|
@@ -358,19 +357,9 @@ async function getParachainCollatorsInfo(chain, substrateApi) {
|
|
|
358
357
|
}
|
|
359
358
|
const extraInfoMap = {};
|
|
360
359
|
await Promise.all(allCollators.map(async collator => {
|
|
361
|
-
|
|
362
|
-
const [_info, _identity] = await Promise.all([apiProps.api.query.parachainStaking.candidateInfo(collator.address), (_apiProps$api$query = apiProps.api.query) === null || _apiProps$api$query === void 0 ? void 0 : (_apiProps$api$query$i = _apiProps$api$query.identity) === null || _apiProps$api$query$i === void 0 ? void 0 : _apiProps$api$query$i.identityOf(collator.address) // some chains might not have identity pallet
|
|
363
|
-
]);
|
|
360
|
+
const [_info, [identity, isReasonable]] = await Promise.all([apiProps.api.query.parachainStaking.candidateInfo(collator.address), (0, _utils.parseIdentity)(apiProps, collator.address)]);
|
|
364
361
|
const rawInfo = _info.toHuman();
|
|
365
|
-
const rawIdentity = _identity ? _identity.toHuman() : null;
|
|
366
362
|
const active = (rawInfo === null || rawInfo === void 0 ? void 0 : rawInfo.status) === 'Active';
|
|
367
|
-
let isReasonable = false;
|
|
368
|
-
let identity;
|
|
369
|
-
if (rawIdentity !== null) {
|
|
370
|
-
// Check if identity is eth address
|
|
371
|
-
isReasonable = rawIdentity.judgements.length > 0;
|
|
372
|
-
identity = (0, _utils.parseIdentity)(rawIdentity);
|
|
373
|
-
}
|
|
374
363
|
extraInfoMap[collator.address] = {
|
|
375
364
|
identity,
|
|
376
365
|
isVerified: isReasonable,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
@@ -28,6 +29,7 @@ var _utils = require("@subwallet/extension-base/koni/api/staking/bonding/utils")
|
|
|
28
29
|
var _constants = require("@subwallet/extension-base/services/chain-service/constants");
|
|
29
30
|
var _utils2 = require("@subwallet/extension-base/services/chain-service/utils");
|
|
30
31
|
var _utils3 = require("@subwallet/extension-base/utils");
|
|
32
|
+
var _bignumber = _interopRequireDefault(require("bignumber.js"));
|
|
31
33
|
var _i18next = require("i18next");
|
|
32
34
|
var _util = require("@polkadot/util");
|
|
33
35
|
var _utilCrypto = require("@polkadot/util-crypto");
|
|
@@ -58,7 +60,7 @@ function validatePoolBondingCondition(chainInfo, amount, selectedPool, address,
|
|
|
58
60
|
let bnTotalStake = new _util.BN(amount);
|
|
59
61
|
const bnMinStake = new _util.BN(chainStakingMetadata.minJoinNominationPool || '0');
|
|
60
62
|
const minStakeErrorMessage = (0, _utils.getMinStakeErrorMessage)(chainInfo, bnMinStake);
|
|
61
|
-
const existUnstakeErrorMessage = (0, _utils.getExistUnstakeErrorMessage)(chainInfo.slug, true);
|
|
63
|
+
const existUnstakeErrorMessage = (0, _utils.getExistUnstakeErrorMessage)(chainInfo.slug, nominatorMetadata === null || nominatorMetadata === void 0 ? void 0 : nominatorMetadata.type, true);
|
|
62
64
|
if (selectedPool.state !== 'Open') {
|
|
63
65
|
errors.push(new _TransactionError.TransactionError(_KoniTypes.StakingTxErrorType.INACTIVE_NOMINATION_POOL));
|
|
64
66
|
}
|
|
@@ -214,13 +216,13 @@ async function subscribeRelayChainNominatorMetadata(chainInfo, address, substrat
|
|
|
214
216
|
if (nominations) {
|
|
215
217
|
const validatorList = nominations.targets;
|
|
216
218
|
await Promise.all(validatorList.map(async validatorAddress => {
|
|
217
|
-
var _chainApi$api$query$i;
|
|
218
219
|
let nominationStatus = _KoniTypes.StakingStatus.NOT_EARNING;
|
|
219
|
-
const [
|
|
220
|
+
const [[identity], _eraStaker] = await Promise.all([(0, _utils.parseIdentity)(chainApi, validatorAddress), chainApi.api.query.staking.erasStakers(currentEra, validatorAddress)]);
|
|
220
221
|
const eraStaker = _eraStaker.toPrimitive();
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
222
|
+
const sortedNominators = eraStaker.others.sort((a, b) => {
|
|
223
|
+
return new _bignumber.default(b.value).minus(a.value).toNumber();
|
|
224
|
+
});
|
|
225
|
+
const topNominators = sortedNominators.map(nominator => {
|
|
224
226
|
return nominator.who;
|
|
225
227
|
});
|
|
226
228
|
if (!topNominators.includes((0, _utils3.reformatAddress)(address, (0, _utils2._getChainSubstrateAddressPrefix)(chainInfo)))) {
|
|
@@ -278,6 +280,10 @@ async function subscribeRelayChainNominatorMetadata(chainInfo, address, substrat
|
|
|
278
280
|
isBondedBefore: bonded !== null
|
|
279
281
|
};
|
|
280
282
|
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Deprecated
|
|
286
|
+
* */
|
|
281
287
|
async function getRelayChainNominatorMetadata(chainInfo, address, substrateApi) {
|
|
282
288
|
var _chainApi$api$query10, _chainApi$api$query11, _chainApi$api$query12, _chainApi$api$query13, _chainApi$api$query14, _chainApi$api$query15, _chainApi$api$query16, _chainApi$api$query17, _chainApi$api$query18, _chainApi$api$query19, _chainApi$api$query20, _chainApi$api$query21, _chainApi$api$query22, _chainApi$api$query23;
|
|
283
289
|
if ((0, _utilCrypto.isEthereumAddress)(address)) {
|
|
@@ -315,11 +321,12 @@ async function getRelayChainNominatorMetadata(chainInfo, address, substrateApi)
|
|
|
315
321
|
const validatorList = nominations.targets;
|
|
316
322
|
await Promise.all(validatorList.map(async validatorAddress => {
|
|
317
323
|
let nominationStatus = _KoniTypes.StakingStatus.NOT_EARNING;
|
|
318
|
-
const [
|
|
324
|
+
const [[identity], _eraStaker] = await Promise.all([(0, _utils.parseIdentity)(chainApi, validatorAddress), chainApi.api.query.staking.erasStakers(currentEra, validatorAddress)]);
|
|
319
325
|
const eraStaker = _eraStaker.toPrimitive();
|
|
320
|
-
const
|
|
321
|
-
|
|
322
|
-
|
|
326
|
+
const sortedNominators = eraStaker.others.sort((a, b) => {
|
|
327
|
+
return new _bignumber.default(b.value).minus(a.value).toNumber();
|
|
328
|
+
});
|
|
329
|
+
const topNominators = sortedNominators.map(nominator => {
|
|
323
330
|
return nominator.who;
|
|
324
331
|
});
|
|
325
332
|
if (!topNominators.includes((0, _utils3.reformatAddress)(address, (0, _utils2._getChainSubstrateAddressPrefix)(chainInfo)))) {
|
|
@@ -393,7 +400,10 @@ async function subscribeRelayChainPoolMemberMetadata(chainInfo, address, substra
|
|
|
393
400
|
await Promise.all(validatorList.map(async validatorAddress => {
|
|
394
401
|
const _eraStaker = await substrateApi.api.query.staking.erasStakers(currentEra, validatorAddress);
|
|
395
402
|
const eraStaker = _eraStaker.toPrimitive();
|
|
396
|
-
const
|
|
403
|
+
const sortedNominators = eraStaker.others.sort((a, b) => {
|
|
404
|
+
return new _bignumber.default(b.value).minus(a.value).toNumber();
|
|
405
|
+
});
|
|
406
|
+
const topNominators = sortedNominators.map(nominator => {
|
|
397
407
|
return nominator.who;
|
|
398
408
|
}).slice(0, maxNominatorRewardedPerValidator);
|
|
399
409
|
if (topNominators.includes((0, _utils3.reformatAddress)(poolStashAccount, (0, _utils2._getChainSubstrateAddressPrefix)(chainInfo)))) {
|
|
@@ -471,7 +481,10 @@ async function getRelayChainPoolMemberMetadata(chainInfo, address, substrateApi)
|
|
|
471
481
|
await Promise.all(validatorList.map(async validatorAddress => {
|
|
472
482
|
const _eraStaker = await chainApi.api.query.staking.erasStakers(currentEra, validatorAddress);
|
|
473
483
|
const eraStaker = _eraStaker.toPrimitive();
|
|
474
|
-
const
|
|
484
|
+
const sortedNominators = eraStaker.others.sort((a, b) => {
|
|
485
|
+
return new _bignumber.default(b.value).minus(a.value).toNumber();
|
|
486
|
+
});
|
|
487
|
+
const topNominators = sortedNominators.map(nominator => {
|
|
475
488
|
return nominator.who;
|
|
476
489
|
}).slice(0, maxNominatorRewardedPerValidator);
|
|
477
490
|
if (topNominators.includes((0, _utils3.reformatAddress)(poolStashAccount, (0, _utils2._getChainSubstrateAddressPrefix)(chainInfo)))) {
|
|
@@ -568,20 +581,14 @@ async function getRelayValidatorsInfo(chain, substrateApi, decimals, chainStakin
|
|
|
568
581
|
}
|
|
569
582
|
const extraInfoMap = {};
|
|
570
583
|
await Promise.all(allValidators.map(async address => {
|
|
571
|
-
var _chainApi$api$query24, _chainApi$api$query25, _identityInfo$judgeme;
|
|
572
584
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
573
|
-
const [_commissionInfo,
|
|
585
|
+
const [_commissionInfo, [identity, isVerified]] = await Promise.all([chainApi.api.query.staking.validators(address), (0, _utils.parseIdentity)(chainApi, address)]);
|
|
574
586
|
const commissionInfo = _commissionInfo.toHuman();
|
|
575
|
-
const identityInfo = _identityInfo ? _identityInfo.toHuman() : null;
|
|
576
|
-
let identity;
|
|
577
|
-
if (identityInfo !== null) {
|
|
578
|
-
identity = (0, _utils.parseIdentity)(identityInfo);
|
|
579
|
-
}
|
|
580
587
|
extraInfoMap[address] = {
|
|
581
588
|
commission: commissionInfo.commission,
|
|
582
589
|
blocked: commissionInfo.blocked,
|
|
583
590
|
identity,
|
|
584
|
-
isVerified:
|
|
591
|
+
isVerified: isVerified
|
|
585
592
|
};
|
|
586
593
|
}));
|
|
587
594
|
const bnAvgStake = bnTotalEraStake.divn(validatorInfoList.length).div(bnDecimals);
|
|
@@ -613,10 +620,20 @@ async function getRelayPoolsInfo(chain, substrateApi) {
|
|
|
613
620
|
const poolAddressList = _poolInfo[0].toHuman();
|
|
614
621
|
const poolAddress = poolAddressList[0];
|
|
615
622
|
const poolId = _poolInfo[1].toPrimitive();
|
|
616
|
-
const
|
|
623
|
+
const poolsPalletId = substrateApi.api.consts.nominationPools.palletId.toString();
|
|
624
|
+
const poolStashAccount = (0, _utils.parsePoolStashAddress)(substrateApi.api, 0, poolId, poolsPalletId);
|
|
625
|
+
const [_nominations, _bondedPool, _metadata, _minimumActiveStake] = await Promise.all([chainApi.api.query.staking.nominators(poolStashAccount), chainApi.api.query.nominationPools.bondedPools(poolId), chainApi.api.query.nominationPools.metadata(poolId), chainApi.api.query.staking.minimumActiveStake()]);
|
|
626
|
+
const minimumActiveStake = _minimumActiveStake.toPrimitive();
|
|
627
|
+
const nominations = _nominations.toJSON();
|
|
617
628
|
const poolMetadata = _metadata.toPrimitive();
|
|
618
629
|
const bondedPool = _bondedPool.toPrimitive();
|
|
619
|
-
|
|
630
|
+
|
|
631
|
+
// const poolName = transformPoolName(poolMetadata.isUtf8 ? poolMetadata.toUtf8() : poolMetadata.toString());
|
|
632
|
+
|
|
633
|
+
const poolName = (0, _util.isHex)(poolMetadata) ? (0, _util.hexToString)(poolMetadata) : poolMetadata;
|
|
634
|
+
const isPoolOpen = bondedPool.state === 'Open';
|
|
635
|
+
const isPoolNominating = !!nominations && nominations.targets.length > 0;
|
|
636
|
+
const isPoolEarningReward = bondedPool.points > minimumActiveStake;
|
|
620
637
|
nominationPools.push({
|
|
621
638
|
id: poolId,
|
|
622
639
|
address: poolAddress,
|
|
@@ -624,7 +641,8 @@ async function getRelayPoolsInfo(chain, substrateApi) {
|
|
|
624
641
|
bondedAmount: ((_bondedPool$points = bondedPool.points) === null || _bondedPool$points === void 0 ? void 0 : _bondedPool$points.toString()) || '0',
|
|
625
642
|
roles: bondedPool.roles,
|
|
626
643
|
memberCounter: bondedPool.memberCounter,
|
|
627
|
-
state: bondedPool.state
|
|
644
|
+
state: bondedPool.state,
|
|
645
|
+
isProfitable: isPoolOpen && isPoolNominating && isPoolEarningReward
|
|
628
646
|
});
|
|
629
647
|
}));
|
|
630
648
|
return nominationPools;
|
|
@@ -57,22 +57,63 @@ function parsePoolStashAddress(api, index, poolId, poolsPalletId) {
|
|
|
57
57
|
function transformPoolName(input) {
|
|
58
58
|
return input.replace(/[^\x20-\x7E]/g, '');
|
|
59
59
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @returns
|
|
63
|
+
* <p>
|
|
64
|
+
* [0] - identity
|
|
65
|
+
* </p>
|
|
66
|
+
* <p>
|
|
67
|
+
* [1] - isReasonable (isVerified)
|
|
68
|
+
* </p>
|
|
69
|
+
* */
|
|
70
|
+
async function parseIdentity(substrateApi, address, children) {
|
|
71
|
+
const compactResult = rs => {
|
|
72
|
+
const result = [];
|
|
73
|
+
if (rs) {
|
|
74
|
+
result.push(rs);
|
|
75
|
+
}
|
|
76
|
+
if (children) {
|
|
77
|
+
result.push(children);
|
|
78
|
+
}
|
|
79
|
+
if (result.length > 0) {
|
|
80
|
+
return result.join('/');
|
|
71
81
|
} else {
|
|
72
|
-
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
if (substrateApi.api.query.identity) {
|
|
86
|
+
let identity;
|
|
87
|
+
const _parent = await substrateApi.api.query.identity.superOf(address);
|
|
88
|
+
const parentInfo = _parent.toHuman();
|
|
89
|
+
if (parentInfo) {
|
|
90
|
+
const [parentAddress, {
|
|
91
|
+
Raw: data
|
|
92
|
+
}] = parentInfo;
|
|
93
|
+
const child = (0, _util.isHex)(data) ? (0, _util.hexToString)(data) : data;
|
|
94
|
+
if (!(0, _utils2.isSameAddress)(address, parentAddress)) {
|
|
95
|
+
const [rs, isReasonable] = await parseIdentity(substrateApi, parentAddress, child);
|
|
96
|
+
return [compactResult(rs), isReasonable];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const _identity = await substrateApi.api.query.identity.identityOf(address);
|
|
100
|
+
const identityInfo = _identity.toHuman();
|
|
101
|
+
if (identityInfo) {
|
|
102
|
+
var _identityInfo$info, _identityInfo$info$di, _identityInfo$info2, _identityInfo$info2$w, _identityInfo$info3, _identityInfo$info3$r, _identityInfo$info4, _identityInfo$info4$t;
|
|
103
|
+
const displayName = (_identityInfo$info = identityInfo.info) === null || _identityInfo$info === void 0 ? void 0 : (_identityInfo$info$di = _identityInfo$info.display) === null || _identityInfo$info$di === void 0 ? void 0 : _identityInfo$info$di.Raw;
|
|
104
|
+
const web = (_identityInfo$info2 = identityInfo.info) === null || _identityInfo$info2 === void 0 ? void 0 : (_identityInfo$info2$w = _identityInfo$info2.web) === null || _identityInfo$info2$w === void 0 ? void 0 : _identityInfo$info2$w.Raw;
|
|
105
|
+
const riot = (_identityInfo$info3 = identityInfo.info) === null || _identityInfo$info3 === void 0 ? void 0 : (_identityInfo$info3$r = _identityInfo$info3.riot) === null || _identityInfo$info3$r === void 0 ? void 0 : _identityInfo$info3$r.Raw;
|
|
106
|
+
const twitter = (_identityInfo$info4 = identityInfo.info) === null || _identityInfo$info4 === void 0 ? void 0 : (_identityInfo$info4$t = _identityInfo$info4.twitter) === null || _identityInfo$info4$t === void 0 ? void 0 : _identityInfo$info4$t.Raw;
|
|
107
|
+
const isReasonable = identityInfo.judgements.length > 0;
|
|
108
|
+
if (displayName && !displayName.startsWith('0x')) {
|
|
109
|
+
identity = displayName;
|
|
110
|
+
} else {
|
|
111
|
+
identity = twitter || web || riot;
|
|
112
|
+
}
|
|
113
|
+
return [compactResult(identity), isReasonable];
|
|
73
114
|
}
|
|
74
115
|
}
|
|
75
|
-
return
|
|
116
|
+
return [undefined, false];
|
|
76
117
|
}
|
|
77
118
|
function getInflationParams(networkKey) {
|
|
78
119
|
return _constants._KNOWN_CHAIN_INFLATION_PARAMS[networkKey] || _constants._SUBSTRATE_DEFAULT_INFLATION_PARAMS;
|
|
@@ -330,7 +371,7 @@ const getMaxValidatorErrorMessage = (chainInfo, max) => {
|
|
|
330
371
|
});
|
|
331
372
|
};
|
|
332
373
|
exports.getMaxValidatorErrorMessage = getMaxValidatorErrorMessage;
|
|
333
|
-
const getExistUnstakeErrorMessage = (chain, isStakeMore) => {
|
|
374
|
+
const getExistUnstakeErrorMessage = (chain, type, isStakeMore) => {
|
|
334
375
|
const label = getValidatorLabel(chain);
|
|
335
376
|
if (!isStakeMore) {
|
|
336
377
|
switch (label) {
|
|
@@ -339,7 +380,12 @@ const getExistUnstakeErrorMessage = (chain, isStakeMore) => {
|
|
|
339
380
|
case 'Collator':
|
|
340
381
|
return (0, _i18next.t)('You can unstake from a collator once');
|
|
341
382
|
case 'Validator':
|
|
342
|
-
|
|
383
|
+
{
|
|
384
|
+
if (type === _KoniTypes.StakingType.POOLED) {
|
|
385
|
+
return (0, _i18next.t)('You can unstake from a pool once');
|
|
386
|
+
}
|
|
387
|
+
return (0, _i18next.t)('You can unstake from a validator once');
|
|
388
|
+
}
|
|
343
389
|
}
|
|
344
390
|
} else {
|
|
345
391
|
switch (label) {
|
|
@@ -348,7 +394,12 @@ const getExistUnstakeErrorMessage = (chain, isStakeMore) => {
|
|
|
348
394
|
case 'Collator':
|
|
349
395
|
return (0, _i18next.t)('You cannot stake more for a collator you are unstaking from');
|
|
350
396
|
case 'Validator':
|
|
351
|
-
|
|
397
|
+
{
|
|
398
|
+
if (type === _KoniTypes.StakingType.POOLED) {
|
|
399
|
+
return (0, _i18next.t)('You cannot stake more for a pool you are unstaking from');
|
|
400
|
+
}
|
|
401
|
+
return (0, _i18next.t)('You cannot stake more for a validator you are unstaking from');
|
|
402
|
+
}
|
|
352
403
|
}
|
|
353
404
|
}
|
|
354
405
|
};
|
|
@@ -10,6 +10,10 @@ exports.getEVMBalance = getEVMBalance;
|
|
|
10
10
|
async function getEVMBalance(networkKey, addresses, evmApiMap) {
|
|
11
11
|
const web3Api = evmApiMap[networkKey];
|
|
12
12
|
return await Promise.all(addresses.map(async address => {
|
|
13
|
-
|
|
13
|
+
try {
|
|
14
|
+
return await web3Api.api.eth.getBalance(address);
|
|
15
|
+
} catch (e) {
|
|
16
|
+
return '0';
|
|
17
|
+
}
|
|
14
18
|
}));
|
|
15
19
|
}
|
|
@@ -11,6 +11,7 @@ var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
|
11
11
|
var _web = require("@subwallet/extension-base/koni/api/tokens/evm/web3");
|
|
12
12
|
var _constants = require("@subwallet/extension-base/services/chain-service/constants");
|
|
13
13
|
var _helper = require("@subwallet/extension-base/services/chain-service/helper");
|
|
14
|
+
var _eth = require("@subwallet/extension-base/utils/eth");
|
|
14
15
|
var _util = require("@polkadot/util");
|
|
15
16
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
16
17
|
// SPDX-License-Identifier: Apache-2.0
|
|
@@ -46,7 +47,8 @@ exports.handleTransferBalanceResult = handleTransferBalanceResult;
|
|
|
46
47
|
async function getEVMTransactionObject(chainInfo, from, to, value, transferAll, evmApiMap) {
|
|
47
48
|
const networkKey = chainInfo.slug;
|
|
48
49
|
const web3Api = evmApiMap[networkKey];
|
|
49
|
-
const
|
|
50
|
+
const _price = await web3Api.api.eth.getGasPrice();
|
|
51
|
+
const gasPrice = (0, _eth.recalculateGasPrice)(_price, chainInfo.slug);
|
|
50
52
|
const transactionObject = {
|
|
51
53
|
gasPrice: gasPrice,
|
|
52
54
|
to: to,
|
|
@@ -80,11 +82,12 @@ async function getERC20TransactionObject(assetAddress, chainInfo, from, to, valu
|
|
|
80
82
|
return erc20Contract.methods.transfer(to, transferValue).encodeABI();
|
|
81
83
|
}
|
|
82
84
|
const transferData = generateTransferData(to, transferValue);
|
|
83
|
-
const [gasLimit,
|
|
85
|
+
const [gasLimit, _price] = await Promise.all([
|
|
84
86
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
85
87
|
erc20Contract.methods.transfer(to, transferValue).estimateGas({
|
|
86
88
|
from
|
|
87
89
|
}), evmApi.api.eth.getGasPrice()]);
|
|
90
|
+
const gasPrice = (0, _eth.recalculateGasPrice)(_price, chainInfo.slug);
|
|
88
91
|
const transactionObject = {
|
|
89
92
|
gasPrice: gasPrice,
|
|
90
93
|
gas: gasLimit,
|
|
@@ -98,14 +101,15 @@ async function getERC20TransactionObject(assetAddress, chainInfo, from, to, valu
|
|
|
98
101
|
}
|
|
99
102
|
return [transactionObject, transferValue];
|
|
100
103
|
}
|
|
101
|
-
async function getERC721Transaction(web3Api, contractAddress, senderAddress, recipientAddress, tokenId) {
|
|
104
|
+
async function getERC721Transaction(web3Api, chain, contractAddress, senderAddress, recipientAddress, tokenId) {
|
|
102
105
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
103
106
|
const contract = new web3Api.api.eth.Contract(_helper._ERC721_ABI, contractAddress);
|
|
104
|
-
const [gasLimit,
|
|
107
|
+
const [gasLimit, _price] = await Promise.all([
|
|
105
108
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
106
109
|
contract.methods.safeTransferFrom(senderAddress, recipientAddress, tokenId).estimateGas({
|
|
107
110
|
from: senderAddress
|
|
108
111
|
}), web3Api.api.eth.getGasPrice()]);
|
|
112
|
+
const gasPrice = (0, _eth.recalculateGasPrice)(_price, chain);
|
|
109
113
|
return {
|
|
110
114
|
from: senderAddress,
|
|
111
115
|
gasPrice,
|
|
@@ -115,8 +115,8 @@ class KoniCron {
|
|
|
115
115
|
if (Object.keys(this.state.getSubstrateApiMap()).length !== 0 || Object.keys(this.state.getEvmApiMap()).length !== 0) {
|
|
116
116
|
this.resetNft(currentAccountInfo.address);
|
|
117
117
|
this.addCron('refreshNft', this.refreshNft(currentAccountInfo.address, this.state.getApiMap(), this.state.getSmartContractNfts(), this.state.getActiveChainInfoMap()), _constants.CRON_REFRESH_NFT_INTERVAL);
|
|
118
|
-
this.addCron('refreshStakingReward', this.refreshStakingReward(currentAccountInfo.address),
|
|
119
|
-
this.addCron('
|
|
118
|
+
// this.addCron('refreshStakingReward', this.refreshStakingReward(currentAccountInfo.address), CRON_REFRESH_STAKING_REWARD_INTERVAL);
|
|
119
|
+
this.addCron('refreshPoolingStakingReward', this.refreshStakingRewardFastInterval(currentAccountInfo.address), _constants.CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL);
|
|
120
120
|
this.addCron('syncMantaPay', this.syncMantaPay, _constants.CRON_SYNC_MANTA_PAY);
|
|
121
121
|
} else {
|
|
122
122
|
this.setStakingRewardReady();
|
|
@@ -33,7 +33,6 @@ var _constants4 = require("@subwallet/extension-base/services/setting-service/co
|
|
|
33
33
|
var _constants5 = require("@subwallet/extension-base/services/wallet-connect-service/constants");
|
|
34
34
|
var _helpers2 = require("@subwallet/extension-base/services/wallet-connect-service/helpers");
|
|
35
35
|
var _utils2 = require("@subwallet/extension-base/utils");
|
|
36
|
-
var _address2 = require("@subwallet/extension-base/utils/address");
|
|
37
36
|
var _eth = require("@subwallet/extension-base/utils/eth");
|
|
38
37
|
var _parseTransaction2 = require("@subwallet/extension-base/utils/eth/parseTransaction");
|
|
39
38
|
var _number = require("@subwallet/extension-base/utils/number");
|
|
@@ -546,7 +545,7 @@ class KoniExtension {
|
|
|
546
545
|
subscribeAddresses(id, port) {
|
|
547
546
|
const _cb = (0, _subscriptions.createSubscription)(id, port);
|
|
548
547
|
const subscription = this.#koniState.keyringService.addressesSubject.subscribe(subjectInfo => {
|
|
549
|
-
const addresses = (0,
|
|
548
|
+
const addresses = (0, _utils2.convertSubjectInfoToAddresses)(subjectInfo);
|
|
550
549
|
_cb({
|
|
551
550
|
addresses: addresses
|
|
552
551
|
});
|
|
@@ -557,7 +556,7 @@ class KoniExtension {
|
|
|
557
556
|
});
|
|
558
557
|
const subjectInfo = this.#koniState.keyringService.addresses;
|
|
559
558
|
return {
|
|
560
|
-
addresses: (0,
|
|
559
|
+
addresses: (0, _utils2.convertSubjectInfoToAddresses)(subjectInfo)
|
|
561
560
|
};
|
|
562
561
|
}
|
|
563
562
|
saveRecentAccount(_ref22) {
|
|
@@ -1779,7 +1778,7 @@ class KoniExtension {
|
|
|
1779
1778
|
} = inputData;
|
|
1780
1779
|
const contractAddress = params.contractAddress;
|
|
1781
1780
|
const tokenId = params.tokenId;
|
|
1782
|
-
const transaction = await (0, _transfer3.getERC721Transaction)(this.#koniState.getEvmApi(networkKey), contractAddress, senderAddress, recipientAddress, tokenId);
|
|
1781
|
+
const transaction = await (0, _transfer3.getERC721Transaction)(this.#koniState.getEvmApi(networkKey), networkKey, contractAddress, senderAddress, recipientAddress, tokenId);
|
|
1783
1782
|
|
|
1784
1783
|
// this.addContact(recipientAddress);
|
|
1785
1784
|
|
|
@@ -1930,7 +1929,8 @@ class KoniExtension {
|
|
|
1930
1929
|
// null address
|
|
1931
1930
|
from: address
|
|
1932
1931
|
};
|
|
1933
|
-
const
|
|
1932
|
+
const _price = await web3.api.eth.getGasPrice();
|
|
1933
|
+
const gasPrice = (0, _eth.recalculateGasPrice)(_price, networkKey);
|
|
1934
1934
|
const gasLimit = await web3.api.eth.estimateGas(transaction);
|
|
1935
1935
|
estimatedFee = (gasLimit * parseInt(gasPrice)).toString();
|
|
1936
1936
|
} else {
|
|
@@ -119,7 +119,7 @@ class Mobile {
|
|
|
119
119
|
if (storage) {
|
|
120
120
|
const storageData = JSON.parse(storage);
|
|
121
121
|
for (const key in storageData) {
|
|
122
|
-
localStorage.setItem(key,
|
|
122
|
+
localStorage.setItem(key, storageData[key]);
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
if (indexedDB) {
|