@subwallet/extension-base 1.3.72-0 → 1.3.73-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/cjs/koni/background/handlers/Extension.js +0 -2
- package/cjs/koni/background/handlers/State.js +0 -4
- package/cjs/koni/background/subscription.js +2 -22
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +17 -2
- package/koni/background/handlers/Extension.js +0 -2
- package/koni/background/handlers/State.d.ts +0 -1
- package/koni/background/handlers/State.js +0 -4
- package/koni/background/subscription.js +2 -22
- package/package.json +6 -6
- package/packageInfo.js +1 -1
- package/services/earning-service/handlers/native-staking/para-chain.js +17 -2
- package/types/yield/info/pallet.d.ts +1 -1
|
@@ -3397,8 +3397,6 @@ class KoniExtension {
|
|
|
3397
3397
|
return await this.#koniState.reloadStaking();
|
|
3398
3398
|
} else if (data === 'balance') {
|
|
3399
3399
|
return await this.#koniState.reloadBalance();
|
|
3400
|
-
} else if (data === 'crowdloan') {
|
|
3401
|
-
return await this.#koniState.reloadCrowdloan();
|
|
3402
3400
|
}
|
|
3403
3401
|
return Promise.resolve(false);
|
|
3404
3402
|
}
|
|
@@ -1824,10 +1824,6 @@ class KoniState {
|
|
|
1824
1824
|
await this.balanceService.reloadBalance();
|
|
1825
1825
|
return true;
|
|
1826
1826
|
}
|
|
1827
|
-
async reloadCrowdloan() {
|
|
1828
|
-
await this.subscription.reloadCrowdloan();
|
|
1829
|
-
return true;
|
|
1830
|
-
}
|
|
1831
1827
|
async approvePassPhishingPage(_url) {
|
|
1832
1828
|
return new Promise(resolve => {
|
|
1833
1829
|
this.settingService.getPassPhishingList(value => {
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.KoniSubscription = void 0;
|
|
7
7
|
var _crowdloan = require("@subwallet/extension-base/koni/api/dotsama/crowdloan");
|
|
8
8
|
var _nft = require("@subwallet/extension-base/koni/api/nft");
|
|
9
|
-
var _types = require("@subwallet/extension-base/services/event-service/types");
|
|
10
9
|
var _utils = require("@subwallet/extension-base/utils");
|
|
11
10
|
var _util = require("@polkadot/util");
|
|
12
11
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
@@ -47,26 +46,7 @@ class KoniSubscription {
|
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
48
|
async start() {
|
|
50
|
-
var _this$state$keyringSe;
|
|
51
49
|
await Promise.all([this.state.eventService.waitCryptoReady, this.state.eventService.waitKeyringReady, this.state.eventService.waitAssetReady]);
|
|
52
|
-
const currentAddress = (_this$state$keyringSe = this.state.keyringService.context.currentAccount) === null || _this$state$keyringSe === void 0 ? void 0 : _this$state$keyringSe.proxyId;
|
|
53
|
-
if (currentAddress) {
|
|
54
|
-
this.subscribeCrowdloans(currentAddress, this.state.getSubstrateApiMap());
|
|
55
|
-
}
|
|
56
|
-
this.eventHandler = (events, eventTypes) => {
|
|
57
|
-
var _serviceInfo$currentA;
|
|
58
|
-
const serviceInfo = this.state.getServiceInfo();
|
|
59
|
-
const needReload = eventTypes.some(eventType => _types.COMMON_RELOAD_EVENTS.includes(eventType));
|
|
60
|
-
if (!needReload) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
const address = (_serviceInfo$currentA = serviceInfo.currentAccountInfo) === null || _serviceInfo$currentA === void 0 ? void 0 : _serviceInfo$currentA.proxyId;
|
|
64
|
-
if (!address) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
this.subscribeCrowdloans(address, serviceInfo.chainApiMap.substrate);
|
|
68
|
-
};
|
|
69
|
-
this.state.eventService.onLazy(this.eventHandler.bind(this));
|
|
70
50
|
}
|
|
71
51
|
async stop() {
|
|
72
52
|
if (this.eventHandler) {
|
|
@@ -117,8 +97,8 @@ class KoniSubscription {
|
|
|
117
97
|
}).catch(this.logger.log);
|
|
118
98
|
}
|
|
119
99
|
async reloadCrowdloan() {
|
|
120
|
-
var _this$state$
|
|
121
|
-
const currentAddress = (_this$state$
|
|
100
|
+
var _this$state$keyringSe;
|
|
101
|
+
const currentAddress = (_this$state$keyringSe = this.state.keyringService.context.currentAccount) === null || _this$state$keyringSe === void 0 ? void 0 : _this$state$keyringSe.proxyId;
|
|
122
102
|
this.subscribeCrowdloans(currentAddress, this.state.getSubstrateApiMap());
|
|
123
103
|
await (0, _utils.waitTimeout)(1800);
|
|
124
104
|
}
|
package/cjs/packageInfo.js
CHANGED
|
@@ -19,6 +19,17 @@ var _basePara = _interopRequireDefault(require("./base-para"));
|
|
|
19
19
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
20
20
|
// SPDX-License-Identifier: Apache-2.0
|
|
21
21
|
|
|
22
|
+
async function queryDelegationScheduledRequestsFallback(api, delegator, collator) {
|
|
23
|
+
const query = api.query.parachainStaking.delegationScheduledRequests;
|
|
24
|
+
const key = await query.keys();
|
|
25
|
+
if (key[0].args.length === 1) {
|
|
26
|
+
return await query(collator);
|
|
27
|
+
} else if (key[0].args.length === 2) {
|
|
28
|
+
return await query(collator, delegator);
|
|
29
|
+
} else {
|
|
30
|
+
throw new _TransactionError.TransactionError(_types.BasicTxErrorType.INVALID_PARAMS, 'More args than 2 and 1');
|
|
31
|
+
}
|
|
32
|
+
}
|
|
22
33
|
function calculateMantaNominatorReturn(decimal, commission, totalActiveCollators, bnAnnualInflation, blocksPreviousRound, bnCollatorExpectedBlocksPerRound, bnCollatorTotalStaked, isCountCommission) {
|
|
23
34
|
const MIN_DELEGATION = new _bignumber.default(_constants2.MANTA_MIN_DELEGATION);
|
|
24
35
|
const factor = new _bignumber.default(10).pow(decimal);
|
|
@@ -148,7 +159,10 @@ class ParaNativeStakingPoolHandler extends _basePara.default {
|
|
|
148
159
|
const roundInfo = _roundInfo.toPrimitive();
|
|
149
160
|
const currentRound = roundInfo.current;
|
|
150
161
|
await Promise.all(delegatorState.delegations.map(async delegation => {
|
|
151
|
-
const [_delegationScheduledRequests, [identity], _collatorInfo, _currentBlock, _currentTimestamp] = await Promise.all([
|
|
162
|
+
const [_delegationScheduledRequests, [identity], _collatorInfo, _currentBlock, _currentTimestamp] = await Promise.all([queryDelegationScheduledRequestsFallback(substrateApi.api, address,
|
|
163
|
+
// delegator
|
|
164
|
+
delegation.owner // collator
|
|
165
|
+
), (0, _utils2.parseIdentity)(substrateIdentityApi, delegation.owner), substrateApi.api.query.parachainStaking.candidateInfo(delegation.owner), substrateApi.api.query.system.number(), substrateApi.api.query.timestamp.now()]);
|
|
152
166
|
const currentBlock = _currentBlock.toPrimitive();
|
|
153
167
|
const currentTimestamp = _currentTimestamp.toPrimitive();
|
|
154
168
|
const collatorInfo = _collatorInfo.toPrimitive();
|
|
@@ -160,7 +174,8 @@ class ParaNativeStakingPoolHandler extends _basePara.default {
|
|
|
160
174
|
// parse unstaking info
|
|
161
175
|
if (delegationScheduledRequests) {
|
|
162
176
|
for (const scheduledRequest of delegationScheduledRequests) {
|
|
163
|
-
|
|
177
|
+
const requestDelegator = scheduledRequest.delegator ? scheduledRequest.delegator : address;
|
|
178
|
+
if ((0, _utils3.reformatAddress)(requestDelegator, 0) === (0, _utils3.reformatAddress)(address, 0)) {
|
|
164
179
|
// add network prefix
|
|
165
180
|
const isClaimable = scheduledRequest.whenExecutable - parseInt(currentRound) <= 0;
|
|
166
181
|
const remainingEra = scheduledRequest.whenExecutable - parseInt(currentRound);
|
|
@@ -3320,8 +3320,6 @@ export default class KoniExtension {
|
|
|
3320
3320
|
return await this.#koniState.reloadStaking();
|
|
3321
3321
|
} else if (data === 'balance') {
|
|
3322
3322
|
return await this.#koniState.reloadBalance();
|
|
3323
|
-
} else if (data === 'crowdloan') {
|
|
3324
|
-
return await this.#koniState.reloadCrowdloan();
|
|
3325
3323
|
}
|
|
3326
3324
|
return Promise.resolve(false);
|
|
3327
3325
|
}
|
|
@@ -267,7 +267,6 @@ export default class KoniState {
|
|
|
267
267
|
reloadNft(): Promise<boolean>;
|
|
268
268
|
reloadStaking(): Promise<boolean>;
|
|
269
269
|
reloadBalance(): Promise<boolean>;
|
|
270
|
-
reloadCrowdloan(): Promise<boolean>;
|
|
271
270
|
approvePassPhishingPage(_url: string): Promise<boolean>;
|
|
272
271
|
saveEnvConfig<T extends keyof EnvConfig>(key: T, value: EnvConfig[T]): void;
|
|
273
272
|
initEnvConfig(envConfig: EnvConfig): void;
|
|
@@ -1792,10 +1792,6 @@ export default class KoniState {
|
|
|
1792
1792
|
await this.balanceService.reloadBalance();
|
|
1793
1793
|
return true;
|
|
1794
1794
|
}
|
|
1795
|
-
async reloadCrowdloan() {
|
|
1796
|
-
await this.subscription.reloadCrowdloan();
|
|
1797
|
-
return true;
|
|
1798
|
-
}
|
|
1799
1795
|
async approvePassPhishingPage(_url) {
|
|
1800
1796
|
return new Promise(resolve => {
|
|
1801
1797
|
this.settingService.getPassPhishingList(value => {
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
import { subscribeCrowdloan } from '@subwallet/extension-base/koni/api/dotsama/crowdloan';
|
|
5
5
|
import { NftHandler } from '@subwallet/extension-base/koni/api/nft';
|
|
6
|
-
import { COMMON_RELOAD_EVENTS } from '@subwallet/extension-base/services/event-service/types';
|
|
7
6
|
import { waitTimeout } from '@subwallet/extension-base/utils';
|
|
8
7
|
import { logger as createLogger } from '@polkadot/util';
|
|
9
8
|
const nftHandler = new NftHandler();
|
|
@@ -41,26 +40,7 @@ export class KoniSubscription {
|
|
|
41
40
|
}
|
|
42
41
|
}
|
|
43
42
|
async start() {
|
|
44
|
-
var _this$state$keyringSe;
|
|
45
43
|
await Promise.all([this.state.eventService.waitCryptoReady, this.state.eventService.waitKeyringReady, this.state.eventService.waitAssetReady]);
|
|
46
|
-
const currentAddress = (_this$state$keyringSe = this.state.keyringService.context.currentAccount) === null || _this$state$keyringSe === void 0 ? void 0 : _this$state$keyringSe.proxyId;
|
|
47
|
-
if (currentAddress) {
|
|
48
|
-
this.subscribeCrowdloans(currentAddress, this.state.getSubstrateApiMap());
|
|
49
|
-
}
|
|
50
|
-
this.eventHandler = (events, eventTypes) => {
|
|
51
|
-
var _serviceInfo$currentA;
|
|
52
|
-
const serviceInfo = this.state.getServiceInfo();
|
|
53
|
-
const needReload = eventTypes.some(eventType => COMMON_RELOAD_EVENTS.includes(eventType));
|
|
54
|
-
if (!needReload) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const address = (_serviceInfo$currentA = serviceInfo.currentAccountInfo) === null || _serviceInfo$currentA === void 0 ? void 0 : _serviceInfo$currentA.proxyId;
|
|
58
|
-
if (!address) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
this.subscribeCrowdloans(address, serviceInfo.chainApiMap.substrate);
|
|
62
|
-
};
|
|
63
|
-
this.state.eventService.onLazy(this.eventHandler.bind(this));
|
|
64
44
|
}
|
|
65
45
|
async stop() {
|
|
66
46
|
if (this.eventHandler) {
|
|
@@ -106,8 +86,8 @@ export class KoniSubscription {
|
|
|
106
86
|
nftHandler.handleNfts(smartContractNfts, (...args) => this.state.updateNftData(...args), (...args) => this.state.setNftCollection(...args)).catch(this.logger.log);
|
|
107
87
|
}
|
|
108
88
|
async reloadCrowdloan() {
|
|
109
|
-
var _this$state$
|
|
110
|
-
const currentAddress = (_this$state$
|
|
89
|
+
var _this$state$keyringSe;
|
|
90
|
+
const currentAddress = (_this$state$keyringSe = this.state.keyringService.context.currentAccount) === null || _this$state$keyringSe === void 0 ? void 0 : _this$state$keyringSe.proxyId;
|
|
111
91
|
this.subscribeCrowdloans(currentAddress, this.state.getSubstrateApiMap());
|
|
112
92
|
await waitTimeout(1800);
|
|
113
93
|
}
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "1.3.
|
|
20
|
+
"version": "1.3.73-0",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -2972,12 +2972,12 @@
|
|
|
2972
2972
|
"@snowbridge/registry": "^0.2.0",
|
|
2973
2973
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
2974
2974
|
"@substrate/connect": "^0.8.9",
|
|
2975
|
-
"@subwallet-monorepos/subwallet-services-sdk": "0.1.
|
|
2975
|
+
"@subwallet-monorepos/subwallet-services-sdk": "0.1.16",
|
|
2976
2976
|
"@subwallet/chain-list": "0.2.123",
|
|
2977
|
-
"@subwallet/extension-base": "^1.3.
|
|
2978
|
-
"@subwallet/extension-chains": "^1.3.
|
|
2979
|
-
"@subwallet/extension-dapp": "^1.3.
|
|
2980
|
-
"@subwallet/extension-inject": "^1.3.
|
|
2977
|
+
"@subwallet/extension-base": "^1.3.73-0",
|
|
2978
|
+
"@subwallet/extension-chains": "^1.3.73-0",
|
|
2979
|
+
"@subwallet/extension-dapp": "^1.3.73-0",
|
|
2980
|
+
"@subwallet/extension-inject": "^1.3.73-0",
|
|
2981
2981
|
"@subwallet/keyring": "^0.1.14",
|
|
2982
2982
|
"@subwallet/ui-keyring": "^0.1.14",
|
|
2983
2983
|
"@ton/core": "^0.56.3",
|
package/packageInfo.js
CHANGED
|
@@ -7,5 +7,5 @@ export const packageInfo = {
|
|
|
7
7
|
name: '@subwallet/extension-base',
|
|
8
8
|
path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
|
|
9
9
|
type: 'esm',
|
|
10
|
-
version: '1.3.
|
|
10
|
+
version: '1.3.73-0'
|
|
11
11
|
};
|
|
@@ -12,6 +12,17 @@ import { balanceFormatter, formatNumber, parseRawNumber, reformatAddress } from
|
|
|
12
12
|
import BigN from 'bignumber.js';
|
|
13
13
|
import { BN, BN_ZERO } from '@polkadot/util';
|
|
14
14
|
import BaseParaNativeStakingPoolHandler from "./base-para.js";
|
|
15
|
+
async function queryDelegationScheduledRequestsFallback(api, delegator, collator) {
|
|
16
|
+
const query = api.query.parachainStaking.delegationScheduledRequests;
|
|
17
|
+
const key = await query.keys();
|
|
18
|
+
if (key[0].args.length === 1) {
|
|
19
|
+
return await query(collator);
|
|
20
|
+
} else if (key[0].args.length === 2) {
|
|
21
|
+
return await query(collator, delegator);
|
|
22
|
+
} else {
|
|
23
|
+
throw new TransactionError(BasicTxErrorType.INVALID_PARAMS, 'More args than 2 and 1');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
15
26
|
function calculateMantaNominatorReturn(decimal, commission, totalActiveCollators, bnAnnualInflation, blocksPreviousRound, bnCollatorExpectedBlocksPerRound, bnCollatorTotalStaked, isCountCommission) {
|
|
16
27
|
const MIN_DELEGATION = new BigN(MANTA_MIN_DELEGATION);
|
|
17
28
|
const factor = new BigN(10).pow(decimal);
|
|
@@ -141,7 +152,10 @@ export default class ParaNativeStakingPoolHandler extends BaseParaNativeStakingP
|
|
|
141
152
|
const roundInfo = _roundInfo.toPrimitive();
|
|
142
153
|
const currentRound = roundInfo.current;
|
|
143
154
|
await Promise.all(delegatorState.delegations.map(async delegation => {
|
|
144
|
-
const [_delegationScheduledRequests, [identity], _collatorInfo, _currentBlock, _currentTimestamp] = await Promise.all([
|
|
155
|
+
const [_delegationScheduledRequests, [identity], _collatorInfo, _currentBlock, _currentTimestamp] = await Promise.all([queryDelegationScheduledRequestsFallback(substrateApi.api, address,
|
|
156
|
+
// delegator
|
|
157
|
+
delegation.owner // collator
|
|
158
|
+
), parseIdentity(substrateIdentityApi, delegation.owner), substrateApi.api.query.parachainStaking.candidateInfo(delegation.owner), substrateApi.api.query.system.number(), substrateApi.api.query.timestamp.now()]);
|
|
145
159
|
const currentBlock = _currentBlock.toPrimitive();
|
|
146
160
|
const currentTimestamp = _currentTimestamp.toPrimitive();
|
|
147
161
|
const collatorInfo = _collatorInfo.toPrimitive();
|
|
@@ -153,7 +167,8 @@ export default class ParaNativeStakingPoolHandler extends BaseParaNativeStakingP
|
|
|
153
167
|
// parse unstaking info
|
|
154
168
|
if (delegationScheduledRequests) {
|
|
155
169
|
for (const scheduledRequest of delegationScheduledRequests) {
|
|
156
|
-
|
|
170
|
+
const requestDelegator = scheduledRequest.delegator ? scheduledRequest.delegator : address;
|
|
171
|
+
if (reformatAddress(requestDelegator, 0) === reformatAddress(address, 0)) {
|
|
157
172
|
// add network prefix
|
|
158
173
|
const isClaimable = scheduledRequest.whenExecutable - parseInt(currentRound) <= 0;
|
|
159
174
|
const remainingEra = scheduledRequest.whenExecutable - parseInt(currentRound);
|
|
@@ -54,7 +54,7 @@ export declare enum PalletParachainStakingRequestType {
|
|
|
54
54
|
BOND_LESS = "bondLess"
|
|
55
55
|
}
|
|
56
56
|
export interface PalletParachainStakingDelegationRequestsScheduledRequest {
|
|
57
|
-
delegator
|
|
57
|
+
delegator?: string;
|
|
58
58
|
whenExecutable: number;
|
|
59
59
|
action: Record<PalletParachainStakingRequestType, number>;
|
|
60
60
|
}
|