@subwallet/extension-base 1.1.32-0 → 1.1.33-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 +2 -0
- package/background/KoniTypes.js +1 -0
- package/cjs/background/KoniTypes.js +1 -0
- package/cjs/koni/api/staking/bonding/amplitude.js +97 -63
- package/cjs/koni/api/staking/paraChain.js +31 -5
- package/cjs/koni/api/xcm/xTokens.js +1 -1
- package/cjs/koni/background/handlers/Tabs.js +19 -2
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/campaign-service/index.js +19 -0
- package/cjs/services/chain-service/constants.js +5 -3
- package/cjs/services/history-service/index.js +12 -8
- package/cjs/services/storage-service/DatabaseService.js +3 -0
- package/cjs/services/storage-service/db-stores/Campaign.js +9 -3
- package/cjs/services/transaction-service/index.js +58 -13
- package/cjs/utils/fetchEvmChainInfo.js +20 -0
- package/cjs/utils/index.js +24 -0
- package/koni/api/staking/bonding/amplitude.d.ts +1 -1
- package/koni/api/staking/bonding/amplitude.js +98 -64
- package/koni/api/staking/bonding/utils.d.ts +4 -0
- package/koni/api/staking/paraChain.js +31 -5
- package/koni/api/xcm/xTokens.js +1 -1
- package/koni/background/handlers/Tabs.js +20 -3
- package/package.json +11 -6
- package/packageInfo.js +1 -1
- package/services/campaign-service/index.js +19 -0
- package/services/chain-service/constants.d.ts +1 -0
- package/services/chain-service/constants.js +5 -3
- package/services/event-service/types.d.ts +1 -0
- package/services/history-service/index.js +12 -8
- package/services/storage-service/DatabaseService.d.ts +1 -0
- package/services/storage-service/DatabaseService.js +3 -0
- package/services/storage-service/db-stores/Campaign.js +9 -3
- package/services/transaction-service/index.d.ts +1 -0
- package/services/transaction-service/index.js +45 -1
- package/services/transaction-service/types.d.ts +1 -0
- package/utils/fetchEvmChainInfo.d.ts +17 -0
- package/utils/fetchEvmChainInfo.js +14 -0
- package/utils/index.d.ts +2 -0
- package/utils/index.js +3 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getEVMChainInfo = getEVMChainInfo;
|
|
7
|
+
// Copyright 2019-2022 @subwallet/extension-base
|
|
8
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
|
|
10
|
+
const onlineMap = {};
|
|
11
|
+
async function getEVMChainInfo(chainId) {
|
|
12
|
+
if (Object.keys(onlineMap).length === 0) {
|
|
13
|
+
const rs = await fetch('https://chainid.network/chains.json');
|
|
14
|
+
const data = await rs.json();
|
|
15
|
+
data.forEach(item => {
|
|
16
|
+
onlineMap[item.chainId] = item;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return onlineMap[chainId];
|
|
20
|
+
}
|
package/cjs/utils/index.js
CHANGED
|
@@ -150,6 +150,30 @@ Object.keys(_translate).forEach(function (key) {
|
|
|
150
150
|
}
|
|
151
151
|
});
|
|
152
152
|
});
|
|
153
|
+
var _fetchStaticData = require("./fetchStaticData");
|
|
154
|
+
Object.keys(_fetchStaticData).forEach(function (key) {
|
|
155
|
+
if (key === "default" || key === "__esModule") return;
|
|
156
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
157
|
+
if (key in exports && exports[key] === _fetchStaticData[key]) return;
|
|
158
|
+
Object.defineProperty(exports, key, {
|
|
159
|
+
enumerable: true,
|
|
160
|
+
get: function () {
|
|
161
|
+
return _fetchStaticData[key];
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
var _fetchEvmChainInfo = require("./fetchEvmChainInfo");
|
|
166
|
+
Object.keys(_fetchEvmChainInfo).forEach(function (key) {
|
|
167
|
+
if (key === "default" || key === "__esModule") return;
|
|
168
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
169
|
+
if (key in exports && exports[key] === _fetchEvmChainInfo[key]) return;
|
|
170
|
+
Object.defineProperty(exports, key, {
|
|
171
|
+
enumerable: true,
|
|
172
|
+
get: function () {
|
|
173
|
+
return _fetchEvmChainInfo[key];
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
});
|
|
153
177
|
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
154
178
|
// SPDX-License-Identifier: Apache-2.0
|
|
155
179
|
|
|
@@ -5,7 +5,7 @@ import { _SubstrateApi } from '@subwallet/extension-base/services/chain-service/
|
|
|
5
5
|
import { Codec } from '@polkadot/types/types';
|
|
6
6
|
export declare function subscribeAmplitudeStakingMetadata(chain: string, substrateApi: _SubstrateApi, callback: (chain: string, rs: ChainStakingMetadata) => void): Promise<Codec>;
|
|
7
7
|
export declare function getAmplitudeStakingMetadata(chain: string, substrateApi: _SubstrateApi): Promise<ChainStakingMetadata>;
|
|
8
|
-
export declare function subscribeAmplitudeNominatorMetadata(chainInfo: _ChainInfo, address: string, substrateApi: _SubstrateApi, delegatorState: ParachainStakingStakeOption, unstakingInfo: Record<string, number>): Promise<NominatorMetadata>;
|
|
8
|
+
export declare function subscribeAmplitudeNominatorMetadata(chainInfo: _ChainInfo, address: string, substrateApi: _SubstrateApi, delegatorState: ParachainStakingStakeOption[], unstakingInfo: Record<string, number>): Promise<NominatorMetadata>;
|
|
9
9
|
/**
|
|
10
10
|
* Deprecated
|
|
11
11
|
* */
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import { StakingStatus, StakingType, UnstakingStatus } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
5
|
import { getBondedValidators, getStakingStatusByNominations, isUnstakeAll, parseIdentity } from '@subwallet/extension-base/koni/api/staking/bonding/utils';
|
|
6
|
-
import { _STAKING_ERA_LENGTH_MAP } from '@subwallet/extension-base/services/chain-service/constants';
|
|
6
|
+
import { _STAKING_CHAIN_GROUP, _STAKING_ERA_LENGTH_MAP } from '@subwallet/extension-base/services/chain-service/constants';
|
|
7
7
|
import { parseRawNumber, reformatAddress } from '@subwallet/extension-base/utils';
|
|
8
8
|
import { BN, BN_ZERO } from '@polkadot/util';
|
|
9
9
|
import { isEthereumAddress } from '@polkadot/util-crypto';
|
|
@@ -16,7 +16,7 @@ export function subscribeAmplitudeStakingMetadata(chain, substrateApi, callback)
|
|
|
16
16
|
const unstakingDelay = substrateApi.api.consts.parachainStaking.stakeDuration.toString();
|
|
17
17
|
const _blockPerRound = substrateApi.api.consts.parachainStaking.defaultBlocksPerRound.toString();
|
|
18
18
|
const blockPerRound = parseFloat(_blockPerRound);
|
|
19
|
-
const blockDuration = (_STAKING_ERA_LENGTH_MAP[chain] || _STAKING_ERA_LENGTH_MAP.default) / blockPerRound;
|
|
19
|
+
const blockDuration = (_STAKING_ERA_LENGTH_MAP[chain] || _STAKING_ERA_LENGTH_MAP.default) / blockPerRound;
|
|
20
20
|
const unstakingPeriod = blockDuration * parseInt(unstakingDelay);
|
|
21
21
|
callback(chain, {
|
|
22
22
|
chain,
|
|
@@ -58,46 +58,52 @@ export async function subscribeAmplitudeNominatorMetadata(chainInfo, address, su
|
|
|
58
58
|
const nominationList = [];
|
|
59
59
|
const unstakingList = [];
|
|
60
60
|
const minDelegatorStake = substrateApi.api.consts.parachainStaking.minDelegatorStake.toString();
|
|
61
|
+
const hasUnstakingInfo = unstakingInfo && Object.values(unstakingInfo).length > 0;
|
|
61
62
|
let activeStake = '0';
|
|
62
63
|
if (delegatorState) {
|
|
63
64
|
// delegatorState can be null while unstaking all
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
65
|
+
const identityPromises = delegatorState.map(delegate => parseIdentity(substrateApi, delegate.owner));
|
|
66
|
+
const identities = await Promise.all(identityPromises);
|
|
67
|
+
for (let i = 0; i < delegatorState.length; i++) {
|
|
68
|
+
const delegate = delegatorState[i];
|
|
69
|
+
const [identity] = identities[i];
|
|
70
|
+
activeStake = delegate.amount.toString();
|
|
71
|
+
const bnActiveStake = new BN(activeStake);
|
|
72
|
+
let delegationStatus = StakingStatus.NOT_EARNING;
|
|
73
|
+
if (bnActiveStake.gt(BN_ZERO) && bnActiveStake.gte(new BN(minDelegatorStake))) {
|
|
74
|
+
delegationStatus = StakingStatus.EARNING_REWARD;
|
|
75
|
+
}
|
|
76
|
+
nominationList.push({
|
|
77
|
+
status: delegationStatus,
|
|
78
|
+
chain: chainInfo.slug,
|
|
79
|
+
validatorAddress: delegate.owner,
|
|
80
|
+
activeStake: delegate.amount.toString(),
|
|
81
|
+
validatorMinStake: '0',
|
|
82
|
+
hasUnstaking: hasUnstakingInfo,
|
|
83
|
+
validatorIdentity: identity
|
|
84
|
+
});
|
|
85
|
+
if (hasUnstakingInfo) {
|
|
86
|
+
const _currentBlockInfo = await substrateApi.api.rpc.chain.getHeader();
|
|
87
|
+
const currentBlockInfo = _currentBlockInfo.toPrimitive();
|
|
88
|
+
const currentBlockNumber = currentBlockInfo.number;
|
|
89
|
+
const _blockPerRound = substrateApi.api.consts.parachainStaking.defaultBlocksPerRound.toString();
|
|
90
|
+
const blockPerRound = parseFloat(_blockPerRound);
|
|
91
|
+
const nearestUnstakingBlock = Object.keys(unstakingInfo)[0];
|
|
92
|
+
const nearestUnstakingAmount = Object.values(unstakingInfo)[0];
|
|
93
|
+
const blockDuration = (_STAKING_ERA_LENGTH_MAP[chainInfo.slug] || _STAKING_ERA_LENGTH_MAP.default) / blockPerRound; // in hours
|
|
90
94
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
95
|
+
const isClaimable = parseInt(nearestUnstakingBlock) - currentBlockNumber < 0;
|
|
96
|
+
const remainingBlock = parseInt(nearestUnstakingBlock) - currentBlockNumber;
|
|
97
|
+
const waitingTime = remainingBlock * blockDuration;
|
|
98
|
+
unstakingList.push({
|
|
99
|
+
chain: chainInfo.slug,
|
|
100
|
+
status: isClaimable ? UnstakingStatus.CLAIMABLE : UnstakingStatus.UNLOCKING,
|
|
101
|
+
claimable: nearestUnstakingAmount.toString(),
|
|
102
|
+
waitingTime,
|
|
103
|
+
validatorAddress: (delegate === null || delegate === void 0 ? void 0 : delegate.owner) || undefined
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
101
107
|
}
|
|
102
108
|
const stakingStatus = getStakingStatusByNominations(new BN(activeStake), nominationList);
|
|
103
109
|
return {
|
|
@@ -194,33 +200,61 @@ export async function getAmplitudeNominatorMetadata(chainInfo, address, substrat
|
|
|
194
200
|
}
|
|
195
201
|
export async function getAmplitudeCollatorsInfo(chain, substrateApi) {
|
|
196
202
|
const chainApi = await substrateApi.isReady;
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
203
|
+
|
|
204
|
+
// Noted: Krest do not have reward
|
|
205
|
+
if (_STAKING_CHAIN_GROUP.krest_network.includes(chain)) {
|
|
206
|
+
const _allCollators = await chainApi.api.query.parachainStaking.candidatePool.entries();
|
|
207
|
+
const maxDelegatorsPerCollator = chainApi.api.consts.parachainStaking.maxDelegatorsPerCollator.toString();
|
|
208
|
+
const allCollators = [];
|
|
209
|
+
for (const _collator of _allCollators) {
|
|
210
|
+
const collatorInfo = _collator[1].toPrimitive();
|
|
211
|
+
const bnTotalStake = new BN(collatorInfo.total);
|
|
212
|
+
const bnOwnStake = new BN(collatorInfo.stake);
|
|
213
|
+
const bnOtherStake = bnTotalStake.sub(bnOwnStake);
|
|
214
|
+
allCollators.push({
|
|
215
|
+
address: collatorInfo.id,
|
|
216
|
+
totalStake: bnTotalStake.toString(),
|
|
217
|
+
ownStake: bnOwnStake.toString(),
|
|
218
|
+
otherStake: bnOtherStake.toString(),
|
|
219
|
+
nominatorCount: collatorInfo.delegators.length,
|
|
220
|
+
commission: 0,
|
|
221
|
+
blocked: false,
|
|
222
|
+
isVerified: false,
|
|
223
|
+
minBond: '0',
|
|
224
|
+
chain,
|
|
225
|
+
isCrowded: collatorInfo.delegators.length >= parseInt(maxDelegatorsPerCollator)
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
return allCollators;
|
|
229
|
+
} else {
|
|
230
|
+
const [_allCollators, _inflationConfig] = await Promise.all([chainApi.api.query.parachainStaking.candidatePool.entries(), chainApi.api.query.parachainStaking.inflationConfig()]);
|
|
231
|
+
const maxDelegatorsPerCollator = chainApi.api.consts.parachainStaking.maxDelegatorsPerCollator.toString();
|
|
232
|
+
const inflationConfig = _inflationConfig.toHuman();
|
|
233
|
+
const rawDelegatorReturn = inflationConfig.delegator.rewardRate.annual;
|
|
234
|
+
const delegatorReturn = parseFloat(rawDelegatorReturn.split('%')[0]);
|
|
235
|
+
const allCollators = [];
|
|
236
|
+
for (const _collator of _allCollators) {
|
|
237
|
+
const collatorInfo = _collator[1].toPrimitive();
|
|
238
|
+
const bnTotalStake = new BN(collatorInfo.total);
|
|
239
|
+
const bnOwnStake = new BN(collatorInfo.stake);
|
|
240
|
+
const bnOtherStake = bnTotalStake.sub(bnOwnStake);
|
|
241
|
+
allCollators.push({
|
|
242
|
+
address: collatorInfo.id,
|
|
243
|
+
totalStake: bnTotalStake.toString(),
|
|
244
|
+
ownStake: bnOwnStake.toString(),
|
|
245
|
+
otherStake: bnOtherStake.toString(),
|
|
246
|
+
nominatorCount: collatorInfo.delegators.length,
|
|
247
|
+
commission: 0,
|
|
248
|
+
expectedReturn: delegatorReturn,
|
|
249
|
+
blocked: false,
|
|
250
|
+
isVerified: false,
|
|
251
|
+
minBond: '0',
|
|
252
|
+
chain,
|
|
253
|
+
isCrowded: collatorInfo.delegators.length >= parseInt(maxDelegatorsPerCollator)
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
return allCollators;
|
|
222
257
|
}
|
|
223
|
-
return allCollators;
|
|
224
258
|
}
|
|
225
259
|
export async function getAmplitudeBondingExtrinsic(substrateApi, amount, selectedValidatorInfo, nominatorMetadata) {
|
|
226
260
|
const chainApi = await substrateApi.isReady;
|
|
@@ -39,6 +39,10 @@ export interface ParachainStakingStakeOption {
|
|
|
39
39
|
owner: string;
|
|
40
40
|
amount: number;
|
|
41
41
|
}
|
|
42
|
+
export interface KrestDelegateState {
|
|
43
|
+
delegations: ParachainStakingStakeOption[];
|
|
44
|
+
total: string;
|
|
45
|
+
}
|
|
42
46
|
export interface ParachainStakingCandidateMetadata {
|
|
43
47
|
bond: string;
|
|
44
48
|
delegationCount: number;
|
|
@@ -12,7 +12,15 @@ import { BN, BN_ZERO } from '@polkadot/util';
|
|
|
12
12
|
import { isEthereumAddress } from '@polkadot/util-crypto';
|
|
13
13
|
function getSingleStakingAmplitude(substrateApi, address, chainInfoMap, chain, stakingCallback, nominatorStateCallback) {
|
|
14
14
|
return substrateApi.api.queryMulti([[substrateApi.api.query.parachainStaking.delegatorState, address], [substrateApi.api.query.parachainStaking.unstaking, address]], async ([_delegatorState, _unstaking]) => {
|
|
15
|
-
|
|
15
|
+
let delegatorState = [];
|
|
16
|
+
if (_STAKING_CHAIN_GROUP.krest_network.includes(chain)) {
|
|
17
|
+
const krestDelegatorState = _delegatorState.toPrimitive();
|
|
18
|
+
const delegates = krestDelegatorState === null || krestDelegatorState === void 0 ? void 0 : krestDelegatorState.delegations;
|
|
19
|
+
delegatorState = delegatorState.concat(delegates);
|
|
20
|
+
} else {
|
|
21
|
+
const delegate = _delegatorState.toPrimitive();
|
|
22
|
+
delegatorState.push(delegate);
|
|
23
|
+
}
|
|
16
24
|
const unstakingInfo = _unstaking.toPrimitive();
|
|
17
25
|
const {
|
|
18
26
|
symbol
|
|
@@ -41,8 +49,13 @@ function getSingleStakingAmplitude(substrateApi, address, chainInfoMap, chain, s
|
|
|
41
49
|
unstakings: []
|
|
42
50
|
});
|
|
43
51
|
} else {
|
|
44
|
-
|
|
52
|
+
let activeBalance = BN_ZERO;
|
|
45
53
|
let unstakingBalance = BN_ZERO;
|
|
54
|
+
for (const delegate of delegatorState) {
|
|
55
|
+
var _delegate$amount;
|
|
56
|
+
const amount = new BN((_delegate$amount = delegate.amount) === null || _delegate$amount === void 0 ? void 0 : _delegate$amount.toString());
|
|
57
|
+
activeBalance = activeBalance.add(amount);
|
|
58
|
+
}
|
|
46
59
|
if (unstakingInfo) {
|
|
47
60
|
Object.values(unstakingInfo).forEach(unstakingAmount => {
|
|
48
61
|
const bnUnstakingAmount = new BN(unstakingAmount.toString());
|
|
@@ -77,7 +90,15 @@ function getMultiStakingAmplitude(substrateApi, useAddresses, chainInfoMap, chai
|
|
|
77
90
|
const _unstakingStates = await substrateApi.api.query.parachainStaking.unstaking.multi(useAddresses);
|
|
78
91
|
await Promise.all(ledgers.map(async (_delegatorState, i) => {
|
|
79
92
|
const owner = reformatAddress(useAddresses[i], 42);
|
|
80
|
-
|
|
93
|
+
let delegatorState = [];
|
|
94
|
+
if (_STAKING_CHAIN_GROUP.krest_network.includes(chain)) {
|
|
95
|
+
const krestDelegatorState = _delegatorState.toPrimitive();
|
|
96
|
+
const delegates = krestDelegatorState === null || krestDelegatorState === void 0 ? void 0 : krestDelegatorState.delegations;
|
|
97
|
+
delegatorState = delegatorState.concat(delegates);
|
|
98
|
+
} else {
|
|
99
|
+
const delegate = _delegatorState.toPrimitive();
|
|
100
|
+
delegatorState.push(delegate);
|
|
101
|
+
}
|
|
81
102
|
const unstakingInfo = _unstakingStates[i].toPrimitive();
|
|
82
103
|
if (!delegatorState && !unstakingInfo) {
|
|
83
104
|
stakingCallback(chain, {
|
|
@@ -102,8 +123,13 @@ function getMultiStakingAmplitude(substrateApi, useAddresses, chainInfoMap, chai
|
|
|
102
123
|
unstakings: []
|
|
103
124
|
});
|
|
104
125
|
} else {
|
|
105
|
-
|
|
126
|
+
let activeBalance = BN_ZERO;
|
|
106
127
|
let unstakingBalance = BN_ZERO;
|
|
128
|
+
for (const delegate of delegatorState) {
|
|
129
|
+
var _delegate$amount2;
|
|
130
|
+
const amount = new BN((_delegate$amount2 = delegate.amount) === null || _delegate$amount2 === void 0 ? void 0 : _delegate$amount2.toString());
|
|
131
|
+
activeBalance = activeBalance.add(amount);
|
|
132
|
+
}
|
|
107
133
|
if (unstakingInfo) {
|
|
108
134
|
Object.values(unstakingInfo).forEach(unstakingAmount => {
|
|
109
135
|
const bnUnstakingAmount = new BN(unstakingAmount.toString());
|
|
@@ -149,7 +175,7 @@ export async function getAmplitudeUnclaimedStakingReward(substrateApiMap, addres
|
|
|
149
175
|
});
|
|
150
176
|
const unclaimedRewardList = [];
|
|
151
177
|
await Promise.all(chains.map(async chain => {
|
|
152
|
-
if (_STAKING_CHAIN_GROUP.amplitude.includes(chain) && !_STAKING_CHAIN_GROUP.kilt.includes(chain)) {
|
|
178
|
+
if (_STAKING_CHAIN_GROUP.amplitude.includes(chain) && !_STAKING_CHAIN_GROUP.kilt.includes(chain) && !_STAKING_CHAIN_GROUP.krest_network.includes(chain)) {
|
|
153
179
|
const networkInfo = networks[chain];
|
|
154
180
|
const apiProps = await substrateApiMap[chain].isReady;
|
|
155
181
|
await Promise.all(useAddresses.map(async address => {
|
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', 'astar', 'shiden', 'centrifuge'].includes(originChainInfo.slug) ? 'V3' : undefined;
|
|
22
|
+
const destVersion = ['moonbeam', 'moonriver', 'bifrost_dot', 'interlay', 'hydradx_main', 'acala', 'parallel', 'astar', 'shiden', 'centrifuge', 'manta_network'].includes(originChainInfo.slug) ? 'V3' : undefined;
|
|
23
23
|
return api.tx.xTokens.transfer(getCurrencyId(tokenInfo), value, getDestMultilocation(destinationChainInfo, recipientAddress, destVersion), weightParam);
|
|
24
24
|
}
|
|
@@ -13,7 +13,7 @@ import { PHISHING_PAGE_REDIRECT } from '@subwallet/extension-base/defaults';
|
|
|
13
13
|
import { _CHAIN_VALIDATION_ERROR } from '@subwallet/extension-base/services/chain-service/handler/types';
|
|
14
14
|
import { _generateCustomProviderKey } from '@subwallet/extension-base/services/chain-service/utils';
|
|
15
15
|
import { DEFAULT_CHAIN_PATROL_ENABLE } from '@subwallet/extension-base/services/setting-service/constants';
|
|
16
|
-
import { canDerive, stripUrl } from '@subwallet/extension-base/utils';
|
|
16
|
+
import { canDerive, getEVMChainInfo, stripUrl } from '@subwallet/extension-base/utils';
|
|
17
17
|
import keyring from '@subwallet/ui-keyring';
|
|
18
18
|
import { t } from 'i18next';
|
|
19
19
|
import Web3 from 'web3';
|
|
@@ -382,15 +382,32 @@ export default class KoniTabs {
|
|
|
382
382
|
}) {
|
|
383
383
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
384
384
|
const chainId = params[0].chainId;
|
|
385
|
+
const chainIdDec = parseInt(chainId, 16);
|
|
385
386
|
const evmState = await this.getEvmState(url);
|
|
386
387
|
if (evmState.chainId === chainId) {
|
|
387
388
|
return null;
|
|
388
389
|
}
|
|
389
|
-
const [networkKey] = this.#koniState.findNetworkKeyByChainId(
|
|
390
|
+
const [networkKey] = this.#koniState.findNetworkKeyByChainId(chainIdDec);
|
|
390
391
|
if (networkKey) {
|
|
391
392
|
await this.#koniState.switchEvmNetworkByUrl(stripUrl(url), networkKey);
|
|
392
393
|
} else {
|
|
393
|
-
|
|
394
|
+
const onlineData = await getEVMChainInfo(chainIdDec);
|
|
395
|
+
if (onlineData) {
|
|
396
|
+
const chainData = {
|
|
397
|
+
chainId: chainId,
|
|
398
|
+
rpcUrls: onlineData.rpc.filter(url => url.startsWith('https://')),
|
|
399
|
+
chainName: onlineData.name,
|
|
400
|
+
blockExplorerUrls: onlineData.explorers.map(explorer => explorer.url),
|
|
401
|
+
nativeCurrency: onlineData.nativeCurrency,
|
|
402
|
+
requestId: id
|
|
403
|
+
};
|
|
404
|
+
await this.addEvmChain(id, url, {
|
|
405
|
+
method: 'wallet_addEthereumChain',
|
|
406
|
+
params: [chainData]
|
|
407
|
+
});
|
|
408
|
+
} else {
|
|
409
|
+
throw new EvmProviderError(EvmProviderErrorType.INVALID_PARAMS, 'This network is currently not supported');
|
|
410
|
+
}
|
|
394
411
|
}
|
|
395
412
|
return null;
|
|
396
413
|
}
|
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.33-0",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -1313,6 +1313,11 @@
|
|
|
1313
1313
|
"require": "./cjs/utils/eth/parseTransaction/base.js",
|
|
1314
1314
|
"default": "./utils/eth/parseTransaction/base.js"
|
|
1315
1315
|
},
|
|
1316
|
+
"./utils/fetchEvmChainInfo": {
|
|
1317
|
+
"types": "./utils/fetchEvmChainInfo.d.ts",
|
|
1318
|
+
"require": "./cjs/utils/fetchEvmChainInfo.js",
|
|
1319
|
+
"default": "./utils/fetchEvmChainInfo.js"
|
|
1320
|
+
},
|
|
1316
1321
|
"./utils/fetchStaticData": {
|
|
1317
1322
|
"types": "./utils/fetchStaticData.d.ts",
|
|
1318
1323
|
"require": "./cjs/utils/fetchStaticData.js",
|
|
@@ -1393,11 +1398,11 @@
|
|
|
1393
1398
|
"@reduxjs/toolkit": "^1.9.1",
|
|
1394
1399
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
1395
1400
|
"@substrate/connect": "^0.7.26",
|
|
1396
|
-
"@subwallet/chain-list": "0.2.
|
|
1397
|
-
"@subwallet/extension-base": "^1.1.
|
|
1398
|
-
"@subwallet/extension-chains": "^1.1.
|
|
1399
|
-
"@subwallet/extension-dapp": "^1.1.
|
|
1400
|
-
"@subwallet/extension-inject": "^1.1.
|
|
1401
|
+
"@subwallet/chain-list": "0.2.39-beta.5",
|
|
1402
|
+
"@subwallet/extension-base": "^1.1.33-0",
|
|
1403
|
+
"@subwallet/extension-chains": "^1.1.33-0",
|
|
1404
|
+
"@subwallet/extension-dapp": "^1.1.33-0",
|
|
1405
|
+
"@subwallet/extension-inject": "^1.1.33-0",
|
|
1401
1406
|
"@subwallet/keyring": "^0.1.1",
|
|
1402
1407
|
"@subwallet/ui-keyring": "^0.1.1",
|
|
1403
1408
|
"@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.33-0'
|
|
11
11
|
};
|
|
@@ -44,6 +44,7 @@ export default class CampaignService {
|
|
|
44
44
|
endTime,
|
|
45
45
|
startTime,
|
|
46
46
|
isDone: false,
|
|
47
|
+
isArchive: false,
|
|
47
48
|
campaignId,
|
|
48
49
|
type: CampaignDataType.BANNER,
|
|
49
50
|
buttons,
|
|
@@ -64,6 +65,7 @@ export default class CampaignService {
|
|
|
64
65
|
endTime,
|
|
65
66
|
startTime,
|
|
66
67
|
isDone: false,
|
|
68
|
+
isArchive: false,
|
|
67
69
|
campaignId,
|
|
68
70
|
type: CampaignDataType.NOTIFICATION,
|
|
69
71
|
buttons,
|
|
@@ -76,6 +78,23 @@ export default class CampaignService {
|
|
|
76
78
|
const exists = await this.#state.dbService.getCampaign(campaign.slug);
|
|
77
79
|
if (!exists) {
|
|
78
80
|
await this.#state.dbService.upsertCampaign(campaign);
|
|
81
|
+
} else {
|
|
82
|
+
const data = {
|
|
83
|
+
...campaign,
|
|
84
|
+
isDone: exists.isDone
|
|
85
|
+
};
|
|
86
|
+
await this.#state.dbService.upsertCampaign(data);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const allCampaign = await this.#state.dbService.getAllCampaign();
|
|
90
|
+
for (const stored of allCampaign) {
|
|
91
|
+
const exists = campaigns.find(campaign => campaign.slug === stored.slug);
|
|
92
|
+
if (!exists) {
|
|
93
|
+
const data = {
|
|
94
|
+
...stored,
|
|
95
|
+
isArchive: true
|
|
96
|
+
};
|
|
97
|
+
await this.#state.dbService.upsertCampaign(data);
|
|
79
98
|
}
|
|
80
99
|
}
|
|
81
100
|
this.#state.eventService.emit('campaign.ready', true);
|
|
@@ -29,7 +29,7 @@ export const _BALANCE_CHAIN_GROUP = {
|
|
|
29
29
|
genshiro: ['genshiro_testnet', 'genshiro'],
|
|
30
30
|
equilibrium_parachain: ['equilibrium_parachain'],
|
|
31
31
|
bifrost: ['bifrost', 'acala', 'karura', 'acala_testnet', 'pioneer', 'bitcountry', 'bifrost_dot', 'hydradx_main', 'pendulum', 'amplitude'],
|
|
32
|
-
statemine: ['statemine', 'astar', 'shiden', 'statemint', 'moonbeam', 'moonbase', 'moonriver', 'crabParachain', 'darwinia2', 'parallel', 'calamari'],
|
|
32
|
+
statemine: ['statemine', 'astar', 'shiden', 'statemint', 'moonbeam', 'moonbase', 'moonriver', 'crabParachain', 'darwinia2', 'parallel', 'calamari', 'manta_network'],
|
|
33
33
|
kusama: ['kusama', 'kintsugi', 'kintsugi_test', 'interlay', 'acala', 'statemint', 'karura', 'bifrost'],
|
|
34
34
|
// perhaps there are some runtime updates
|
|
35
35
|
centrifuge: ['centrifuge']
|
|
@@ -56,8 +56,9 @@ export const _STAKING_CHAIN_GROUP = {
|
|
|
56
56
|
relay: ['polkadot', 'kusama', 'aleph', 'polkadex', 'ternoa', 'ternoa_alphanet', 'alephTest', 'polkadexTest', 'westend', 'kate', 'edgeware', 'creditcoin', 'vara_network', 'goldberg_testnet'],
|
|
57
57
|
para: ['moonbeam', 'moonriver', 'moonbase', 'turing', 'turingStaging', 'bifrost', 'bifrost_testnet', 'calamari_test', 'calamari', 'manta_network'],
|
|
58
58
|
astar: ['astar', 'shiden', 'shibuya'],
|
|
59
|
-
amplitude: ['amplitude', 'amplitude_test', 'kilt', 'kilt_peregrine', 'pendulum'],
|
|
59
|
+
amplitude: ['amplitude', 'amplitude_test', 'kilt', 'kilt_peregrine', 'pendulum', 'krest_network'],
|
|
60
60
|
// amplitude and kilt only share some common logic
|
|
61
|
+
krest_network: ['krest_network'],
|
|
61
62
|
kilt: ['kilt', 'kilt_peregrine'],
|
|
62
63
|
nominationPool: ['polkadot', 'kusama', 'westend', 'alephTest', 'aleph', 'kate', 'vara_network', 'goldberg_testnet'],
|
|
63
64
|
bifrost: ['bifrost', 'bifrost_testnet'],
|
|
@@ -97,7 +98,8 @@ export const _STAKING_ERA_LENGTH_MAP = {
|
|
|
97
98
|
creditcoin: 24,
|
|
98
99
|
vara_network: 12,
|
|
99
100
|
goldberg_testnet: 24,
|
|
100
|
-
manta_network: 6
|
|
101
|
+
manta_network: 6,
|
|
102
|
+
krest_network: 4
|
|
101
103
|
};
|
|
102
104
|
export const _EXPECTED_BLOCK_TIME = {
|
|
103
105
|
// in seconds
|
|
@@ -18,6 +18,7 @@ export interface EventRegistry {
|
|
|
18
18
|
'asset.updateState': [string];
|
|
19
19
|
'transaction.done': [SWTransaction];
|
|
20
20
|
'transaction.failed': [SWTransaction | undefined];
|
|
21
|
+
'transaction.timeout': [SWTransaction | undefined];
|
|
21
22
|
'transaction.submitStaking': [string];
|
|
22
23
|
'transaction.transferNft': [SWTransaction | undefined];
|
|
23
24
|
'mantaPay.initSync': [string | undefined];
|
|
@@ -166,14 +166,18 @@ export class HistoryService {
|
|
|
166
166
|
|
|
167
167
|
// Insert history with check override origin 'app'
|
|
168
168
|
async addHistoryItems(historyItems) {
|
|
169
|
-
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
169
|
+
const updateRecords = [];
|
|
170
|
+
const appItems = this.historySubject.value.filter(i => i.origin === 'app');
|
|
171
|
+
historyItems.forEach(item => {
|
|
172
|
+
const needUpdateItem = appItems.find(item_ => item_.extrinsicHash === item.extrinsicHash && item.chain === item_.chain && item.address === item_.address);
|
|
173
|
+
if (needUpdateItem) {
|
|
174
|
+
updateRecords.push({
|
|
175
|
+
...needUpdateItem,
|
|
176
|
+
status: item.status
|
|
177
|
+
});
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
updateRecords.push(item);
|
|
177
181
|
});
|
|
178
182
|
await this.dbService.upsertHistory(updateRecords);
|
|
179
183
|
this.historySubject.next(await this.dbService.getHistories());
|
|
@@ -83,6 +83,7 @@ export default class DatabaseService {
|
|
|
83
83
|
subscribeMantaPayConfig(chain: string, callback: (data: MantaPayConfig[]) => void): void;
|
|
84
84
|
getMantaPayConfig(chain: string): Promise<any[]>;
|
|
85
85
|
getMantaPayFirstConfig(chain: string): Promise<any>;
|
|
86
|
+
getAllCampaign(): Promise<import("@subwallet/extension-base/background/KoniTypes").CampaignData[]>;
|
|
86
87
|
subscribeProcessingCampaign(): import("dexie").Observable<import("@subwallet/extension-base/background/KoniTypes").CampaignData[]>;
|
|
87
88
|
getProcessingCampaign(): Promise<import("@subwallet/extension-base/background/KoniTypes").CampaignData[]>;
|
|
88
89
|
getCampaign(slug: string): Promise<import("@subwallet/extension-base/background/KoniTypes").CampaignData | undefined>;
|
|
@@ -6,7 +6,13 @@ import { liveQuery } from 'dexie';
|
|
|
6
6
|
const filterProcessing = campaign => {
|
|
7
7
|
const now = new Date().getTime();
|
|
8
8
|
const isExpired = now <= campaign.startTime || now >= campaign.endTime;
|
|
9
|
-
return !(campaign.isDone || isExpired);
|
|
9
|
+
return !(campaign.isArchive || campaign.isDone || isExpired);
|
|
10
|
+
};
|
|
11
|
+
const getId = campaign => {
|
|
12
|
+
return campaign.campaignId;
|
|
13
|
+
};
|
|
14
|
+
const sortById = (a, b) => {
|
|
15
|
+
return getId(a) - getId(b);
|
|
10
16
|
};
|
|
11
17
|
export default class CampaignStore extends BaseStore {
|
|
12
18
|
async getAll() {
|
|
@@ -16,10 +22,10 @@ export default class CampaignStore extends BaseStore {
|
|
|
16
22
|
return this.table.get(slug);
|
|
17
23
|
}
|
|
18
24
|
async getProcessingCampaign() {
|
|
19
|
-
return (await this.table.toArray()).filter(filterProcessing);
|
|
25
|
+
return (await this.table.toArray()).filter(filterProcessing).sort(sortById);
|
|
20
26
|
}
|
|
21
27
|
subscribeProcessingCampaign() {
|
|
22
|
-
return liveQuery(() => this.table.filter(filterProcessing).toArray());
|
|
28
|
+
return liveQuery(async () => (await this.table.filter(filterProcessing).toArray()).sort(sortById));
|
|
23
29
|
}
|
|
24
30
|
upsertCampaign(campaign) {
|
|
25
31
|
return this.table.put(campaign);
|
|
@@ -43,6 +43,7 @@ export default class TransactionService {
|
|
|
43
43
|
private handlePostProcessing;
|
|
44
44
|
private onSuccess;
|
|
45
45
|
private onFailed;
|
|
46
|
+
private onTimeOut;
|
|
46
47
|
generateHashPayload(chain: string, transaction: TransactionConfig): HexString;
|
|
47
48
|
private signAndSendEvmTransaction;
|
|
48
49
|
private signAndSendSubstrateTransaction;
|