@subwallet/extension-base 1.0.4-1 → 1.0.5-1
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 +12 -1
- package/background/KoniTypes.js +1 -0
- package/background/errors/TransactionError.js +4 -0
- package/background/handlers/State.d.ts +1 -1
- package/background/handlers/State.js +2 -8
- package/background/handlers/subscriptions.js +0 -1
- package/background/types.d.ts +2 -2
- package/cjs/background/KoniTypes.js +1 -0
- package/cjs/background/errors/TransactionError.js +4 -0
- package/cjs/background/handlers/State.js +1 -7
- package/cjs/background/handlers/subscriptions.js +0 -1
- package/cjs/constants/index.js +6 -6
- package/cjs/koni/api/coingecko.js +1 -4
- package/cjs/koni/api/dotsama/balance.js +7 -5
- package/cjs/koni/api/dotsama/crowdloan.js +0 -4
- package/cjs/koni/api/dotsama/transfer.js +0 -4
- package/cjs/koni/api/nft/acala_nft/index.js +1 -1
- package/cjs/koni/api/nft/bit.country/index.js +1 -1
- package/cjs/koni/api/nft/evm_nft/index.js +2 -3
- package/cjs/koni/api/nft/index.js +1 -2
- package/cjs/koni/api/nft/karura_nft/index.js +1 -1
- package/cjs/koni/api/nft/quartz_nft/index.js +1 -1
- package/cjs/koni/api/nft/rmrk_nft/index.js +2 -3
- package/cjs/koni/api/nft/statemine_nft/index.js +1 -1
- package/cjs/koni/api/nft/transfer.js +5 -5
- package/cjs/koni/api/nft/unique_nft/index.js +1 -1
- package/cjs/koni/api/nft/unique_nft/uniqueNftV2.js +0 -1
- package/cjs/koni/api/nft/wasm_nft/index.js +1 -2
- package/cjs/koni/api/staking/bonding/astar.js +28 -12
- package/cjs/koni/api/staking/bonding/utils.js +4 -0
- package/cjs/koni/api/staking/relayChain.js +0 -1
- package/cjs/koni/api/staking/subsquidStaking.js +0 -2
- package/cjs/koni/api/tokens/wasm/index.js +0 -1
- package/cjs/koni/api/tokens/wasm/utils.js +0 -1
- package/cjs/koni/api/xcm/index.js +0 -1
- package/cjs/koni/background/cron.js +0 -45
- package/cjs/koni/background/handlers/Extension.js +163 -133
- package/cjs/koni/background/handlers/State.js +18 -3
- package/cjs/koni/background/handlers/Tabs.js +34 -2
- package/cjs/koni/background/handlers/index.js +3 -2
- package/cjs/koni/background/subscription.js +0 -26
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/chain-service/handler/EvmChainHandler.js +1 -1
- package/cjs/services/chain-service/handler/SubstrateChainHandler.js +2 -9
- package/cjs/services/chain-service/handler/light-client/index.js +9 -6
- package/cjs/services/chain-service/index.js +0 -2
- package/cjs/services/chain-service/utils.js +3 -0
- package/cjs/services/history-service/helpers/recoverHistoryStatus.js +108 -0
- package/cjs/services/history-service/index.js +60 -5
- package/cjs/services/history-service/subsquid-multi-chain-history.js +3 -2
- package/cjs/services/history-service/testChainMap.js +724 -0
- package/cjs/services/keyring-service/index.js +0 -2
- package/cjs/services/migration-service/index.js +0 -3
- package/cjs/services/migration-service/scripts/MigrateAutoLock.js +30 -0
- package/cjs/services/migration-service/scripts/MigrateChainPatrol.js +30 -0
- package/cjs/services/migration-service/scripts/index.js +5 -1
- package/cjs/services/price-service/coingecko.js +1 -1
- package/cjs/services/price-service/index.js +0 -3
- package/cjs/services/request-service/handler/AuthRequestHandler.js +1 -1
- package/cjs/services/setting-service/constants.js +8 -2
- package/cjs/services/storage-service/DatabaseService.js +2 -44
- package/cjs/services/transaction-service/constants.js +11 -0
- package/cjs/services/transaction-service/index.js +28 -9
- package/cjs/services/transaction-service/utils.js +25 -14
- package/constants/index.d.ts +1 -1
- package/constants/index.js +1 -1
- package/koni/api/coingecko.js +1 -4
- package/koni/api/dotsama/balance.js +7 -5
- package/koni/api/dotsama/crowdloan.js +0 -4
- package/koni/api/dotsama/transfer.js +0 -4
- package/koni/api/nft/acala_nft/index.js +1 -1
- package/koni/api/nft/bit.country/index.js +1 -1
- package/koni/api/nft/evm_nft/index.js +2 -3
- package/koni/api/nft/index.js +1 -2
- package/koni/api/nft/karura_nft/index.js +1 -1
- package/koni/api/nft/quartz_nft/index.js +1 -1
- package/koni/api/nft/rmrk_nft/index.js +2 -3
- package/koni/api/nft/statemine_nft/index.js +1 -1
- package/koni/api/nft/transfer.js +5 -5
- package/koni/api/nft/unique_nft/index.js +1 -1
- package/koni/api/nft/unique_nft/uniqueNftV2.js +0 -1
- package/koni/api/nft/wasm_nft/index.js +1 -2
- package/koni/api/staking/bonding/astar.d.ts +2 -1
- package/koni/api/staking/bonding/astar.js +27 -12
- package/koni/api/staking/bonding/utils.js +4 -0
- package/koni/api/staking/relayChain.js +0 -1
- package/koni/api/staking/subsquidStaking.js +0 -2
- package/koni/api/tokens/wasm/index.js +0 -1
- package/koni/api/tokens/wasm/utils.js +0 -1
- package/koni/api/xcm/index.js +0 -1
- package/koni/background/cron.js +0 -45
- package/koni/background/handlers/Extension.d.ts +2 -0
- package/koni/background/handlers/Extension.js +78 -50
- package/koni/background/handlers/State.d.ts +3 -1
- package/koni/background/handlers/State.js +18 -3
- package/koni/background/handlers/Tabs.d.ts +1 -0
- package/koni/background/handlers/Tabs.js +32 -1
- package/koni/background/handlers/index.js +3 -2
- package/koni/background/subscription.d.ts +0 -1
- package/koni/background/subscription.js +0 -26
- package/package.json +55 -34
- package/packageInfo.js +1 -1
- package/services/chain-service/handler/EvmChainHandler.js +1 -1
- package/services/chain-service/handler/SubstrateChainHandler.js +2 -9
- package/services/chain-service/handler/light-client/index.js +8 -6
- package/services/chain-service/helper/api-helper/spec/acala.d.ts +3 -3
- package/services/chain-service/index.js +0 -2
- package/services/chain-service/utils.js +3 -0
- package/services/history-service/helpers/recoverHistoryStatus.d.ts +11 -0
- package/services/history-service/helpers/recoverHistoryStatus.js +98 -0
- package/services/history-service/index.d.ts +6 -0
- package/services/history-service/index.js +61 -6
- package/services/history-service/subsquid-multi-chain-history.js +3 -2
- package/services/history-service/testChainMap.d.ts +3 -0
- package/services/history-service/testChainMap.js +716 -0
- package/services/keyring-service/index.js +0 -2
- package/services/migration-service/index.js +0 -3
- package/services/migration-service/scripts/MigrateAutoLock.d.ts +4 -0
- package/services/migration-service/scripts/MigrateAutoLock.js +22 -0
- package/services/migration-service/scripts/MigrateChainPatrol.d.ts +4 -0
- package/services/migration-service/scripts/MigrateChainPatrol.js +22 -0
- package/services/migration-service/scripts/index.js +5 -1
- package/services/price-service/coingecko.js +1 -1
- package/services/price-service/index.js +0 -3
- package/services/request-service/handler/AuthRequestHandler.js +1 -1
- package/services/setting-service/constants.d.ts +4 -2
- package/services/setting-service/constants.js +5 -1
- package/services/storage-service/DatabaseService.js +2 -44
- package/services/transaction-service/constants.d.ts +1 -0
- package/services/transaction-service/constants.js +4 -0
- package/services/transaction-service/index.d.ts +1 -0
- package/services/transaction-service/index.js +29 -10
- package/services/transaction-service/utils.d.ts +1 -1
- package/services/transaction-service/utils.js +24 -13
|
@@ -94,7 +94,6 @@ export const createTransferExtrinsic = async ({
|
|
|
94
94
|
transferAll,
|
|
95
95
|
value
|
|
96
96
|
}) => {
|
|
97
|
-
var _transfer;
|
|
98
97
|
const api = substrateApi.api;
|
|
99
98
|
|
|
100
99
|
// @ts-ignore
|
|
@@ -142,8 +141,5 @@ export const createTransferExtrinsic = async ({
|
|
|
142
141
|
transfer = api.tx.balances.transfer(to, new BN(value));
|
|
143
142
|
}
|
|
144
143
|
}
|
|
145
|
-
|
|
146
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
147
|
-
console.log('transfer extrinsic: ', (_transfer = transfer) === null || _transfer === void 0 ? void 0 : _transfer.toHex());
|
|
148
144
|
return [transfer, transferAmount || value];
|
|
149
145
|
};
|
|
@@ -113,7 +113,7 @@ export class AcalaNftApi extends BaseNftApi {
|
|
|
113
113
|
}));
|
|
114
114
|
params.cleanUpNfts(this.chain, address, collectionIds, nftIds);
|
|
115
115
|
} catch (e) {
|
|
116
|
-
console.error(
|
|
116
|
+
console.error(`${this.chain}`, e);
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
async handleNfts(params) {
|
|
@@ -111,7 +111,7 @@ export class BitCountryNftApi extends BaseNftApi {
|
|
|
111
111
|
}));
|
|
112
112
|
params.cleanUpNfts(this.chain, address, collectionIds, nftIds);
|
|
113
113
|
} catch (e) {
|
|
114
|
-
console.error(
|
|
114
|
+
console.error(`${this.chain}`, e);
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
async handleNfts(params) {
|
|
@@ -106,7 +106,6 @@ export class EvmNftApi extends BaseNftApi {
|
|
|
106
106
|
const resp = await fetch(detailUrl);
|
|
107
107
|
const itemDetail = resp && resp.ok && (await resp.json());
|
|
108
108
|
if (!itemDetail) {
|
|
109
|
-
console.warn((resp === null || resp === void 0 ? void 0 : resp.statusText) || `Cannot fetch NFT id [${nftId}] from Web3.`);
|
|
110
109
|
return;
|
|
111
110
|
}
|
|
112
111
|
const parsedItem = this.parseMetadata(itemDetail);
|
|
@@ -123,13 +122,13 @@ export class EvmNftApi extends BaseNftApi {
|
|
|
123
122
|
ownItem = true;
|
|
124
123
|
}
|
|
125
124
|
} catch (e) {
|
|
126
|
-
console.error(
|
|
125
|
+
console.error(`${this.chain}`, e);
|
|
127
126
|
}
|
|
128
127
|
}
|
|
129
128
|
}));
|
|
130
129
|
nftOwnerMap[address] = nftIds;
|
|
131
130
|
} catch (e) {
|
|
132
|
-
console.error(
|
|
131
|
+
console.error(`${this.chain}`, e);
|
|
133
132
|
}
|
|
134
133
|
}));
|
|
135
134
|
if (ownItem) {
|
package/koni/api/nft/index.js
CHANGED
|
@@ -118,10 +118,9 @@ export class NftHandler {
|
|
|
118
118
|
}
|
|
119
119
|
});
|
|
120
120
|
this.needSetupApi = false;
|
|
121
|
-
// console.log(`${this.handlers.length} nft handlers connected`, this.handlers);
|
|
122
121
|
}
|
|
123
122
|
} catch (e) {
|
|
124
|
-
console.error(
|
|
123
|
+
console.error(e);
|
|
125
124
|
}
|
|
126
125
|
}
|
|
127
126
|
async handleNfts(nftContracts, updateItem, updateCollection, cleanUpNfts) {
|
|
@@ -118,7 +118,7 @@ export class KaruraNftApi extends BaseNftApi {
|
|
|
118
118
|
}));
|
|
119
119
|
params.cleanUpNfts(this.chain, address, collectionIds, nftIds);
|
|
120
120
|
} catch (e) {
|
|
121
|
-
console.error(
|
|
121
|
+
console.error(`${this.chain}`, e);
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
async handleNfts(params) {
|
|
@@ -193,7 +193,6 @@ export class RmrkNftApi extends BaseNftApi {
|
|
|
193
193
|
return {};
|
|
194
194
|
}
|
|
195
195
|
} catch (e) {
|
|
196
|
-
console.error('error fetching collection info', url);
|
|
197
196
|
return {};
|
|
198
197
|
}
|
|
199
198
|
}));
|
|
@@ -220,7 +219,7 @@ export class RmrkNftApi extends BaseNftApi {
|
|
|
220
219
|
};
|
|
221
220
|
}
|
|
222
221
|
} catch (e) {
|
|
223
|
-
console.error(
|
|
222
|
+
console.error(item.url, e);
|
|
224
223
|
}
|
|
225
224
|
}));
|
|
226
225
|
allCollections.forEach(item => {
|
|
@@ -245,7 +244,7 @@ export class RmrkNftApi extends BaseNftApi {
|
|
|
245
244
|
const allNftIds = allNfts.map(nft => nft === null || nft === void 0 ? void 0 : nft.id);
|
|
246
245
|
params.cleanUpNfts(this.chain, address, allCollectionIds, allNftIds);
|
|
247
246
|
} catch (e) {
|
|
248
|
-
console.error(
|
|
247
|
+
console.error(`${this.chain}`, e);
|
|
249
248
|
}
|
|
250
249
|
}
|
|
251
250
|
async handleNfts(params) {
|
|
@@ -119,7 +119,7 @@ export default class StatemineNftApi extends BaseNftApi {
|
|
|
119
119
|
}));
|
|
120
120
|
params.cleanUpNfts(this.chain, address, collectionIds, nftIds);
|
|
121
121
|
} catch (e) {
|
|
122
|
-
console.error(
|
|
122
|
+
console.error(`${this.chain}`, e);
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
async handleNfts(params) {
|
package/koni/api/nft/transfer.js
CHANGED
|
@@ -12,7 +12,7 @@ export function acalaGetExtrinsic(substrateApi, senderAddress, recipientAddress,
|
|
|
12
12
|
const collectionId = params.collectionId;
|
|
13
13
|
return substrateApi.api.tx.nft.transfer(recipientAddress, [collectionId, itemId]);
|
|
14
14
|
} catch (e) {
|
|
15
|
-
console.error(
|
|
15
|
+
console.error(e);
|
|
16
16
|
return null;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -25,7 +25,7 @@ export function rmrkGetExtrinsic(substrateApi, senderAddress, recipientAddress,
|
|
|
25
25
|
const parsedRemark = remark.concat(recipientAddress.replace(/\\s/g, ''));
|
|
26
26
|
return substrateApi.api.tx.system.remark(parsedRemark);
|
|
27
27
|
} catch (e) {
|
|
28
|
-
console.error(
|
|
28
|
+
console.error(e);
|
|
29
29
|
return null;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -37,7 +37,7 @@ export function uniqueGetExtrinsic(substrateApi, senderAddress, recipientAddress
|
|
|
37
37
|
Substrate: recipientAddress
|
|
38
38
|
}, collectionId, itemId, 1);
|
|
39
39
|
} catch (e) {
|
|
40
|
-
console.error(
|
|
40
|
+
console.error(e);
|
|
41
41
|
return null;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -49,7 +49,7 @@ export function quartzGetExtrinsic(substrateApi, senderAddress, recipientAddress
|
|
|
49
49
|
Substrate: recipientAddress
|
|
50
50
|
}, collectionId, itemId, 1);
|
|
51
51
|
} catch (e) {
|
|
52
|
-
console.error(
|
|
52
|
+
console.error(e);
|
|
53
53
|
return null;
|
|
54
54
|
}
|
|
55
55
|
}
|
|
@@ -59,7 +59,7 @@ export function statemineGetExtrinsic(substrateApi, senderAddress, recipientAddr
|
|
|
59
59
|
const collectionId = params.collectionId;
|
|
60
60
|
return substrateApi.api.tx.uniques.transfer(collectionId, itemId, recipientAddress);
|
|
61
61
|
} catch (e) {
|
|
62
|
-
console.error(
|
|
62
|
+
console.error(e);
|
|
63
63
|
return null;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -175,7 +175,7 @@ export default class UniqueNftApi extends BaseNftApi {
|
|
|
175
175
|
}));
|
|
176
176
|
params.cleanUpNfts(this.chain, address, collectionIds, allNftIds);
|
|
177
177
|
} catch (e) {
|
|
178
|
-
console.error(
|
|
178
|
+
console.error(`${this.chain}`, e);
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
async handleNfts(params) {
|
|
@@ -216,7 +216,6 @@ export class WasmNftApi extends BaseNftApi {
|
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
if (!itemDetail) {
|
|
219
|
-
console.warn(`Cannot fetch NFT metadata [${tokenId}] from PSP-34 contract.`);
|
|
220
219
|
return nftItem;
|
|
221
220
|
}
|
|
222
221
|
nftItem.name = itemDetail.name;
|
|
@@ -298,7 +297,7 @@ export class WasmNftApi extends BaseNftApi {
|
|
|
298
297
|
|
|
299
298
|
nftOwnerMap[address] = nftIds;
|
|
300
299
|
} catch (e) {
|
|
301
|
-
console.error(
|
|
300
|
+
console.error(`${this.chain}`, e);
|
|
302
301
|
}
|
|
303
302
|
}));
|
|
304
303
|
if (isFeatured) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _ChainInfo } from '@subwallet/chain-list/types';
|
|
2
|
-
import { ChainStakingMetadata, NominatorMetadata, ValidatorInfo } from '@subwallet/extension-base/background/KoniTypes';
|
|
2
|
+
import { ChainStakingMetadata, NominatorMetadata, UnstakingInfo, ValidatorInfo } from '@subwallet/extension-base/background/KoniTypes';
|
|
3
3
|
import { _SubstrateApi } from '@subwallet/extension-base/services/chain-service/types';
|
|
4
4
|
export declare function getAstarStakingMetadata(chain: string, substrateApi: _SubstrateApi): Promise<ChainStakingMetadata>;
|
|
5
5
|
export declare function getAstarNominatorMetadata(chainInfo: _ChainInfo, address: string, substrateApi: _SubstrateApi): Promise<NominatorMetadata | undefined>;
|
|
@@ -8,3 +8,4 @@ export declare function getAstarBondingExtrinsic(substrateApi: _SubstrateApi, am
|
|
|
8
8
|
export declare function getAstarUnbondingExtrinsic(substrateApi: _SubstrateApi, amount: string, dappAddress: string): Promise<import("@polkadot/api-base/types").SubmittableExtrinsic<"promise", import("@polkadot/types/types").ISubmittableResult>>;
|
|
9
9
|
export declare function getAstarWithdrawalExtrinsic(substrateApi: _SubstrateApi): Promise<import("@polkadot/api-base/types").SubmittableExtrinsic<"promise", import("@polkadot/types/types").ISubmittableResult>>;
|
|
10
10
|
export declare function getAstarClaimRewardExtrinsic(substrateApi: _SubstrateApi, address: string): Promise<import("@polkadot/api-base/types").SubmittableExtrinsic<"promise", import("@polkadot/types/types").ISubmittableResult>>;
|
|
11
|
+
export declare function getAstarWithdrawable(nominatorMetadata: NominatorMetadata): UnstakingInfo;
|
|
@@ -96,17 +96,17 @@ export async function getAstarNominatorMetadata(chainInfo, address, substrateApi
|
|
|
96
96
|
|
|
97
97
|
const unlockingChunks = ledger.unbondingInfo.unlockingChunks;
|
|
98
98
|
if (unlockingChunks.length > 0) {
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
99
|
+
for (const unlockingChunk of unlockingChunks) {
|
|
100
|
+
const isClaimable = unlockingChunk.unlockEra - parseInt(currentEra) <= 0;
|
|
101
|
+
const remainingEra = unlockingChunk.unlockEra - (parseInt(currentEra) + 1);
|
|
102
|
+
const waitingTime = remainingEra * _STAKING_ERA_LENGTH_MAP[chain];
|
|
103
|
+
unstakingList.push({
|
|
104
|
+
chain,
|
|
105
|
+
status: isClaimable ? UnstakingStatus.CLAIMABLE : UnstakingStatus.UNLOCKING,
|
|
106
|
+
claimable: unlockingChunk.amount.toString(),
|
|
107
|
+
waitingTime: waitingTime > 0 ? waitingTime : 0
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
110
|
}
|
|
111
111
|
if (nominationList.length === 0 && unstakingList.length === 0) {
|
|
112
112
|
return {
|
|
@@ -247,6 +247,21 @@ export async function getAstarClaimRewardExtrinsic(substrateApi, address) {
|
|
|
247
247
|
transactions.push(tx);
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
|
-
console.log('no of astar claim reward tx: ', transactions.length);
|
|
251
250
|
return apiPromise.api.tx.utility.batch(transactions);
|
|
251
|
+
}
|
|
252
|
+
export function getAstarWithdrawable(nominatorMetadata) {
|
|
253
|
+
const unstakingInfo = {
|
|
254
|
+
chain: nominatorMetadata.chain,
|
|
255
|
+
status: UnstakingStatus.CLAIMABLE,
|
|
256
|
+
claimable: '0',
|
|
257
|
+
waitingTime: 0
|
|
258
|
+
};
|
|
259
|
+
let bnWithdrawable = BN_ZERO;
|
|
260
|
+
for (const unstaking of nominatorMetadata.unstakings) {
|
|
261
|
+
if (unstaking.status === UnstakingStatus.CLAIMABLE) {
|
|
262
|
+
bnWithdrawable = bnWithdrawable.add(new BN(unstaking.claimable));
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
unstakingInfo.claimable = bnWithdrawable.toString();
|
|
266
|
+
return unstakingInfo;
|
|
252
267
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { StakingStatus, StakingType, UnstakingStatus } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
|
+
import { getAstarWithdrawable } from '@subwallet/extension-base/koni/api/staking/bonding/astar';
|
|
5
6
|
import { _KNOWN_CHAIN_INFLATION_PARAMS, _STAKING_CHAIN_GROUP, _SUBSTRATE_DEFAULT_INFLATION_PARAMS } from '@subwallet/extension-base/services/chain-service/constants';
|
|
6
7
|
import { parseRawNumber, reformatAddress } from '@subwallet/extension-base/utils';
|
|
7
8
|
import { BN, BN_BILLION, BN_HUNDRED, BN_MILLION, BN_THOUSAND, BN_ZERO, bnToU8a, stringToU8a, u8aConcat } from '@polkadot/util';
|
|
@@ -211,6 +212,9 @@ export function isActionFromValidator(stakingType, chain) {
|
|
|
211
212
|
export function getWithdrawalInfo(nominatorMetadata) {
|
|
212
213
|
const unstakings = nominatorMetadata.unstakings;
|
|
213
214
|
let result;
|
|
215
|
+
if (_STAKING_CHAIN_GROUP.astar.includes(nominatorMetadata.chain)) {
|
|
216
|
+
return getAstarWithdrawable(nominatorMetadata);
|
|
217
|
+
}
|
|
214
218
|
for (const unstaking of unstakings) {
|
|
215
219
|
if (unstaking.status === UnstakingStatus.CLAIMABLE) {
|
|
216
220
|
result = unstaking; // only get the first withdrawal
|
|
@@ -76,7 +76,6 @@ const getSubsquidStaking = async (accounts, chain, chainInfoMap) => {
|
|
|
76
76
|
}));
|
|
77
77
|
return result;
|
|
78
78
|
} catch (e) {
|
|
79
|
-
console.error(`error getting ${chain} staking reward from subsquid`, e);
|
|
80
79
|
return [];
|
|
81
80
|
}
|
|
82
81
|
};
|
|
@@ -94,7 +93,6 @@ export const getAllSubsquidStaking = async (accounts, chainInfoMap) => {
|
|
|
94
93
|
rewardList = rewardList.concat(rewardItems);
|
|
95
94
|
}));
|
|
96
95
|
} catch (e) {
|
|
97
|
-
console.error('Error fetching staking reward from SubSquid', e);
|
|
98
96
|
return rewardList;
|
|
99
97
|
}
|
|
100
98
|
return rewardList;
|
|
@@ -9,7 +9,6 @@ const toContractAbiMessage = (contractPromise, message) => {
|
|
|
9
9
|
if (!value) {
|
|
10
10
|
const messages = contractPromise === null || contractPromise === void 0 ? void 0 : contractPromise.abi.messages.map(m => m.method).join(', ');
|
|
11
11
|
const error = `"${message}" not found in metadata.spec.messages: [${messages}]`;
|
|
12
|
-
console.error(error);
|
|
13
12
|
return {
|
|
14
13
|
ok: false,
|
|
15
14
|
error
|
package/koni/api/xcm/index.js
CHANGED
|
@@ -25,6 +25,5 @@ export const createXcmExtrinsic = async ({
|
|
|
25
25
|
} else {
|
|
26
26
|
extrinsic = getExtrinsicByXtokensPallet(originTokenInfo, originChainInfo, destinationChainInfo, recipient, sendingValue, api);
|
|
27
27
|
}
|
|
28
|
-
console.log('XCM extrinsic: ', extrinsic.toHex());
|
|
29
28
|
return extrinsic;
|
|
30
29
|
};
|
package/koni/background/cron.js
CHANGED
|
@@ -93,7 +93,6 @@ export class KoniCron {
|
|
|
93
93
|
if (!commonReload && !chainUpdated && !stakingSubmitted) {
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
|
-
this.logger.log('ServiceInfo updated, Cron restarting...', eventTypes);
|
|
97
96
|
const address = (_serviceInfo$currentA = serviceInfo.currentAccountInfo) === null || _serviceInfo$currentA === void 0 ? void 0 : _serviceInfo$currentA.address;
|
|
98
97
|
if (!address) {
|
|
99
98
|
return;
|
|
@@ -133,7 +132,6 @@ export class KoniCron {
|
|
|
133
132
|
if (!(currentAccountInfo !== null && currentAccountInfo !== void 0 && currentAccountInfo.address)) {
|
|
134
133
|
return;
|
|
135
134
|
}
|
|
136
|
-
this.logger.log('Starting cron jobs');
|
|
137
135
|
if (Object.keys(this.state.getSubstrateApiMap()).length !== 0 || Object.keys(this.state.getEvmApiMap()).length !== 0) {
|
|
138
136
|
this.resetNft(currentAccountInfo.address);
|
|
139
137
|
this.addCron('refreshNft', this.refreshNft(currentAccountInfo.address, this.state.getApiMap(), this.state.getSmartContractNfts(), this.state.getActiveChainInfoMap()), CRON_REFRESH_NFT_INTERVAL);
|
|
@@ -162,48 +160,12 @@ export class KoniCron {
|
|
|
162
160
|
this.serviceSubscription.unsubscribe();
|
|
163
161
|
this.serviceSubscription = undefined;
|
|
164
162
|
}
|
|
165
|
-
this.logger.log('Stopping cron jobs');
|
|
166
163
|
this.removeAllCrons();
|
|
167
164
|
this.status = 'stopped';
|
|
168
165
|
};
|
|
169
166
|
updateApiMapStatus = () => {
|
|
170
167
|
this.state.chainService.updateApiMapStatus().catch(console.error);
|
|
171
|
-
// const apiMap = this.state.getApiMap();
|
|
172
|
-
// const networkMap = this.state.getChainStateMap();
|
|
173
|
-
//
|
|
174
|
-
// for (const [key, substrateApi] of Object.entries(apiMap.substrate)) {
|
|
175
|
-
// let status: _ChainConnectionStatus = _ChainConnectionStatus.CONNECTING;
|
|
176
|
-
//
|
|
177
|
-
// if (substrateApi.isApiConnected) {
|
|
178
|
-
// status = _ChainConnectionStatus.CONNECTED;
|
|
179
|
-
// }
|
|
180
|
-
//
|
|
181
|
-
// if (!networkMap[key].connectionStatus) {
|
|
182
|
-
// this.state.updateChainConnectionStatus(key, status);
|
|
183
|
-
// } else if (networkMap[key].connectionStatus && networkMap[key].connectionStatus !== status) {
|
|
184
|
-
// this.state.updateChainConnectionStatus(key, status);
|
|
185
|
-
// }
|
|
186
|
-
// }
|
|
187
|
-
//
|
|
188
|
-
// for (const [key, evmApi] of Object.entries(apiMap.evm)) {
|
|
189
|
-
// evmApi.api.eth.net.isListening()
|
|
190
|
-
// .then(() => {
|
|
191
|
-
// if (!networkMap[key].connectionStatus) {
|
|
192
|
-
// this.state.updateChainConnectionStatus(key, _ChainConnectionStatus.CONNECTED);
|
|
193
|
-
// } else if (networkMap[key].connectionStatus && networkMap[key].connectionStatus !== _ChainConnectionStatus.CONNECTED) {
|
|
194
|
-
// this.state.updateChainConnectionStatus(key, _ChainConnectionStatus.CONNECTED);
|
|
195
|
-
// }
|
|
196
|
-
// })
|
|
197
|
-
// .catch(() => {
|
|
198
|
-
// if (!networkMap[key].connectionStatus) {
|
|
199
|
-
// this.state.updateChainConnectionStatus(key, _ChainConnectionStatus.CONNECTING);
|
|
200
|
-
// } else if (networkMap[key].connectionStatus && networkMap[key].connectionStatus !== _ChainConnectionStatus.CONNECTING) {
|
|
201
|
-
// this.state.updateChainConnectionStatus(key, _ChainConnectionStatus.CONNECTING);
|
|
202
|
-
// }
|
|
203
|
-
// });
|
|
204
|
-
// }
|
|
205
168
|
};
|
|
206
|
-
|
|
207
169
|
recoverApiMap = () => {
|
|
208
170
|
var _this$subscriptions;
|
|
209
171
|
const apiMap = this.state.getApiMap();
|
|
@@ -224,7 +186,6 @@ export class KoniCron {
|
|
|
224
186
|
};
|
|
225
187
|
refreshNft = (address, apiMap, smartContractNfts, chainInfoMap) => {
|
|
226
188
|
return () => {
|
|
227
|
-
console.debug('Refresh NFT state');
|
|
228
189
|
this.subscriptions.subscribeNft(address, apiMap.substrate, apiMap.evm, smartContractNfts, chainInfoMap);
|
|
229
190
|
};
|
|
230
191
|
};
|
|
@@ -236,13 +197,11 @@ export class KoniCron {
|
|
|
236
197
|
};
|
|
237
198
|
refreshStakingReward = address => {
|
|
238
199
|
return () => {
|
|
239
|
-
console.debug('Refresh staking reward state');
|
|
240
200
|
this.subscriptions.subscribeStakingReward(address).catch(this.logger.error);
|
|
241
201
|
};
|
|
242
202
|
};
|
|
243
203
|
refreshStakingRewardFastInterval = address => {
|
|
244
204
|
return () => {
|
|
245
|
-
console.debug('Refresh staking reward data with fast interval');
|
|
246
205
|
this.subscriptions.subscribeStakingRewardFastInterval(address).catch(this.logger.error);
|
|
247
206
|
};
|
|
248
207
|
};
|
|
@@ -254,20 +213,17 @@ export class KoniCron {
|
|
|
254
213
|
};
|
|
255
214
|
updateChainStakingMetadata = (chainInfoMap, chainStateMap, substrateApiMap) => {
|
|
256
215
|
return () => {
|
|
257
|
-
console.debug('Fetching chain staking metadata');
|
|
258
216
|
this.subscriptions.fetchChainStakingMetadata(chainInfoMap, chainStateMap, substrateApiMap).catch(this.logger.error);
|
|
259
217
|
};
|
|
260
218
|
};
|
|
261
219
|
updateNominatorMetadata = (address, chainInfoMap, chainStateMap, substrateApiMap) => {
|
|
262
220
|
return () => {
|
|
263
|
-
console.debug('Fetching nominator data for', address);
|
|
264
221
|
this.subscriptions.fetchNominatorMetadata(address, chainInfoMap, chainStateMap, substrateApiMap).catch(this.logger.error);
|
|
265
222
|
};
|
|
266
223
|
};
|
|
267
224
|
async reloadNft() {
|
|
268
225
|
const address = this.state.keyringService.currentAccount.address;
|
|
269
226
|
const serviceInfo = this.state.getServiceInfo();
|
|
270
|
-
console.debug('Hard refresh NFT for', address);
|
|
271
227
|
this.resetNft(address);
|
|
272
228
|
this.removeCron('refreshNft');
|
|
273
229
|
this.addCron('refreshNft', this.refreshNft(address, serviceInfo.chainApiMap, this.state.getSmartContractNfts(), this.state.getActiveChainInfoMap()), CRON_REFRESH_NFT_INTERVAL);
|
|
@@ -276,7 +232,6 @@ export class KoniCron {
|
|
|
276
232
|
}
|
|
277
233
|
async reloadStaking() {
|
|
278
234
|
const address = this.state.keyringService.currentAccount.address;
|
|
279
|
-
console.debug('Hard refresh staking meta for', address);
|
|
280
235
|
this.resetStakingReward();
|
|
281
236
|
this.removeCron('refreshStakingReward');
|
|
282
237
|
this.removeCron('refreshPoolingStakingReward');
|
|
@@ -73,7 +73,9 @@ export default class KoniExtension {
|
|
|
73
73
|
private saveTheme;
|
|
74
74
|
private setCamera;
|
|
75
75
|
private saveBrowserConfirmationType;
|
|
76
|
+
private setAutoLockTime;
|
|
76
77
|
private subscribeSettings;
|
|
78
|
+
private setEnableChainPatrol;
|
|
77
79
|
private subscribeAuthUrls;
|
|
78
80
|
private _saveCurrentAccountAddress;
|
|
79
81
|
private updateCurrentAccountAddress;
|