@leofcoin/endpoints 0.3.2 → 0.3.4
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/api.md +336 -0
- package/exports/http.js +2 -1
- package/exports/ws.js +1 -1
- package/package.json +1 -1
package/exports/api.md
ADDED
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
#### [selectAccount(address: `string`)](https://remote.leofcoin.org/select-account?address=)
|
|
2
|
+
|
|
3
|
+
`address`: desired address
|
|
4
|
+
|
|
5
|
+
> set default account to given address
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
await client.selectAccount(address)
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
<br>
|
|
12
|
+
|
|
13
|
+
#### [getBlock(index: `number`)](https://remote.leofcoin.org/getblock?index=0)
|
|
14
|
+
|
|
15
|
+
`index`: index of the block to fetch<br>
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
await client.getBlock(10)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
<br>
|
|
22
|
+
|
|
23
|
+
#### [blocks(amount)](https://remote.leofcoin.org/blocks)
|
|
24
|
+
|
|
25
|
+
`amount`: the amount to slice
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
await client.blocks(-25)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
<br>
|
|
32
|
+
|
|
33
|
+
#### createTransactionFrom(from: `string`, to: `string`, method: `string`, parameters: `array`, nonce: `number` | `undefined`)
|
|
34
|
+
|
|
35
|
+
`from`:<br>
|
|
36
|
+
`to`: <br>
|
|
37
|
+
`method`: <br>
|
|
38
|
+
`parameters`: <br>
|
|
39
|
+
`nonce`: <br>
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
await client.createTransactionFrom(from, to, method, parameters, nonce)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
<br>
|
|
46
|
+
|
|
47
|
+
#### [lookup(name: `string`)](https://remote.leofcoin.org/lookup?name=ArtOnlineContractFactory)
|
|
48
|
+
|
|
49
|
+
`name`: name of the contract to lookup the address and owner of
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
await client.lookup('contractName')
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
<br>
|
|
56
|
+
|
|
57
|
+
#### participate(address: `string`)
|
|
58
|
+
|
|
59
|
+
`address`: <br>
|
|
60
|
+
|
|
61
|
+
```js
|
|
62
|
+
await client.participate(address)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
<br>
|
|
66
|
+
|
|
67
|
+
#### staticCall(contract: `string`, method: `string`, params: `array`)
|
|
68
|
+
|
|
69
|
+
`contract`: contract address todo the call on
|
|
70
|
+
`method`: method/function to call
|
|
71
|
+
`params`: array containing params needed to call the desired method
|
|
72
|
+
|
|
73
|
+
```js
|
|
74
|
+
await client.staticCall(contract, method, params)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
<br>
|
|
78
|
+
|
|
79
|
+
#### createContractAddress(owner: `string`, code: `string`, params: `array`)
|
|
80
|
+
|
|
81
|
+
`owner`: address of the deployer<br>
|
|
82
|
+
`code`: contract as a string<br>
|
|
83
|
+
`params`: contract constructor params<br>
|
|
84
|
+
|
|
85
|
+
```js
|
|
86
|
+
const address = await client.createContractAddress(owner, code, params)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
<br>
|
|
90
|
+
|
|
91
|
+
#### deployContract(code: `string`, params: `array`)
|
|
92
|
+
|
|
93
|
+
`code`: contract as a string<br>
|
|
94
|
+
`params`: contract constructor params<br>
|
|
95
|
+
|
|
96
|
+
```js
|
|
97
|
+
const tx = await client.deployContract(code, params)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
<br>
|
|
101
|
+
|
|
102
|
+
#### [accounts()](https://remote.leofcoin.org/accounts)
|
|
103
|
+
|
|
104
|
+
```js
|
|
105
|
+
await client.accounts()
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
<br>
|
|
109
|
+
|
|
110
|
+
#### [hasTransactionToHandle()](https://remote.leofcoin.org/hasTransactionToHandle)
|
|
111
|
+
|
|
112
|
+
```js
|
|
113
|
+
await client.hasTransactionToHandle()
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
<br>
|
|
117
|
+
|
|
118
|
+
#### [balances()](https://remote.leofcoin.org/balances)
|
|
119
|
+
|
|
120
|
+
> returns all balances
|
|
121
|
+
|
|
122
|
+
```js
|
|
123
|
+
await client.balances()
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
<br>
|
|
127
|
+
|
|
128
|
+
#### [balancOf(address: `string`, format: `boolean`)](https://remote.leofcoin.org/balanceOf?address=YTqxKshWH4Qo7KprGYxQVCNYutedaE6YGoUdUPnUdFUVBPrTzgsrP&format=true)
|
|
129
|
+
|
|
130
|
+
`address`: The address to check<br>
|
|
131
|
+
`format`: Wether or not to format<br>
|
|
132
|
+
|
|
133
|
+
> returns the balance of given address as BigNumber or string (when format is true)
|
|
134
|
+
|
|
135
|
+
```js
|
|
136
|
+
await client.balanceOf(address, true)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
<br>
|
|
140
|
+
|
|
141
|
+
#### [getNonce(address: `string`)](https://remote.leofcoin.org/getNonce?address=YTqxKshWH4Qo7KprGYxQVCNYutedaE6YGoUdUPnUdFUVBPrTzgsrP)
|
|
142
|
+
|
|
143
|
+
`address`: The address to check<br>
|
|
144
|
+
`format`: Wether or not to format<br>
|
|
145
|
+
|
|
146
|
+
> returns the balance of given address as BigNumber or string (when format is true)
|
|
147
|
+
|
|
148
|
+
```js
|
|
149
|
+
await client.getNonce(address)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
<br>
|
|
153
|
+
|
|
154
|
+
#### [selectedAccount()](https://remote.leofcoin.org/selectedAccount)
|
|
155
|
+
|
|
156
|
+
```js
|
|
157
|
+
await client.selectedAccount()
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
<br>
|
|
161
|
+
|
|
162
|
+
#### [peerId()](https://remote.leofcoin.org/peerId)
|
|
163
|
+
|
|
164
|
+
```js
|
|
165
|
+
await client.peerId()
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
<br>
|
|
169
|
+
|
|
170
|
+
#### [peers()](https://remote.leofcoin.org/peers)
|
|
171
|
+
|
|
172
|
+
```js
|
|
173
|
+
await client.peers()
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
<br>
|
|
177
|
+
|
|
178
|
+
#### [validators()](https://remote.leofcoin.org/validators)
|
|
179
|
+
|
|
180
|
+
```js
|
|
181
|
+
await client.validators()
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
<br>
|
|
185
|
+
|
|
186
|
+
#### [nativeBurns()](https://remote.leofcoin.org/nativeBurns)
|
|
187
|
+
|
|
188
|
+
```js
|
|
189
|
+
await client.nativeBurns()
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
<br>
|
|
193
|
+
|
|
194
|
+
#### [contracts()](https://remote.leofcoin.org/contracts)
|
|
195
|
+
|
|
196
|
+
```js
|
|
197
|
+
await client.contracts()
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
<br>
|
|
201
|
+
|
|
202
|
+
#### [nativeMints()](https://remote.leofcoin.org/nativeMints)
|
|
203
|
+
|
|
204
|
+
```js
|
|
205
|
+
await client.nativeMints()
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
<br>
|
|
209
|
+
|
|
210
|
+
#### [nativeToken()](https://remote.leofcoin.org/nativeToken)
|
|
211
|
+
|
|
212
|
+
```js
|
|
213
|
+
await client.nativeToken()
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
<br>
|
|
217
|
+
|
|
218
|
+
#### [nativeTransfers()](https://remote.leofcoin.org/nativeTransfers)
|
|
219
|
+
|
|
220
|
+
```js
|
|
221
|
+
await client.nativeTransfers()
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
<br>
|
|
225
|
+
|
|
226
|
+
#### [totalSize()](https://remote.leofcoin.org/totalSize)
|
|
227
|
+
|
|
228
|
+
```js
|
|
229
|
+
await client.totalSize()
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
<br>
|
|
233
|
+
|
|
234
|
+
#### [totalTransactions()](https://remote.leofcoin.org/totalTransactions)
|
|
235
|
+
|
|
236
|
+
```js
|
|
237
|
+
await client.totalTransactions()
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
<br>
|
|
241
|
+
|
|
242
|
+
#### [poolTransactions()](https://remote.leofcoin.org/poolTransactions)
|
|
243
|
+
|
|
244
|
+
```js
|
|
245
|
+
await client.poolTransactions()
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
<br>
|
|
249
|
+
|
|
250
|
+
#### [transactionsInPool()](https://remote.leofcoin.org/transactionsInPool)
|
|
251
|
+
|
|
252
|
+
```js
|
|
253
|
+
await client.transactionsInPool()
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
<br>
|
|
257
|
+
|
|
258
|
+
#### [transactionPoolSize()](https://remote.leofcoin.org/transactionPoolSize)
|
|
259
|
+
|
|
260
|
+
```js
|
|
261
|
+
await client.transactionPoolSize()
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
<br>
|
|
265
|
+
|
|
266
|
+
#### [totalBlocks()](https://remote.leofcoin.org/totalBlocks)
|
|
267
|
+
|
|
268
|
+
```js
|
|
269
|
+
await client.totalBlocks()
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
<br>
|
|
273
|
+
|
|
274
|
+
#### [nativeCalls()](https://remote.leofcoin.org/nativeCalls)
|
|
275
|
+
|
|
276
|
+
```js
|
|
277
|
+
await client.nativeCalls()
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
<br>
|
|
281
|
+
|
|
282
|
+
#### [participating()](https://remote.leofcoin.org/participating)
|
|
283
|
+
|
|
284
|
+
```js
|
|
285
|
+
await client.participating()
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
<br>
|
|
289
|
+
|
|
290
|
+
#### [network()](https://remote.leofcoin.org/network)
|
|
291
|
+
|
|
292
|
+
```js
|
|
293
|
+
await client.network()
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
<br>
|
|
297
|
+
|
|
298
|
+
#### [networkStats()](https://remote.leofcoin.org/networkStats)
|
|
299
|
+
|
|
300
|
+
```js
|
|
301
|
+
await client.networkStats()
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
<br>
|
|
305
|
+
|
|
306
|
+
#### [networkStats()](https://remote.leofcoin.org/networkStats)
|
|
307
|
+
|
|
308
|
+
```js
|
|
309
|
+
await client.networkStats()
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
<br>
|
|
313
|
+
|
|
314
|
+
#### [lastBlock()](https://remote.leofcoin.org/lastBlock)
|
|
315
|
+
|
|
316
|
+
```js
|
|
317
|
+
await client.lastBlock()
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
<br>
|
|
321
|
+
|
|
322
|
+
#### [blockHashMap()](https://remote.leofcoin.org/blockHashMap)
|
|
323
|
+
|
|
324
|
+
```js
|
|
325
|
+
await client.blockHashMap()
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
<br>
|
|
329
|
+
|
|
330
|
+
#### [bootstrap()](https://remote.leofcoin.org/bootstrap)
|
|
331
|
+
|
|
332
|
+
```js
|
|
333
|
+
await client.bootstrap()
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
<br>
|
package/exports/http.js
CHANGED
|
@@ -75,7 +75,8 @@ export default (chain, port, networkVersion, remote = false) => {
|
|
|
75
75
|
});
|
|
76
76
|
router.get('/getBlock', async (ctx) => (ctx.body = await chain.getBlock(ctx.query.index)));
|
|
77
77
|
router.get('/blocks', async (ctx) => {
|
|
78
|
-
|
|
78
|
+
const limit = ctx.query.amount;
|
|
79
|
+
ctx.body = await globalThis.blockStore.values(limit);
|
|
79
80
|
});
|
|
80
81
|
router.get('/sendTransaction', async (ctx) => {
|
|
81
82
|
try {
|
package/exports/ws.js
CHANGED
|
@@ -45,7 +45,7 @@ export default (chain, port, networkVersion, remote = false) => {
|
|
|
45
45
|
hasTransactionToHandle: async ({ send }) => send(await chain.hasTransactionToHandle()),
|
|
46
46
|
getBlock: async ({ index }, { send }) => send(await chain.getBlock(index)),
|
|
47
47
|
blocks: async ({ amount }, { send }) => {
|
|
48
|
-
send(await
|
|
48
|
+
send(await globalThis.blockStore.values(amount));
|
|
49
49
|
},
|
|
50
50
|
sendTransaction: async (transaction, { send }) => {
|
|
51
51
|
try {
|