@leofcoin/endpoints 0.2.2 → 0.2.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/README.md +7 -0
- package/exports/api.md +31 -22
- package/exports/http.js +11 -6
- package/exports/ws.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
package/exports/api.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#### selectAccount(address: `string`)
|
|
1
|
+
#### [selectAccount(address: `string`)](https://remote.leofcoin.org/select-account?address=)
|
|
2
2
|
`address`: desired address
|
|
3
3
|
> set default account to given address
|
|
4
4
|
```js
|
|
@@ -6,14 +6,14 @@ await client.selectAccount(address)
|
|
|
6
6
|
```
|
|
7
7
|
<br>
|
|
8
8
|
|
|
9
|
-
#### getBlock(index: `number`)
|
|
9
|
+
#### [getBlock(index: `number`)](https://remote.leofcoin.org/getblock?index=0)
|
|
10
10
|
`index`: index of the block to fetch<br>
|
|
11
11
|
```js
|
|
12
12
|
await client.getBlock(10)
|
|
13
13
|
```
|
|
14
14
|
<br>
|
|
15
15
|
|
|
16
|
-
#### blocks(amount)
|
|
16
|
+
#### [blocks(amount)](https://remote.leofcoin.org/blocks)
|
|
17
17
|
`amount`: the amount to slice
|
|
18
18
|
```js
|
|
19
19
|
await client.blocks(-25)
|
|
@@ -32,7 +32,7 @@ await client.createTransactionFrom(from, to, method, parameters, nonce)
|
|
|
32
32
|
```
|
|
33
33
|
<br>
|
|
34
34
|
|
|
35
|
-
#### lookup(name: `string`)
|
|
35
|
+
#### [lookup(name: `string`)](https://remote.leofcoin.org/lookup?name=ArtOnlineContractFactory)
|
|
36
36
|
`name`: name of the contract to lookup the address and owner of
|
|
37
37
|
```js
|
|
38
38
|
await client.lookup('contractName')
|
|
@@ -75,26 +75,26 @@ const tx = await client.deployContract(code, params)
|
|
|
75
75
|
```
|
|
76
76
|
<br>
|
|
77
77
|
|
|
78
|
-
#### accounts()
|
|
78
|
+
#### [accounts()](https://remote.leofcoin.org/accounts)
|
|
79
79
|
```js
|
|
80
80
|
await client.accounts()
|
|
81
81
|
```
|
|
82
82
|
<br>
|
|
83
83
|
|
|
84
|
-
#### hasTransactionToHandle()
|
|
84
|
+
#### [hasTransactionToHandle()](https://remote.leofcoin.org/hasTransactionToHandle)
|
|
85
85
|
```js
|
|
86
86
|
await client.hasTransactionToHandle()
|
|
87
87
|
```
|
|
88
88
|
<br>
|
|
89
89
|
|
|
90
|
-
#### balances()
|
|
90
|
+
#### [balances()](https://remote.leofcoin.org/balances)
|
|
91
91
|
> returns all balances
|
|
92
92
|
```js
|
|
93
93
|
await client.balances()
|
|
94
94
|
```
|
|
95
95
|
<br>
|
|
96
96
|
|
|
97
|
-
#### balancOf(address: `string`, format: `boolean`)
|
|
97
|
+
#### [balancOf(address: `string`, format: `boolean`)](https://remote.leofcoin.org/balanceOf?address=YTqxKshWH4Qo7KprGYxQVCNYutedaE6YGoUdUPnUdFUVBPrTzgsrP&format=true)
|
|
98
98
|
`address`: The address to check<br>
|
|
99
99
|
`format`: Wether or not to format<br>
|
|
100
100
|
> returns the balance of given address as BigNumber or string (when format is true)
|
|
@@ -103,85 +103,94 @@ await client.balanceOf(address, true)
|
|
|
103
103
|
```
|
|
104
104
|
<br>
|
|
105
105
|
|
|
106
|
-
####
|
|
106
|
+
#### [getNonce(address: `string`)](https://remote.leofcoin.org/getNonce?address=YTqxKshWH4Qo7KprGYxQVCNYutedaE6YGoUdUPnUdFUVBPrTzgsrP)
|
|
107
|
+
`address`: The address to check<br>
|
|
108
|
+
`format`: Wether or not to format<br>
|
|
109
|
+
> returns the balance of given address as BigNumber or string (when format is true)
|
|
110
|
+
```js
|
|
111
|
+
await client.getNonce(address)
|
|
112
|
+
```
|
|
113
|
+
<br>
|
|
114
|
+
|
|
115
|
+
#### [selectedAccount()](https://remote.leofcoin.org/selectedAccount)
|
|
107
116
|
```js
|
|
108
117
|
await client.selectedAccount()
|
|
109
118
|
```
|
|
110
119
|
<br>
|
|
111
120
|
|
|
112
|
-
#### peerId()
|
|
121
|
+
#### [peerId()](https://remote.leofcoin.org/peerId)
|
|
113
122
|
```js
|
|
114
123
|
await client.peerId()
|
|
115
124
|
```
|
|
116
125
|
<br>
|
|
117
126
|
|
|
118
|
-
#### peers()
|
|
127
|
+
#### [peers()](https://remote.leofcoin.org/peers)
|
|
119
128
|
```js
|
|
120
129
|
await client.peers()
|
|
121
130
|
```
|
|
122
131
|
<br>
|
|
123
132
|
|
|
124
|
-
#### validators()
|
|
133
|
+
#### [validators()](https://remote.leofcoin.org/validators)
|
|
125
134
|
```js
|
|
126
135
|
await client.validators()
|
|
127
136
|
```
|
|
128
137
|
<br>
|
|
129
138
|
|
|
130
|
-
#### nativeBurns()
|
|
139
|
+
#### [nativeBurns()](https://remote.leofcoin.org/nativeBurns)
|
|
131
140
|
```js
|
|
132
141
|
await client.nativeBurns()
|
|
133
142
|
```
|
|
134
143
|
<br>
|
|
135
144
|
|
|
136
|
-
#### contracts()
|
|
145
|
+
#### [contracts()](https://remote.leofcoin.org/contracts)
|
|
137
146
|
```js
|
|
138
147
|
await client.contracts()
|
|
139
148
|
```
|
|
140
149
|
<br>
|
|
141
150
|
|
|
142
|
-
#### nativeMints()
|
|
151
|
+
#### [nativeMints()](https://remote.leofcoin.org/nativeMints)
|
|
143
152
|
```js
|
|
144
153
|
await client.nativeMints()
|
|
145
154
|
```
|
|
146
155
|
<br>
|
|
147
156
|
|
|
148
|
-
#### nativeToken()
|
|
157
|
+
#### [nativeToken()](https://remote.leofcoin.org/nativeToken)
|
|
149
158
|
```js
|
|
150
159
|
await client.nativeToken()
|
|
151
160
|
```
|
|
152
161
|
<br>
|
|
153
162
|
|
|
154
|
-
#### nativeTransfers()
|
|
163
|
+
#### [nativeTransfers()](https://remote.leofcoin.org/nativeTransfers)
|
|
155
164
|
```js
|
|
156
165
|
await client. nativeTransfers()
|
|
157
166
|
```
|
|
158
167
|
<br>
|
|
159
168
|
|
|
160
|
-
#### totalSize()
|
|
169
|
+
#### [totalSize()](https://remote.leofcoin.org/totalSize)
|
|
161
170
|
```js
|
|
162
171
|
await client.totalSize()
|
|
163
172
|
```
|
|
164
173
|
<br>
|
|
165
174
|
|
|
166
|
-
#### totalTransactions()
|
|
175
|
+
#### [totalTransactions()](https://remote.leofcoin.org/totalTransactions)
|
|
167
176
|
```js
|
|
168
177
|
await client.totalTransactions()
|
|
169
178
|
```
|
|
170
179
|
<br>
|
|
171
180
|
|
|
172
|
-
#### totalBlocks()
|
|
181
|
+
#### [totalBlocks()](https://remote.leofcoin.org/totalBlocks)
|
|
173
182
|
```js
|
|
174
183
|
await client.totalBlocks()
|
|
175
184
|
```
|
|
176
185
|
<br>
|
|
177
186
|
|
|
178
|
-
#### nativeCalls()
|
|
187
|
+
#### [nativeCalls()](https://remote.leofcoin.org/nativeCalls)
|
|
179
188
|
```js
|
|
180
189
|
await client.nativeCalls()
|
|
181
190
|
```
|
|
182
191
|
<br>
|
|
183
192
|
|
|
184
|
-
#### participating()
|
|
193
|
+
#### [participating()](https://remote.leofcoin.org/participating)
|
|
185
194
|
```js
|
|
186
195
|
await client.participating()
|
|
187
196
|
```
|
package/exports/http.js
CHANGED
|
@@ -25,9 +25,9 @@ export default (chain, port, networkVersion) => {
|
|
|
25
25
|
ctx.body = await chain.balances
|
|
26
26
|
})
|
|
27
27
|
|
|
28
|
-
router.get('balanceOf', async ctx => {
|
|
28
|
+
router.get('/balanceOf', async ctx => {
|
|
29
29
|
const balance = (await chain.balances)[ctx.query.address]
|
|
30
|
-
|
|
30
|
+
ctx.body = ctx.query.format ? formatUnits(balance) : balance
|
|
31
31
|
})
|
|
32
32
|
|
|
33
33
|
router.get('/selectedAccount', ctx => ctx.body = peernet.selectedAccount)
|
|
@@ -47,6 +47,11 @@ export default (chain, port, networkVersion) => {
|
|
|
47
47
|
router.get('/hasTransactionToHandle', async ctx => {
|
|
48
48
|
ctx.body = await chain.hasTransactionToHandle()
|
|
49
49
|
})
|
|
50
|
+
|
|
51
|
+
router.get('/getNonce', async ctx => {
|
|
52
|
+
ctx.body = await chain.getNonce(ctx.query.address)
|
|
53
|
+
})
|
|
54
|
+
|
|
50
55
|
router.get('/getBlock', ctx => ctx.body = chain.blocks[ctx.query.index])
|
|
51
56
|
|
|
52
57
|
router.get('/blocks', ctx => {
|
|
@@ -71,9 +76,9 @@ export default (chain, port, networkVersion) => {
|
|
|
71
76
|
ctx.body = chain.validators
|
|
72
77
|
)
|
|
73
78
|
|
|
74
|
-
router.get('/lookup', ctx =>
|
|
75
|
-
ctx.body = chain.lookup(ctx.query.name)
|
|
76
|
-
)
|
|
79
|
+
router.get('/lookup', async ctx => {
|
|
80
|
+
ctx.body = await chain.lookup(ctx.query.name)
|
|
81
|
+
})
|
|
77
82
|
|
|
78
83
|
router.get('/staticCall', async ctx =>
|
|
79
84
|
ctx.body = await chain.staticCall(ctx.query.contract, ctx.query.method, ctx.query.params)
|
|
@@ -119,7 +124,7 @@ export default (chain, port, networkVersion) => {
|
|
|
119
124
|
ctx.body = chain.participating
|
|
120
125
|
)
|
|
121
126
|
|
|
122
|
-
router.get('participate', async ctx =>
|
|
127
|
+
router.get('/participate', async ctx =>
|
|
123
128
|
ctx.body = await chain.participate(ctx.query.address)
|
|
124
129
|
)
|
|
125
130
|
|
package/exports/ws.js
CHANGED
|
@@ -9,6 +9,7 @@ export default (chain, port, protocol) => {
|
|
|
9
9
|
const balance = (await chain.balances)[address]
|
|
10
10
|
send(format ? formatUnits(balance) : balance)
|
|
11
11
|
},
|
|
12
|
+
getNonce: async ({address}, {send}) => send((await chain.balances)[address]),
|
|
12
13
|
selectedAccount: ({send}) => send(peernet.selectedAccount),
|
|
13
14
|
selectAccount: async ({address}, {send}) => {
|
|
14
15
|
try {
|