@leofcoin/endpoint-clients 0.2.1 → 0.2.2
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/LICENSE +20 -20
- package/README.md +30 -29
- package/exports/http.js +97 -106
- package/exports/index.js +2 -0
- package/exports/types/http.d.ts +32 -0
- package/exports/types/index.d.ts +2 -0
- package/exports/types/ws.d.ts +40 -0
- package/exports/ws.js +106 -114
- package/package.json +12 -2
- package/rollup.config.js +15 -0
- package/src/http.ts +106 -0
- package/src/index.ts +2 -0
- package/src/ws.ts +117 -0
- package/test/index.js +12 -12
- package/test/spec.js +42 -42
- package/tsconfig.json +17 -0
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2022 vandeurenglenn
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 vandeurenglenn
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -10,14 +10,15 @@ npm i @leofcoin/endpoint-clients
|
|
|
10
10
|
import WsClient from '@leofcoin/endpoint-clients/ws'
|
|
11
11
|
import HttpClient from '@leofcoin/endpoint-clients/http'
|
|
12
12
|
|
|
13
|
-
const networkVersion = '
|
|
13
|
+
const networkVersion = 'peach'
|
|
14
14
|
|
|
15
15
|
const ws = new WsClient('ws://localhost:4040', networkVersion)
|
|
16
16
|
const http = new HttpClient('http://localhost:8080', networkVersion)
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
## api
|
|
20
|
-
###
|
|
20
|
+
### new Client(url, networkVersion)
|
|
21
|
+
#### selectAccount(address: `string`)
|
|
21
22
|
`address`: desired address
|
|
22
23
|
> set default account to given address
|
|
23
24
|
```js
|
|
@@ -25,21 +26,21 @@ await client.selectAccount(address)
|
|
|
25
26
|
```
|
|
26
27
|
<br>
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
#### getBlock(index: `number`)
|
|
29
30
|
`index`: index of the block to fetch<br>
|
|
30
31
|
```js
|
|
31
32
|
await client.getBlock(10)
|
|
32
33
|
```
|
|
33
34
|
<br>
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
#### blocks(amount)
|
|
36
37
|
`amount`: the amount to slice
|
|
37
38
|
```js
|
|
38
39
|
await client.blocks(-25)
|
|
39
40
|
```
|
|
40
41
|
<br>
|
|
41
42
|
|
|
42
|
-
|
|
43
|
+
#### createTransactionFrom(from: `string`, to: `string`, method: `string`, parameters: `array`, nonce: `number` | `undefined`)
|
|
43
44
|
|
|
44
45
|
`from`:<br>
|
|
45
46
|
`to`: <br>
|
|
@@ -51,14 +52,14 @@ await client.createTransactionFrom(from, to, method, parameters, nonce)
|
|
|
51
52
|
```
|
|
52
53
|
<br>
|
|
53
54
|
|
|
54
|
-
|
|
55
|
+
#### lookup(name: `string`)
|
|
55
56
|
`name`: name of the contract to lookup the address and owner of
|
|
56
57
|
```js
|
|
57
58
|
await client.lookup('contractName')
|
|
58
59
|
```
|
|
59
60
|
<br>
|
|
60
61
|
|
|
61
|
-
|
|
62
|
+
#### participate(address: `string`)
|
|
62
63
|
`address`: <br>
|
|
63
64
|
|
|
64
65
|
```js
|
|
@@ -66,7 +67,7 @@ await client.participate(address)
|
|
|
66
67
|
```
|
|
67
68
|
<br>
|
|
68
69
|
|
|
69
|
-
|
|
70
|
+
#### staticCall(contract: `string`, method: `string`, params: `array`)
|
|
70
71
|
`contract`: contract address todo the call on
|
|
71
72
|
`method`: method/function to call
|
|
72
73
|
`params`: array containing params needed to call the desired method
|
|
@@ -75,7 +76,7 @@ await client.staticCall(contract, method, params)
|
|
|
75
76
|
```
|
|
76
77
|
<br>
|
|
77
78
|
|
|
78
|
-
|
|
79
|
+
#### createContractAddress(owner: `string`, code: `string`, params: `array`)
|
|
79
80
|
`owner`: address of the deployer<br>
|
|
80
81
|
`code`: contract as a string<br>
|
|
81
82
|
`params`: contract constructor params<br>
|
|
@@ -85,7 +86,7 @@ const address = await client.createContractAddress(owner, code, params)
|
|
|
85
86
|
```
|
|
86
87
|
<br>
|
|
87
88
|
|
|
88
|
-
|
|
89
|
+
#### deployContract(code: `string`, params: `array`)
|
|
89
90
|
`code`: contract as a string<br>
|
|
90
91
|
`params`: contract constructor params<br>
|
|
91
92
|
|
|
@@ -94,26 +95,26 @@ const tx = await client.deployContract(code, params)
|
|
|
94
95
|
```
|
|
95
96
|
<br>
|
|
96
97
|
|
|
97
|
-
|
|
98
|
+
#### accounts()
|
|
98
99
|
```js
|
|
99
100
|
await client.accounts()
|
|
100
101
|
```
|
|
101
102
|
<br>
|
|
102
103
|
|
|
103
|
-
|
|
104
|
+
#### hasTransactionToHandle()
|
|
104
105
|
```js
|
|
105
106
|
await client.hasTransactionToHandle()
|
|
106
107
|
```
|
|
107
108
|
<br>
|
|
108
109
|
|
|
109
|
-
|
|
110
|
+
#### balances()
|
|
110
111
|
> returns all balances
|
|
111
112
|
```js
|
|
112
113
|
await client.balances()
|
|
113
114
|
```
|
|
114
115
|
<br>
|
|
115
116
|
|
|
116
|
-
|
|
117
|
+
#### balancOf(address: `string`, format: `boolean`)
|
|
117
118
|
`address`: The address to check<br>
|
|
118
119
|
`format`: Wether or not to format<br>
|
|
119
120
|
> returns the balance of given address as BigNumber or string (when format is true)
|
|
@@ -122,86 +123,86 @@ await client.balanceOf(address, true)
|
|
|
122
123
|
```
|
|
123
124
|
<br>
|
|
124
125
|
|
|
125
|
-
|
|
126
|
+
#### selectedAccount()
|
|
126
127
|
```js
|
|
127
128
|
await client.selectedAccount()
|
|
128
129
|
```
|
|
129
130
|
<br>
|
|
130
131
|
|
|
131
|
-
|
|
132
|
+
#### peerId()
|
|
132
133
|
```js
|
|
133
134
|
await client.peerId()
|
|
134
135
|
```
|
|
135
136
|
<br>
|
|
136
137
|
|
|
137
|
-
|
|
138
|
+
#### peers()
|
|
138
139
|
```js
|
|
139
140
|
await client.peers()
|
|
140
141
|
```
|
|
141
142
|
<br>
|
|
142
143
|
|
|
143
|
-
|
|
144
|
+
#### validators()
|
|
144
145
|
```js
|
|
145
146
|
await client.validators()
|
|
146
147
|
```
|
|
147
148
|
<br>
|
|
148
149
|
|
|
149
|
-
|
|
150
|
+
#### nativeBurns()
|
|
150
151
|
```js
|
|
151
152
|
await client.nativeBurns()
|
|
152
153
|
```
|
|
153
154
|
<br>
|
|
154
155
|
|
|
155
|
-
|
|
156
|
+
#### contracts()
|
|
156
157
|
```js
|
|
157
158
|
await client.contracts()
|
|
158
159
|
```
|
|
159
160
|
<br>
|
|
160
161
|
|
|
161
|
-
|
|
162
|
+
#### nativeMints()
|
|
162
163
|
```js
|
|
163
164
|
await client.nativeMints()
|
|
164
165
|
```
|
|
165
166
|
<br>
|
|
166
167
|
|
|
167
|
-
|
|
168
|
+
#### nativeToken()
|
|
168
169
|
```js
|
|
169
170
|
await client.nativeToken()
|
|
170
171
|
```
|
|
171
172
|
<br>
|
|
172
173
|
|
|
173
|
-
|
|
174
|
+
#### nativeTransfers()
|
|
174
175
|
```js
|
|
175
176
|
await client. nativeTransfers()
|
|
176
177
|
```
|
|
177
178
|
<br>
|
|
178
179
|
|
|
179
|
-
|
|
180
|
+
#### totalSize()
|
|
180
181
|
```js
|
|
181
182
|
await client.totalSize()
|
|
182
183
|
```
|
|
183
184
|
<br>
|
|
184
185
|
|
|
185
|
-
|
|
186
|
+
#### totalTransactions()
|
|
186
187
|
```js
|
|
187
188
|
await client.totalTransactions()
|
|
188
189
|
```
|
|
189
190
|
<br>
|
|
190
191
|
|
|
191
|
-
|
|
192
|
+
#### totalBlocks()
|
|
192
193
|
```js
|
|
193
194
|
await client.totalBlocks()
|
|
194
195
|
```
|
|
195
196
|
<br>
|
|
196
197
|
|
|
197
|
-
|
|
198
|
+
#### nativeCalls()
|
|
198
199
|
```js
|
|
199
200
|
await client.nativeCalls()
|
|
200
201
|
```
|
|
201
202
|
<br>
|
|
202
203
|
|
|
203
|
-
|
|
204
|
+
#### participating()
|
|
204
205
|
```js
|
|
205
206
|
await client.participating()
|
|
206
207
|
```
|
|
207
|
-
<br>
|
|
208
|
+
<br>
|
package/exports/http.js
CHANGED
|
@@ -1,106 +1,97 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
createContractAddress(owner, code, params) {
|
|
101
|
-
return this._fetch('createContractAddress', { owner, code, params })
|
|
102
|
-
}
|
|
103
|
-
deployContract(code, params) {
|
|
104
|
-
return this._fetch('deployContract', { code, params })
|
|
105
|
-
}
|
|
106
|
-
}
|
|
1
|
+
class http {
|
|
2
|
+
get isHttpClient() {
|
|
3
|
+
return true;
|
|
4
|
+
}
|
|
5
|
+
constructor(url, networkVersion) {
|
|
6
|
+
this.url = url;
|
|
7
|
+
this.networkVersion = networkVersion;
|
|
8
|
+
}
|
|
9
|
+
async _fetch(method, params) {
|
|
10
|
+
params = new URLSearchParams(params).toString();
|
|
11
|
+
const response = await fetch(`${this.url}/${method}?${params}`);
|
|
12
|
+
return response.json();
|
|
13
|
+
}
|
|
14
|
+
balances() {
|
|
15
|
+
return this._fetch('balances');
|
|
16
|
+
}
|
|
17
|
+
balanceOf(address, format) {
|
|
18
|
+
return this._fetch(`balanceOf`, { address, format });
|
|
19
|
+
}
|
|
20
|
+
selectedAccount() {
|
|
21
|
+
return this._fetch('selectedAccount');
|
|
22
|
+
}
|
|
23
|
+
selectAccount(address) {
|
|
24
|
+
return this._fetch('selectAccount', { address });
|
|
25
|
+
}
|
|
26
|
+
accounts() {
|
|
27
|
+
return this._fetch('accounts');
|
|
28
|
+
}
|
|
29
|
+
hasTransactionToHandle() {
|
|
30
|
+
return this._fetch('hasTransactionToHandle');
|
|
31
|
+
}
|
|
32
|
+
getBlock(index) {
|
|
33
|
+
return this._fetch('getBlock', { index });
|
|
34
|
+
}
|
|
35
|
+
blocks(amount) {
|
|
36
|
+
return this._fetch('blocks', { amount });
|
|
37
|
+
}
|
|
38
|
+
sendTransaction(transaction) {
|
|
39
|
+
return this._fetch('sendTransaction', transaction);
|
|
40
|
+
}
|
|
41
|
+
peerId() {
|
|
42
|
+
return this._fetch('peerId');
|
|
43
|
+
}
|
|
44
|
+
peers() {
|
|
45
|
+
return this._fetch('peers');
|
|
46
|
+
}
|
|
47
|
+
validators() {
|
|
48
|
+
return this._fetch('validators');
|
|
49
|
+
}
|
|
50
|
+
lookup(name) {
|
|
51
|
+
return this._fetch('lookup', { name });
|
|
52
|
+
}
|
|
53
|
+
staticCall(contract, method, params) {
|
|
54
|
+
return this._fetch('staticCall', { contract, method, params });
|
|
55
|
+
}
|
|
56
|
+
nativeBurns() {
|
|
57
|
+
return this._fetch('nativeBurns');
|
|
58
|
+
}
|
|
59
|
+
contracts() {
|
|
60
|
+
return this._fetch('contracts');
|
|
61
|
+
}
|
|
62
|
+
nativeMints() {
|
|
63
|
+
return this._fetch('nativeMints');
|
|
64
|
+
}
|
|
65
|
+
nativeToken() {
|
|
66
|
+
return this._fetch('nativeToken');
|
|
67
|
+
}
|
|
68
|
+
nativeTransfers() {
|
|
69
|
+
return this._fetch('nativeTransfers');
|
|
70
|
+
}
|
|
71
|
+
totalSize() {
|
|
72
|
+
return this._fetch('totalSize');
|
|
73
|
+
}
|
|
74
|
+
totalTransactions() {
|
|
75
|
+
return this._fetch('totalTransactions');
|
|
76
|
+
}
|
|
77
|
+
totalBlocks() {
|
|
78
|
+
return this._fetch('totalBlocks');
|
|
79
|
+
}
|
|
80
|
+
nativeCalls() {
|
|
81
|
+
return this._fetch('nativeCalls');
|
|
82
|
+
}
|
|
83
|
+
participating() {
|
|
84
|
+
return this._fetch('participating');
|
|
85
|
+
}
|
|
86
|
+
participate(address) {
|
|
87
|
+
return this._fetch('participate', { address });
|
|
88
|
+
}
|
|
89
|
+
createContractAddress(owner, code, params) {
|
|
90
|
+
return this._fetch('createContractAddress', { owner, code, params });
|
|
91
|
+
}
|
|
92
|
+
deployContract(code, params) {
|
|
93
|
+
return this._fetch('deployContract', { code, params });
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export { http as default };
|
package/exports/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export default class {
|
|
2
|
+
get isHttpClient(): boolean;
|
|
3
|
+
constructor(url: any, networkVersion: any);
|
|
4
|
+
_fetch(method: any, params: any): Promise<any>;
|
|
5
|
+
balances(): Promise<any>;
|
|
6
|
+
balanceOf(address: any, format: any): Promise<any>;
|
|
7
|
+
selectedAccount(): Promise<any>;
|
|
8
|
+
selectAccount(address: any): Promise<any>;
|
|
9
|
+
accounts(): Promise<any>;
|
|
10
|
+
hasTransactionToHandle(): Promise<any>;
|
|
11
|
+
getBlock(index: any): Promise<any>;
|
|
12
|
+
blocks(amount: any): Promise<any>;
|
|
13
|
+
sendTransaction(transaction: any): Promise<any>;
|
|
14
|
+
peerId(): Promise<any>;
|
|
15
|
+
peers(): Promise<any>;
|
|
16
|
+
validators(): Promise<any>;
|
|
17
|
+
lookup(name: any): Promise<any>;
|
|
18
|
+
staticCall(contract: any, method: any, params: any): Promise<any>;
|
|
19
|
+
nativeBurns(): Promise<any>;
|
|
20
|
+
contracts(): Promise<any>;
|
|
21
|
+
nativeMints(): Promise<any>;
|
|
22
|
+
nativeToken(): Promise<any>;
|
|
23
|
+
nativeTransfers(): Promise<any>;
|
|
24
|
+
totalSize(): Promise<any>;
|
|
25
|
+
totalTransactions(): Promise<any>;
|
|
26
|
+
totalBlocks(): Promise<any>;
|
|
27
|
+
nativeCalls(): Promise<any>;
|
|
28
|
+
participating(): Promise<any>;
|
|
29
|
+
participate(address: any): Promise<any>;
|
|
30
|
+
createContractAddress(owner: any, code: any, params: any): Promise<any>;
|
|
31
|
+
deployContract(code: any, params: any): Promise<any>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import socketRequestClient from 'socket-request-client';
|
|
2
|
+
export default class Client {
|
|
3
|
+
url: string;
|
|
4
|
+
networkVersion: string;
|
|
5
|
+
client: socketRequestClient;
|
|
6
|
+
constructor(url?: string, networkVersion?: string);
|
|
7
|
+
init(): Promise<void>;
|
|
8
|
+
get pubsub(): {
|
|
9
|
+
publish: any;
|
|
10
|
+
subscribe: any;
|
|
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
|
+
totalBlocks(): number;
|
|
35
|
+
nativeCalls(): number;
|
|
36
|
+
participating(): boolean;
|
|
37
|
+
participate(address: string): {};
|
|
38
|
+
createContractAddress(owner: string, code: string, params: {}): {};
|
|
39
|
+
deployContract(code: string, params: {}): {};
|
|
40
|
+
}
|
package/exports/ws.js
CHANGED
|
@@ -1,114 +1,106 @@
|
|
|
1
|
-
import socketRequestClient from 'socket-request-client'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
createContractAddress(owner, code, params) {
|
|
109
|
-
return this.request('createContractAddress', { owner, code, params })
|
|
110
|
-
}
|
|
111
|
-
deployContract(code, params) {
|
|
112
|
-
return this.request('deployContract', { code, params })
|
|
113
|
-
}
|
|
114
|
-
}
|
|
1
|
+
import socketRequestClient from 'socket-request-client';
|
|
2
|
+
|
|
3
|
+
class Client {
|
|
4
|
+
url;
|
|
5
|
+
networkVersion;
|
|
6
|
+
client;
|
|
7
|
+
constructor(url = 'ws://localhost:4040', networkVersion = 'leofcoin-peach') {
|
|
8
|
+
this.url = url;
|
|
9
|
+
this.networkVersion = networkVersion;
|
|
10
|
+
}
|
|
11
|
+
async init() {
|
|
12
|
+
this.client = await socketRequestClient(this.url, this.networkVersion);
|
|
13
|
+
}
|
|
14
|
+
get pubsub() {
|
|
15
|
+
return {
|
|
16
|
+
publish: this.client.pubsub.publish,
|
|
17
|
+
subscribe: this.client.pubsub.subscribe
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
request(url, params) {
|
|
21
|
+
return this.client.request({ url, params });
|
|
22
|
+
}
|
|
23
|
+
balances() {
|
|
24
|
+
return this.request('balances');
|
|
25
|
+
}
|
|
26
|
+
balanceOf(address, format) {
|
|
27
|
+
return this.request('balanceOf', { address, format });
|
|
28
|
+
}
|
|
29
|
+
selectedAccount() {
|
|
30
|
+
return this.request('selectedAccount');
|
|
31
|
+
}
|
|
32
|
+
selectAccount(address) {
|
|
33
|
+
return this.request('selectAccount', { address });
|
|
34
|
+
}
|
|
35
|
+
accounts() {
|
|
36
|
+
return this.request('accounts');
|
|
37
|
+
}
|
|
38
|
+
hasTransactionToHandle() {
|
|
39
|
+
return this.request('hasTransactionToHandle');
|
|
40
|
+
}
|
|
41
|
+
getBlock(index) {
|
|
42
|
+
return this.request('getBlock', { index });
|
|
43
|
+
}
|
|
44
|
+
blocks(amount) {
|
|
45
|
+
return this.request('blocks', { amount });
|
|
46
|
+
}
|
|
47
|
+
sendTransaction(transaction) {
|
|
48
|
+
return this.request('sendTransaction', transaction);
|
|
49
|
+
}
|
|
50
|
+
peerId() {
|
|
51
|
+
return this.request('peerId');
|
|
52
|
+
}
|
|
53
|
+
peers() {
|
|
54
|
+
return this.request('peers');
|
|
55
|
+
}
|
|
56
|
+
validators() {
|
|
57
|
+
return this.request('validators');
|
|
58
|
+
}
|
|
59
|
+
lookup(name) {
|
|
60
|
+
return this.request('lookup', { name });
|
|
61
|
+
}
|
|
62
|
+
staticCall(contract, method, params) {
|
|
63
|
+
return this.request('staticCall', { contract, method, params });
|
|
64
|
+
}
|
|
65
|
+
nativeBurns() {
|
|
66
|
+
return this.request('nativeBurns');
|
|
67
|
+
}
|
|
68
|
+
contracts() {
|
|
69
|
+
return this.request('contracts');
|
|
70
|
+
}
|
|
71
|
+
nativeMints() {
|
|
72
|
+
return this.request('nativeMints');
|
|
73
|
+
}
|
|
74
|
+
nativeToken() {
|
|
75
|
+
return this.request('nativeToken');
|
|
76
|
+
}
|
|
77
|
+
nativeTransfers() {
|
|
78
|
+
return this.request('nativeTransfers');
|
|
79
|
+
}
|
|
80
|
+
totalSize() {
|
|
81
|
+
return this.request('totalSize');
|
|
82
|
+
}
|
|
83
|
+
totalTransactions() {
|
|
84
|
+
return this.request('totalTransactions');
|
|
85
|
+
}
|
|
86
|
+
totalBlocks() {
|
|
87
|
+
return this.request('totalBlocks');
|
|
88
|
+
}
|
|
89
|
+
nativeCalls() {
|
|
90
|
+
return this.request('nativeCalls');
|
|
91
|
+
}
|
|
92
|
+
participating() {
|
|
93
|
+
return this.request('participating');
|
|
94
|
+
}
|
|
95
|
+
participate(address) {
|
|
96
|
+
return this.request('participate', { address });
|
|
97
|
+
}
|
|
98
|
+
createContractAddress(owner, code, params) {
|
|
99
|
+
return this.request('createContractAddress', { owner, code, params });
|
|
100
|
+
}
|
|
101
|
+
deployContract(code, params) {
|
|
102
|
+
return this.request('deployContract', { code, params });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export { Client as default };
|
package/package.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leofcoin/endpoint-clients",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./ws": "./exports/ws.js",
|
|
7
7
|
"./http": "./exports/http.js"
|
|
8
8
|
},
|
|
9
|
+
"types": "./exports/types/index.d.ts",
|
|
9
10
|
"type": "module",
|
|
10
11
|
"scripts": {
|
|
12
|
+
"build": "rollup -c",
|
|
11
13
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
12
14
|
},
|
|
13
15
|
"repository": {
|
|
@@ -20,5 +22,13 @@
|
|
|
20
22
|
"bugs": {
|
|
21
23
|
"url": "https://github.com/leofcoin/endpoint-clients/issues"
|
|
22
24
|
},
|
|
23
|
-
"homepage": "https://github.com/leofcoin/endpoint-clients#readme"
|
|
25
|
+
"homepage": "https://github.com/leofcoin/endpoint-clients#readme",
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@rollup/plugin-typescript": "^11.0.0",
|
|
28
|
+
"rollup": "^3.14.0",
|
|
29
|
+
"tslib": "^2.5.0"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"socket-request-client": "^1.7.3"
|
|
33
|
+
}
|
|
24
34
|
}
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import typescript from '@rollup/plugin-typescript'
|
|
2
|
+
import tsConfig from './tsconfig.json' assert { type: 'json'}
|
|
3
|
+
export default [{
|
|
4
|
+
input: ['./src/index.ts', './src/http.ts', './src/ws.ts'],
|
|
5
|
+
output: {
|
|
6
|
+
dir: './exports',
|
|
7
|
+
format: 'es'
|
|
8
|
+
},
|
|
9
|
+
plugins: [
|
|
10
|
+
typescript(tsConfig)
|
|
11
|
+
],
|
|
12
|
+
external: [
|
|
13
|
+
'./identity.js'
|
|
14
|
+
]
|
|
15
|
+
}]
|
package/src/http.ts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
export default class {
|
|
2
|
+
get isHttpClient() {
|
|
3
|
+
return true
|
|
4
|
+
}
|
|
5
|
+
constructor(url, networkVersion) {
|
|
6
|
+
this.url = url
|
|
7
|
+
this.networkVersion = networkVersion
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async _fetch(method, params) {
|
|
11
|
+
params = new URLSearchParams(params).toString()
|
|
12
|
+
const response = await fetch(`${this.url}/${method}?${params}`)
|
|
13
|
+
return response.json()
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
balances() {
|
|
17
|
+
return this._fetch('balances')
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
balanceOf(address, format) {
|
|
21
|
+
return this._fetch(`balanceOf`, {address, format})
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
selectedAccount() {
|
|
25
|
+
return this._fetch('selectedAccount')
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
selectAccount(address) {
|
|
29
|
+
return this._fetch('selectAccount', {address})
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
accounts() {
|
|
33
|
+
return this._fetch('accounts')
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
hasTransactionToHandle() {
|
|
37
|
+
return this._fetch('hasTransactionToHandle')
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
getBlock(index) {
|
|
41
|
+
return this._fetch('getBlock', { index })
|
|
42
|
+
}
|
|
43
|
+
blocks(amount) {
|
|
44
|
+
return this._fetch('blocks', {amount})
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
sendTransaction(transaction) {
|
|
48
|
+
return this._fetch('sendTransaction', transaction)
|
|
49
|
+
}
|
|
50
|
+
peerId() {
|
|
51
|
+
return this._fetch('peerId')
|
|
52
|
+
}
|
|
53
|
+
peers() {
|
|
54
|
+
return this._fetch('peers')
|
|
55
|
+
}
|
|
56
|
+
validators() {
|
|
57
|
+
return this._fetch('validators')
|
|
58
|
+
}
|
|
59
|
+
lookup(name) {
|
|
60
|
+
return this._fetch('lookup', { name })
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
staticCall(contract, method, params) {
|
|
64
|
+
return this._fetch('staticCall', {contract, method, params})
|
|
65
|
+
}
|
|
66
|
+
nativeBurns() {
|
|
67
|
+
return this._fetch('nativeBurns')
|
|
68
|
+
}
|
|
69
|
+
contracts() {
|
|
70
|
+
return this._fetch('contracts')
|
|
71
|
+
}
|
|
72
|
+
nativeMints() {
|
|
73
|
+
return this._fetch('nativeMints')
|
|
74
|
+
}
|
|
75
|
+
nativeToken() {
|
|
76
|
+
return this._fetch('nativeToken')
|
|
77
|
+
}
|
|
78
|
+
nativeTransfers() {
|
|
79
|
+
return this._fetch('nativeTransfers')
|
|
80
|
+
}
|
|
81
|
+
totalSize() {
|
|
82
|
+
return this._fetch('totalSize')
|
|
83
|
+
}
|
|
84
|
+
totalTransactions() {
|
|
85
|
+
return this._fetch('totalTransactions')
|
|
86
|
+
}
|
|
87
|
+
totalBlocks() {
|
|
88
|
+
return this._fetch('totalBlocks')
|
|
89
|
+
}
|
|
90
|
+
nativeCalls() {
|
|
91
|
+
return this._fetch('nativeCalls')
|
|
92
|
+
}
|
|
93
|
+
participating() {
|
|
94
|
+
return this._fetch('participating')
|
|
95
|
+
}
|
|
96
|
+
participate(address) {
|
|
97
|
+
return this._fetch('participate', { address })
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
createContractAddress(owner, code, params) {
|
|
101
|
+
return this._fetch('createContractAddress', { owner, code, params })
|
|
102
|
+
}
|
|
103
|
+
deployContract(code, params) {
|
|
104
|
+
return this._fetch('deployContract', { code, params })
|
|
105
|
+
}
|
|
106
|
+
}
|
package/src/index.ts
ADDED
package/src/ws.ts
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import socketRequestClient from 'socket-request-client'
|
|
2
|
+
|
|
3
|
+
export default class Client {
|
|
4
|
+
url: string
|
|
5
|
+
networkVersion: string
|
|
6
|
+
client: socketRequestClient
|
|
7
|
+
|
|
8
|
+
constructor(url = 'ws://localhost:4040', networkVersion = 'leofcoin-peach') {
|
|
9
|
+
this.url = url
|
|
10
|
+
this.networkVersion = networkVersion
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async init() {
|
|
14
|
+
this.client = await socketRequestClient(this.url, this.networkVersion)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
get pubsub() {
|
|
18
|
+
return {
|
|
19
|
+
publish: this.client.pubsub.publish,
|
|
20
|
+
subscribe: this.client.pubsub.subscribe
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
request(url: string, params?: {}) {
|
|
25
|
+
return this.client.request({url, params})
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
balances() {
|
|
29
|
+
return this.request('balances')
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
balanceOf(address: string, format: boolean) {
|
|
33
|
+
return this.request('balanceOf', {address, format})
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
selectedAccount() {
|
|
37
|
+
return this.request('selectedAccount')
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
selectAccount(address: any) {
|
|
41
|
+
return this.request('selectAccount', {address})
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
accounts() {
|
|
45
|
+
return this.request('accounts')
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
hasTransactionToHandle() {
|
|
49
|
+
return this.request('hasTransactionToHandle')
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
getBlock(index: number) {
|
|
53
|
+
return this.request('getBlock', { index })
|
|
54
|
+
}
|
|
55
|
+
blocks(amount: number) {
|
|
56
|
+
return this.request('blocks', {amount})
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
sendTransaction(transaction) {
|
|
60
|
+
return this.request('sendTransaction', transaction)
|
|
61
|
+
}
|
|
62
|
+
peerId() {
|
|
63
|
+
return this.request('peerId')
|
|
64
|
+
}
|
|
65
|
+
peers() {
|
|
66
|
+
return this.request('peers')
|
|
67
|
+
}
|
|
68
|
+
validators() {
|
|
69
|
+
return this.request('validators')
|
|
70
|
+
}
|
|
71
|
+
lookup(name: string) {
|
|
72
|
+
return this.request('lookup', { name })
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
staticCall(contract: string, method: string, params: {}) {
|
|
76
|
+
return this.request('staticCall', {contract, method, params})
|
|
77
|
+
}
|
|
78
|
+
nativeBurns(): number {
|
|
79
|
+
return this.request('nativeBurns')
|
|
80
|
+
}
|
|
81
|
+
contracts(): number {
|
|
82
|
+
return this.request('contracts')
|
|
83
|
+
}
|
|
84
|
+
nativeMints(): number {
|
|
85
|
+
return this.request('nativeMints')
|
|
86
|
+
}
|
|
87
|
+
nativeToken(): number {
|
|
88
|
+
return this.request('nativeToken')
|
|
89
|
+
}
|
|
90
|
+
nativeTransfers(): number {
|
|
91
|
+
return this.request('nativeTransfers')
|
|
92
|
+
}
|
|
93
|
+
totalSize(): number {
|
|
94
|
+
return this.request('totalSize')
|
|
95
|
+
}
|
|
96
|
+
totalTransactions(): number {
|
|
97
|
+
return this.request('totalTransactions')
|
|
98
|
+
}
|
|
99
|
+
totalBlocks(): number {
|
|
100
|
+
return this.request('totalBlocks')
|
|
101
|
+
}
|
|
102
|
+
nativeCalls(): number {
|
|
103
|
+
return this.request('nativeCalls')
|
|
104
|
+
}
|
|
105
|
+
participating(): boolean {
|
|
106
|
+
return this.request('participating')
|
|
107
|
+
}
|
|
108
|
+
participate(address: string): {} {
|
|
109
|
+
return this.request('participate', { address })
|
|
110
|
+
}
|
|
111
|
+
createContractAddress(owner: string, code: string, params: {}): {} {
|
|
112
|
+
return this.request('createContractAddress', { owner, code, params })
|
|
113
|
+
}
|
|
114
|
+
deployContract(code: string, params: {}): {} {
|
|
115
|
+
return this.request('deployContract', { code, params })
|
|
116
|
+
}
|
|
117
|
+
}
|
package/test/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { needsImplementations } from './spec.js';
|
|
2
|
-
import WsClient from './../exports/ws.js'
|
|
3
|
-
import HttpClient from './../exports/http.js'
|
|
4
|
-
|
|
5
|
-
try {
|
|
6
|
-
const wsNeeds = needsImplementations(new WsClient())
|
|
7
|
-
if (wsNeeds.length > 0) throw new Error(`ws: missing implementations ${wsNeeds.length > 2 ? wsNeeds.join(', ') : wsNeeds.join(' & ')}`)
|
|
8
|
-
|
|
9
|
-
const httpNeeds = needsImplementations(new HttpClient())
|
|
10
|
-
if (httpNeeds.length > 0) throw new Error(`http: missing implementations ${httpNeeds.length > 2 ? httpNeeds.join(', ') : httpNeeds.join(' & ')}`)
|
|
11
|
-
} catch (error) {
|
|
12
|
-
console.error(error);
|
|
1
|
+
import { needsImplementations } from './spec.js';
|
|
2
|
+
import WsClient from './../exports/ws.js'
|
|
3
|
+
import HttpClient from './../exports/http.js'
|
|
4
|
+
|
|
5
|
+
try {
|
|
6
|
+
const wsNeeds = needsImplementations(new WsClient())
|
|
7
|
+
if (wsNeeds.length > 0) throw new Error(`ws: missing implementations ${wsNeeds.length > 2 ? wsNeeds.join(', ') : wsNeeds.join(' & ')}`)
|
|
8
|
+
|
|
9
|
+
const httpNeeds = needsImplementations(new HttpClient())
|
|
10
|
+
if (httpNeeds.length > 0) throw new Error(`http: missing implementations ${httpNeeds.length > 2 ? httpNeeds.join(', ') : httpNeeds.join(' & ')}`)
|
|
11
|
+
} catch (error) {
|
|
12
|
+
console.error(error);
|
|
13
13
|
}
|
package/test/spec.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
export const implementations = [
|
|
2
|
-
'accounts',
|
|
3
|
-
'balanceOf',
|
|
4
|
-
'balances',
|
|
5
|
-
'blocks',
|
|
6
|
-
'contracts',
|
|
7
|
-
'createContractAddress',
|
|
8
|
-
'createTransactionFrom',
|
|
9
|
-
'deployContract',
|
|
10
|
-
'getBlock',
|
|
11
|
-
'hasTransactionToHandle',
|
|
12
|
-
'lookup',
|
|
13
|
-
'nativeBurns',
|
|
14
|
-
'nativeCalls',
|
|
15
|
-
'nativeMints',
|
|
16
|
-
'nativeToken',
|
|
17
|
-
'nativeTransfers',
|
|
18
|
-
'participate',
|
|
19
|
-
'participating',
|
|
20
|
-
'peerId',
|
|
21
|
-
'peers',
|
|
22
|
-
'pubsub',
|
|
23
|
-
'selectAccount',
|
|
24
|
-
'selectedAccount',
|
|
25
|
-
'staticCall',
|
|
26
|
-
'totalBlocks',
|
|
27
|
-
'totalSize',
|
|
28
|
-
'totalTransactions',
|
|
29
|
-
'validators'
|
|
30
|
-
]
|
|
31
|
-
|
|
32
|
-
export const needsImplementations = (client) => {
|
|
33
|
-
const needs = []
|
|
34
|
-
for (const key of implementations) {
|
|
35
|
-
try {
|
|
36
|
-
if (!client[key] && key === 'pubsub' && !client.isHttpClient) needs.push(key)
|
|
37
|
-
} catch (error) {
|
|
38
|
-
if (error.message !== "Cannot read properties of undefined (reading 'pubsub')") throw new Error(error)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
return needs
|
|
1
|
+
export const implementations = [
|
|
2
|
+
'accounts',
|
|
3
|
+
'balanceOf',
|
|
4
|
+
'balances',
|
|
5
|
+
'blocks',
|
|
6
|
+
'contracts',
|
|
7
|
+
'createContractAddress',
|
|
8
|
+
'createTransactionFrom',
|
|
9
|
+
'deployContract',
|
|
10
|
+
'getBlock',
|
|
11
|
+
'hasTransactionToHandle',
|
|
12
|
+
'lookup',
|
|
13
|
+
'nativeBurns',
|
|
14
|
+
'nativeCalls',
|
|
15
|
+
'nativeMints',
|
|
16
|
+
'nativeToken',
|
|
17
|
+
'nativeTransfers',
|
|
18
|
+
'participate',
|
|
19
|
+
'participating',
|
|
20
|
+
'peerId',
|
|
21
|
+
'peers',
|
|
22
|
+
'pubsub',
|
|
23
|
+
'selectAccount',
|
|
24
|
+
'selectedAccount',
|
|
25
|
+
'staticCall',
|
|
26
|
+
'totalBlocks',
|
|
27
|
+
'totalSize',
|
|
28
|
+
'totalTransactions',
|
|
29
|
+
'validators'
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
export const needsImplementations = (client) => {
|
|
33
|
+
const needs = []
|
|
34
|
+
for (const key of implementations) {
|
|
35
|
+
try {
|
|
36
|
+
if (!client[key] && key === 'pubsub' && !client.isHttpClient) needs.push(key)
|
|
37
|
+
} catch (error) {
|
|
38
|
+
if (error.message !== "Cannot read properties of undefined (reading 'pubsub')") throw new Error(error)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
return needs
|
|
43
43
|
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "es2022",
|
|
4
|
+
"target": "es2022",
|
|
5
|
+
"outDir": "./exports",
|
|
6
|
+
"moduleResolution":"NodeNext",
|
|
7
|
+
"allowJs": true,
|
|
8
|
+
"declaration": true,
|
|
9
|
+
"declarationDir": "./exports/types",
|
|
10
|
+
"allowSyntheticDefaultImports": true,
|
|
11
|
+
"resolveJsonModule": true
|
|
12
|
+
},
|
|
13
|
+
"include": [
|
|
14
|
+
"./src/**/*"
|
|
15
|
+
],
|
|
16
|
+
"exclude": ["./node_modules"]
|
|
17
|
+
}
|