@subwallet/extension-base 1.1.22-0 → 1.1.23-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 +10 -1
- package/cjs/koni/api/dotsama/balance.js +49 -0
- package/cjs/koni/api/dotsama/crowdloan.js +29 -3
- package/cjs/koni/api/dotsama/transfer.js +10 -3
- package/cjs/koni/api/staking/bonding/astar.js +9 -5
- package/cjs/koni/api/xcm/index.js +6 -1
- package/cjs/koni/api/xcm/polkadotXcm.js +1 -3
- package/cjs/koni/api/xcm/xTokens.js +1 -1
- package/cjs/koni/background/handlers/Extension.js +114 -96
- package/cjs/koni/background/handlers/State.js +12 -6
- package/cjs/koni/background/subscription.js +1 -1
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/chain-service/constants.js +5 -2
- package/cjs/services/chain-service/index.js +18 -0
- package/cjs/services/history-service/helpers/subscan-extrinsic-parser-helper.js +53 -0
- package/cjs/services/history-service/index.js +78 -21
- package/cjs/services/history-service/subscan-history.js +107 -0
- package/cjs/services/subscan-service/index.js +109 -4
- package/cjs/services/subscan-service/subscan-chain-map.js +82 -8
- package/cjs/utils/index.js +10 -1
- package/koni/api/dotsama/balance.js +49 -0
- package/koni/api/dotsama/crowdloan.d.ts +2 -2
- package/koni/api/dotsama/crowdloan.js +29 -2
- package/koni/api/dotsama/transfer.js +10 -3
- package/koni/api/staking/bonding/astar.js +9 -5
- package/koni/api/xcm/index.js +6 -1
- package/koni/api/xcm/polkadotXcm.js +2 -4
- package/koni/api/xcm/xTokens.js +1 -1
- package/koni/background/handlers/Extension.d.ts +1 -0
- package/koni/background/handlers/Extension.js +17 -0
- package/koni/background/handlers/State.d.ts +1 -0
- package/koni/background/handlers/State.js +13 -7
- package/koni/background/subscription.js +1 -1
- package/package.json +16 -6
- package/packageInfo.js +1 -1
- package/services/chain-service/constants.d.ts +2 -0
- package/services/chain-service/constants.js +5 -3
- package/services/chain-service/index.d.ts +1 -0
- package/services/chain-service/index.js +18 -0
- package/services/history-service/helpers/subscan-extrinsic-parser-helper.d.ts +6 -0
- package/services/history-service/helpers/subscan-extrinsic-parser-helper.js +44 -0
- package/services/history-service/index.d.ts +10 -6
- package/services/history-service/index.js +79 -22
- package/services/history-service/subscan-history.d.ts +5 -0
- package/services/history-service/subscan-history.js +100 -0
- package/services/subscan-service/index.d.ts +10 -2
- package/services/subscan-service/index.js +105 -4
- package/services/subscan-service/subscan-chain-map.d.ts +9 -3
- package/services/subscan-service/subscan-chain-map.js +78 -5
- package/services/subscan-service/types.d.ts +146 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.js +7 -0
|
@@ -3,11 +3,81 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.SUBSCAN_BALANCE_CHAIN_MAP_REVERSE = exports.SUBSCAN_BALANCE_CHAIN_MAP = exports.SUBSCAN_API_CHAIN_MAP = void 0;
|
|
7
7
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
8
8
|
// SPDX-License-Identifier: Apache-2.0
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Only use this for initiating SubscanService or unit test
|
|
12
|
+
*/
|
|
13
|
+
const SUBSCAN_API_CHAIN_MAP = {
|
|
14
|
+
polkadot: 'polkadot',
|
|
15
|
+
kusama: 'kusama',
|
|
16
|
+
moonbeam: 'moonbeam',
|
|
17
|
+
pioneer: 'pioneer',
|
|
18
|
+
aleph: 'alephzero',
|
|
19
|
+
astar: 'astar',
|
|
20
|
+
statemint: 'assethub-polkadot',
|
|
21
|
+
acala: 'acala',
|
|
22
|
+
shiden: 'shiden',
|
|
23
|
+
shibuya: 'shibuya',
|
|
24
|
+
westend: 'westend',
|
|
25
|
+
rococo: 'rococo',
|
|
26
|
+
moonbase: 'moonbase',
|
|
27
|
+
moonriver: 'moonriver',
|
|
28
|
+
turing: 'turing',
|
|
29
|
+
bifrost: 'bifrost-kusama',
|
|
30
|
+
bifrost_dot: 'bifrost',
|
|
31
|
+
calamari: 'calamari',
|
|
32
|
+
parallel: 'parallel',
|
|
33
|
+
clover: 'clv',
|
|
34
|
+
hydradx_main: 'hydradx',
|
|
35
|
+
centrifuge: 'centrifuge',
|
|
36
|
+
interlay: 'interlay',
|
|
37
|
+
nodle: 'nodle',
|
|
38
|
+
darwinia2: 'darwinia',
|
|
39
|
+
polkadex: 'polkadex-parachain',
|
|
40
|
+
composableFinance: 'composable',
|
|
41
|
+
phala: 'phala',
|
|
42
|
+
crust: 'crust-parachain',
|
|
43
|
+
statemine: 'assethub-kusama',
|
|
44
|
+
karura: 'karura',
|
|
45
|
+
khala: 'khala',
|
|
46
|
+
kilt: 'spiritnet',
|
|
47
|
+
basilisk: 'basilisk',
|
|
48
|
+
altair: 'altair',
|
|
49
|
+
heiko: 'parallel-heiko',
|
|
50
|
+
kintsugi: 'kintsugi',
|
|
51
|
+
picasso: 'picasso',
|
|
52
|
+
unique_network: 'unique',
|
|
53
|
+
zeitgeist: 'zeitgeist',
|
|
54
|
+
sakura: 'sakura',
|
|
55
|
+
shadow: 'shadow',
|
|
56
|
+
robonomics: 'robonomics',
|
|
57
|
+
integritee: 'integritee',
|
|
58
|
+
crabParachain: 'crab',
|
|
59
|
+
acala_testnet: 'acala-testnet',
|
|
60
|
+
mangatax_para: 'mangatax',
|
|
61
|
+
origintrail: 'origintrail',
|
|
62
|
+
subspace_gemini_3g: 'subspace',
|
|
63
|
+
bajun: 'bajun',
|
|
64
|
+
tanganika: 'datahighway',
|
|
65
|
+
kilt_peregrine: 'kilt-testnet',
|
|
66
|
+
dockPosMainnet: 'dock',
|
|
67
|
+
polymesh: 'polymesh',
|
|
68
|
+
sora_substrate: 'sora',
|
|
69
|
+
joystream: 'joystream',
|
|
70
|
+
vara_network: 'vara',
|
|
71
|
+
krest_network: 'krest',
|
|
72
|
+
crust_mainnet: 'crust',
|
|
73
|
+
manta_network: 'manta'
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Map for token self-activation feature
|
|
78
|
+
*/
|
|
79
|
+
exports.SUBSCAN_API_CHAIN_MAP = SUBSCAN_API_CHAIN_MAP;
|
|
80
|
+
const SUBSCAN_BALANCE_CHAIN_MAP = {
|
|
11
81
|
polkadot: 'polkadot',
|
|
12
82
|
kusama: 'kusama',
|
|
13
83
|
moonbeam: 'moonbeam',
|
|
@@ -27,7 +97,7 @@ const SUBSCAN_CHAIN_MAP = {
|
|
|
27
97
|
clover: 'clover',
|
|
28
98
|
hydradx_main: 'hydradx',
|
|
29
99
|
edgeware: 'edgeware',
|
|
30
|
-
centrifuge: 'centrifuge',
|
|
100
|
+
centrifuge: 'centrifuge-parachain',
|
|
31
101
|
interlay: 'interlay',
|
|
32
102
|
nodle: 'nodle',
|
|
33
103
|
darwinia: 'darwinia',
|
|
@@ -63,12 +133,16 @@ const SUBSCAN_CHAIN_MAP = {
|
|
|
63
133
|
bajun: 'bajun',
|
|
64
134
|
snow: 'snow',
|
|
65
135
|
kilt_peregrine: 'kilt-testnet',
|
|
66
|
-
polymesh: 'polymesh'
|
|
136
|
+
polymesh: 'polymesh',
|
|
137
|
+
bifrost_dot: 'bifrost-p',
|
|
138
|
+
vara_network: 'vara',
|
|
139
|
+
bifrost: 'bifrost',
|
|
140
|
+
creditcoin: 'creditcoin',
|
|
141
|
+
joystream: 'joystream'
|
|
67
142
|
};
|
|
68
|
-
|
|
143
|
+
exports.SUBSCAN_BALANCE_CHAIN_MAP = SUBSCAN_BALANCE_CHAIN_MAP;
|
|
144
|
+
const SUBSCAN_BALANCE_CHAIN_MAP_REVERSE = Object.fromEntries(Object.entries(SUBSCAN_BALANCE_CHAIN_MAP).map(_ref => {
|
|
69
145
|
let [k, v] = _ref;
|
|
70
146
|
return [v, k];
|
|
71
147
|
}));
|
|
72
|
-
exports.
|
|
73
|
-
var _default = SUBSCAN_CHAIN_MAP;
|
|
74
|
-
exports.default = _default;
|
|
148
|
+
exports.SUBSCAN_BALANCE_CHAIN_MAP_REVERSE = SUBSCAN_BALANCE_CHAIN_MAP_REVERSE;
|
package/cjs/utils/index.js
CHANGED
|
@@ -36,6 +36,7 @@ var _exportNames = {
|
|
|
36
36
|
getDomainFromUrl: true,
|
|
37
37
|
waitTimeout: true,
|
|
38
38
|
stripUrl: true,
|
|
39
|
+
wait: true,
|
|
39
40
|
canDerive: true
|
|
40
41
|
};
|
|
41
42
|
Object.defineProperty(exports, "canDerive", {
|
|
@@ -68,6 +69,7 @@ exports.stripUrl = void 0;
|
|
|
68
69
|
exports.sumBN = sumBN;
|
|
69
70
|
exports.toUnit = void 0;
|
|
70
71
|
exports.utf16ToString = utf16ToString;
|
|
72
|
+
exports.wait = wait;
|
|
71
73
|
exports.waitTimeout = waitTimeout;
|
|
72
74
|
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
73
75
|
var _constants = require("@subwallet/extension-base/constants");
|
|
@@ -435,4 +437,11 @@ const stripUrl = url => {
|
|
|
435
437
|
const parts = url.split('/');
|
|
436
438
|
return parts[2];
|
|
437
439
|
};
|
|
438
|
-
exports.stripUrl = stripUrl;
|
|
440
|
+
exports.stripUrl = stripUrl;
|
|
441
|
+
function wait(milliseconds) {
|
|
442
|
+
return new Promise(resolve => {
|
|
443
|
+
setTimeout(() => {
|
|
444
|
+
resolve();
|
|
445
|
+
}, milliseconds);
|
|
446
|
+
});
|
|
447
|
+
}
|
|
@@ -69,6 +69,8 @@ export async function subscribeSubstrateBalance(addresses, chainInfo, chain, net
|
|
|
69
69
|
unsubLocalToken = await subscribeEqBalanceAccountPallet(addresses, chain, networkAPI.api, callBack, true);
|
|
70
70
|
} else if (_BALANCE_CHAIN_GROUP.equilibrium_parachain.includes(chain)) {
|
|
71
71
|
unsubLocalToken = await subscribeEquilibriumTokenBalance(addresses, chain, networkAPI.api, callBack, true);
|
|
72
|
+
} else if (_BALANCE_CHAIN_GROUP.centrifuge.includes(chain)) {
|
|
73
|
+
unsubLocalToken = await subscribeOrmlTokensPallet(addresses, chain, networkAPI.api, callBack);
|
|
72
74
|
}
|
|
73
75
|
if (_isChainEvmCompatible(chainInfo)) {
|
|
74
76
|
unsubEvmContractToken = subscribeERC20Interval(addresses, chain, evmApiMap, callBack);
|
|
@@ -280,6 +282,53 @@ async function subscribeEqBalanceAccountPallet(addresses, chain, api, callBack,
|
|
|
280
282
|
});
|
|
281
283
|
};
|
|
282
284
|
}
|
|
285
|
+
|
|
286
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
287
|
+
async function subscribeOrmlTokensPallet(addresses, chain, api, callBack) {
|
|
288
|
+
const tokenTypes = [_AssetType.LOCAL];
|
|
289
|
+
const tokenMap = state.getAssetByChainAndAsset(chain, tokenTypes);
|
|
290
|
+
const unsubList = Object.values(tokenMap).map(async tokenInfo => {
|
|
291
|
+
try {
|
|
292
|
+
const onChainInfo = _getTokenOnChainInfo(tokenInfo);
|
|
293
|
+
|
|
294
|
+
// Get Token Balance
|
|
295
|
+
// @ts-ignore
|
|
296
|
+
const unsub = await api.query.ormlTokens.accounts.multi(addresses.map(address => [address, onChainInfo]), balances => {
|
|
297
|
+
const tokenBalance = {
|
|
298
|
+
reserved: sumBN(balances.map(b => b.reserved || new BN(0))),
|
|
299
|
+
frozen: sumBN(balances.map(b => b.frozen || new BN(0))),
|
|
300
|
+
free: sumBN(balances.map(b => b.free || new BN(0))) // free is actually total balance
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
// free balance = total balance - frozen misc
|
|
304
|
+
// locked balance = reserved + frozen misc
|
|
305
|
+
const freeBalance = tokenBalance.free.sub(tokenBalance.frozen);
|
|
306
|
+
const lockedBalance = tokenBalance.frozen.add(tokenBalance.reserved);
|
|
307
|
+
callBack({
|
|
308
|
+
tokenSlug: tokenInfo.slug,
|
|
309
|
+
state: APIItemState.READY,
|
|
310
|
+
free: freeBalance.toString(),
|
|
311
|
+
locked: lockedBalance.toString(),
|
|
312
|
+
substrateInfo: {
|
|
313
|
+
reserved: tokenBalance.reserved.toString(),
|
|
314
|
+
miscFrozen: tokenBalance.frozen.toString()
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
return unsub;
|
|
319
|
+
} catch (err) {
|
|
320
|
+
console.warn(err);
|
|
321
|
+
return undefined;
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
return () => {
|
|
325
|
+
unsubList.forEach(subProm => {
|
|
326
|
+
subProm.then(unsub => {
|
|
327
|
+
unsub && unsub();
|
|
328
|
+
}).catch(console.error);
|
|
329
|
+
});
|
|
330
|
+
};
|
|
331
|
+
}
|
|
283
332
|
async function subscribeTokensAccountsPallet(addresses, chain, api, callBack, includeNativeToken) {
|
|
284
333
|
const tokenTypes = includeNativeToken ? [_AssetType.NATIVE, _AssetType.LOCAL] : [_AssetType.LOCAL];
|
|
285
334
|
const tokenMap = state.getAssetByChainAndAsset(chain, tokenTypes);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _CrowdloanFund } from '@subwallet/chain-list/types';
|
|
2
2
|
import { CrowdloanItem } from '@subwallet/extension-base/background/KoniTypes';
|
|
3
3
|
import { _SubstrateApi } from '@subwallet/extension-base/services/chain-service/types';
|
|
4
4
|
export declare type CrowdloanFundInfo = _CrowdloanFund & {
|
|
5
5
|
chain: string;
|
|
6
6
|
};
|
|
7
7
|
export declare const subscribeAcalaContributeInterval: (polkadotAddresses: string[], fundInfo: _CrowdloanFund, callback: (rs: CrowdloanItem) => void) => () => void;
|
|
8
|
-
export declare function subscribeCrowdloan(addresses: string[], substrateApiMap: Record<string, _SubstrateApi>, callback: (networkKey: string, rs: CrowdloanItem) => void
|
|
8
|
+
export declare function subscribeCrowdloan(addresses: string[], substrateApiMap: Record<string, _SubstrateApi>, callback: (networkKey: string, rs: CrowdloanItem) => void): Promise<(() => void) | undefined>;
|
|
@@ -16,7 +16,20 @@ const STATUS_MAP = {
|
|
|
16
16
|
[_FundStatus.FAILED]: CrowdloanParaState.FAILED,
|
|
17
17
|
[_FundStatus.WON]: CrowdloanParaState.COMPLETED
|
|
18
18
|
};
|
|
19
|
+
function getChainInfoMap(chainInfoList) {
|
|
20
|
+
const result = {};
|
|
21
|
+
chainInfoList.forEach(ci => {
|
|
22
|
+
if (ci.slug) {
|
|
23
|
+
result[ci.slug] = ci;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
19
28
|
const getOnlineFundList = fetchStaticData('crowdloan-funds');
|
|
29
|
+
const getOnlineChainInfoMap = (async () => {
|
|
30
|
+
const chainInfoList = await fetchStaticData('chains');
|
|
31
|
+
return getChainInfoMap(chainInfoList);
|
|
32
|
+
})();
|
|
20
33
|
function getRPCCrowdloan(parentAPI, fundInfo, hexAddresses, callback) {
|
|
21
34
|
const {
|
|
22
35
|
auctionIndex,
|
|
@@ -123,14 +136,28 @@ export const subscribeAcalaContributeInterval = (polkadotAddresses, fundInfo, ca
|
|
|
123
136
|
// }, {} as Record<string, CrowdloanParaState>);
|
|
124
137
|
// }
|
|
125
138
|
|
|
139
|
+
function isNeedToUpdateLatestFundInfoMap(latestMap, chainSlug, fundInfo) {
|
|
140
|
+
if (!latestMap[chainSlug]) {
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
if (!fundInfo.auctionIndex && fundInfo.status === _FundStatus.IN_AUCTION) {
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
if (fundInfo.auctionIndex > latestMap[chainSlug].auctionIndex) {
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
|
|
126
152
|
// Get All crowdloan
|
|
127
|
-
export async function subscribeCrowdloan(addresses, substrateApiMap, callback
|
|
153
|
+
export async function subscribeCrowdloan(addresses, substrateApiMap, callback) {
|
|
128
154
|
const unsubMap = {};
|
|
129
155
|
const latestMap = {};
|
|
130
156
|
const rawFundList = await getOnlineFundList;
|
|
157
|
+
const chainInfoMap = await getOnlineChainInfoMap;
|
|
131
158
|
rawFundList.forEach(fundInfo => {
|
|
132
159
|
const chainSlug = fundInfo.chain;
|
|
133
|
-
if (
|
|
160
|
+
if (isNeedToUpdateLatestFundInfoMap(latestMap, chainSlug, fundInfo)) {
|
|
134
161
|
latestMap[chainSlug] = fundInfo;
|
|
135
162
|
}
|
|
136
163
|
});
|
|
@@ -97,8 +97,11 @@ export async function checkSupportTransfer(networkKey, tokenInfo, substrateApiMa
|
|
|
97
97
|
// result.supportTransfer = true;
|
|
98
98
|
// result.supportTransferAll = true;
|
|
99
99
|
} else if (_TRANSFER_CHAIN_GROUP.avail.includes(networkKey)) {
|
|
100
|
-
result.supportTransfer =
|
|
101
|
-
result.supportTransferAll =
|
|
100
|
+
result.supportTransfer = true;
|
|
101
|
+
result.supportTransferAll = true;
|
|
102
|
+
} else if (_TRANSFER_CHAIN_GROUP.centrifuge.includes(networkKey)) {
|
|
103
|
+
result.supportTransfer = true;
|
|
104
|
+
result.supportTransferAll = true;
|
|
102
105
|
}
|
|
103
106
|
return result;
|
|
104
107
|
}
|
|
@@ -181,7 +184,11 @@ export const createTransferExtrinsic = async ({
|
|
|
181
184
|
if (transferAll) {
|
|
182
185
|
transfer = api.tx.balances.transferAll(to, false);
|
|
183
186
|
} else if (value) {
|
|
184
|
-
|
|
187
|
+
if (api.tx.balances.transferKeepAlive) {
|
|
188
|
+
transfer = api.tx.balances.transferKeepAlive(to, new BN(value));
|
|
189
|
+
} else {
|
|
190
|
+
transfer = api.tx.balances.transfer(to, new BN(value));
|
|
191
|
+
}
|
|
185
192
|
}
|
|
186
193
|
}
|
|
187
194
|
return [transfer, transferAmount || value];
|
|
@@ -63,6 +63,9 @@ export async function getAstarStakingMetadata(chain, substrateApi) {
|
|
|
63
63
|
unstakingPeriod
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
|
+
const convertAddress = address => {
|
|
67
|
+
return isEthereumAddress(address) ? address.toLowerCase() : address;
|
|
68
|
+
};
|
|
66
69
|
export async function subscribeAstarNominatorMetadata(chainInfo, address, substrateApi, ledger) {
|
|
67
70
|
const nominationList = [];
|
|
68
71
|
const unstakingList = [];
|
|
@@ -81,14 +84,15 @@ export async function subscribeAstarNominatorMetadata(chainInfo, address, substr
|
|
|
81
84
|
if (_stakerInfo.length > 0) {
|
|
82
85
|
const dAppInfoMap = {};
|
|
83
86
|
allDapps.forEach(dappInfo => {
|
|
84
|
-
dAppInfoMap[dappInfo.address
|
|
87
|
+
dAppInfoMap[convertAddress(dappInfo.address)] = dappInfo;
|
|
85
88
|
});
|
|
86
89
|
for (const item of _stakerInfo) {
|
|
87
90
|
const data = item[0].toHuman();
|
|
88
91
|
const stakedDapp = data[1];
|
|
89
92
|
const stakeData = item[1].toPrimitive();
|
|
90
93
|
const stakeList = stakeData.stakes;
|
|
91
|
-
const
|
|
94
|
+
const _dappAddress = stakedDapp.Evm ? stakedDapp.Evm.toLowerCase() : stakedDapp.Wasm;
|
|
95
|
+
const dappAddress = convertAddress(_dappAddress);
|
|
92
96
|
const currentStake = stakeList.slice(-1)[0].staked.toString() || '0';
|
|
93
97
|
const bnCurrentStake = new BN(currentStake);
|
|
94
98
|
if (bnCurrentStake.gt(BN_ZERO)) {
|
|
@@ -98,7 +102,7 @@ export async function subscribeAstarNominatorMetadata(chainInfo, address, substr
|
|
|
98
102
|
nominationList.push({
|
|
99
103
|
status: dappStakingStatus,
|
|
100
104
|
chain: chainInfo.slug,
|
|
101
|
-
validatorAddress:
|
|
105
|
+
validatorAddress: dappAddress,
|
|
102
106
|
activeStake: currentStake,
|
|
103
107
|
validatorMinStake: '0',
|
|
104
108
|
validatorIdentity: dappInfo === null || dappInfo === void 0 ? void 0 : dappInfo.name,
|
|
@@ -176,7 +180,7 @@ export async function getAstarNominatorMetadata(chainInfo, address, substrateApi
|
|
|
176
180
|
const stakedDapp = data[1];
|
|
177
181
|
const stakeData = item[1].toPrimitive();
|
|
178
182
|
const stakeList = stakeData.stakes;
|
|
179
|
-
const dappAddress =
|
|
183
|
+
const dappAddress = convertAddress(stakedDapp.Evm);
|
|
180
184
|
const currentStake = stakeList.slice(-1)[0].staked.toString() || '0';
|
|
181
185
|
const bnCurrentStake = new BN(currentStake);
|
|
182
186
|
if (bnCurrentStake.gt(BN_ZERO)) {
|
|
@@ -269,7 +273,7 @@ export async function getAstarDappsInfo(networkKey, substrateApi) {
|
|
|
269
273
|
allDappsInfo.push({
|
|
270
274
|
commission: 0,
|
|
271
275
|
expectedReturn: 0,
|
|
272
|
-
address:
|
|
276
|
+
address: convertAddress(dappAddress),
|
|
273
277
|
totalStake: totalStake,
|
|
274
278
|
ownStake: '0',
|
|
275
279
|
otherStake: totalStake.toString(),
|
package/koni/api/xcm/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { getExtrinsicByPolkadotXcmPallet } from '@subwallet/extension-base/koni/
|
|
|
5
5
|
import { getExtrinsicByXcmPalletPallet } from '@subwallet/extension-base/koni/api/xcm/xcmPallet';
|
|
6
6
|
import { getExtrinsicByXtokensPallet } from '@subwallet/extension-base/koni/api/xcm/xTokens';
|
|
7
7
|
import { _XCM_CHAIN_GROUP } from '@subwallet/extension-base/services/chain-service/constants';
|
|
8
|
+
import { _isNativeToken } from '@subwallet/extension-base/services/chain-service/utils';
|
|
8
9
|
export const createXcmExtrinsic = async ({
|
|
9
10
|
chainInfoMap,
|
|
10
11
|
destinationTokenInfo,
|
|
@@ -19,7 +20,11 @@ export const createXcmExtrinsic = async ({
|
|
|
19
20
|
const api = chainApi.api;
|
|
20
21
|
let extrinsic;
|
|
21
22
|
if (_XCM_CHAIN_GROUP.polkadotXcm.includes(originTokenInfo.originChain)) {
|
|
22
|
-
|
|
23
|
+
if (['astar', 'shiden'].includes(originChainInfo.slug) && !_isNativeToken(originTokenInfo)) {
|
|
24
|
+
extrinsic = getExtrinsicByXtokensPallet(originTokenInfo, originChainInfo, destinationChainInfo, recipient, sendingValue, api);
|
|
25
|
+
} else {
|
|
26
|
+
extrinsic = getExtrinsicByPolkadotXcmPallet(originTokenInfo, originChainInfo, destinationChainInfo, recipient, sendingValue, api);
|
|
27
|
+
}
|
|
23
28
|
} else if (_XCM_CHAIN_GROUP.xcmPallet.includes(originTokenInfo.originChain)) {
|
|
24
29
|
extrinsic = getExtrinsicByXcmPalletPallet(originTokenInfo, originChainInfo, destinationChainInfo, recipient, sendingValue, api);
|
|
25
30
|
} else {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { getBeneficiary, getDestinationChainLocation, getDestWeight, getTokenLocation } from '@subwallet/extension-base/koni/api/xcm/utils';
|
|
5
|
-
import {
|
|
5
|
+
import { _isSubstrateRelayChain } from '@subwallet/extension-base/services/chain-service/utils';
|
|
6
6
|
export function getExtrinsicByPolkadotXcmPallet(tokenInfo, originChainInfo, destinationChainInfo, recipientAddress, value, api) {
|
|
7
7
|
const weightParam = getDestWeight();
|
|
8
8
|
const version = ['statemint', 'statemine', 'shiden', 'astar'].includes(originChainInfo.slug) ? 'V3' : 'V1';
|
|
@@ -10,9 +10,7 @@ export function getExtrinsicByPolkadotXcmPallet(tokenInfo, originChainInfo, dest
|
|
|
10
10
|
const destination = getDestinationChainLocation(originChainInfo, destinationChainInfo, version);
|
|
11
11
|
let assetLocation = getTokenLocation(tokenInfo, value, version);
|
|
12
12
|
let method = 'limitedReserveTransferAssets';
|
|
13
|
-
if (['
|
|
14
|
-
method = 'limitedReserveWithdrawAssets';
|
|
15
|
-
} else if (['statemint', 'statemine'].includes(originChainInfo.slug) && _isSubstrateRelayChain(destinationChainInfo)) {
|
|
13
|
+
if (['statemint', 'statemine'].includes(originChainInfo.slug) && _isSubstrateRelayChain(destinationChainInfo)) {
|
|
16
14
|
assetLocation = {
|
|
17
15
|
[version]: [{
|
|
18
16
|
id: {
|
package/koni/api/xcm/xTokens.js
CHANGED
|
@@ -19,6 +19,6 @@ function getCurrencyId(tokenInfo) {
|
|
|
19
19
|
}
|
|
20
20
|
export function getExtrinsicByXtokensPallet(tokenInfo, originChainInfo, destinationChainInfo, recipientAddress, value, api) {
|
|
21
21
|
const weightParam = ['pioneer'].includes(originChainInfo.slug) ? FOUR_INSTRUCTIONS_WEIGHT : getDestWeight();
|
|
22
|
-
const destVersion = ['moonbeam', 'moonriver', 'bifrost_dot', 'interlay', 'hydradx_main', 'acala', 'parallel'].includes(originChainInfo.slug) ? 'V3' : undefined;
|
|
22
|
+
const destVersion = ['moonbeam', 'moonriver', 'bifrost_dot', 'interlay', 'hydradx_main', 'acala', 'parallel', 'astar', 'shiden'].includes(originChainInfo.slug) ? 'V3' : undefined;
|
|
23
23
|
return api.tx.xTokens.transfer(getCurrencyId(tokenInfo), value, getDestMultilocation(destinationChainInfo, recipientAddress, destVersion), weightParam);
|
|
24
24
|
}
|
|
@@ -116,6 +116,7 @@ export default class KoniExtension {
|
|
|
116
116
|
private getStaking;
|
|
117
117
|
private subscribeStaking;
|
|
118
118
|
private subscribeHistory;
|
|
119
|
+
private subscribeHistoryByChainAndAddress;
|
|
119
120
|
private validateTransfer;
|
|
120
121
|
private makeTransfer;
|
|
121
122
|
private validateCrossChainTransfer;
|
|
@@ -1439,6 +1439,21 @@ export default class KoniExtension {
|
|
|
1439
1439
|
// Re-filter
|
|
1440
1440
|
return historySubject.getValue().filter(item => addresses.some(address => isSameAddress(item.address, address)));
|
|
1441
1441
|
}
|
|
1442
|
+
subscribeHistoryByChainAndAddress({
|
|
1443
|
+
address,
|
|
1444
|
+
chain
|
|
1445
|
+
}, id, port) {
|
|
1446
|
+
const cb = createSubscription(id, port);
|
|
1447
|
+
const subscribeHistoriesResponse = this.#koniState.historyService.subscribeHistories(chain, address, cb);
|
|
1448
|
+
this.createUnsubscriptionHandle(id, subscribeHistoriesResponse.unsubscribe);
|
|
1449
|
+
port.onDisconnect.addListener(() => {
|
|
1450
|
+
this.cancelSubscription(id);
|
|
1451
|
+
});
|
|
1452
|
+
return {
|
|
1453
|
+
id,
|
|
1454
|
+
items: subscribeHistoriesResponse.value
|
|
1455
|
+
};
|
|
1456
|
+
}
|
|
1442
1457
|
|
|
1443
1458
|
// Save address to contact
|
|
1444
1459
|
// private addContact (to: string) {
|
|
@@ -3746,6 +3761,8 @@ export default class KoniExtension {
|
|
|
3746
3761
|
return this.subscribeStakingReward(id, port);
|
|
3747
3762
|
case 'pri(transaction.history.getSubscription)':
|
|
3748
3763
|
return await this.subscribeHistory(id, port);
|
|
3764
|
+
case 'pri(transaction.history.subscribe)':
|
|
3765
|
+
return this.subscribeHistoryByChainAndAddress(request, id, port);
|
|
3749
3766
|
|
|
3750
3767
|
/* Account management */
|
|
3751
3768
|
// Add account
|
|
@@ -84,6 +84,7 @@ export default class KoniState {
|
|
|
84
84
|
sign(url: string, request: RequestSign, account: AccountJson): Promise<ResponseSigning>;
|
|
85
85
|
get authSubjectV2(): BehaviorSubject<import("@subwallet/extension-base/background/types").AuthorizeRequest[]>;
|
|
86
86
|
generateDefaultBalanceMap(): Record<string, BalanceItem>;
|
|
87
|
+
private afterChainServiceInit;
|
|
87
88
|
init(): Promise<void>;
|
|
88
89
|
initMantaPay(password: string): Promise<void>;
|
|
89
90
|
private startSubscription;
|
|
@@ -23,7 +23,7 @@ import RequestService from '@subwallet/extension-base/services/request-service';
|
|
|
23
23
|
import SettingService from '@subwallet/extension-base/services/setting-service/SettingService';
|
|
24
24
|
import DatabaseService from '@subwallet/extension-base/services/storage-service/DatabaseService';
|
|
25
25
|
import { SubscanService } from '@subwallet/extension-base/services/subscan-service';
|
|
26
|
-
import {
|
|
26
|
+
import { SUBSCAN_API_CHAIN_MAP, SUBSCAN_BALANCE_CHAIN_MAP_REVERSE } from '@subwallet/extension-base/services/subscan-service/subscan-chain-map';
|
|
27
27
|
import TransactionService from '@subwallet/extension-base/services/transaction-service';
|
|
28
28
|
import WalletConnectService from '@subwallet/extension-base/services/wallet-connect-service';
|
|
29
29
|
import AccountRefStore from '@subwallet/extension-base/stores/AccountRef';
|
|
@@ -84,14 +84,14 @@ export default class KoniState {
|
|
|
84
84
|
this.eventService = new EventService();
|
|
85
85
|
this.dbService = new DatabaseService(this.eventService);
|
|
86
86
|
this.keyringService = new KeyringService(this.eventService);
|
|
87
|
-
this.subscanService = new SubscanService();
|
|
88
87
|
this.notificationService = new NotificationService();
|
|
89
88
|
this.chainService = new ChainService(this.dbService, this.eventService);
|
|
89
|
+
this.subscanService = new SubscanService(SUBSCAN_API_CHAIN_MAP);
|
|
90
90
|
this.settingService = new SettingService();
|
|
91
91
|
this.requestService = new RequestService(this.chainService, this.settingService, this.keyringService);
|
|
92
92
|
this.priceService = new PriceService(this.dbService, this.eventService, this.chainService);
|
|
93
93
|
this.balanceService = new BalanceService(this.chainService);
|
|
94
|
-
this.historyService = new HistoryService(this.dbService, this.chainService, this.eventService, this.keyringService);
|
|
94
|
+
this.historyService = new HistoryService(this.dbService, this.chainService, this.eventService, this.keyringService, this.subscanService);
|
|
95
95
|
this.transactionService = new TransactionService(this.chainService, this.eventService, this.requestService, this.balanceService, this.historyService, this.notificationService, this.dbService);
|
|
96
96
|
this.walletConnectService = new WalletConnectService(this, this.requestService);
|
|
97
97
|
this.migrationService = new MigrationService(this, this.eventService);
|
|
@@ -198,9 +198,13 @@ export default class KoniState {
|
|
|
198
198
|
});
|
|
199
199
|
return balanceMap;
|
|
200
200
|
}
|
|
201
|
+
afterChainServiceInit() {
|
|
202
|
+
this.subscanService.setSubscanChainMap(this.chainService.getSubscanChainMap());
|
|
203
|
+
}
|
|
201
204
|
async init() {
|
|
202
205
|
await this.eventService.waitCryptoReady;
|
|
203
206
|
await this.chainService.init();
|
|
207
|
+
this.afterChainServiceInit();
|
|
204
208
|
await this.migrationService.run();
|
|
205
209
|
this.eventService.emit('chain.ready', true);
|
|
206
210
|
this.onReady();
|
|
@@ -1469,7 +1473,7 @@ export default class KoniState {
|
|
|
1469
1473
|
symbol
|
|
1470
1474
|
}) => {
|
|
1471
1475
|
var _currentAssetSettings;
|
|
1472
|
-
const chain =
|
|
1476
|
+
const chain = SUBSCAN_BALANCE_CHAIN_MAP_REVERSE[network];
|
|
1473
1477
|
const chainInfo = chain ? chainMap[chain] : null;
|
|
1474
1478
|
const balanceIsEmpty = (!balance || balance === '0') && (!locked || locked === '0') && (!bonded || bonded === '0');
|
|
1475
1479
|
|
|
@@ -1478,10 +1482,11 @@ export default class KoniState {
|
|
|
1478
1482
|
return;
|
|
1479
1483
|
}
|
|
1480
1484
|
const tokenKey = `${chain}-${category === 'native' ? 'NATIVE' : 'LOCAL'}-${symbol.toUpperCase()}`;
|
|
1481
|
-
|
|
1485
|
+
const existedKey = Object.keys(assetMap).find(v => v.toLowerCase() === tokenKey.toLowerCase());
|
|
1486
|
+
if (existedKey && !((_currentAssetSettings = currentAssetSettings[existedKey]) !== null && _currentAssetSettings !== void 0 && _currentAssetSettings.visible)) {
|
|
1482
1487
|
needEnableChains.push(chain);
|
|
1483
|
-
needActiveTokens.push(
|
|
1484
|
-
currentAssetSettings[
|
|
1488
|
+
needActiveTokens.push(existedKey);
|
|
1489
|
+
currentAssetSettings[existedKey] = {
|
|
1485
1490
|
visible: true
|
|
1486
1491
|
};
|
|
1487
1492
|
}
|
|
@@ -1553,6 +1558,7 @@ export default class KoniState {
|
|
|
1553
1558
|
this.chainService.resetWallet(resetAll);
|
|
1554
1559
|
await this.walletConnectService.resetWallet(resetAll);
|
|
1555
1560
|
await this.chainService.init();
|
|
1561
|
+
this.afterChainServiceInit();
|
|
1556
1562
|
}
|
|
1557
1563
|
async enableMantaPay(updateStore, address, password, seedPhrase) {
|
|
1558
1564
|
var _this$chainService3, _this$chainService3$m, _this$chainService4, _this$chainService4$m, _this$chainService4$m2, _this$chainService11, _this$chainService11$, _this$chainService11$2;
|
|
@@ -163,7 +163,7 @@ export class KoniSubscription {
|
|
|
163
163
|
initCrowdloanSubscription(addresses, substrateApiMap, onlyRunOnFirstTime) {
|
|
164
164
|
const subscriptionPromise = subscribeCrowdloan(addresses, substrateApiMap, (networkKey, rs) => {
|
|
165
165
|
this.state.setCrowdloanItem(networkKey, rs);
|
|
166
|
-
}
|
|
166
|
+
});
|
|
167
167
|
if (onlyRunOnFirstTime) {
|
|
168
168
|
subscriptionPromise.then(unsub => {
|
|
169
169
|
unsub && unsub();
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "1.1.
|
|
20
|
+
"version": "1.1.23-0",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -673,6 +673,16 @@
|
|
|
673
673
|
"require": "./cjs/services/history-service/helpers/recoverHistoryStatus.js",
|
|
674
674
|
"default": "./services/history-service/helpers/recoverHistoryStatus.js"
|
|
675
675
|
},
|
|
676
|
+
"./services/history-service/helpers/subscan-extrinsic-parser-helper": {
|
|
677
|
+
"types": "./services/history-service/helpers/subscan-extrinsic-parser-helper.d.ts",
|
|
678
|
+
"require": "./cjs/services/history-service/helpers/subscan-extrinsic-parser-helper.js",
|
|
679
|
+
"default": "./services/history-service/helpers/subscan-extrinsic-parser-helper.js"
|
|
680
|
+
},
|
|
681
|
+
"./services/history-service/subscan-history": {
|
|
682
|
+
"types": "./services/history-service/subscan-history.d.ts",
|
|
683
|
+
"require": "./cjs/services/history-service/subscan-history.js",
|
|
684
|
+
"default": "./services/history-service/subscan-history.js"
|
|
685
|
+
},
|
|
676
686
|
"./services/history-service/subsquid-multi-chain-history": {
|
|
677
687
|
"types": "./services/history-service/subsquid-multi-chain-history.d.ts",
|
|
678
688
|
"require": "./cjs/services/history-service/subsquid-multi-chain-history.js",
|
|
@@ -1312,11 +1322,11 @@
|
|
|
1312
1322
|
"@reduxjs/toolkit": "^1.9.1",
|
|
1313
1323
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
1314
1324
|
"@substrate/connect": "^0.7.26",
|
|
1315
|
-
"@subwallet/chain-list": "0.2.
|
|
1316
|
-
"@subwallet/extension-base": "^1.1.
|
|
1317
|
-
"@subwallet/extension-chains": "^1.1.
|
|
1318
|
-
"@subwallet/extension-dapp": "^1.1.
|
|
1319
|
-
"@subwallet/extension-inject": "^1.1.
|
|
1325
|
+
"@subwallet/chain-list": "0.2.26",
|
|
1326
|
+
"@subwallet/extension-base": "^1.1.23-0",
|
|
1327
|
+
"@subwallet/extension-chains": "^1.1.23-0",
|
|
1328
|
+
"@subwallet/extension-dapp": "^1.1.23-0",
|
|
1329
|
+
"@subwallet/extension-inject": "^1.1.23-0",
|
|
1320
1330
|
"@subwallet/keyring": "^0.1.1",
|
|
1321
1331
|
"@subwallet/ui-keyring": "^0.1.1",
|
|
1322
1332
|
"@walletconnect/sign-client": "^2.8.4",
|
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.1.
|
|
10
|
+
version: '1.1.23-0'
|
|
11
11
|
};
|
|
@@ -17,6 +17,7 @@ export declare const _BALANCE_CHAIN_GROUP: {
|
|
|
17
17
|
bifrost: string[];
|
|
18
18
|
statemine: string[];
|
|
19
19
|
kusama: string[];
|
|
20
|
+
centrifuge: string[];
|
|
20
21
|
};
|
|
21
22
|
export declare const _BALANCE_TOKEN_GROUP: {
|
|
22
23
|
crab: string[];
|
|
@@ -71,6 +72,7 @@ export declare const _TRANSFER_CHAIN_GROUP: {
|
|
|
71
72
|
sora_substrate: string[];
|
|
72
73
|
avail: string[];
|
|
73
74
|
pendulum: string[];
|
|
75
|
+
centrifuge: string[];
|
|
74
76
|
};
|
|
75
77
|
export declare const _BALANCE_PARSING_CHAIN_GROUP: {
|
|
76
78
|
bobabeam: string[];
|
|
@@ -30,9 +30,10 @@ export const _BALANCE_CHAIN_GROUP = {
|
|
|
30
30
|
equilibrium_parachain: ['equilibrium_parachain'],
|
|
31
31
|
bifrost: ['bifrost', 'acala', 'karura', 'acala_testnet', 'pioneer', 'bitcountry', 'bifrost_dot', 'hydradx_main', 'pendulum', 'amplitude'],
|
|
32
32
|
statemine: ['statemine', 'astar', 'shiden', 'statemint', 'moonbeam', 'moonbase', 'moonriver', 'crabParachain', 'darwinia2', 'parallel', 'calamari'],
|
|
33
|
-
kusama: ['kusama', 'kintsugi', 'kintsugi_test', 'interlay', 'acala', 'statemint', 'karura', 'bifrost']
|
|
33
|
+
kusama: ['kusama', 'kintsugi', 'kintsugi_test', 'interlay', 'acala', 'statemint', 'karura', 'bifrost'],
|
|
34
|
+
// perhaps there are some runtime updates
|
|
35
|
+
centrifuge: ['centrifuge']
|
|
34
36
|
};
|
|
35
|
-
|
|
36
37
|
export const _BALANCE_TOKEN_GROUP = {
|
|
37
38
|
crab: ['CKTON', 'PKTON'],
|
|
38
39
|
bitcountry: ['BIT']
|
|
@@ -194,7 +195,8 @@ export const _TRANSFER_CHAIN_GROUP = {
|
|
|
194
195
|
riochain: ['riochain'],
|
|
195
196
|
sora_substrate: ['sora_substrate'],
|
|
196
197
|
avail: ['kate', 'goldberg_testnet'],
|
|
197
|
-
pendulum: ['pendulum', 'amplitude', 'amplitude_test']
|
|
198
|
+
pendulum: ['pendulum', 'amplitude', 'amplitude_test'],
|
|
199
|
+
centrifuge: ['centrifuge']
|
|
198
200
|
};
|
|
199
201
|
export const _BALANCE_PARSING_CHAIN_GROUP = {
|
|
200
202
|
bobabeam: ['bobabeam', 'bobabase']
|
|
@@ -113,4 +113,5 @@ export declare class ChainService {
|
|
|
113
113
|
getMetadata(chain: string): import("dexie").PromiseExtended<IMetadataItem | undefined>;
|
|
114
114
|
upsertMetadata(chain: string, metadata: IMetadataItem): import("dexie").PromiseExtended<unknown>;
|
|
115
115
|
getMetadataByHash(hash: string): import("dexie").PromiseExtended<IMetadataItem | undefined>;
|
|
116
|
+
getSubscanChainMap(reverse?: boolean): Record<string, string>;
|
|
116
117
|
}
|