@leofcoin/endpoint-clients 0.2.7 → 0.2.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/direct.js +50 -14
- package/exports/http.js +9 -0
- package/exports/index.js +2 -0
- package/exports/types/direct.d.ts +8 -3
- package/exports/types/http.d.ts +3 -0
- package/exports/types/index.d.ts +1 -0
- package/exports/types/ws.d.ts +39 -36
- package/exports/ws.js +12 -2
- package/package.json +3 -2
- package/src/direct.ts +57 -14
- package/src/http.ts +12 -0
- package/src/index.ts +2 -1
- package/src/ws.ts +29 -15
- package/test/index.js +4 -0
- package/test/spec.js +3 -1
- package/tsconfig.json +1 -2
package/exports/direct.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { formatUnits, BigNumber } from '@leofcoin/utils';
|
|
2
|
+
|
|
1
3
|
class Client {
|
|
2
4
|
url;
|
|
3
5
|
networkVersion;
|
|
@@ -8,15 +10,17 @@ class Client {
|
|
|
8
10
|
}
|
|
9
11
|
get pubsub() {
|
|
10
12
|
return {
|
|
11
|
-
publish:
|
|
12
|
-
subscribe:
|
|
13
|
+
publish: globalThis.pubsub.publish,
|
|
14
|
+
subscribe: globalThis.pubsub.subscribe
|
|
13
15
|
};
|
|
14
16
|
}
|
|
15
17
|
balances() {
|
|
16
18
|
return chain.balances;
|
|
17
19
|
}
|
|
18
|
-
balanceOf(address, format) {
|
|
19
|
-
|
|
20
|
+
async balanceOf(address, format) {
|
|
21
|
+
const balances = await chain.balances;
|
|
22
|
+
const balance = balances[address];
|
|
23
|
+
return format ? formatUnits(balance) : balance;
|
|
20
24
|
}
|
|
21
25
|
selectedAccount() {
|
|
22
26
|
return chain.selectedAccount;
|
|
@@ -28,22 +32,22 @@ class Client {
|
|
|
28
32
|
return chain.accounts;
|
|
29
33
|
}
|
|
30
34
|
hasTransactionToHandle() {
|
|
31
|
-
return chain.hasTransactionToHandle;
|
|
35
|
+
return chain.hasTransactionToHandle();
|
|
32
36
|
}
|
|
33
37
|
getBlock(index) {
|
|
34
38
|
return chain.getBlock(index);
|
|
35
39
|
}
|
|
36
40
|
blocks(amount) {
|
|
37
|
-
return chain.blocks(amount);
|
|
41
|
+
return chain.blocks.slice(amount);
|
|
38
42
|
}
|
|
39
43
|
sendTransaction(transaction) {
|
|
40
44
|
return chain.sendTransaction(transaction);
|
|
41
45
|
}
|
|
42
46
|
peerId() {
|
|
43
|
-
return
|
|
47
|
+
return peernet.peerId;
|
|
44
48
|
}
|
|
45
49
|
peers() {
|
|
46
|
-
return
|
|
50
|
+
return peernet.peers;
|
|
47
51
|
}
|
|
48
52
|
validators() {
|
|
49
53
|
return chain.validators;
|
|
@@ -76,16 +80,16 @@ class Client {
|
|
|
76
80
|
return chain.totalTransactions;
|
|
77
81
|
}
|
|
78
82
|
poolTransactions() {
|
|
79
|
-
return
|
|
83
|
+
return transactionPoolStore.get();
|
|
80
84
|
}
|
|
81
85
|
transactionsInPool() {
|
|
82
|
-
return
|
|
86
|
+
return transactionPoolStore.length();
|
|
83
87
|
}
|
|
84
88
|
transactionPoolSize() {
|
|
85
|
-
return
|
|
89
|
+
return transactionPoolStore.size();
|
|
86
90
|
}
|
|
87
91
|
totalBlocks() {
|
|
88
|
-
return chain.
|
|
92
|
+
return chain.blocks.length;
|
|
89
93
|
}
|
|
90
94
|
nativeCalls() {
|
|
91
95
|
return chain.nativeCalls;
|
|
@@ -105,12 +109,44 @@ class Client {
|
|
|
105
109
|
network() {
|
|
106
110
|
return chain.network;
|
|
107
111
|
}
|
|
108
|
-
networkStats() {
|
|
109
|
-
|
|
112
|
+
async networkStats() {
|
|
113
|
+
let accountsHolding = 0;
|
|
114
|
+
let accountsHoldingAmount = BigNumber.from(0);
|
|
115
|
+
let topHolders = [];
|
|
116
|
+
const balances = Object.entries(await chain.balances)
|
|
117
|
+
.map(([holder, amount]) => {
|
|
118
|
+
amount = BigNumber.from(amount);
|
|
119
|
+
return { holder, amount };
|
|
120
|
+
})
|
|
121
|
+
.sort((a, b) => formatUnits(b.amount.sub(a.amount)));
|
|
122
|
+
for (let { holder, amount } of balances) {
|
|
123
|
+
if (amount.gt(0)) {
|
|
124
|
+
accountsHoldingAmount = accountsHoldingAmount.add(amount);
|
|
125
|
+
accountsHolding += 1;
|
|
126
|
+
topHolders.length < 100 && topHolders.push({ holder, amount: formatUnits(amount) });
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
version: peernet.networkVersion,
|
|
131
|
+
peers: peernet.peers.map(([id, peer]) => id),
|
|
132
|
+
accounts: await accountsStore.length(),
|
|
133
|
+
accountsHolding,
|
|
134
|
+
accountsHoldingAmount: formatUnits(accountsHoldingAmount).toString(),
|
|
135
|
+
topHolders
|
|
136
|
+
};
|
|
110
137
|
}
|
|
111
138
|
getNonce(address) {
|
|
112
139
|
return chain.getNonce(address);
|
|
113
140
|
}
|
|
141
|
+
lastBlock() {
|
|
142
|
+
return chain.lastBlock;
|
|
143
|
+
}
|
|
144
|
+
blockHashMap() {
|
|
145
|
+
return chain.blockHashMap;
|
|
146
|
+
}
|
|
147
|
+
bootstrap() {
|
|
148
|
+
return chain.blockHashMap;
|
|
149
|
+
}
|
|
114
150
|
}
|
|
115
151
|
|
|
116
152
|
export { Client as default };
|
package/exports/http.js
CHANGED
|
@@ -121,6 +121,15 @@ class Client {
|
|
|
121
121
|
getNonce(address) {
|
|
122
122
|
return this._fetchNumber('getNonce', { address });
|
|
123
123
|
}
|
|
124
|
+
lastBlock() {
|
|
125
|
+
return this._fetch('lastBlock');
|
|
126
|
+
}
|
|
127
|
+
blockHashMap() {
|
|
128
|
+
return this._fetch('blockHashMap');
|
|
129
|
+
}
|
|
130
|
+
bootstrap() {
|
|
131
|
+
return this._fetch('blockHashMap');
|
|
132
|
+
}
|
|
124
133
|
}
|
|
125
134
|
|
|
126
135
|
export { Client as default };
|
package/exports/index.js
CHANGED
|
@@ -8,7 +8,7 @@ export default class Client {
|
|
|
8
8
|
subscribe: any;
|
|
9
9
|
};
|
|
10
10
|
balances(): any;
|
|
11
|
-
balanceOf(address: string, format: boolean): any
|
|
11
|
+
balanceOf(address: string, format: boolean): Promise<any>;
|
|
12
12
|
selectedAccount(): any;
|
|
13
13
|
selectAccount(address: any): any;
|
|
14
14
|
accounts(): any;
|
|
@@ -38,11 +38,16 @@ export default class Client {
|
|
|
38
38
|
createContractAddress(owner: string, code: string, params: {}): {};
|
|
39
39
|
deployContract(code: string, params: {}): {};
|
|
40
40
|
network(): any;
|
|
41
|
-
networkStats(): {
|
|
41
|
+
networkStats(): Promise<{
|
|
42
42
|
version: string;
|
|
43
43
|
peers: {}[];
|
|
44
44
|
accounts: number;
|
|
45
45
|
accountsHolding: number;
|
|
46
|
-
|
|
46
|
+
accountsHoldingAmount: number;
|
|
47
|
+
topHolders: any[];
|
|
48
|
+
}>;
|
|
47
49
|
getNonce(address: string): any;
|
|
50
|
+
lastBlock(): any;
|
|
51
|
+
blockHashMap(): any;
|
|
52
|
+
bootstrap(): any;
|
|
48
53
|
}
|
package/exports/types/http.d.ts
CHANGED
package/exports/types/index.d.ts
CHANGED
package/exports/types/ws.d.ts
CHANGED
|
@@ -1,51 +1,54 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ClientConnection from 'socket-request-client/connection';
|
|
2
2
|
export default class Client {
|
|
3
3
|
url: string;
|
|
4
4
|
networkVersion: string;
|
|
5
|
-
client:
|
|
5
|
+
client: ClientConnection;
|
|
6
6
|
constructor(url?: string, networkVersion?: string);
|
|
7
7
|
init(): Promise<void>;
|
|
8
8
|
get pubsub(): {
|
|
9
|
-
publish: any
|
|
10
|
-
subscribe: any
|
|
9
|
+
publish: (topic: string, value: any) => Promise<any>;
|
|
10
|
+
subscribe: (topic: string, cb: any) => Promise<any>;
|
|
11
11
|
};
|
|
12
|
-
request(url: string, params?: {}): any
|
|
13
|
-
balances(): any
|
|
14
|
-
balanceOf(address: string, format: boolean): any
|
|
15
|
-
selectedAccount(): any
|
|
16
|
-
selectAccount(address: any): any
|
|
17
|
-
accounts(): any
|
|
18
|
-
hasTransactionToHandle(): any
|
|
19
|
-
getBlock(index: number): any
|
|
20
|
-
blocks(amount: number): any
|
|
21
|
-
sendTransaction(transaction: any): any
|
|
22
|
-
peerId(): any
|
|
23
|
-
peers(): any
|
|
24
|
-
validators(): any
|
|
25
|
-
lookup(name: string): any
|
|
26
|
-
staticCall(contract: string, method: string, params: {}): any
|
|
27
|
-
nativeBurns(): number
|
|
28
|
-
contracts(): number
|
|
29
|
-
nativeMints(): number
|
|
30
|
-
nativeToken(): number
|
|
31
|
-
nativeTransfers(): number
|
|
32
|
-
totalSize(): number
|
|
33
|
-
totalTransactions(): number
|
|
34
|
-
poolTransactions(): any
|
|
35
|
-
transactionsInPool(): any
|
|
36
|
-
transactionPoolSize(): any
|
|
37
|
-
totalBlocks(): number
|
|
38
|
-
nativeCalls(): number
|
|
39
|
-
participating(): boolean
|
|
12
|
+
request(url: string, params?: {}): Promise<any>;
|
|
13
|
+
balances(): Promise<any>;
|
|
14
|
+
balanceOf(address: string, format: boolean): Promise<any>;
|
|
15
|
+
selectedAccount(): Promise<any>;
|
|
16
|
+
selectAccount(address: any): Promise<any>;
|
|
17
|
+
accounts(): Promise<any>;
|
|
18
|
+
hasTransactionToHandle(): Promise<any>;
|
|
19
|
+
getBlock(index: number): Promise<any>;
|
|
20
|
+
blocks(amount: number): Promise<any>;
|
|
21
|
+
sendTransaction(transaction: any): Promise<any>;
|
|
22
|
+
peerId(): Promise<any>;
|
|
23
|
+
peers(): Promise<any>;
|
|
24
|
+
validators(): Promise<any>;
|
|
25
|
+
lookup(name: string): Promise<any>;
|
|
26
|
+
staticCall(contract: string, method: string, params: {}): Promise<any>;
|
|
27
|
+
nativeBurns(): Promise<number>;
|
|
28
|
+
contracts(): Promise<number>;
|
|
29
|
+
nativeMints(): Promise<number>;
|
|
30
|
+
nativeToken(): Promise<number>;
|
|
31
|
+
nativeTransfers(): Promise<number>;
|
|
32
|
+
totalSize(): Promise<number>;
|
|
33
|
+
totalTransactions(): Promise<number>;
|
|
34
|
+
poolTransactions(): Promise<any>;
|
|
35
|
+
transactionsInPool(): Promise<any>;
|
|
36
|
+
transactionPoolSize(): Promise<any>;
|
|
37
|
+
totalBlocks(): Promise<number>;
|
|
38
|
+
nativeCalls(): Promise<number>;
|
|
39
|
+
participating(): Promise<boolean>;
|
|
40
40
|
participate(address: string): {};
|
|
41
41
|
createContractAddress(owner: string, code: string, params: {}): {};
|
|
42
42
|
deployContract(code: string, params: {}): {};
|
|
43
|
-
network(): any
|
|
44
|
-
networkStats(): {
|
|
43
|
+
network(): Promise<any>;
|
|
44
|
+
networkStats(): Promise<{
|
|
45
45
|
version: string;
|
|
46
46
|
peers: {}[];
|
|
47
47
|
accounts: number;
|
|
48
48
|
accountsHolding: number;
|
|
49
|
-
}
|
|
50
|
-
getNonce(address: string): any
|
|
49
|
+
}>;
|
|
50
|
+
getNonce(address: string): Promise<any>;
|
|
51
|
+
lastBlock(): Promise<any>;
|
|
52
|
+
blockHashMap(): Promise<any>;
|
|
53
|
+
bootstrap(): Promise<any>;
|
|
51
54
|
}
|
package/exports/ws.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { SocketRequestClient } from 'socket-request-client';
|
|
2
2
|
|
|
3
3
|
class Client {
|
|
4
4
|
url;
|
|
@@ -9,7 +9,8 @@ class Client {
|
|
|
9
9
|
this.networkVersion = networkVersion;
|
|
10
10
|
}
|
|
11
11
|
async init() {
|
|
12
|
-
|
|
12
|
+
const client = new SocketRequestClient(this.url, this.networkVersion);
|
|
13
|
+
this.client = await client.init();
|
|
13
14
|
}
|
|
14
15
|
get pubsub() {
|
|
15
16
|
return {
|
|
@@ -119,6 +120,15 @@ class Client {
|
|
|
119
120
|
getNonce(address) {
|
|
120
121
|
return this.request('getNonce', { address });
|
|
121
122
|
}
|
|
123
|
+
lastBlock() {
|
|
124
|
+
return this.request('lastBlock');
|
|
125
|
+
}
|
|
126
|
+
blockHashMap() {
|
|
127
|
+
return this.request('blockHashMap');
|
|
128
|
+
}
|
|
129
|
+
bootstrap() {
|
|
130
|
+
return this.request('blockHashMap');
|
|
131
|
+
}
|
|
122
132
|
}
|
|
123
133
|
|
|
124
134
|
export { Client as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leofcoin/endpoint-clients",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"description": "",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"tslib": "^2.5.0"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"
|
|
49
|
+
"@leofcoin/utils": "^1.1.7",
|
|
50
|
+
"socket-request-client": "^2.0.0"
|
|
50
51
|
}
|
|
51
52
|
}
|
package/src/direct.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import {formatUnits, BigNumber} from '@leofcoin/utils'
|
|
2
|
+
|
|
1
3
|
declare var chain
|
|
2
4
|
declare var peernet
|
|
5
|
+
declare var transactionPoolStore
|
|
6
|
+
declare var accountsStore
|
|
3
7
|
|
|
4
8
|
export default class Client {
|
|
5
9
|
url: string
|
|
@@ -13,8 +17,8 @@ export default class Client {
|
|
|
13
17
|
|
|
14
18
|
get pubsub() {
|
|
15
19
|
return {
|
|
16
|
-
publish:
|
|
17
|
-
subscribe:
|
|
20
|
+
publish: globalThis.pubsub.publish,
|
|
21
|
+
subscribe: globalThis.pubsub.subscribe
|
|
18
22
|
}
|
|
19
23
|
}
|
|
20
24
|
|
|
@@ -22,8 +26,10 @@ export default class Client {
|
|
|
22
26
|
return chain.balances
|
|
23
27
|
}
|
|
24
28
|
|
|
25
|
-
balanceOf(address: string, format: boolean) {
|
|
26
|
-
|
|
29
|
+
async balanceOf(address: string, format: boolean) {
|
|
30
|
+
const balances = await chain.balances
|
|
31
|
+
const balance = balances[address]
|
|
32
|
+
return format ? formatUnits(balance) : balance
|
|
27
33
|
}
|
|
28
34
|
|
|
29
35
|
selectedAccount() {
|
|
@@ -39,24 +45,24 @@ export default class Client {
|
|
|
39
45
|
}
|
|
40
46
|
|
|
41
47
|
hasTransactionToHandle() {
|
|
42
|
-
return chain.hasTransactionToHandle
|
|
48
|
+
return chain.hasTransactionToHandle()
|
|
43
49
|
}
|
|
44
50
|
|
|
45
51
|
getBlock(index: number) {
|
|
46
52
|
return chain.getBlock(index)
|
|
47
53
|
}
|
|
48
54
|
blocks(amount: number) {
|
|
49
|
-
return chain.blocks(amount)
|
|
55
|
+
return chain.blocks.slice(amount)
|
|
50
56
|
}
|
|
51
57
|
|
|
52
58
|
sendTransaction(transaction) {
|
|
53
59
|
return chain.sendTransaction(transaction)
|
|
54
60
|
}
|
|
55
61
|
peerId() {
|
|
56
|
-
return
|
|
62
|
+
return peernet.peerId
|
|
57
63
|
}
|
|
58
64
|
peers() {
|
|
59
|
-
return
|
|
65
|
+
return peernet.peers
|
|
60
66
|
}
|
|
61
67
|
validators() {
|
|
62
68
|
return chain.validators
|
|
@@ -90,16 +96,16 @@ export default class Client {
|
|
|
90
96
|
return chain.totalTransactions
|
|
91
97
|
}
|
|
92
98
|
poolTransactions() {
|
|
93
|
-
return
|
|
99
|
+
return transactionPoolStore.get()
|
|
94
100
|
}
|
|
95
101
|
transactionsInPool() {
|
|
96
|
-
return
|
|
102
|
+
return transactionPoolStore.length()
|
|
97
103
|
}
|
|
98
104
|
transactionPoolSize() {
|
|
99
|
-
return
|
|
105
|
+
return transactionPoolStore.size()
|
|
100
106
|
}
|
|
101
107
|
totalBlocks(): number {
|
|
102
|
-
return chain.
|
|
108
|
+
return chain.blocks.length
|
|
103
109
|
}
|
|
104
110
|
nativeCalls(): number {
|
|
105
111
|
return chain.nativeCalls
|
|
@@ -120,11 +126,48 @@ export default class Client {
|
|
|
120
126
|
return chain.network
|
|
121
127
|
}
|
|
122
128
|
|
|
123
|
-
networkStats(): { version: string; peers: {}[]; accounts: number; accountsHolding: number } {
|
|
124
|
-
|
|
129
|
+
async networkStats(): Promise<{ version: string; peers: {}[]; accounts: number; accountsHolding: number, accountsHoldingAmount: number, topHolders: any[] }> {
|
|
130
|
+
let accountsHolding = 0
|
|
131
|
+
let accountsHoldingAmount = BigNumber.from(0)
|
|
132
|
+
let topHolders = []
|
|
133
|
+
const balances = Object.entries(await chain.balances)
|
|
134
|
+
.map(([holder, amount]): {holder: string, amount: BigNumber} => {
|
|
135
|
+
amount = BigNumber.from(amount)
|
|
136
|
+
return {holder, amount}
|
|
137
|
+
})
|
|
138
|
+
.sort((a, b) => formatUnits(b.amount.sub(a.amount)))
|
|
139
|
+
|
|
140
|
+
for (let {holder, amount} of balances) {
|
|
141
|
+
if (amount.gt(0)) {
|
|
142
|
+
accountsHoldingAmount = accountsHoldingAmount.add(amount)
|
|
143
|
+
accountsHolding += 1
|
|
144
|
+
topHolders.length < 100 && topHolders.push({holder, amount: formatUnits(amount)})
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return {
|
|
149
|
+
version: peernet.networkVersion,
|
|
150
|
+
peers: peernet.peers.map(([id, peer]) => id),
|
|
151
|
+
accounts: await accountsStore.length(),
|
|
152
|
+
accountsHolding,
|
|
153
|
+
accountsHoldingAmount: formatUnits(accountsHoldingAmount).toString(),
|
|
154
|
+
topHolders
|
|
155
|
+
}
|
|
125
156
|
}
|
|
126
157
|
|
|
127
158
|
getNonce(address: string) {
|
|
128
159
|
return chain.getNonce(address)
|
|
129
160
|
}
|
|
161
|
+
|
|
162
|
+
lastBlock() {
|
|
163
|
+
return chain.lastBlock
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
blockHashMap() {
|
|
167
|
+
return chain.blockHashMap
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
bootstrap() {
|
|
171
|
+
return chain.blockHashMap
|
|
172
|
+
}
|
|
130
173
|
}
|
package/src/http.ts
CHANGED
|
@@ -145,4 +145,16 @@ export default class Client {
|
|
|
145
145
|
getNonce(address: string) {
|
|
146
146
|
return this._fetchNumber('getNonce', { address })
|
|
147
147
|
}
|
|
148
|
+
|
|
149
|
+
lastBlock() {
|
|
150
|
+
return this._fetch('lastBlock')
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
blockHashMap() {
|
|
154
|
+
return this._fetch('blockHashMap')
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
bootstrap() {
|
|
158
|
+
return this._fetch('blockHashMap')
|
|
159
|
+
}
|
|
148
160
|
}
|
package/src/index.ts
CHANGED
package/src/ws.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { SocketRequestClient } from 'socket-request-client'
|
|
2
|
+
import ClientConnection from 'socket-request-client/connection'
|
|
2
3
|
|
|
3
4
|
export default class Client {
|
|
4
5
|
url: string
|
|
5
6
|
networkVersion: string
|
|
6
|
-
client:
|
|
7
|
+
client: ClientConnection
|
|
7
8
|
|
|
8
9
|
constructor(url = 'ws://localhost:4040', networkVersion = 'leofcoin-peach') {
|
|
9
10
|
this.url = url
|
|
@@ -11,7 +12,8 @@ export default class Client {
|
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
async init() {
|
|
14
|
-
|
|
15
|
+
const client = new SocketRequestClient(this.url, this.networkVersion)
|
|
16
|
+
this.client = await client.init() as ClientConnection
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
get pubsub() {
|
|
@@ -75,25 +77,25 @@ export default class Client {
|
|
|
75
77
|
staticCall(contract: string, method: string, params: {}) {
|
|
76
78
|
return this.request('staticCall', {contract, method, params})
|
|
77
79
|
}
|
|
78
|
-
nativeBurns(): number {
|
|
80
|
+
nativeBurns(): Promise<number> {
|
|
79
81
|
return this.request('nativeBurns')
|
|
80
82
|
}
|
|
81
|
-
contracts(): number {
|
|
83
|
+
contracts(): Promise<number> {
|
|
82
84
|
return this.request('contracts')
|
|
83
85
|
}
|
|
84
|
-
nativeMints(): number {
|
|
86
|
+
nativeMints(): Promise<number> {
|
|
85
87
|
return this.request('nativeMints')
|
|
86
88
|
}
|
|
87
|
-
nativeToken(): number {
|
|
89
|
+
nativeToken(): Promise<number> {
|
|
88
90
|
return this.request('nativeToken')
|
|
89
91
|
}
|
|
90
|
-
nativeTransfers(): number {
|
|
92
|
+
nativeTransfers(): Promise<number> {
|
|
91
93
|
return this.request('nativeTransfers')
|
|
92
94
|
}
|
|
93
|
-
totalSize(): number {
|
|
95
|
+
totalSize(): Promise<number> {
|
|
94
96
|
return this.request('totalSize')
|
|
95
97
|
}
|
|
96
|
-
totalTransactions(): number {
|
|
98
|
+
totalTransactions(): Promise<number> {
|
|
97
99
|
return this.request('totalTransactions')
|
|
98
100
|
}
|
|
99
101
|
poolTransactions() {
|
|
@@ -105,13 +107,13 @@ export default class Client {
|
|
|
105
107
|
transactionPoolSize() {
|
|
106
108
|
return this.request('transactionPoolSize')
|
|
107
109
|
}
|
|
108
|
-
totalBlocks(): number {
|
|
110
|
+
totalBlocks(): Promise<number> {
|
|
109
111
|
return this.request('totalBlocks')
|
|
110
112
|
}
|
|
111
|
-
nativeCalls(): number {
|
|
113
|
+
nativeCalls(): Promise<number> {
|
|
112
114
|
return this.request('nativeCalls')
|
|
113
115
|
}
|
|
114
|
-
participating(): boolean {
|
|
116
|
+
participating(): Promise<boolean> {
|
|
115
117
|
return this.request('participating')
|
|
116
118
|
}
|
|
117
119
|
participate(address: string): {} {
|
|
@@ -127,11 +129,23 @@ export default class Client {
|
|
|
127
129
|
return this.request('network')
|
|
128
130
|
}
|
|
129
131
|
|
|
130
|
-
networkStats(): { version: string; peers: {}[]; accounts: number; accountsHolding: number } {
|
|
132
|
+
networkStats(): Promise<{ version: string; peers: {}[]; accounts: number; accountsHolding: number }> {
|
|
131
133
|
return this.request('networkStats')
|
|
132
134
|
}
|
|
133
135
|
|
|
134
136
|
getNonce(address: string) {
|
|
135
137
|
return this.request('getNonce', { address })
|
|
136
|
-
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
lastBlock() {
|
|
141
|
+
return this.request('lastBlock')
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
blockHashMap() {
|
|
145
|
+
return this.request('blockHashMap')
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
bootstrap() {
|
|
149
|
+
return this.request('blockHashMap')
|
|
150
|
+
}
|
|
137
151
|
}
|
package/test/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { needsImplementations } from './spec.js';
|
|
2
2
|
import WsClient from './../exports/ws.js'
|
|
3
3
|
import HttpClient from './../exports/http.js'
|
|
4
|
+
import DirectClient from './../exports/direct.js'
|
|
4
5
|
|
|
5
6
|
try {
|
|
6
7
|
const wsNeeds = needsImplementations(new WsClient())
|
|
@@ -8,6 +9,9 @@ try {
|
|
|
8
9
|
|
|
9
10
|
const httpNeeds = needsImplementations(new HttpClient())
|
|
10
11
|
if (httpNeeds.length > 0) throw new Error(`http: missing implementations ${httpNeeds.length > 2 ? httpNeeds.join(', ') : httpNeeds.join(' & ')}`)
|
|
12
|
+
|
|
13
|
+
const directNeeds = needsImplementations(new DirectClient())
|
|
14
|
+
if (directNeeds.length > 0) throw new Error(`direct: missing implementations ${directNeeds.length > 2 ? directNeeds.join(', ') : directNeeds.join(' & ')}`)
|
|
11
15
|
} catch (error) {
|
|
12
16
|
console.error(error);
|
|
13
17
|
}
|
package/test/spec.js
CHANGED
|
@@ -26,7 +26,8 @@ export const implementations = [
|
|
|
26
26
|
'totalBlocks',
|
|
27
27
|
'totalSize',
|
|
28
28
|
'totalTransactions',
|
|
29
|
-
'validators'
|
|
29
|
+
'validators',
|
|
30
|
+
'lastBlock'
|
|
30
31
|
]
|
|
31
32
|
|
|
32
33
|
export const needsImplementations = (client) => {
|
|
@@ -39,5 +40,6 @@ export const needsImplementations = (client) => {
|
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
}
|
|
43
|
+
console.log(needs);
|
|
42
44
|
return needs
|
|
43
45
|
}
|