Skip to content

Commit e421a1e

Browse files
committed
Merge branch 'develop'
2 parents b0ce707 + 7fbe80d commit e421a1e

File tree

12 files changed

+413
-209
lines changed

12 files changed

+413
-209
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## [0.4.0] - 20220104
2+
3+
* bump polkadot-js/api v7.1.1
4+
* speed up connection with connectAll()
5+
* add heart beat & reconnect
6+
* add TokenBalanceData.type
7+
* add aggregatedAssetsWidget support
8+
19
## [0.3.8] - 20211126
210

311
* bump polkadot-js/api v6.9.2

js_api/dist/main.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js_api/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
"build-dev": "webpack --mode development"
2525
},
2626
"resolutions": {
27-
"@polkadot/api": "^6.9.2"
27+
"@polkadot/api": "^7.1.1"
2828
},
2929
"dependencies": {
30-
"@polkadot/api": "^6.9.2",
30+
"@polkadot/api": "^7.1.1",
3131
"@polkadot/extension-dapp": "^0.40.3",
3232
"@polkadot/ui-shared": "0.86.7",
3333
"@walletconnect/client": "2.0.0-alpha.26",

js_api/src/index.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,19 @@ function send(path: string, data: any) {
1717
}
1818
send("log", "main js loaded");
1919
(<any>window).send = send;
20+
21+
async function connectAll(nodes: string[]) {
22+
return Promise.race(nodes.map(node => connect([node])));
23+
}
24+
2025
/**
2126
* connect to a specific node.
2227
*
2328
* @param {string} nodeEndpoint
2429
*/
2530
async function connect(nodes: string[]) {
31+
(<any>window).api = undefined;
32+
2633
return new Promise(async (resolve, reject) => {
2734
const wsProvider = new WsProvider(nodes);
2835
try {
@@ -34,10 +41,17 @@ async function connect(nodes: string[]) {
3441
[`${STATEMINE_GENESIS}-504`]: localMetadata["statemine"],
3542
},
3643
});
37-
(<any>window).api = res;
38-
const url = nodes[(<any>res)._options.provider.__private_16_endpointIndex];
39-
send("log", `${url} wss connected success`);
40-
resolve(url);
44+
if (!(<any>window).api) {
45+
(<any>window).api = res;
46+
const url = nodes[(<any>res)._options.provider.__private_16_endpointIndex];
47+
send("log", `${url} wss connected success`);
48+
resolve(url);
49+
} else {
50+
res.disconnect();
51+
const url = nodes[(<any>res)._options.provider.__private_16_endpointIndex];
52+
send("log", `${url} wss success and disconnected`);
53+
resolve(url);
54+
}
4155
} catch (err) {
4256
send("log", `connect failed`);
4357
wsProvider.disconnect();
@@ -54,6 +68,7 @@ const test = async () => {
5468
const settings = {
5569
test,
5670
connect,
71+
connectAll,
5772
subscribeMessage,
5873
getNetworkConst,
5974
getNetworkProperties,

js_api/src/service/staking/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function _extractRewards(
4949
avgCount++;
5050
}
5151

52-
labels.push(era.toHuman());
52+
labels.push(era.toString());
5353
rewardSet.push(reward);
5454
avgSet.push((avgCount ? Math.ceil((total * 100) / avgCount) : 0) / 100);
5555
slashSet.push(slash);
@@ -70,7 +70,7 @@ function _extractPoints(points: any[]) {
7070

7171
points.forEach(({ era, points }) => {
7272
total += points.toNumber();
73-
labels.push(era.toHuman());
73+
labels.push(era.toString());
7474

7575
if (points.gtn(0)) {
7676
avgCount++;
@@ -104,7 +104,7 @@ function _extractStake(exposures: any[]) {
104104
}
105105

106106
avgSet.push((avgCount ? Math.ceil((total * 100) / avgCount) : 0) / 100);
107-
labels.push(era.toHuman());
107+
labels.push(era.toString());
108108
cliSet.push(cli);
109109
expSet.push(exp);
110110
});

0 commit comments

Comments
 (0)