@leofcoin/endpoint-clients 0.3.6 → 0.3.8
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/.prettierrc +7 -0
- package/LICENSE +20 -20
- package/README.md +208 -208
- package/package.json +52 -52
- package/rollup.config.js +14 -14
- package/src/direct.ts +185 -177
- package/src/http.ts +159 -160
- package/src/index.ts +3 -3
- package/src/ws.ts +156 -151
- package/test/index.js +16 -16
- package/test/spec.js +44 -44
- package/tsconfig.json +15 -15
- package/exports/direct.js +0 -157
- package/exports/http.js +0 -135
- package/exports/index.js +0 -5
- package/exports/types/direct.d.ts +0 -53
- package/exports/types/http.d.ts +0 -54
- package/exports/types/index.d.ts +0 -3
- package/exports/types/ws.d.ts +0 -54
- package/exports/ws.js +0 -134
package/src/http.ts
CHANGED
|
@@ -1,160 +1,159 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
this.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
1
|
+
// see https://developer.mozilla.org/en-US/docs/Web/API/Response#instance_methods
|
|
2
|
+
type responseType = 'json' | 'text' | 'arrayBuffer' | 'clone' | 'formData' | 'blob'
|
|
3
|
+
type networkVersion = 'peach' | string
|
|
4
|
+
|
|
5
|
+
export default class Client {
|
|
6
|
+
url: string
|
|
7
|
+
networkVersion: networkVersion
|
|
8
|
+
get isHttpClient() {
|
|
9
|
+
return true
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
constructor(url, networkVersion) {
|
|
13
|
+
this.url = url
|
|
14
|
+
this.networkVersion = networkVersion
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async _fetch(method: string, params?, type: responseType = 'json') {
|
|
18
|
+
params = new URLSearchParams(params).toString()
|
|
19
|
+
const response = await fetch(`${this.url}/${method}?${params}`)
|
|
20
|
+
return response[type]()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async _fetchString(method: string, params?) {
|
|
24
|
+
return String(await this._fetch(method, params, 'text'))
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async _fetchNumber(method: string, params?) {
|
|
28
|
+
return Number(await this._fetchString(method, params))
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async _fetchBoolean(method: string, params?) {
|
|
32
|
+
return Boolean((await this._fetchString(method, params)) === 'true')
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
balances() {
|
|
36
|
+
return this._fetch('balances')
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
balanceOf(address, format) {
|
|
40
|
+
return this._fetch(`balanceOf`, { address, format })
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
selectedAccount() {
|
|
44
|
+
return this._fetchString('selectedAccount')
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
selectAccount(address) {
|
|
48
|
+
return this._fetch('selectAccount', { address })
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
accounts() {
|
|
52
|
+
return this._fetch('accounts')
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
hasTransactionToHandle() {
|
|
56
|
+
return this._fetchBoolean('hasTransactionToHandle')
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
getBlock(index) {
|
|
60
|
+
return this._fetch('getBlock', { index })
|
|
61
|
+
}
|
|
62
|
+
blocks(amount) {
|
|
63
|
+
return this._fetch('blocks', { amount })
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
sendTransaction(transaction) {
|
|
67
|
+
return this._fetch('sendTransaction', transaction)
|
|
68
|
+
}
|
|
69
|
+
peerId() {
|
|
70
|
+
return this._fetchString('peerId')
|
|
71
|
+
}
|
|
72
|
+
peers() {
|
|
73
|
+
return this._fetch('peers')
|
|
74
|
+
}
|
|
75
|
+
validators() {
|
|
76
|
+
return this._fetch('validators')
|
|
77
|
+
}
|
|
78
|
+
lookup(name) {
|
|
79
|
+
return this._fetch('lookup', { name })
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
staticCall(contract, method, params) {
|
|
83
|
+
return this._fetch('staticCall', { contract, method, params })
|
|
84
|
+
}
|
|
85
|
+
nativeBurns() {
|
|
86
|
+
return this._fetchNumber('nativeBurns')
|
|
87
|
+
}
|
|
88
|
+
contracts() {
|
|
89
|
+
return this._fetch('contracts')
|
|
90
|
+
}
|
|
91
|
+
nativeMints() {
|
|
92
|
+
return this._fetchNumber('nativeMints')
|
|
93
|
+
}
|
|
94
|
+
nativeToken() {
|
|
95
|
+
return this._fetchString('nativeToken')
|
|
96
|
+
}
|
|
97
|
+
nativeTransfers() {
|
|
98
|
+
return this._fetchNumber('nativeTransfers')
|
|
99
|
+
}
|
|
100
|
+
totalSize() {
|
|
101
|
+
return this._fetchNumber('totalSize')
|
|
102
|
+
}
|
|
103
|
+
totalTransactions() {
|
|
104
|
+
return this._fetchNumber('totalTransactions')
|
|
105
|
+
}
|
|
106
|
+
poolTransactions() {
|
|
107
|
+
return this._fetch('poolTransactions')
|
|
108
|
+
}
|
|
109
|
+
transactionsInPool() {
|
|
110
|
+
return this._fetchNumber('transactionsInPool')
|
|
111
|
+
}
|
|
112
|
+
transactionPoolSize() {
|
|
113
|
+
return this._fetchNumber('transactionPoolSize')
|
|
114
|
+
}
|
|
115
|
+
totalBlocks() {
|
|
116
|
+
return this._fetchNumber('totalBlocks')
|
|
117
|
+
}
|
|
118
|
+
nativeCalls() {
|
|
119
|
+
return this._fetchNumber('nativeCalls')
|
|
120
|
+
}
|
|
121
|
+
participating() {
|
|
122
|
+
return this._fetchBoolean('participating')
|
|
123
|
+
}
|
|
124
|
+
participate(address) {
|
|
125
|
+
return this._fetch('participate', { address })
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
createContractAddress(owner, code, params) {
|
|
129
|
+
return this._fetch('createContractAddress', { owner, code, params })
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
deployContract(code, params) {
|
|
133
|
+
return this._fetch('deployContract', { code, params })
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
network() {
|
|
137
|
+
return this._fetch('network')
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
networkStats(): Promise<{ version: string; peers: {}[]; accounts: number; accountsHolding: number }> {
|
|
141
|
+
return this._fetch('networkStats')
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
getNonce(address: string) {
|
|
145
|
+
return this._fetchNumber('getNonce', { address })
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
lastBlock() {
|
|
149
|
+
return this._fetch('lastBlock')
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
blockHashMap() {
|
|
153
|
+
return this._fetch('blockHashMap')
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
bootstrap() {
|
|
157
|
+
return this._fetch('blockHashMap')
|
|
158
|
+
}
|
|
159
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {default as ws} from './ws.js'
|
|
2
|
-
export {default as http} from './http.js'
|
|
3
|
-
export {default as direct} from './direct.js'
|
|
1
|
+
export { default as ws } from './ws.js'
|
|
2
|
+
export { default as http } from './http.js'
|
|
3
|
+
export { default as direct } from './direct.js'
|
package/src/ws.ts
CHANGED
|
@@ -1,151 +1,156 @@
|
|
|
1
|
-
import { SocketRequestClient } from 'socket-request-client'
|
|
2
|
-
import ClientConnection from 'socket-request-client/connection'
|
|
3
|
-
|
|
4
|
-
export default class Client {
|
|
5
|
-
url: string
|
|
6
|
-
networkVersion: string
|
|
7
|
-
client: ClientConnection
|
|
8
|
-
|
|
9
|
-
constructor(url = 'ws://localhost:4040', networkVersion = 'leofcoin-peach') {
|
|
10
|
-
this.url = url
|
|
11
|
-
this.networkVersion = networkVersion
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
async init() {
|
|
15
|
-
const client = new SocketRequestClient(this.url, this.networkVersion)
|
|
16
|
-
this.client = await client.init() as ClientConnection
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
get pubsub() {
|
|
20
|
-
return {
|
|
21
|
-
publish: this.client.pubsub.publish,
|
|
22
|
-
subscribe: this.client.pubsub.subscribe
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
request(url: string, params?: {}) {
|
|
27
|
-
return this.client.request({url, params})
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
balances() {
|
|
31
|
-
return this.request('balances')
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
balanceOf(address: string, format: boolean) {
|
|
35
|
-
return this.request('balanceOf', {address, format})
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
selectedAccount() {
|
|
39
|
-
return this.request('selectedAccount')
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
selectAccount(address: any) {
|
|
43
|
-
return this.request('selectAccount', {address})
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
accounts() {
|
|
47
|
-
return this.request('accounts')
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
hasTransactionToHandle() {
|
|
51
|
-
return this.request('hasTransactionToHandle')
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
getBlock(index: number) {
|
|
55
|
-
return this.request('getBlock', { index })
|
|
56
|
-
}
|
|
57
|
-
blocks(amount: number) {
|
|
58
|
-
return this.request('blocks', {amount})
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
sendTransaction(transaction) {
|
|
62
|
-
return this.request('sendTransaction', transaction)
|
|
63
|
-
}
|
|
64
|
-
peerId() {
|
|
65
|
-
return this.request('peerId')
|
|
66
|
-
}
|
|
67
|
-
peers() {
|
|
68
|
-
return this.request('peers')
|
|
69
|
-
}
|
|
70
|
-
validators() {
|
|
71
|
-
return this.request('validators')
|
|
72
|
-
}
|
|
73
|
-
lookup(name: string) {
|
|
74
|
-
return this.request('lookup', { name })
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
staticCall(contract: string, method: string, params: {}) {
|
|
78
|
-
return this.request('staticCall', {contract, method, params})
|
|
79
|
-
}
|
|
80
|
-
nativeBurns(): Promise<number> {
|
|
81
|
-
return this.request('nativeBurns')
|
|
82
|
-
}
|
|
83
|
-
contracts(): Promise<number> {
|
|
84
|
-
return this.request('contracts')
|
|
85
|
-
}
|
|
86
|
-
nativeMints(): Promise<number> {
|
|
87
|
-
return this.request('nativeMints')
|
|
88
|
-
}
|
|
89
|
-
nativeToken(): Promise<
|
|
90
|
-
return this.request('nativeToken')
|
|
91
|
-
}
|
|
92
|
-
nativeTransfers(): Promise<number> {
|
|
93
|
-
return this.request('nativeTransfers')
|
|
94
|
-
}
|
|
95
|
-
totalSize(): Promise<number> {
|
|
96
|
-
return this.request('totalSize')
|
|
97
|
-
}
|
|
98
|
-
totalTransactions(): Promise<number> {
|
|
99
|
-
return this.request('totalTransactions')
|
|
100
|
-
}
|
|
101
|
-
poolTransactions() {
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
transactionsInPool() {
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
transactionPoolSize() {
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
totalBlocks(): Promise<number> {
|
|
111
|
-
return this.request('totalBlocks')
|
|
112
|
-
}
|
|
113
|
-
nativeCalls(): Promise<number> {
|
|
114
|
-
return this.request('nativeCalls')
|
|
115
|
-
}
|
|
116
|
-
participating(): Promise<boolean> {
|
|
117
|
-
return this.request('participating')
|
|
118
|
-
}
|
|
119
|
-
participate(address: string): {} {
|
|
120
|
-
return this.request('participate', { address })
|
|
121
|
-
}
|
|
122
|
-
createContractAddress(owner: string, code: string, params: {}): {} {
|
|
123
|
-
return this.request('createContractAddress', { owner, code, params })
|
|
124
|
-
}
|
|
125
|
-
deployContract(code: string, params: {}): {} {
|
|
126
|
-
return this.request('deployContract', { code, params })
|
|
127
|
-
}
|
|
128
|
-
network() {
|
|
129
|
-
return this.request('network')
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
networkStats(): Promise<{
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
1
|
+
import { SocketRequestClient } from 'socket-request-client'
|
|
2
|
+
import ClientConnection from 'socket-request-client/connection'
|
|
3
|
+
|
|
4
|
+
export default class Client {
|
|
5
|
+
url: string
|
|
6
|
+
networkVersion: string
|
|
7
|
+
client: ClientConnection
|
|
8
|
+
|
|
9
|
+
constructor(url = 'ws://localhost:4040', networkVersion = 'leofcoin-peach') {
|
|
10
|
+
this.url = url
|
|
11
|
+
this.networkVersion = networkVersion
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async init() {
|
|
15
|
+
const client = new SocketRequestClient(this.url, this.networkVersion)
|
|
16
|
+
this.client = (await client.init()) as ClientConnection
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
get pubsub() {
|
|
20
|
+
return {
|
|
21
|
+
publish: this.client.pubsub.publish,
|
|
22
|
+
subscribe: this.client.pubsub.subscribe
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
request(url: string, params?: {}) {
|
|
27
|
+
return this.client.request({ url, params })
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
balances() {
|
|
31
|
+
return this.request('balances')
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
balanceOf(address: string, format: boolean) {
|
|
35
|
+
return this.request('balanceOf', { address, format })
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
selectedAccount() {
|
|
39
|
+
return this.request('selectedAccount')
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
selectAccount(address: any) {
|
|
43
|
+
return this.request('selectAccount', { address })
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
accounts() {
|
|
47
|
+
return this.request('accounts')
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
hasTransactionToHandle() {
|
|
51
|
+
return this.request('hasTransactionToHandle')
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
getBlock(index: number) {
|
|
55
|
+
return this.request('getBlock', { index })
|
|
56
|
+
}
|
|
57
|
+
blocks(amount: number) {
|
|
58
|
+
return this.request('blocks', { amount })
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
sendTransaction(transaction) {
|
|
62
|
+
return this.request('sendTransaction', transaction)
|
|
63
|
+
}
|
|
64
|
+
peerId() {
|
|
65
|
+
return this.request('peerId')
|
|
66
|
+
}
|
|
67
|
+
peers() {
|
|
68
|
+
return this.request('peers')
|
|
69
|
+
}
|
|
70
|
+
validators() {
|
|
71
|
+
return this.request('validators')
|
|
72
|
+
}
|
|
73
|
+
lookup(name: string) {
|
|
74
|
+
return this.request('lookup', { name })
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
staticCall(contract: string, method: string, params: {}) {
|
|
78
|
+
return this.request('staticCall', { contract, method, params })
|
|
79
|
+
}
|
|
80
|
+
nativeBurns(): Promise<number> {
|
|
81
|
+
return this.request('nativeBurns')
|
|
82
|
+
}
|
|
83
|
+
contracts(): Promise<number> {
|
|
84
|
+
return this.request('contracts')
|
|
85
|
+
}
|
|
86
|
+
nativeMints(): Promise<number> {
|
|
87
|
+
return this.request('nativeMints')
|
|
88
|
+
}
|
|
89
|
+
nativeToken(): Promise<string> {
|
|
90
|
+
return this.request('nativeToken')
|
|
91
|
+
}
|
|
92
|
+
nativeTransfers(): Promise<number> {
|
|
93
|
+
return this.request('nativeTransfers')
|
|
94
|
+
}
|
|
95
|
+
totalSize(): Promise<number> {
|
|
96
|
+
return this.request('totalSize')
|
|
97
|
+
}
|
|
98
|
+
totalTransactions(): Promise<number> {
|
|
99
|
+
return this.request('totalTransactions')
|
|
100
|
+
}
|
|
101
|
+
poolTransactions() {
|
|
102
|
+
return this.request('poolTransactions')
|
|
103
|
+
}
|
|
104
|
+
transactionsInPool() {
|
|
105
|
+
return this.request('transactionsInPool')
|
|
106
|
+
}
|
|
107
|
+
transactionPoolSize() {
|
|
108
|
+
return this.request('transactionPoolSize')
|
|
109
|
+
}
|
|
110
|
+
totalBlocks(): Promise<number> {
|
|
111
|
+
return this.request('totalBlocks')
|
|
112
|
+
}
|
|
113
|
+
nativeCalls(): Promise<number> {
|
|
114
|
+
return this.request('nativeCalls')
|
|
115
|
+
}
|
|
116
|
+
participating(): Promise<boolean> {
|
|
117
|
+
return this.request('participating')
|
|
118
|
+
}
|
|
119
|
+
participate(address: string): {} {
|
|
120
|
+
return this.request('participate', { address })
|
|
121
|
+
}
|
|
122
|
+
createContractAddress(owner: string, code: string, params: {}): {} {
|
|
123
|
+
return this.request('createContractAddress', { owner, code, params })
|
|
124
|
+
}
|
|
125
|
+
deployContract(code: string, params: {}): {} {
|
|
126
|
+
return this.request('deployContract', { code, params })
|
|
127
|
+
}
|
|
128
|
+
network() {
|
|
129
|
+
return this.request('network')
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
networkStats(): Promise<{
|
|
133
|
+
version: string
|
|
134
|
+
peers: {}[]
|
|
135
|
+
accounts: number
|
|
136
|
+
accountsHolding: number
|
|
137
|
+
}> {
|
|
138
|
+
return this.request('networkStats')
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
getNonce(address: string) {
|
|
142
|
+
return this.request('getNonce', { address })
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
lastBlock() {
|
|
146
|
+
return this.request('lastBlock')
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
blockHashMap() {
|
|
150
|
+
return this.request('blockHashMap')
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
bootstrap() {
|
|
154
|
+
return this.request('blockHashMap')
|
|
155
|
+
}
|
|
156
|
+
}
|
package/test/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { needsImplementations } from './spec.js';
|
|
2
|
-
import WsClient from './../exports/ws.js'
|
|
3
|
-
import HttpClient from './../exports/http.js'
|
|
4
|
-
import DirectClient from './../exports/direct.js'
|
|
5
|
-
|
|
6
|
-
try {
|
|
7
|
-
const wsNeeds = needsImplementations(new WsClient())
|
|
8
|
-
if (wsNeeds.length > 0) throw new Error(`ws: missing implementations ${wsNeeds.length > 2 ? wsNeeds.join(', ') : wsNeeds.join(' & ')}`)
|
|
9
|
-
|
|
10
|
-
const httpNeeds = needsImplementations(new HttpClient())
|
|
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(' & ')}`)
|
|
15
|
-
} catch (error) {
|
|
16
|
-
console.error(error);
|
|
1
|
+
import { needsImplementations } from './spec.js';
|
|
2
|
+
import WsClient from './../exports/ws.js'
|
|
3
|
+
import HttpClient from './../exports/http.js'
|
|
4
|
+
import DirectClient from './../exports/direct.js'
|
|
5
|
+
|
|
6
|
+
try {
|
|
7
|
+
const wsNeeds = needsImplementations(new WsClient())
|
|
8
|
+
if (wsNeeds.length > 0) throw new Error(`ws: missing implementations ${wsNeeds.length > 2 ? wsNeeds.join(', ') : wsNeeds.join(' & ')}`)
|
|
9
|
+
|
|
10
|
+
const httpNeeds = needsImplementations(new HttpClient())
|
|
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(' & ')}`)
|
|
15
|
+
} catch (error) {
|
|
16
|
+
console.error(error);
|
|
17
17
|
}
|