@leofcoin/endpoint-clients 0.2.8 → 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 +6 -0
- package/exports/http.js +7 -0
- package/exports/types/direct.d.ts +2 -0
- package/exports/types/http.d.ts +3 -1
- package/exports/types/ws.d.ts +39 -36
- package/exports/ws.js +12 -2
- package/package.json +2 -2
- package/src/direct.ts +9 -1
- package/src/http.ts +9 -1
- package/src/ws.ts +29 -15
package/exports/direct.js
CHANGED
package/exports/http.js
CHANGED
|
@@ -122,6 +122,13 @@ class Client {
|
|
|
122
122
|
return this._fetchNumber('getNonce', { address });
|
|
123
123
|
}
|
|
124
124
|
lastBlock() {
|
|
125
|
+
return this._fetch('lastBlock');
|
|
126
|
+
}
|
|
127
|
+
blockHashMap() {
|
|
128
|
+
return this._fetch('blockHashMap');
|
|
129
|
+
}
|
|
130
|
+
bootstrap() {
|
|
131
|
+
return this._fetch('blockHashMap');
|
|
125
132
|
}
|
|
126
133
|
}
|
|
127
134
|
|
package/exports/types/http.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 SocketRequestClient from 'socket-request-client';
|
|
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
|
".": {
|
|
@@ -47,6 +47,6 @@
|
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@leofcoin/utils": "^1.1.7",
|
|
50
|
-
"socket-request-client": "^
|
|
50
|
+
"socket-request-client": "^2.0.0"
|
|
51
51
|
}
|
|
52
52
|
}
|
package/src/direct.ts
CHANGED
|
@@ -131,7 +131,7 @@ export default class Client {
|
|
|
131
131
|
let accountsHoldingAmount = BigNumber.from(0)
|
|
132
132
|
let topHolders = []
|
|
133
133
|
const balances = Object.entries(await chain.balances)
|
|
134
|
-
.map(([holder, amount]) => {
|
|
134
|
+
.map(([holder, amount]): {holder: string, amount: BigNumber} => {
|
|
135
135
|
amount = BigNumber.from(amount)
|
|
136
136
|
return {holder, amount}
|
|
137
137
|
})
|
|
@@ -162,4 +162,12 @@ export default class Client {
|
|
|
162
162
|
lastBlock() {
|
|
163
163
|
return chain.lastBlock
|
|
164
164
|
}
|
|
165
|
+
|
|
166
|
+
blockHashMap() {
|
|
167
|
+
return chain.blockHashMap
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
bootstrap() {
|
|
171
|
+
return chain.blockHashMap
|
|
172
|
+
}
|
|
165
173
|
}
|
package/src/http.ts
CHANGED
|
@@ -147,6 +147,14 @@ export default class Client {
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
lastBlock() {
|
|
150
|
-
|
|
150
|
+
return this._fetch('lastBlock')
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
blockHashMap() {
|
|
154
|
+
return this._fetch('blockHashMap')
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
bootstrap() {
|
|
158
|
+
return this._fetch('blockHashMap')
|
|
151
159
|
}
|
|
152
160
|
}
|
package/src/ws.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import SocketRequestClient from 'socket-request-client'
|
|
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
|
}
|