@leofcoin/endpoints 0.4.7 → 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/http.js +3 -3
- package/exports/shared.d.ts +14 -9
- package/exports/shared.js +6 -7
- package/exports/ws.js +3 -3
- package/package.json +15 -8
package/exports/http.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import koa from 'koa';
|
|
2
2
|
import cors from '@koa/cors';
|
|
3
3
|
import Router from '@koa/router';
|
|
4
|
-
import { formatUnits } from '@leofcoin/utils';
|
|
4
|
+
import { formatUnits, jsonStringifyBigInt } from '@leofcoin/utils';
|
|
5
5
|
import { readFile } from 'fs/promises';
|
|
6
6
|
import Showdown from 'showdown';
|
|
7
7
|
import shared from './shared.js';
|
|
@@ -83,7 +83,7 @@ export default (chain, port, networkVersion, remote = false) => {
|
|
|
83
83
|
const tx = await chain.sendTransaction(ctx.query.transaction);
|
|
84
84
|
await tx.wait();
|
|
85
85
|
delete tx.wait;
|
|
86
|
-
ctx.body = tx;
|
|
86
|
+
ctx.body = JSON.stringify(tx, jsonStringifyBigInt);
|
|
87
87
|
}
|
|
88
88
|
catch (error) {
|
|
89
89
|
// ctx(202)
|
|
@@ -126,7 +126,7 @@ export default (chain, port, networkVersion, remote = false) => {
|
|
|
126
126
|
const tx = await chain.deployContract(ctx.query.contract, ctx.query.transaction);
|
|
127
127
|
await tx.wait();
|
|
128
128
|
delete tx.wait;
|
|
129
|
-
ctx.body = JSON.stringify(tx);
|
|
129
|
+
ctx.body = JSON.stringify(tx, jsonStringifyBigInt);
|
|
130
130
|
}
|
|
131
131
|
catch (error) {
|
|
132
132
|
ctx.body = error.mesage;
|
package/exports/shared.d.ts
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
version: string;
|
|
1
|
+
export declare const networkStats: (chain: any, networkVersion: any) => Promise<{
|
|
2
|
+
version: any;
|
|
4
3
|
peers: any;
|
|
5
4
|
accounts: any;
|
|
6
5
|
accountsHolding: number;
|
|
7
|
-
accountsHoldingAmount:
|
|
8
|
-
topHolders:
|
|
6
|
+
accountsHoldingAmount: string;
|
|
7
|
+
topHolders: {
|
|
8
|
+
holder: string;
|
|
9
|
+
amount: string;
|
|
10
|
+
}[];
|
|
9
11
|
}>;
|
|
10
12
|
declare const _default: {
|
|
11
|
-
networkStats: (chain:
|
|
12
|
-
version:
|
|
13
|
+
networkStats: (chain: any, networkVersion: any) => Promise<{
|
|
14
|
+
version: any;
|
|
13
15
|
peers: any;
|
|
14
16
|
accounts: any;
|
|
15
17
|
accountsHolding: number;
|
|
16
|
-
accountsHoldingAmount:
|
|
17
|
-
topHolders:
|
|
18
|
+
accountsHoldingAmount: string;
|
|
19
|
+
topHolders: {
|
|
20
|
+
holder: string;
|
|
21
|
+
amount: string;
|
|
22
|
+
}[];
|
|
18
23
|
}>;
|
|
19
24
|
bootstrap: () => Promise<any>;
|
|
20
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"
|