@subwallet/extension-base 1.3.2-0 → 1.3.4-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 +13 -0
- package/background/KoniTypes.js +1 -0
- package/cjs/background/KoniTypes.js +1 -0
- package/cjs/constants/blocked-actions-list.js +1 -2
- package/cjs/constants/index.js +16 -1
- package/cjs/constants/remind-notification-time.js +14 -0
- package/cjs/core/logic-validation/transfer.js +12 -6
- package/cjs/core/substrate/xcm-parser.js +13 -1
- package/cjs/koni/api/contract-handler/utils/index.js +20 -1
- package/cjs/koni/api/nft/assethub_nft/index.js +30 -7
- package/cjs/koni/background/handlers/Extension.js +110 -23
- package/cjs/koni/background/handlers/State.js +5 -2
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/process.js +2 -1
- package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +11 -12
- package/cjs/services/balance-service/transfer/xcm/availBridge.js +198 -0
- package/cjs/services/balance-service/transfer/xcm/index.js +50 -5
- package/cjs/services/chain-service/handler/EvmApi.js +12 -21
- package/cjs/services/chain-service/handler/SubstrateChainHandler.js +29 -0
- package/cjs/services/chain-service/index.js +44 -13
- package/cjs/services/chain-service/utils/index.js +20 -0
- package/cjs/services/earning-service/handlers/base.js +14 -4
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +10 -2
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +2 -0
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +2 -0
- package/cjs/services/earning-service/handlers/native-staking/tao.js +25 -38
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +9 -4
- package/cjs/services/earning-service/service.js +5 -0
- package/cjs/services/earning-service/utils/index.js +0 -11
- package/cjs/services/inapp-notification-service/consts.js +31 -0
- package/cjs/services/inapp-notification-service/index.js +260 -0
- package/cjs/services/inapp-notification-service/interfaces.js +32 -0
- package/cjs/services/inapp-notification-service/utils.js +197 -0
- package/cjs/services/keyring-service/context/account-context.js +9 -0
- package/cjs/services/keyring-service/context/state.js +4 -0
- package/cjs/services/setting-service/SettingService.js +9 -1
- package/cjs/services/setting-service/constants.js +16 -1
- package/cjs/services/storage-service/DatabaseService.js +42 -3
- package/cjs/services/storage-service/databases/index.js +3 -0
- package/cjs/services/storage-service/db-stores/InappNotification.js +81 -0
- package/cjs/services/transaction-service/index.js +13 -0
- package/cjs/services/transaction-service/utils.js +3 -0
- package/cjs/types/avail-bridge/index.js +1 -0
- package/cjs/types/notification/index.js +1 -0
- package/cjs/utils/account/transform.js +9 -5
- package/cjs/utils/staticData/index.js +7 -2
- package/constants/blocked-actions-list.js +1 -2
- package/constants/index.d.ts +2 -0
- package/constants/index.js +3 -1
- package/constants/remind-notification-time.d.ts +2 -0
- package/constants/remind-notification-time.js +7 -0
- package/core/logic-validation/transfer.js +12 -6
- package/core/substrate/xcm-parser.d.ts +1 -0
- package/core/substrate/xcm-parser.js +12 -1
- package/koni/api/contract-handler/utils/avail_bridge_abi.json +1659 -0
- package/koni/api/contract-handler/utils/avail_test_bridge_abi.json +1692 -0
- package/koni/api/contract-handler/utils/index.d.ts +4 -0
- package/koni/api/contract-handler/utils/index.js +15 -0
- package/koni/api/nft/assethub_nft/index.d.ts +2 -0
- package/koni/api/nft/assethub_nft/index.js +30 -7
- package/koni/background/handlers/Extension.d.ts +7 -0
- package/koni/background/handlers/Extension.js +112 -25
- package/koni/background/handlers/State.d.ts +2 -0
- package/koni/background/handlers/State.js +5 -2
- package/package.json +54 -6
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/process.js +2 -1
- package/services/balance-service/helpers/subscribe/substrate/index.js +5 -6
- package/services/balance-service/transfer/xcm/availBridge.d.ts +45 -0
- package/services/balance-service/transfer/xcm/availBridge.js +186 -0
- package/services/balance-service/transfer/xcm/index.d.ts +8 -8
- package/services/balance-service/transfer/xcm/index.js +46 -5
- package/services/chain-service/handler/EvmApi.js +12 -21
- package/services/chain-service/handler/SubstrateChainHandler.d.ts +2 -0
- package/services/chain-service/handler/SubstrateChainHandler.js +29 -0
- package/services/chain-service/index.d.ts +2 -0
- package/services/chain-service/index.js +45 -14
- package/services/chain-service/types.d.ts +2 -1
- package/services/chain-service/utils/index.d.ts +3 -0
- package/services/chain-service/utils/index.js +14 -0
- package/services/earning-service/handlers/base.d.ts +2 -0
- package/services/earning-service/handlers/base.js +11 -1
- package/services/earning-service/handlers/native-staking/amplitude.js +10 -2
- package/services/earning-service/handlers/native-staking/para-chain.js +2 -0
- package/services/earning-service/handlers/native-staking/relay-chain.js +2 -0
- package/services/earning-service/handlers/native-staking/tao.d.ts +15 -11
- package/services/earning-service/handlers/native-staking/tao.js +21 -38
- package/services/earning-service/handlers/nomination-pool/index.d.ts +1 -1
- package/services/earning-service/handlers/nomination-pool/index.js +9 -4
- package/services/earning-service/service.d.ts +2 -0
- package/services/earning-service/service.js +5 -0
- package/services/earning-service/utils/index.d.ts +0 -2
- package/services/earning-service/utils/index.js +0 -10
- package/services/inapp-notification-service/consts.d.ts +18 -0
- package/services/inapp-notification-service/consts.js +22 -0
- package/services/inapp-notification-service/index.d.ts +37 -0
- package/services/inapp-notification-service/index.js +252 -0
- package/services/inapp-notification-service/interfaces.d.ts +77 -0
- package/services/inapp-notification-service/interfaces.js +24 -0
- package/services/inapp-notification-service/utils.d.ts +55 -0
- package/services/inapp-notification-service/utils.js +173 -0
- package/services/keyring-service/context/account-context.d.ts +3 -0
- package/services/keyring-service/context/account-context.js +9 -0
- package/services/keyring-service/context/state.d.ts +1 -0
- package/services/keyring-service/context/state.js +4 -0
- package/services/setting-service/SettingService.js +9 -1
- package/services/setting-service/constants.d.ts +2 -0
- package/services/setting-service/constants.js +15 -0
- package/services/storage-service/DatabaseService.d.ts +15 -0
- package/services/storage-service/DatabaseService.js +42 -3
- package/services/storage-service/databases/index.d.ts +2 -0
- package/services/storage-service/databases/index.js +3 -0
- package/services/storage-service/db-stores/InappNotification.d.ts +14 -0
- package/services/storage-service/db-stores/InappNotification.js +73 -0
- package/services/transaction-service/index.js +13 -0
- package/services/transaction-service/utils.js +3 -0
- package/types/avail-bridge/index.d.ts +6 -0
- package/types/avail-bridge/index.js +1 -0
- package/types/notification/index.d.ts +9 -0
- package/types/notification/index.js +1 -0
- package/utils/account/transform.js +9 -5
- package/utils/staticData/index.d.ts +5 -1
- package/utils/staticData/index.js +5 -2
- package/utils/staticData/remindNotificationTime.json +1 -0
|
@@ -159,6 +159,7 @@ export default class AmplitudeNativeStakingPoolHandler extends BaseParaNativeSta
|
|
|
159
159
|
}
|
|
160
160
|
const totalBalance = new BN(activeStake).add(new BN(unstakingBalance));
|
|
161
161
|
const stakingStatus = getEarningStatusByNominations(new BN(activeStake), nominationList);
|
|
162
|
+
await this.createWithdrawNotifications(unstakingList, this.nativeToken, address);
|
|
162
163
|
return {
|
|
163
164
|
status: stakingStatus,
|
|
164
165
|
balanceToken: this.nativeToken.slug,
|
|
@@ -244,13 +245,20 @@ export default class AmplitudeNativeStakingPoolHandler extends BaseParaNativeSta
|
|
|
244
245
|
if (cancel) {
|
|
245
246
|
return;
|
|
246
247
|
}
|
|
247
|
-
|
|
248
|
+
const earningRewardItem = {
|
|
248
249
|
...this.baseInfo,
|
|
249
250
|
address: address,
|
|
250
251
|
type: this.type,
|
|
251
252
|
unclaimedReward: _unclaimedReward.toString(),
|
|
252
253
|
state: APIItemState.READY
|
|
253
|
-
}
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
// TODO: Enable this when claim action is ready
|
|
257
|
+
// if (_unclaimedReward.toString() !== '0') {
|
|
258
|
+
// await this.createClaimNotification(earningRewardItem, this.nativeToken);
|
|
259
|
+
// }
|
|
260
|
+
|
|
261
|
+
callBack(earningRewardItem);
|
|
254
262
|
}));
|
|
255
263
|
}
|
|
256
264
|
return () => {
|
|
@@ -209,6 +209,8 @@ export default class ParaNativeStakingPoolHandler extends BaseParaNativeStakingP
|
|
|
209
209
|
const totalStake = bnTotalStake.toString();
|
|
210
210
|
const activeStake = bnTotalActiveStake.toString();
|
|
211
211
|
const unstakingBalance = bnTotalUnstaking.toString();
|
|
212
|
+
const tokenInfo = this.state.chainService.getAssetBySlug(this.nativeToken.slug);
|
|
213
|
+
await this.createWithdrawNotifications(Object.values(unstakingMap), tokenInfo, address);
|
|
212
214
|
return {
|
|
213
215
|
status: stakingStatus,
|
|
214
216
|
totalStake,
|
|
@@ -171,6 +171,8 @@ export default class RelayNativeStakingPoolHandler extends BaseNativeStakingPool
|
|
|
171
171
|
targetTimestampMs: targetTimestampMs
|
|
172
172
|
});
|
|
173
173
|
});
|
|
174
|
+
const tokenInfo = this.state.chainService.getAssetBySlug(this.nativeToken.slug);
|
|
175
|
+
await this.createWithdrawNotifications(unstakingList, tokenInfo, address);
|
|
174
176
|
return {
|
|
175
177
|
status: stakingStatus,
|
|
176
178
|
balanceToken: this.nativeToken.slug,
|
|
@@ -7,36 +7,40 @@ interface TaoStakingStakeOption {
|
|
|
7
7
|
amount: string;
|
|
8
8
|
}
|
|
9
9
|
export interface RawDelegateState {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
delegate_address: {
|
|
10
|
+
data: Array<{
|
|
11
|
+
delegate: {
|
|
13
12
|
ss58: string;
|
|
14
13
|
};
|
|
14
|
+
balance: string;
|
|
15
15
|
}>;
|
|
16
16
|
}
|
|
17
17
|
interface ValidatorResponse {
|
|
18
|
-
|
|
19
|
-
validators: Validator[];
|
|
18
|
+
data: Validator[];
|
|
20
19
|
}
|
|
21
20
|
interface Validator {
|
|
22
|
-
|
|
23
|
-
amount: string;
|
|
24
|
-
nominators: number;
|
|
25
|
-
apr: string;
|
|
26
|
-
hot_key: {
|
|
21
|
+
hotkey: {
|
|
27
22
|
ss58: string;
|
|
28
23
|
};
|
|
24
|
+
name: string;
|
|
25
|
+
nominators: number;
|
|
26
|
+
stake: string;
|
|
27
|
+
validator_stake: string;
|
|
29
28
|
take: string;
|
|
30
|
-
|
|
29
|
+
apr: string;
|
|
31
30
|
}
|
|
32
31
|
export declare const BITTENSOR_API_KEY_1: string;
|
|
33
32
|
export declare const BITTENSOR_API_KEY_2: string;
|
|
33
|
+
export declare const BITTENSOR_API_KEY_3: string;
|
|
34
|
+
export declare const BITTENSOR_API_KEY_4: string;
|
|
35
|
+
export declare const BITTENSOR_API_KEY_5: string;
|
|
36
|
+
export declare const BITTENSOR_API_KEY_6: string;
|
|
34
37
|
export declare const bittensorApiKey: () => string;
|
|
35
38
|
export declare function fetchDelegates(): Promise<ValidatorResponse>;
|
|
36
39
|
export declare function fetchTaoDelegateState(address: string): Promise<RawDelegateState>;
|
|
37
40
|
export default class TaoNativeStakingPoolHandler extends BaseParaStakingPoolHandler {
|
|
38
41
|
handleYieldWithdraw(address: string, unstakingInfo: UnstakingInfo): Promise<TransactionData>;
|
|
39
42
|
handleYieldCancelUnstake(params: StakeCancelWithdrawalParams): Promise<TransactionData>;
|
|
43
|
+
get maintainBalance(): string;
|
|
40
44
|
subscribePoolInfo(callback: (data: YieldPoolInfo) => void): Promise<VoidFunction>;
|
|
41
45
|
parseNominatorMetadata(chainInfo: _ChainInfo, address: string, delegatorState: TaoStakingStakeOption[]): Promise<Omit<YieldPositionInfo, keyof BaseYieldPositionInfo>>;
|
|
42
46
|
subscribePoolPosition(useAddresses: string[], rsCallback: (rs: YieldPositionInfo) => void): Promise<VoidFunction>;
|
|
@@ -9,23 +9,21 @@ import BaseParaStakingPoolHandler from '@subwallet/extension-base/services/earni
|
|
|
9
9
|
import { BasicTxErrorType, EarningStatus } from '@subwallet/extension-base/types';
|
|
10
10
|
import { reformatAddress } from '@subwallet/extension-base/utils';
|
|
11
11
|
import BigN from 'bignumber.js';
|
|
12
|
-
import { BN, BN_ZERO } from '@polkadot/util';
|
|
12
|
+
import { BN, BN_TEN, BN_ZERO } from '@polkadot/util';
|
|
13
13
|
import { calculateReward } from "../../utils/index.js";
|
|
14
|
-
// interface ValidatorName {
|
|
15
|
-
// count: number;
|
|
16
|
-
// delegates: {
|
|
17
|
-
// name: string;
|
|
18
|
-
// }[];
|
|
19
|
-
// }
|
|
20
14
|
export const BITTENSOR_API_KEY_1 = process.env.BITTENSOR_API_KEY_1 || '';
|
|
21
15
|
export const BITTENSOR_API_KEY_2 = process.env.BITTENSOR_API_KEY_2 || '';
|
|
16
|
+
export const BITTENSOR_API_KEY_3 = process.env.BITTENSOR_API_KEY_3 || '';
|
|
17
|
+
export const BITTENSOR_API_KEY_4 = process.env.BITTENSOR_API_KEY_4 || '';
|
|
18
|
+
export const BITTENSOR_API_KEY_5 = process.env.BITTENSOR_API_KEY_5 || '';
|
|
19
|
+
export const BITTENSOR_API_KEY_6 = process.env.BITTENSOR_API_KEY_6 || '';
|
|
22
20
|
function random(...keys) {
|
|
23
21
|
const validKeys = keys.filter(key => key);
|
|
24
22
|
const randomIndex = Math.floor(Math.random() * validKeys.length);
|
|
25
23
|
return validKeys[randomIndex];
|
|
26
24
|
}
|
|
27
25
|
export const bittensorApiKey = () => {
|
|
28
|
-
return random(BITTENSOR_API_KEY_1, BITTENSOR_API_KEY_2);
|
|
26
|
+
return random(BITTENSOR_API_KEY_1, BITTENSOR_API_KEY_2, BITTENSOR_API_KEY_3, BITTENSOR_API_KEY_4, BITTENSOR_API_KEY_5, BITTENSOR_API_KEY_6);
|
|
29
27
|
};
|
|
30
28
|
|
|
31
29
|
/* Fetch data */
|
|
@@ -33,7 +31,7 @@ export const bittensorApiKey = () => {
|
|
|
33
31
|
export async function fetchDelegates() {
|
|
34
32
|
const apiKey = bittensorApiKey();
|
|
35
33
|
return new Promise(function (resolve) {
|
|
36
|
-
fetch('https://api.taostats.io/api/v1
|
|
34
|
+
fetch('https://api-prod-v2.taostats.io/api/validator/latest/v1', {
|
|
37
35
|
method: 'GET',
|
|
38
36
|
headers: {
|
|
39
37
|
'Content-Type': 'application/json',
|
|
@@ -47,7 +45,7 @@ export async function fetchDelegates() {
|
|
|
47
45
|
export async function fetchTaoDelegateState(address) {
|
|
48
46
|
const apiKey = bittensorApiKey();
|
|
49
47
|
return new Promise(function (resolve) {
|
|
50
|
-
fetch(`https://api.taostats.io/api/
|
|
48
|
+
fetch(`https://api-prod-v2.taostats.io/api/delegation/balance/latest/v1?nominator=${address}`, {
|
|
51
49
|
method: 'GET',
|
|
52
50
|
headers: {
|
|
53
51
|
'Content-Type': 'application/json',
|
|
@@ -81,21 +79,12 @@ export default class TaoNativeStakingPoolHandler extends BaseParaStakingPoolHand
|
|
|
81
79
|
}
|
|
82
80
|
/* Unimplemented function */
|
|
83
81
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
// headers: {
|
|
91
|
-
// 'Content-Type': 'application/json',
|
|
92
|
-
// Authorization: `${apiKey}`
|
|
93
|
-
// }
|
|
94
|
-
// }).then((resp) => {
|
|
95
|
-
// resolve(resp.json());
|
|
96
|
-
// }).catch(console.error);
|
|
97
|
-
// });
|
|
98
|
-
// }
|
|
82
|
+
get maintainBalance() {
|
|
83
|
+
const ed = new BN(this.nativeToken.minAmount || '0');
|
|
84
|
+
const calculateMaintainBalance = new BN(15).mul(ed).div(BN_TEN);
|
|
85
|
+
const maintainBalance = calculateMaintainBalance;
|
|
86
|
+
return maintainBalance.toString();
|
|
87
|
+
}
|
|
99
88
|
|
|
100
89
|
/* Subscribe pool info */
|
|
101
90
|
|
|
@@ -228,11 +217,11 @@ export default class TaoNativeStakingPoolHandler extends BaseParaStakingPoolHand
|
|
|
228
217
|
const owner = reformatAddress(useAddresses[i], 42);
|
|
229
218
|
const delegatorState = [];
|
|
230
219
|
let bnTotalBalance = BN_ZERO;
|
|
231
|
-
const delegateStateInfo = rawDelegateStateInfo.
|
|
220
|
+
const delegateStateInfo = rawDelegateStateInfo.data;
|
|
232
221
|
for (const delegate of delegateStateInfo) {
|
|
233
222
|
bnTotalBalance = bnTotalBalance.add(new BN(delegate.balance));
|
|
234
223
|
delegatorState.push({
|
|
235
|
-
owner: delegate.
|
|
224
|
+
owner: delegate.delegate.ss58,
|
|
236
225
|
amount: delegate.balance.toString()
|
|
237
226
|
});
|
|
238
227
|
}
|
|
@@ -315,11 +304,11 @@ export default class TaoNativeStakingPoolHandler extends BaseParaStakingPoolHand
|
|
|
315
304
|
const getNominatorMinRequiredStake = this.substrateApi.api.query.subtensorModule.nominatorMinRequiredStake();
|
|
316
305
|
const nominatorMinRequiredStake = (await getNominatorMinRequiredStake).toString();
|
|
317
306
|
const bnMinBond = new BN(nominatorMinRequiredStake);
|
|
318
|
-
const validatorList = topValidator.
|
|
307
|
+
const validatorList = topValidator.data;
|
|
319
308
|
const validatorAddresses = Object.keys(validatorList);
|
|
320
309
|
const results = await Promise.all(validatorAddresses.map(i => {
|
|
321
|
-
const address = validatorList[i].
|
|
322
|
-
const bnTotalStake = new BN(validatorList[i].
|
|
310
|
+
const address = validatorList[i].hotkey.ss58;
|
|
311
|
+
const bnTotalStake = new BN(validatorList[i].stake);
|
|
323
312
|
const bnOwnStake = new BN(validatorList[i].validator_stake);
|
|
324
313
|
const otherStake = bnTotalStake.sub(bnOwnStake);
|
|
325
314
|
const nominatorCount = validatorList[i].nominators;
|
|
@@ -327,12 +316,7 @@ export default class TaoNativeStakingPoolHandler extends BaseParaStakingPoolHand
|
|
|
327
316
|
const roundedCommission = (parseFloat(commission) * 100).toFixed(0);
|
|
328
317
|
const apr = (parseFloat(validatorList[i].apr) / 10 ** 9 * 100).toFixed(2);
|
|
329
318
|
const apyCalculate = calculateReward(parseFloat(apr));
|
|
330
|
-
|
|
331
|
-
// let name = '';
|
|
332
|
-
// const delegateInfo = await this.fetchDelegatesInfo(address);
|
|
333
|
-
|
|
334
|
-
// name = delegateInfo.delegates[0]?.name || address;
|
|
335
|
-
|
|
319
|
+
const name = validatorList[i].name || address;
|
|
336
320
|
return {
|
|
337
321
|
address: address,
|
|
338
322
|
totalStake: bnTotalStake.toString(),
|
|
@@ -346,10 +330,9 @@ export default class TaoNativeStakingPoolHandler extends BaseParaStakingPoolHand
|
|
|
346
330
|
isVerified: false,
|
|
347
331
|
chain: this.chain,
|
|
348
332
|
isCrowded: false,
|
|
349
|
-
identity:
|
|
333
|
+
identity: name
|
|
350
334
|
};
|
|
351
335
|
}));
|
|
352
|
-
|
|
353
336
|
return results;
|
|
354
337
|
}
|
|
355
338
|
async getPoolTargets() {
|
|
@@ -15,7 +15,7 @@ export default class NominationPoolHandler extends BasePoolHandler {
|
|
|
15
15
|
constructor(state: KoniState, chain: string);
|
|
16
16
|
protected getDescription(amount?: string): string;
|
|
17
17
|
subscribePoolInfo(callback: (data: YieldPoolInfo) => void): Promise<VoidFunction>;
|
|
18
|
-
parsePoolMemberMetadata(substrateApi: _SubstrateApi, poolMemberInfo: PalletNominationPoolsPoolMember, currentEra: string, _deriveSessionProgress: DeriveSessionProgress): Promise<Omit<YieldPositionInfo, keyof BaseYieldPositionInfo>>;
|
|
18
|
+
parsePoolMemberMetadata(substrateApi: _SubstrateApi, poolMemberInfo: PalletNominationPoolsPoolMember, currentEra: string, _deriveSessionProgress: DeriveSessionProgress, address: string): Promise<Omit<YieldPositionInfo, keyof BaseYieldPositionInfo>>;
|
|
19
19
|
subscribePoolPosition(useAddresses: string[], resultCallback: (rs: YieldPositionInfo) => void): Promise<VoidFunction>;
|
|
20
20
|
getPoolReward(useAddresses: string[], callBack: (rs: EarningRewardItem) => void): Promise<VoidFunction>;
|
|
21
21
|
getPoolRewardHistory(useAddresses: string[], callBack: (rs: EarningRewardHistoryItem) => void): Promise<VoidFunction>;
|
|
@@ -145,7 +145,7 @@ export default class NominationPoolHandler extends BasePoolHandler {
|
|
|
145
145
|
|
|
146
146
|
/* Subscribe pool position */
|
|
147
147
|
|
|
148
|
-
async parsePoolMemberMetadata(substrateApi, poolMemberInfo, currentEra, _deriveSessionProgress) {
|
|
148
|
+
async parsePoolMemberMetadata(substrateApi, poolMemberInfo, currentEra, _deriveSessionProgress, address) {
|
|
149
149
|
const chainInfo = this.chainInfo;
|
|
150
150
|
const unlimitedNominatorRewarded = substrateApi.api.consts.staking.maxExposurePageSize !== undefined;
|
|
151
151
|
const _maxNominatorRewardedPerValidator = (substrateApi.api.consts.staking.maxNominatorRewardedPerValidator || 0).toString();
|
|
@@ -215,6 +215,7 @@ export default class NominationPoolHandler extends BasePoolHandler {
|
|
|
215
215
|
if (!bnActiveStake.gt(BN_ZERO)) {
|
|
216
216
|
stakingStatus = EarningStatus.NOT_EARNING;
|
|
217
217
|
}
|
|
218
|
+
await this.createWithdrawNotifications(unstakings, this.nativeToken, address);
|
|
218
219
|
return {
|
|
219
220
|
status: stakingStatus,
|
|
220
221
|
balanceToken: this.nativeToken.slug,
|
|
@@ -246,7 +247,7 @@ export default class NominationPoolHandler extends BasePoolHandler {
|
|
|
246
247
|
const poolMemberInfo = _poolMemberInfo.toPrimitive();
|
|
247
248
|
const owner = reformatAddress(useAddresses[i], 42);
|
|
248
249
|
if (poolMemberInfo) {
|
|
249
|
-
const nominatorMetadata = await this.parsePoolMemberMetadata(substrateApi, poolMemberInfo, currentEra, _deriveSessionProgress);
|
|
250
|
+
const nominatorMetadata = await this.parsePoolMemberMetadata(substrateApi, poolMemberInfo, currentEra, _deriveSessionProgress, owner);
|
|
250
251
|
resultCallback({
|
|
251
252
|
...defaultInfo,
|
|
252
253
|
...nominatorMetadata,
|
|
@@ -292,13 +293,17 @@ export default class NominationPoolHandler extends BasePoolHandler {
|
|
|
292
293
|
var _substrateApi$api$cal, _substrateApi$api$cal2;
|
|
293
294
|
const _unclaimedReward = await ((_substrateApi$api$cal = substrateApi.api.call) === null || _substrateApi$api$cal === void 0 ? void 0 : (_substrateApi$api$cal2 = _substrateApi$api$cal.nominationPoolsApi) === null || _substrateApi$api$cal2 === void 0 ? void 0 : _substrateApi$api$cal2.pendingRewards(address));
|
|
294
295
|
if (_unclaimedReward) {
|
|
295
|
-
|
|
296
|
+
const earningRewardItem = {
|
|
296
297
|
...this.baseInfo,
|
|
297
298
|
address: address,
|
|
298
299
|
type: this.type,
|
|
299
300
|
unclaimedReward: _unclaimedReward.toString(),
|
|
300
301
|
state: APIItemState.READY
|
|
301
|
-
}
|
|
302
|
+
};
|
|
303
|
+
if (_unclaimedReward.toString() !== '0') {
|
|
304
|
+
await this.createClaimNotification(earningRewardItem, this.nativeToken);
|
|
305
|
+
}
|
|
306
|
+
callBack(earningRewardItem);
|
|
302
307
|
}
|
|
303
308
|
}
|
|
304
309
|
}
|
|
@@ -69,6 +69,8 @@ export default class EarningService implements StoppableServiceInterface, Persis
|
|
|
69
69
|
subscribeEarningReward(): BehaviorSubject<EarningRewardJson>;
|
|
70
70
|
getEarningRewards(): EarningRewardJson;
|
|
71
71
|
earningsRewardInterval: NodeJS.Timer | undefined;
|
|
72
|
+
earningRewardReady: PromiseHandler<void>;
|
|
73
|
+
waitEarningRewardReady(): Promise<void>;
|
|
72
74
|
runSubscribeStakingRewardInterval(): void;
|
|
73
75
|
runUnsubscribeStakingRewardInterval(): void;
|
|
74
76
|
fetchPoolRewardHistory(addresses: string[], callback: (result: EarningRewardHistoryItem) => void): Promise<VoidFunction>;
|
|
@@ -516,6 +516,7 @@ export default class EarningService {
|
|
|
516
516
|
stakingRewardState.ready = true;
|
|
517
517
|
this.earningRewardSubject.next(stakingRewardState);
|
|
518
518
|
this.earningsRewardQueue = [];
|
|
519
|
+
this.earningRewardReady.resolve();
|
|
519
520
|
});
|
|
520
521
|
}
|
|
521
522
|
async getPoolReward(addresses, callback) {
|
|
@@ -553,6 +554,10 @@ export default class EarningService {
|
|
|
553
554
|
getEarningRewards() {
|
|
554
555
|
return this.earningRewardSubject.getValue();
|
|
555
556
|
}
|
|
557
|
+
earningRewardReady = createPromiseHandler();
|
|
558
|
+
waitEarningRewardReady() {
|
|
559
|
+
return this.earningRewardReady.promise;
|
|
560
|
+
}
|
|
556
561
|
runSubscribeStakingRewardInterval() {
|
|
557
562
|
const addresses = this.state.keyringService.context.getDecodedAddresses();
|
|
558
563
|
if (!addresses.length) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { _SubstrateApi } from '@subwallet/extension-base/services/chain-service/types';
|
|
2
|
-
import { RawDelegateState } from '@subwallet/extension-base/services/earning-service/handlers/native-staking/tao';
|
|
3
2
|
import { LendingYieldPoolInfo, LiquidYieldPoolInfo, NativeYieldPoolInfo, NominationYieldPoolInfo, YieldAssetExpectedEarning, YieldCompoundingPeriod, YieldPoolInfo, YieldPoolType } from '@subwallet/extension-base/types';
|
|
4
3
|
import { BN } from '@polkadot/util';
|
|
5
4
|
export declare function calculateReward(apr: number, amount?: number, compoundingPeriod?: YieldCompoundingPeriod, isApy?: boolean): YieldAssetExpectedEarning;
|
|
@@ -19,4 +18,3 @@ export declare const isNativeStakingPool: (pool: YieldPoolInfo) => pool is Nativ
|
|
|
19
18
|
export declare const isLiquidPool: (pool: YieldPoolInfo) => pool is LiquidYieldPoolInfo;
|
|
20
19
|
export declare const isLendingPool: (pool: YieldPoolInfo) => pool is LendingYieldPoolInfo;
|
|
21
20
|
export declare function applyDecimal(bnNumber: BN, decimals: number): BN;
|
|
22
|
-
export declare function getTaoTotalStake(rawDelegateState: RawDelegateState): bigint;
|
|
@@ -123,14 +123,4 @@ export const isLendingPool = pool => {
|
|
|
123
123
|
export function applyDecimal(bnNumber, decimals) {
|
|
124
124
|
const bnDecimals = new BN((10 ** decimals).toString());
|
|
125
125
|
return bnNumber.div(bnDecimals);
|
|
126
|
-
}
|
|
127
|
-
export function getTaoTotalStake(rawDelegateState) {
|
|
128
|
-
const nodeInfos = rawDelegateState.items;
|
|
129
|
-
const stakes = nodeInfos.map(stake => stake.balance);
|
|
130
|
-
let totalStake = BigInt(0);
|
|
131
|
-
for (const _stake of stakes) {
|
|
132
|
-
const stakeAmount = BigInt(_stake);
|
|
133
|
-
totalStake += stakeAmount;
|
|
134
|
-
}
|
|
135
|
-
return totalStake;
|
|
136
126
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { getAvailBridgeClaimDescription, getClaimDescription, getReceiveDescription, getSendDescription, getWithdrawDescription } from '@subwallet/extension-base/services/inapp-notification-service/utils';
|
|
2
|
+
export declare const NotificationTitleMap: {
|
|
3
|
+
WITHDRAW: string;
|
|
4
|
+
CLAIM: string;
|
|
5
|
+
SEND: string;
|
|
6
|
+
RECEIVE: string;
|
|
7
|
+
CLAIM_AVAIL_BRIDGE_ON_AVAIL: string;
|
|
8
|
+
CLAIM_AVAIL_BRIDGE_ON_ETHEREUM: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const NotificationDescriptionMap: {
|
|
11
|
+
WITHDRAW: typeof getWithdrawDescription;
|
|
12
|
+
CLAIM: typeof getClaimDescription;
|
|
13
|
+
SEND: typeof getSendDescription;
|
|
14
|
+
RECEIVE: typeof getReceiveDescription;
|
|
15
|
+
CLAIM_AVAIL_BRIDGE_ON_AVAIL: typeof getAvailBridgeClaimDescription;
|
|
16
|
+
CLAIM_AVAIL_BRIDGE_ON_ETHEREUM: typeof getAvailBridgeClaimDescription;
|
|
17
|
+
};
|
|
18
|
+
export declare const ONE_DAY_MILLISECOND: number;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { NotificationActionType } from '@subwallet/extension-base/services/inapp-notification-service/interfaces';
|
|
5
|
+
import { getAvailBridgeClaimDescription, getClaimDescription, getReceiveDescription, getSendDescription, getWithdrawDescription } from '@subwallet/extension-base/services/inapp-notification-service/utils';
|
|
6
|
+
export const NotificationTitleMap = {
|
|
7
|
+
[NotificationActionType.WITHDRAW]: '[{{accountName}}] WITHDRAW {{tokenSymbol}}',
|
|
8
|
+
[NotificationActionType.CLAIM]: '[{{accountName}}] CLAIM {{tokenSymbol}}',
|
|
9
|
+
[NotificationActionType.SEND]: '[{{accountName}}] SEND {{tokenSymbol}}',
|
|
10
|
+
[NotificationActionType.RECEIVE]: '[{{accountName}}] RECEIVE {{tokenSymbol}}',
|
|
11
|
+
[NotificationActionType.CLAIM_AVAIL_BRIDGE_ON_AVAIL]: '[{{accountName}}] CLAIM {{tokenSymbol}}',
|
|
12
|
+
[NotificationActionType.CLAIM_AVAIL_BRIDGE_ON_ETHEREUM]: '[{{accountName}}] CLAIM {{tokenSymbol}}'
|
|
13
|
+
};
|
|
14
|
+
export const NotificationDescriptionMap = {
|
|
15
|
+
[NotificationActionType.WITHDRAW]: getWithdrawDescription,
|
|
16
|
+
[NotificationActionType.CLAIM]: getClaimDescription,
|
|
17
|
+
[NotificationActionType.SEND]: getSendDescription,
|
|
18
|
+
[NotificationActionType.RECEIVE]: getReceiveDescription,
|
|
19
|
+
[NotificationActionType.CLAIM_AVAIL_BRIDGE_ON_AVAIL]: getAvailBridgeClaimDescription,
|
|
20
|
+
[NotificationActionType.CLAIM_AVAIL_BRIDGE_ON_ETHEREUM]: getAvailBridgeClaimDescription
|
|
21
|
+
};
|
|
22
|
+
export const ONE_DAY_MILLISECOND = 1000 * 24 * 60 * 60;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { _ChainAsset } from '@subwallet/chain-list/types';
|
|
2
|
+
import { CronServiceInterface, ServiceStatus } from '@subwallet/extension-base/services/base/types';
|
|
3
|
+
import { ChainService } from '@subwallet/extension-base/services/chain-service';
|
|
4
|
+
import { EventService } from '@subwallet/extension-base/services/event-service';
|
|
5
|
+
import { _BaseNotificationInfo, _NotificationInfo, NotificationActionType } from '@subwallet/extension-base/services/inapp-notification-service/interfaces';
|
|
6
|
+
import { AvailBridgeTransaction } from '@subwallet/extension-base/services/inapp-notification-service/utils';
|
|
7
|
+
import { KeyringService } from '@subwallet/extension-base/services/keyring-service';
|
|
8
|
+
import DatabaseService from '@subwallet/extension-base/services/storage-service/DatabaseService';
|
|
9
|
+
import { GetNotificationParams, RequestSwitchStatusParams } from '@subwallet/extension-base/types/notification';
|
|
10
|
+
export declare class InappNotificationService implements CronServiceInterface {
|
|
11
|
+
private readonly dbService;
|
|
12
|
+
private readonly keyringService;
|
|
13
|
+
private readonly eventService;
|
|
14
|
+
private readonly chainService;
|
|
15
|
+
status: ServiceStatus;
|
|
16
|
+
private refeshAvailBridgeClaimTimeOut;
|
|
17
|
+
constructor(dbService: DatabaseService, keyringService: KeyringService, eventService: EventService, chainService: ChainService);
|
|
18
|
+
init(): Promise<void>;
|
|
19
|
+
markAllRead(proxyId: string): Promise<void>;
|
|
20
|
+
switchReadStatus(params: RequestSwitchStatusParams): Promise<void>;
|
|
21
|
+
subscribeUnreadNotificationsCountMap(callback: (data: Record<string, number>) => void): import("dexie").Subscription;
|
|
22
|
+
getUnreadNotificationsCountMap(): Promise<Record<string, number>>;
|
|
23
|
+
fetchNotificationsByParams(params: GetNotificationParams): Promise<_NotificationInfo[]>;
|
|
24
|
+
getNotificationById(id: string): Promise<_NotificationInfo | undefined>;
|
|
25
|
+
cleanUpOldNotifications(overdueTime?: number): Promise<number>;
|
|
26
|
+
passValidateNotification(candidateNotification: _BaseNotificationInfo, comparedNotifications: _NotificationInfo[], remindTimeConfigInHrs: Record<NotificationActionType, number>): boolean;
|
|
27
|
+
validateAndWriteNotificationsToDB(notifications: _BaseNotificationInfo[], address: string): Promise<void>;
|
|
28
|
+
cronCreateAvailBridgeClaimNotification(): void;
|
|
29
|
+
createAvailBridgeClaimNotification(): void;
|
|
30
|
+
processWriteAvailBridgeClaim(address: string, transactions: AvailBridgeTransaction[], token: _ChainAsset): Promise<void>;
|
|
31
|
+
start(): Promise<void>;
|
|
32
|
+
startCron(): Promise<void>;
|
|
33
|
+
stop(): Promise<void>;
|
|
34
|
+
stopCron(): Promise<void>;
|
|
35
|
+
onAccountProxyRemove(): void;
|
|
36
|
+
removeAccountNotifications(proxyId: string): void;
|
|
37
|
+
}
|