@subwallet/extension-base 1.1.26-0 → 1.1.27-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 +1 -1
- package/cjs/constants/staking.js +2 -1
- package/cjs/koni/api/staking/bonding/astar.js +15 -24
- package/cjs/koni/background/handlers/Extension.js +4 -0
- package/cjs/koni/background/handlers/State.js +11 -3
- package/cjs/koni/background/handlers/index.js +1 -1
- package/cjs/koni/background/subscription.js +32 -9
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/BalanceMapImpl.js +0 -3
- package/cjs/services/transaction-service/index.js +4 -2
- package/cjs/services/transaction-service/utils.js +3 -0
- package/constants/staking.js +2 -1
- package/koni/api/staking/bonding/astar.js +15 -24
- package/koni/background/handlers/Extension.js +4 -0
- package/koni/background/handlers/State.d.ts +3 -1
- package/koni/background/handlers/State.js +11 -3
- package/koni/background/handlers/index.js +1 -1
- package/koni/background/subscription.d.ts +4 -1
- package/koni/background/subscription.js +32 -9
- package/package.json +6 -6
- package/packageInfo.js +1 -1
- package/services/balance-service/BalanceMapImpl.js +0 -3
- package/services/transaction-service/index.js +4 -2
- package/services/transaction-service/utils.js +3 -0
|
@@ -1444,7 +1444,7 @@ export interface Notification {
|
|
|
1444
1444
|
}
|
|
1445
1445
|
export declare type NotificationParams = Omit<Notification, 'id'>;
|
|
1446
1446
|
export interface CronReloadRequest {
|
|
1447
|
-
data: 'nft' | 'staking';
|
|
1447
|
+
data: 'nft' | 'staking' | 'balance' | 'crowdloan';
|
|
1448
1448
|
}
|
|
1449
1449
|
export interface AllLogoMap {
|
|
1450
1450
|
chainLogoMap: Record<string, string>;
|
package/cjs/constants/staking.js
CHANGED
|
@@ -10,7 +10,8 @@ exports.PREDEFINED_STAKING_POOL = exports.MAX_NOMINATIONS = void 0;
|
|
|
10
10
|
const PREDEFINED_STAKING_POOL = {
|
|
11
11
|
kusama: 80,
|
|
12
12
|
polkadot: 39,
|
|
13
|
-
vara_network: 29
|
|
13
|
+
vara_network: 29,
|
|
14
|
+
aleph: 55
|
|
14
15
|
};
|
|
15
16
|
exports.PREDEFINED_STAKING_POOL = PREDEFINED_STAKING_POOL;
|
|
16
17
|
const MAX_NOMINATIONS = '16';
|
|
@@ -24,6 +24,18 @@ var _utilCrypto = require("@polkadot/util-crypto");
|
|
|
24
24
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
25
25
|
// SPDX-License-Identifier: Apache-2.0
|
|
26
26
|
|
|
27
|
+
const convertAddress = address => {
|
|
28
|
+
return (0, _utilCrypto.isEthereumAddress)(address) ? address.toLowerCase() : address;
|
|
29
|
+
};
|
|
30
|
+
const fetchDApps = async network => {
|
|
31
|
+
return new Promise(function (resolve) {
|
|
32
|
+
(0, _crossFetch.default)(`https://api.astar.network/api/v1/${network}/dapps-staking/dappssimple`, {
|
|
33
|
+
method: 'GET'
|
|
34
|
+
}).then(resp => {
|
|
35
|
+
resolve(resp.json());
|
|
36
|
+
}).catch(console.error);
|
|
37
|
+
});
|
|
38
|
+
};
|
|
27
39
|
function subscribeAstarStakingMetadata(chain, substrateApi, callback) {
|
|
28
40
|
return substrateApi.api.query.dappsStaking.currentEra(_currentEra => {
|
|
29
41
|
const era = _currentEra.toString();
|
|
@@ -79,19 +91,10 @@ async function getAstarStakingMetadata(chain, substrateApi) {
|
|
|
79
91
|
unstakingPeriod
|
|
80
92
|
};
|
|
81
93
|
}
|
|
82
|
-
const convertAddress = address => {
|
|
83
|
-
return (0, _utilCrypto.isEthereumAddress)(address) ? address.toLowerCase() : address;
|
|
84
|
-
};
|
|
85
94
|
async function subscribeAstarNominatorMetadata(chainInfo, address, substrateApi, ledger) {
|
|
86
95
|
const nominationList = [];
|
|
87
96
|
const unstakingList = [];
|
|
88
|
-
const allDappsReq =
|
|
89
|
-
(0, _crossFetch.default)(`https://api.astar.network/api/v1/${chainInfo.slug}/dapps-staking/dapps`, {
|
|
90
|
-
method: 'GET'
|
|
91
|
-
}).then(resp => {
|
|
92
|
-
resolve(resp.json());
|
|
93
|
-
}).catch(console.error);
|
|
94
|
-
});
|
|
97
|
+
const allDappsReq = fetchDApps(chainInfo.slug);
|
|
95
98
|
const [_allDapps, _era, _stakerInfo] = await Promise.all([allDappsReq, substrateApi.api.query.dappsStaking.currentEra(), substrateApi.api.query.dappsStaking.generalStakerInfo.entries(address)]);
|
|
96
99
|
const currentEra = _era.toString();
|
|
97
100
|
const minDelegatorStake = substrateApi.api.consts.dappsStaking.minimumStakingAmount.toString();
|
|
@@ -176,13 +179,7 @@ async function getAstarNominatorMetadata(chainInfo, address, substrateApi) {
|
|
|
176
179
|
const chainApi = await substrateApi.isReady;
|
|
177
180
|
const nominationList = [];
|
|
178
181
|
const unstakingList = [];
|
|
179
|
-
const allDappsReq =
|
|
180
|
-
(0, _crossFetch.default)(`https://api.astar.network/api/v1/${chain}/dapps-staking/dapps`, {
|
|
181
|
-
method: 'GET'
|
|
182
|
-
}).then(resp => {
|
|
183
|
-
resolve(resp.json());
|
|
184
|
-
}).catch(console.error);
|
|
185
|
-
});
|
|
182
|
+
const allDappsReq = fetchDApps(chain);
|
|
186
183
|
const [_ledger, _era, _stakerInfo] = await Promise.all([chainApi.api.query.dappsStaking.ledger(address), chainApi.api.query.dappsStaking.currentEra(), chainApi.api.query.dappsStaking.generalStakerInfo.entries(address)]);
|
|
187
184
|
const ledger = _ledger.toPrimitive();
|
|
188
185
|
const currentEra = _era.toString();
|
|
@@ -261,13 +258,7 @@ async function getAstarDappsInfo(networkKey, substrateApi) {
|
|
|
261
258
|
const rawMaxStakerPerContract = chainApi.api.consts.dappsStaking.maxNumberOfStakersPerContract.toHuman();
|
|
262
259
|
const allDappsInfo = [];
|
|
263
260
|
const maxStakerPerContract = (0, _utils2.parseRawNumber)(rawMaxStakerPerContract);
|
|
264
|
-
const allDappsReq =
|
|
265
|
-
(0, _crossFetch.default)(`https://api.astar.network/api/v1/${networkKey}/dapps-staking/dapps`, {
|
|
266
|
-
method: 'GET'
|
|
267
|
-
}).then(resp => {
|
|
268
|
-
resolve(resp.json());
|
|
269
|
-
}).catch(console.error);
|
|
270
|
-
});
|
|
261
|
+
const allDappsReq = fetchDApps(networkKey);
|
|
271
262
|
const [_era, _allDapps] = await Promise.all([chainApi.api.query.dappsStaking.currentEra(), allDappsReq]);
|
|
272
263
|
const era = (0, _utils2.parseRawNumber)(_era.toHuman());
|
|
273
264
|
const allDapps = _allDapps;
|
|
@@ -3296,6 +3296,10 @@ class KoniExtension {
|
|
|
3296
3296
|
return await this.#koniState.reloadNft();
|
|
3297
3297
|
} else if (data === 'staking') {
|
|
3298
3298
|
return await this.#koniState.reloadStaking();
|
|
3299
|
+
} else if (data === 'balance') {
|
|
3300
|
+
return await this.#koniState.reloadBalance();
|
|
3301
|
+
} else if (data === 'crowdloan') {
|
|
3302
|
+
return await this.#koniState.reloadCrowdloan();
|
|
3299
3303
|
}
|
|
3300
3304
|
return Promise.resolve(false);
|
|
3301
3305
|
}
|
|
@@ -704,12 +704,12 @@ class KoniState {
|
|
|
704
704
|
return await this.dbService.stores.balance.getBalanceMapByAddresses(address);
|
|
705
705
|
}
|
|
706
706
|
isFirstLoad = true;
|
|
707
|
-
async
|
|
708
|
-
if (this.isFirstLoad) {
|
|
707
|
+
async handleResetBalance(newAddress, forceRefresh) {
|
|
708
|
+
if (this.isFirstLoad || forceRefresh) {
|
|
709
709
|
const backupBalanceData = await this.dbService.getStoredBalance();
|
|
710
710
|
this.balanceMap.updateBalanceItems(backupBalanceData, (0, _utils2.isAccountAll)(newAddress));
|
|
711
711
|
}
|
|
712
|
-
await Promise.all([this.
|
|
712
|
+
await Promise.all([this.removeInactiveChainBalances()]);
|
|
713
713
|
}
|
|
714
714
|
async resetCrowdloanMap(newAddress) {
|
|
715
715
|
const defaultData = generateDefaultCrowdloanMap();
|
|
@@ -1564,6 +1564,14 @@ class KoniState {
|
|
|
1564
1564
|
await this.subscription.reloadStaking();
|
|
1565
1565
|
return true;
|
|
1566
1566
|
}
|
|
1567
|
+
async reloadBalance() {
|
|
1568
|
+
await this.subscription.reloadBalance();
|
|
1569
|
+
return true;
|
|
1570
|
+
}
|
|
1571
|
+
async reloadCrowdloan() {
|
|
1572
|
+
await this.subscription.reloadCrowdloan();
|
|
1573
|
+
return true;
|
|
1574
|
+
}
|
|
1567
1575
|
async approvePassPhishingPage(_url) {
|
|
1568
1576
|
return new Promise(resolve => {
|
|
1569
1577
|
this.settingService.getPassPhishingList(value => {
|
|
@@ -58,7 +58,7 @@ function handlers(_ref, port) {
|
|
|
58
58
|
const isMobile = port.name === _defaults.PORT_MOBILE;
|
|
59
59
|
const isExtension = port.name === extensionPortName;
|
|
60
60
|
const sender = port.sender;
|
|
61
|
-
const from = isExtension ? 'extension' : sender.
|
|
61
|
+
const from = isExtension ? 'extension' : sender.url || sender.tab && sender.tab.url || '<unknown>';
|
|
62
62
|
const source = `${from}: ${id}: ${message}`;
|
|
63
63
|
|
|
64
64
|
// console.log(` [in] ${source}`); // :: ${JSON.stringify(request)}`);
|
|
@@ -59,7 +59,8 @@ class KoniSubscription {
|
|
|
59
59
|
await Promise.all([this.state.eventService.waitCryptoReady, this.state.eventService.waitKeyringReady, this.state.eventService.waitAssetReady]);
|
|
60
60
|
const currentAddress = (_this$state$keyringSe = this.state.keyringService.currentAccount) === null || _this$state$keyringSe === void 0 ? void 0 : _this$state$keyringSe.address;
|
|
61
61
|
if (currentAddress) {
|
|
62
|
-
this.
|
|
62
|
+
this.subscribeBalances(currentAddress, this.state.getChainInfoMap(), this.state.getChainStateMap(), this.state.getSubstrateApiMap(), this.state.getEvmApiMap());
|
|
63
|
+
this.subscribeCrowdloans(currentAddress, this.state.getSubstrateApiMap());
|
|
63
64
|
this.subscribeStakingOnChain(currentAddress, this.state.getSubstrateApiMap());
|
|
64
65
|
}
|
|
65
66
|
this.eventHandler = (events, eventTypes) => {
|
|
@@ -73,7 +74,8 @@ class KoniSubscription {
|
|
|
73
74
|
if (!address) {
|
|
74
75
|
return;
|
|
75
76
|
}
|
|
76
|
-
this.
|
|
77
|
+
this.subscribeBalances(address, serviceInfo.chainInfoMap, serviceInfo.chainStateMap, serviceInfo.chainApiMap.substrate, serviceInfo.chainApiMap.evm);
|
|
78
|
+
this.subscribeCrowdloans(address, serviceInfo.chainApiMap.substrate);
|
|
77
79
|
this.subscribeStakingOnChain(address, serviceInfo.chainApiMap.substrate);
|
|
78
80
|
};
|
|
79
81
|
this.state.eventService.onLazy(this.eventHandler.bind(this));
|
|
@@ -86,16 +88,24 @@ class KoniSubscription {
|
|
|
86
88
|
this.stopAllSubscription();
|
|
87
89
|
return Promise.resolve();
|
|
88
90
|
}
|
|
89
|
-
|
|
90
|
-
this.state.
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
91
|
+
subscribeBalances(address, chainInfoMap, chainStateMap, substrateApiMap, web3ApiMap, onlyRunOnFirstTime) {
|
|
92
|
+
const addresses = this.state.getDecodedAddresses(address);
|
|
93
|
+
if (!addresses.length) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
this.state.handleResetBalance(address).then(() => {
|
|
95
97
|
this.updateSubscription('balance', this.initBalanceSubscription(addresses, chainInfoMap, chainStateMap, substrateApiMap, web3ApiMap, onlyRunOnFirstTime));
|
|
96
|
-
this.updateSubscription('crowdloan', this.initCrowdloanSubscription(addresses, substrateApiMap, onlyRunOnFirstTime));
|
|
97
98
|
}).catch(err => this.logger.warn(err));
|
|
98
99
|
}
|
|
100
|
+
subscribeCrowdloans(address, substrateApiMap, onlyRunOnFirstTime) {
|
|
101
|
+
const addresses = this.state.getDecodedAddresses(address);
|
|
102
|
+
if (!addresses.length) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
this.state.resetCrowdloanMap(address).then(() => {
|
|
106
|
+
this.updateSubscription('crowdloan', this.initCrowdloanSubscription(addresses, substrateApiMap, onlyRunOnFirstTime));
|
|
107
|
+
}).catch(console.error);
|
|
108
|
+
}
|
|
99
109
|
subscribeStakingOnChain(address, substrateApiMap, onlyRunOnFirstTime) {
|
|
100
110
|
this.state.resetStaking(address);
|
|
101
111
|
const addresses = this.state.getDecodedAddresses(address);
|
|
@@ -255,5 +265,18 @@ class KoniSubscription {
|
|
|
255
265
|
this.subscribeStakingOnChain(currentAddress, this.state.getSubstrateApiMap());
|
|
256
266
|
await (0, _utils2.waitTimeout)(1800);
|
|
257
267
|
}
|
|
268
|
+
async reloadBalance() {
|
|
269
|
+
var _this$state$keyringSe3;
|
|
270
|
+
const currentAddress = (_this$state$keyringSe3 = this.state.keyringService.currentAccount) === null || _this$state$keyringSe3 === void 0 ? void 0 : _this$state$keyringSe3.address;
|
|
271
|
+
this.subscribeBalances(currentAddress, this.state.getChainInfoMap(), this.state.getChainStateMap(), this.state.getSubstrateApiMap(), this.state.getEvmApiMap());
|
|
272
|
+
await (0, _utils2.waitTimeout)(1800);
|
|
273
|
+
}
|
|
274
|
+
async reloadCrowdloan() {
|
|
275
|
+
var _this$state$keyringSe4;
|
|
276
|
+
const currentAddress = (_this$state$keyringSe4 = this.state.keyringService.currentAccount) === null || _this$state$keyringSe4 === void 0 ? void 0 : _this$state$keyringSe4.address;
|
|
277
|
+
await this.state.handleResetBalance(currentAddress, true);
|
|
278
|
+
this.subscribeCrowdloans(currentAddress, this.state.getSubstrateApiMap());
|
|
279
|
+
await (0, _utils2.waitTimeout)(1800);
|
|
280
|
+
}
|
|
258
281
|
}
|
|
259
282
|
exports.KoniSubscription = KoniSubscription;
|
package/cjs/packageInfo.js
CHANGED
|
@@ -18,6 +18,7 @@ var _eventParser = require("@subwallet/extension-base/services/transaction-servi
|
|
|
18
18
|
var _helpers = require("@subwallet/extension-base/services/transaction-service/helpers");
|
|
19
19
|
var _utils2 = require("@subwallet/extension-base/services/transaction-service/utils");
|
|
20
20
|
var _helpers2 = require("@subwallet/extension-base/services/wallet-connect-service/helpers");
|
|
21
|
+
var _utils3 = require("@subwallet/extension-base/utils");
|
|
21
22
|
var _eth = require("@subwallet/extension-base/utils/eth");
|
|
22
23
|
var _mergeTransactionAndSignature = require("@subwallet/extension-base/utils/eth/mergeTransactionAndSignature");
|
|
23
24
|
var _parseTransaction = require("@subwallet/extension-base/utils/eth/parseTransaction");
|
|
@@ -320,15 +321,16 @@ class TransactionService {
|
|
|
320
321
|
transactionToHistories(id, startBlock, nonce, eventLogs) {
|
|
321
322
|
const transaction = this.getTransaction(id);
|
|
322
323
|
const extrinsicType = transaction.extrinsicType;
|
|
324
|
+
const formattedTransactionAddress = (0, _utils3.reformatAddress)(transaction.address);
|
|
323
325
|
const historyItem = {
|
|
324
326
|
origin: 'app',
|
|
325
327
|
chain: transaction.chain,
|
|
326
328
|
direction: _KoniTypes.TransactionDirection.SEND,
|
|
327
329
|
type: transaction.extrinsicType,
|
|
328
|
-
from:
|
|
330
|
+
from: formattedTransactionAddress,
|
|
329
331
|
to: '',
|
|
330
332
|
chainType: transaction.chainType,
|
|
331
|
-
address:
|
|
333
|
+
address: formattedTransactionAddress,
|
|
332
334
|
status: transaction.status,
|
|
333
335
|
transactionId: transaction.id,
|
|
334
336
|
extrinsicHash: transaction.extrinsicHash,
|
|
@@ -24,6 +24,9 @@ function getBlockExplorerAccountRoute(explorerLink) {
|
|
|
24
24
|
if (explorerLink.includes('subscan.io')) {
|
|
25
25
|
return 'account';
|
|
26
26
|
}
|
|
27
|
+
if (explorerLink.includes('3dpscan.io')) {
|
|
28
|
+
return 'account';
|
|
29
|
+
}
|
|
27
30
|
return 'address';
|
|
28
31
|
}
|
|
29
32
|
function getBlockExplorerTxRoute(chainInfo) {
|
package/constants/staking.js
CHANGED
|
@@ -8,6 +8,18 @@ import { isUrl, parseRawNumber } from '@subwallet/extension-base/utils';
|
|
|
8
8
|
import fetch from 'cross-fetch';
|
|
9
9
|
import { BN, BN_ZERO } from '@polkadot/util';
|
|
10
10
|
import { isEthereumAddress } from '@polkadot/util-crypto';
|
|
11
|
+
const convertAddress = address => {
|
|
12
|
+
return isEthereumAddress(address) ? address.toLowerCase() : address;
|
|
13
|
+
};
|
|
14
|
+
const fetchDApps = async network => {
|
|
15
|
+
return new Promise(function (resolve) {
|
|
16
|
+
fetch(`https://api.astar.network/api/v1/${network}/dapps-staking/dappssimple`, {
|
|
17
|
+
method: 'GET'
|
|
18
|
+
}).then(resp => {
|
|
19
|
+
resolve(resp.json());
|
|
20
|
+
}).catch(console.error);
|
|
21
|
+
});
|
|
22
|
+
};
|
|
11
23
|
export function subscribeAstarStakingMetadata(chain, substrateApi, callback) {
|
|
12
24
|
return substrateApi.api.query.dappsStaking.currentEra(_currentEra => {
|
|
13
25
|
const era = _currentEra.toString();
|
|
@@ -63,19 +75,10 @@ export async function getAstarStakingMetadata(chain, substrateApi) {
|
|
|
63
75
|
unstakingPeriod
|
|
64
76
|
};
|
|
65
77
|
}
|
|
66
|
-
const convertAddress = address => {
|
|
67
|
-
return isEthereumAddress(address) ? address.toLowerCase() : address;
|
|
68
|
-
};
|
|
69
78
|
export async function subscribeAstarNominatorMetadata(chainInfo, address, substrateApi, ledger) {
|
|
70
79
|
const nominationList = [];
|
|
71
80
|
const unstakingList = [];
|
|
72
|
-
const allDappsReq =
|
|
73
|
-
fetch(`https://api.astar.network/api/v1/${chainInfo.slug}/dapps-staking/dapps`, {
|
|
74
|
-
method: 'GET'
|
|
75
|
-
}).then(resp => {
|
|
76
|
-
resolve(resp.json());
|
|
77
|
-
}).catch(console.error);
|
|
78
|
-
});
|
|
81
|
+
const allDappsReq = fetchDApps(chainInfo.slug);
|
|
79
82
|
const [_allDapps, _era, _stakerInfo] = await Promise.all([allDappsReq, substrateApi.api.query.dappsStaking.currentEra(), substrateApi.api.query.dappsStaking.generalStakerInfo.entries(address)]);
|
|
80
83
|
const currentEra = _era.toString();
|
|
81
84
|
const minDelegatorStake = substrateApi.api.consts.dappsStaking.minimumStakingAmount.toString();
|
|
@@ -160,13 +163,7 @@ export async function getAstarNominatorMetadata(chainInfo, address, substrateApi
|
|
|
160
163
|
const chainApi = await substrateApi.isReady;
|
|
161
164
|
const nominationList = [];
|
|
162
165
|
const unstakingList = [];
|
|
163
|
-
const allDappsReq =
|
|
164
|
-
fetch(`https://api.astar.network/api/v1/${chain}/dapps-staking/dapps`, {
|
|
165
|
-
method: 'GET'
|
|
166
|
-
}).then(resp => {
|
|
167
|
-
resolve(resp.json());
|
|
168
|
-
}).catch(console.error);
|
|
169
|
-
});
|
|
166
|
+
const allDappsReq = fetchDApps(chain);
|
|
170
167
|
const [_ledger, _era, _stakerInfo] = await Promise.all([chainApi.api.query.dappsStaking.ledger(address), chainApi.api.query.dappsStaking.currentEra(), chainApi.api.query.dappsStaking.generalStakerInfo.entries(address)]);
|
|
171
168
|
const ledger = _ledger.toPrimitive();
|
|
172
169
|
const currentEra = _era.toString();
|
|
@@ -245,13 +242,7 @@ export async function getAstarDappsInfo(networkKey, substrateApi) {
|
|
|
245
242
|
const rawMaxStakerPerContract = chainApi.api.consts.dappsStaking.maxNumberOfStakersPerContract.toHuman();
|
|
246
243
|
const allDappsInfo = [];
|
|
247
244
|
const maxStakerPerContract = parseRawNumber(rawMaxStakerPerContract);
|
|
248
|
-
const allDappsReq =
|
|
249
|
-
fetch(`https://api.astar.network/api/v1/${networkKey}/dapps-staking/dapps`, {
|
|
250
|
-
method: 'GET'
|
|
251
|
-
}).then(resp => {
|
|
252
|
-
resolve(resp.json());
|
|
253
|
-
}).catch(console.error);
|
|
254
|
-
});
|
|
245
|
+
const allDappsReq = fetchDApps(networkKey);
|
|
255
246
|
const [_era, _allDapps] = await Promise.all([chainApi.api.query.dappsStaking.currentEra(), allDappsReq]);
|
|
256
247
|
const era = parseRawNumber(_era.toHuman());
|
|
257
248
|
const allDapps = _allDapps;
|
|
@@ -3207,6 +3207,10 @@ export default class KoniExtension {
|
|
|
3207
3207
|
return await this.#koniState.reloadNft();
|
|
3208
3208
|
} else if (data === 'staking') {
|
|
3209
3209
|
return await this.#koniState.reloadStaking();
|
|
3210
|
+
} else if (data === 'balance') {
|
|
3211
|
+
return await this.#koniState.reloadBalance();
|
|
3212
|
+
} else if (data === 'crowdloan') {
|
|
3213
|
+
return await this.#koniState.reloadCrowdloan();
|
|
3210
3214
|
}
|
|
3211
3215
|
return Promise.resolve(false);
|
|
3212
3216
|
}
|
|
@@ -153,7 +153,7 @@ export default class KoniState {
|
|
|
153
153
|
getBalance(reset?: boolean): Promise<BalanceJson>;
|
|
154
154
|
getStoredBalance(address: string): Promise<BalanceItem[]>;
|
|
155
155
|
private isFirstLoad;
|
|
156
|
-
|
|
156
|
+
handleResetBalance(newAddress: string, forceRefresh?: boolean): Promise<void>;
|
|
157
157
|
resetCrowdloanMap(newAddress: string): Promise<void>;
|
|
158
158
|
resetStaking(newAddress: string): void;
|
|
159
159
|
private balanceUpdateCache;
|
|
@@ -235,6 +235,8 @@ export default class KoniState {
|
|
|
235
235
|
onAccountRemove(): void;
|
|
236
236
|
reloadNft(): Promise<boolean>;
|
|
237
237
|
reloadStaking(): Promise<boolean>;
|
|
238
|
+
reloadBalance(): Promise<boolean>;
|
|
239
|
+
reloadCrowdloan(): Promise<boolean>;
|
|
238
240
|
approvePassPhishingPage(_url: string): Promise<boolean>;
|
|
239
241
|
resetWallet(resetAll: boolean): Promise<void>;
|
|
240
242
|
enableMantaPay(updateStore: boolean, address: string, password: string, seedPhrase?: string): Promise<string | undefined>;
|
|
@@ -690,12 +690,12 @@ export default class KoniState {
|
|
|
690
690
|
return await this.dbService.stores.balance.getBalanceMapByAddresses(address);
|
|
691
691
|
}
|
|
692
692
|
isFirstLoad = true;
|
|
693
|
-
async
|
|
694
|
-
if (this.isFirstLoad) {
|
|
693
|
+
async handleResetBalance(newAddress, forceRefresh) {
|
|
694
|
+
if (this.isFirstLoad || forceRefresh) {
|
|
695
695
|
const backupBalanceData = await this.dbService.getStoredBalance();
|
|
696
696
|
this.balanceMap.updateBalanceItems(backupBalanceData, isAccountAll(newAddress));
|
|
697
697
|
}
|
|
698
|
-
await Promise.all([this.
|
|
698
|
+
await Promise.all([this.removeInactiveChainBalances()]);
|
|
699
699
|
}
|
|
700
700
|
async resetCrowdloanMap(newAddress) {
|
|
701
701
|
const defaultData = generateDefaultCrowdloanMap();
|
|
@@ -1540,6 +1540,14 @@ export default class KoniState {
|
|
|
1540
1540
|
await this.subscription.reloadStaking();
|
|
1541
1541
|
return true;
|
|
1542
1542
|
}
|
|
1543
|
+
async reloadBalance() {
|
|
1544
|
+
await this.subscription.reloadBalance();
|
|
1545
|
+
return true;
|
|
1546
|
+
}
|
|
1547
|
+
async reloadCrowdloan() {
|
|
1548
|
+
await this.subscription.reloadCrowdloan();
|
|
1549
|
+
return true;
|
|
1550
|
+
}
|
|
1543
1551
|
async approvePassPhishingPage(_url) {
|
|
1544
1552
|
return new Promise(resolve => {
|
|
1545
1553
|
this.settingService.getPassPhishingList(value => {
|
|
@@ -44,7 +44,7 @@ export default function handlers({
|
|
|
44
44
|
const isMobile = port.name === PORT_MOBILE;
|
|
45
45
|
const isExtension = port.name === extensionPortName;
|
|
46
46
|
const sender = port.sender;
|
|
47
|
-
const from = isExtension ? 'extension' : sender.
|
|
47
|
+
const from = isExtension ? 'extension' : sender.url || sender.tab && sender.tab.url || '<unknown>';
|
|
48
48
|
const source = `${from}: ${id}: ${message}`;
|
|
49
49
|
|
|
50
50
|
// console.log(` [in] ${source}`); // :: ${JSON.stringify(request)}`);
|
|
@@ -16,7 +16,8 @@ export declare class KoniSubscription {
|
|
|
16
16
|
stopAllSubscription(): void;
|
|
17
17
|
start(): Promise<void>;
|
|
18
18
|
stop(): Promise<void>;
|
|
19
|
-
|
|
19
|
+
subscribeBalances(address: string, chainInfoMap: Record<string, _ChainInfo>, chainStateMap: Record<string, _ChainState>, substrateApiMap: Record<string, _SubstrateApi>, web3ApiMap: Record<string, _EvmApi>, onlyRunOnFirstTime?: boolean): void;
|
|
20
|
+
subscribeCrowdloans(address: string, substrateApiMap: Record<string, _SubstrateApi>, onlyRunOnFirstTime?: boolean): void;
|
|
20
21
|
subscribeStakingOnChain(address: string, substrateApiMap: Record<string, _SubstrateApi>, onlyRunOnFirstTime?: boolean): void;
|
|
21
22
|
initStakingOnChainSubscription(addresses: string[], substrateApiMap: Record<string, _SubstrateApi>, onlyRunOnFirstTime?: boolean): (() => void) | undefined;
|
|
22
23
|
initEssentialChainStakingMetadataSubscription(substrateApiMap: Record<string, _SubstrateApi>, onlyRunOnFirstTime?: boolean): (() => void) | undefined;
|
|
@@ -27,5 +28,7 @@ export declare class KoniSubscription {
|
|
|
27
28
|
subscribeStakingReward(address: string): Promise<void>;
|
|
28
29
|
subscribeStakingRewardFastInterval(address: string): Promise<void>;
|
|
29
30
|
reloadStaking(): Promise<void>;
|
|
31
|
+
reloadBalance(): Promise<void>;
|
|
32
|
+
reloadCrowdloan(): Promise<void>;
|
|
30
33
|
}
|
|
31
34
|
export {};
|
|
@@ -53,7 +53,8 @@ export class KoniSubscription {
|
|
|
53
53
|
await Promise.all([this.state.eventService.waitCryptoReady, this.state.eventService.waitKeyringReady, this.state.eventService.waitAssetReady]);
|
|
54
54
|
const currentAddress = (_this$state$keyringSe = this.state.keyringService.currentAccount) === null || _this$state$keyringSe === void 0 ? void 0 : _this$state$keyringSe.address;
|
|
55
55
|
if (currentAddress) {
|
|
56
|
-
this.
|
|
56
|
+
this.subscribeBalances(currentAddress, this.state.getChainInfoMap(), this.state.getChainStateMap(), this.state.getSubstrateApiMap(), this.state.getEvmApiMap());
|
|
57
|
+
this.subscribeCrowdloans(currentAddress, this.state.getSubstrateApiMap());
|
|
57
58
|
this.subscribeStakingOnChain(currentAddress, this.state.getSubstrateApiMap());
|
|
58
59
|
}
|
|
59
60
|
this.eventHandler = (events, eventTypes) => {
|
|
@@ -67,7 +68,8 @@ export class KoniSubscription {
|
|
|
67
68
|
if (!address) {
|
|
68
69
|
return;
|
|
69
70
|
}
|
|
70
|
-
this.
|
|
71
|
+
this.subscribeBalances(address, serviceInfo.chainInfoMap, serviceInfo.chainStateMap, serviceInfo.chainApiMap.substrate, serviceInfo.chainApiMap.evm);
|
|
72
|
+
this.subscribeCrowdloans(address, serviceInfo.chainApiMap.substrate);
|
|
71
73
|
this.subscribeStakingOnChain(address, serviceInfo.chainApiMap.substrate);
|
|
72
74
|
};
|
|
73
75
|
this.state.eventService.onLazy(this.eventHandler.bind(this));
|
|
@@ -80,16 +82,24 @@ export class KoniSubscription {
|
|
|
80
82
|
this.stopAllSubscription();
|
|
81
83
|
return Promise.resolve();
|
|
82
84
|
}
|
|
83
|
-
|
|
84
|
-
this.state.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
subscribeBalances(address, chainInfoMap, chainStateMap, substrateApiMap, web3ApiMap, onlyRunOnFirstTime) {
|
|
86
|
+
const addresses = this.state.getDecodedAddresses(address);
|
|
87
|
+
if (!addresses.length) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
this.state.handleResetBalance(address).then(() => {
|
|
89
91
|
this.updateSubscription('balance', this.initBalanceSubscription(addresses, chainInfoMap, chainStateMap, substrateApiMap, web3ApiMap, onlyRunOnFirstTime));
|
|
90
|
-
this.updateSubscription('crowdloan', this.initCrowdloanSubscription(addresses, substrateApiMap, onlyRunOnFirstTime));
|
|
91
92
|
}).catch(err => this.logger.warn(err));
|
|
92
93
|
}
|
|
94
|
+
subscribeCrowdloans(address, substrateApiMap, onlyRunOnFirstTime) {
|
|
95
|
+
const addresses = this.state.getDecodedAddresses(address);
|
|
96
|
+
if (!addresses.length) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
this.state.resetCrowdloanMap(address).then(() => {
|
|
100
|
+
this.updateSubscription('crowdloan', this.initCrowdloanSubscription(addresses, substrateApiMap, onlyRunOnFirstTime));
|
|
101
|
+
}).catch(console.error);
|
|
102
|
+
}
|
|
93
103
|
subscribeStakingOnChain(address, substrateApiMap, onlyRunOnFirstTime) {
|
|
94
104
|
this.state.resetStaking(address);
|
|
95
105
|
const addresses = this.state.getDecodedAddresses(address);
|
|
@@ -242,4 +252,17 @@ export class KoniSubscription {
|
|
|
242
252
|
this.subscribeStakingOnChain(currentAddress, this.state.getSubstrateApiMap());
|
|
243
253
|
await waitTimeout(1800);
|
|
244
254
|
}
|
|
255
|
+
async reloadBalance() {
|
|
256
|
+
var _this$state$keyringSe3;
|
|
257
|
+
const currentAddress = (_this$state$keyringSe3 = this.state.keyringService.currentAccount) === null || _this$state$keyringSe3 === void 0 ? void 0 : _this$state$keyringSe3.address;
|
|
258
|
+
this.subscribeBalances(currentAddress, this.state.getChainInfoMap(), this.state.getChainStateMap(), this.state.getSubstrateApiMap(), this.state.getEvmApiMap());
|
|
259
|
+
await waitTimeout(1800);
|
|
260
|
+
}
|
|
261
|
+
async reloadCrowdloan() {
|
|
262
|
+
var _this$state$keyringSe4;
|
|
263
|
+
const currentAddress = (_this$state$keyringSe4 = this.state.keyringService.currentAccount) === null || _this$state$keyringSe4 === void 0 ? void 0 : _this$state$keyringSe4.address;
|
|
264
|
+
await this.state.handleResetBalance(currentAddress, true);
|
|
265
|
+
this.subscribeCrowdloans(currentAddress, this.state.getSubstrateApiMap());
|
|
266
|
+
await waitTimeout(1800);
|
|
267
|
+
}
|
|
245
268
|
}
|
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.27-1",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -1382,11 +1382,11 @@
|
|
|
1382
1382
|
"@reduxjs/toolkit": "^1.9.1",
|
|
1383
1383
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
1384
1384
|
"@substrate/connect": "^0.7.26",
|
|
1385
|
-
"@subwallet/chain-list": "
|
|
1386
|
-
"@subwallet/extension-base": "^1.1.
|
|
1387
|
-
"@subwallet/extension-chains": "^1.1.
|
|
1388
|
-
"@subwallet/extension-dapp": "^1.1.
|
|
1389
|
-
"@subwallet/extension-inject": "^1.1.
|
|
1385
|
+
"@subwallet/chain-list": "0.2.31",
|
|
1386
|
+
"@subwallet/extension-base": "^1.1.27-1",
|
|
1387
|
+
"@subwallet/extension-chains": "^1.1.27-1",
|
|
1388
|
+
"@subwallet/extension-dapp": "^1.1.27-1",
|
|
1389
|
+
"@subwallet/extension-inject": "^1.1.27-1",
|
|
1390
1390
|
"@subwallet/keyring": "^0.1.1",
|
|
1391
1391
|
"@subwallet/ui-keyring": "^0.1.1",
|
|
1392
1392
|
"@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.27-1'
|
|
11
11
|
};
|
|
@@ -14,6 +14,7 @@ import { parseTransferEventLogs, parseXcmEventLogs } from '@subwallet/extension-
|
|
|
14
14
|
import { getBaseTransactionInfo, getTransactionId, isSubstrateTransaction } from '@subwallet/extension-base/services/transaction-service/helpers';
|
|
15
15
|
import { getExplorerLink, parseTransactionData } from '@subwallet/extension-base/services/transaction-service/utils';
|
|
16
16
|
import { isWalletConnectRequest } from '@subwallet/extension-base/services/wallet-connect-service/helpers';
|
|
17
|
+
import { reformatAddress } from '@subwallet/extension-base/utils';
|
|
17
18
|
import { anyNumberToBN, recalculateGasPrice } from '@subwallet/extension-base/utils/eth';
|
|
18
19
|
import { mergeTransactionAndSignature } from '@subwallet/extension-base/utils/eth/mergeTransactionAndSignature';
|
|
19
20
|
import { isContractAddress, parseContractInput } from '@subwallet/extension-base/utils/eth/parseTransaction';
|
|
@@ -313,15 +314,16 @@ export default class TransactionService {
|
|
|
313
314
|
transactionToHistories(id, startBlock, nonce, eventLogs) {
|
|
314
315
|
const transaction = this.getTransaction(id);
|
|
315
316
|
const extrinsicType = transaction.extrinsicType;
|
|
317
|
+
const formattedTransactionAddress = reformatAddress(transaction.address);
|
|
316
318
|
const historyItem = {
|
|
317
319
|
origin: 'app',
|
|
318
320
|
chain: transaction.chain,
|
|
319
321
|
direction: TransactionDirection.SEND,
|
|
320
322
|
type: transaction.extrinsicType,
|
|
321
|
-
from:
|
|
323
|
+
from: formattedTransactionAddress,
|
|
322
324
|
to: '',
|
|
323
325
|
chainType: transaction.chainType,
|
|
324
|
-
address:
|
|
326
|
+
address: formattedTransactionAddress,
|
|
325
327
|
status: transaction.status,
|
|
326
328
|
transactionId: transaction.id,
|
|
327
329
|
extrinsicHash: transaction.extrinsicHash,
|
|
@@ -18,6 +18,9 @@ function getBlockExplorerAccountRoute(explorerLink) {
|
|
|
18
18
|
if (explorerLink.includes('subscan.io')) {
|
|
19
19
|
return 'account';
|
|
20
20
|
}
|
|
21
|
+
if (explorerLink.includes('3dpscan.io')) {
|
|
22
|
+
return 'account';
|
|
23
|
+
}
|
|
21
24
|
return 'address';
|
|
22
25
|
}
|
|
23
26
|
function getBlockExplorerTxRoute(chainInfo) {
|