@leofcoin/endpoints 0.4.8 → 0.4.9
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/exports/shared.d.ts +10 -4
- package/exports/shared.js +6 -7
- package/exports/ws.js +3 -3
- package/package.json +15 -8
package/exports/shared.d.ts
CHANGED
|
@@ -3,8 +3,11 @@ export declare const networkStats: (chain: any, networkVersion: any) => Promise<
|
|
|
3
3
|
peers: any;
|
|
4
4
|
accounts: any;
|
|
5
5
|
accountsHolding: number;
|
|
6
|
-
accountsHoldingAmount:
|
|
7
|
-
topHolders:
|
|
6
|
+
accountsHoldingAmount: string;
|
|
7
|
+
topHolders: {
|
|
8
|
+
holder: string;
|
|
9
|
+
amount: string;
|
|
10
|
+
}[];
|
|
8
11
|
}>;
|
|
9
12
|
declare const _default: {
|
|
10
13
|
networkStats: (chain: any, networkVersion: any) => Promise<{
|
|
@@ -12,8 +15,11 @@ declare const _default: {
|
|
|
12
15
|
peers: any;
|
|
13
16
|
accounts: any;
|
|
14
17
|
accountsHolding: number;
|
|
15
|
-
accountsHoldingAmount:
|
|
16
|
-
topHolders:
|
|
18
|
+
accountsHoldingAmount: string;
|
|
19
|
+
topHolders: {
|
|
20
|
+
holder: string;
|
|
21
|
+
amount: string;
|
|
22
|
+
}[];
|
|
17
23
|
}>;
|
|
18
24
|
bootstrap: () => Promise<any>;
|
|
19
25
|
};
|
package/exports/shared.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { formatUnits } from '@leofcoin/utils';
|
|
2
2
|
export const networkStats = async (chain, networkVersion) => {
|
|
3
3
|
let accountsHolding = 0;
|
|
4
|
-
let accountsHoldingAmount =
|
|
5
|
-
|
|
6
|
-
const balances = Object.entries(await chain.balances)
|
|
4
|
+
let accountsHoldingAmount = 0n;
|
|
5
|
+
const topHolders = [];
|
|
6
|
+
const balances = Object.entries((await chain.balances))
|
|
7
7
|
.map(([holder, amount]) => {
|
|
8
|
-
|
|
9
|
-
return { holder, amount };
|
|
8
|
+
return { holder, amount: BigInt(amount) };
|
|
10
9
|
})
|
|
11
|
-
.sort((a, b) =>
|
|
10
|
+
.sort((a, b) => (a.amount === b.amount ? 0 : a.amount > b.amount ? -1 : 1));
|
|
12
11
|
for (let { holder, amount } of balances) {
|
|
13
|
-
if (amount >
|
|
12
|
+
if (amount > 0n) {
|
|
14
13
|
accountsHoldingAmount += amount;
|
|
15
14
|
accountsHolding += 1;
|
|
16
15
|
topHolders.length < 100 && topHolders.push({ holder, amount: formatUnits(amount) });
|
package/exports/ws.js
CHANGED
|
@@ -78,8 +78,8 @@ export default (chain, port, networkVersion, remote = false) => {
|
|
|
78
78
|
totalSize: async ({ send }) => send((await globalThis.transactionPoolStore.size()) +
|
|
79
79
|
(await globalThis.blockStore.size()) +
|
|
80
80
|
(await globalThis.accountsStore.size())),
|
|
81
|
-
lastBlock: async (
|
|
82
|
-
lastBlockHeight: async (
|
|
81
|
+
lastBlock: async ({ send }) => send(await chain.lastBlock),
|
|
82
|
+
lastBlockHeight: async ({ send }) => send(await chain.lastBlockHeight),
|
|
83
83
|
participating: async ({ send }) => send(await chain.participating),
|
|
84
84
|
poolTransactions: async ({ send }) => send(await globalThis.transactionPoolStore.get()),
|
|
85
85
|
transactionsInPool: async ({ send }) => send(await globalThis.transactionPoolStore.length()),
|
|
@@ -110,7 +110,7 @@ export default (chain, port, networkVersion, remote = false) => {
|
|
|
110
110
|
send(error);
|
|
111
111
|
}
|
|
112
112
|
},
|
|
113
|
-
blockHashMap: async (
|
|
113
|
+
blockHashMap: async ({ send }) => send(await chain.blockHashMap),
|
|
114
114
|
bootstrap: async ({ send }) => {
|
|
115
115
|
send(await shared.bootstrap());
|
|
116
116
|
}
|
package/package.json
CHANGED
|
@@ -1,35 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leofcoin/endpoints",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.9",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./api": "./exports/api.md",
|
|
8
|
-
"./http":
|
|
9
|
-
|
|
8
|
+
"./http": {
|
|
9
|
+
"import": "./exports/http.js",
|
|
10
|
+
"types": "./exports/http.d.ts"
|
|
11
|
+
},
|
|
12
|
+
"./ws": {
|
|
13
|
+
"import": "./exports/ws.js",
|
|
14
|
+
"types": "./exports/ws.d.ts"
|
|
15
|
+
}
|
|
10
16
|
},
|
|
11
17
|
"files": [
|
|
12
18
|
"./exports"
|
|
13
19
|
],
|
|
14
20
|
"scripts": {
|
|
15
|
-
"build": "
|
|
16
|
-
"test": "
|
|
21
|
+
"build": "tsc -p tsconfig.json",
|
|
22
|
+
"test": "node --test test/*.test.js"
|
|
17
23
|
},
|
|
18
24
|
"keywords": [],
|
|
19
25
|
"author": "",
|
|
20
26
|
"license": "MIT",
|
|
21
27
|
"repository": {
|
|
22
28
|
"type": "git",
|
|
23
|
-
"url": "
|
|
29
|
+
"url": "https://github.com/leofcoin/monorepo.git",
|
|
30
|
+
"directory": "packages/endpoints"
|
|
24
31
|
},
|
|
25
32
|
"bugs": {
|
|
26
33
|
"url": "https://github.com/leofcoin/endpoints/issues"
|
|
27
34
|
},
|
|
28
|
-
"homepage": "https://github.com/leofcoin/endpoints#readme",
|
|
35
|
+
"homepage": "https://github.com/leofcoin/monorepo/tree/main/packages/endpoints#readme",
|
|
29
36
|
"dependencies": {
|
|
30
37
|
"@koa/cors": "^5.0.0",
|
|
31
38
|
"@koa/router": "^13.1.1",
|
|
32
|
-
"@leofcoin/utils": "^1.1.
|
|
39
|
+
"@leofcoin/utils": "^1.1.45",
|
|
33
40
|
"koa": "^3.0.1",
|
|
34
41
|
"showdown": "^2.1.0",
|
|
35
42
|
"socket-request-server": "^1.6.17"
|