@leofcoin/endpoints 0.2.0 → 0.2.1

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 ADDED
@@ -0,0 +1,188 @@
1
+ #### selectAccount(address: `string`)
2
+ `address`: desired address
3
+ > set default account to given address
4
+ ```js
5
+ await client.selectAccount(address)
6
+ ```
7
+ <br>
8
+
9
+ #### getBlock(index: `number`)
10
+ `index`: index of the block to fetch<br>
11
+ ```js
12
+ await client.getBlock(10)
13
+ ```
14
+ <br>
15
+
16
+ #### blocks(amount)
17
+ `amount`: the amount to slice
18
+ ```js
19
+ await client.blocks(-25)
20
+ ```
21
+ <br>
22
+
23
+ #### createTransactionFrom(from: `string`, to: `string`, method: `string`, parameters: `array`, nonce: `number` | `undefined`)
24
+
25
+ `from`:<br>
26
+ `to`: <br>
27
+ `method`: <br>
28
+ `parameters`: <br>
29
+ `nonce`: <br>
30
+ ```js
31
+ await client.createTransactionFrom(from, to, method, parameters, nonce)
32
+ ```
33
+ <br>
34
+
35
+ #### lookup(name: `string`)
36
+ `name`: name of the contract to lookup the address and owner of
37
+ ```js
38
+ await client.lookup('contractName')
39
+ ```
40
+ <br>
41
+
42
+ #### participate(address: `string`)
43
+ `address`: <br>
44
+
45
+ ```js
46
+ await client.participate(address)
47
+ ```
48
+ <br>
49
+
50
+ #### staticCall(contract: `string`, method: `string`, params: `array`)
51
+ `contract`: contract address todo the call on
52
+ `method`: method/function to call
53
+ `params`: array containing params needed to call the desired method
54
+ ```js
55
+ await client.staticCall(contract, method, params)
56
+ ```
57
+ <br>
58
+
59
+ #### createContractAddress(owner: `string`, code: `string`, params: `array`)
60
+ `owner`: address of the deployer<br>
61
+ `code`: contract as a string<br>
62
+ `params`: contract constructor params<br>
63
+
64
+ ```js
65
+ const address = await client.createContractAddress(owner, code, params)
66
+ ```
67
+ <br>
68
+
69
+ #### deployContract(code: `string`, params: `array`)
70
+ `code`: contract as a string<br>
71
+ `params`: contract constructor params<br>
72
+
73
+ ```js
74
+ const tx = await client.deployContract(code, params)
75
+ ```
76
+ <br>
77
+
78
+ #### accounts()
79
+ ```js
80
+ await client.accounts()
81
+ ```
82
+ <br>
83
+
84
+ #### hasTransactionToHandle()
85
+ ```js
86
+ await client.hasTransactionToHandle()
87
+ ```
88
+ <br>
89
+
90
+ #### balances()
91
+ > returns all balances
92
+ ```js
93
+ await client.balances()
94
+ ```
95
+ <br>
96
+
97
+ #### balancOf(address: `string`, format: `boolean`)
98
+ `address`: The address to check<br>
99
+ `format`: Wether or not to format<br>
100
+ > returns the balance of given address as BigNumber or string (when format is true)
101
+ ```js
102
+ await client.balanceOf(address, true)
103
+ ```
104
+ <br>
105
+
106
+ #### selectedAccount()
107
+ ```js
108
+ await client.selectedAccount()
109
+ ```
110
+ <br>
111
+
112
+ #### peerId()
113
+ ```js
114
+ await client.peerId()
115
+ ```
116
+ <br>
117
+
118
+ #### peers()
119
+ ```js
120
+ await client.peers()
121
+ ```
122
+ <br>
123
+
124
+ #### validators()
125
+ ```js
126
+ await client.validators()
127
+ ```
128
+ <br>
129
+
130
+ #### nativeBurns()
131
+ ```js
132
+ await client.nativeBurns()
133
+ ```
134
+ <br>
135
+
136
+ #### contracts()
137
+ ```js
138
+ await client.contracts()
139
+ ```
140
+ <br>
141
+
142
+ #### nativeMints()
143
+ ```js
144
+ await client.nativeMints()
145
+ ```
146
+ <br>
147
+
148
+ #### nativeToken()
149
+ ```js
150
+ await client.nativeToken()
151
+ ```
152
+ <br>
153
+
154
+ #### nativeTransfers()
155
+ ```js
156
+ await client. nativeTransfers()
157
+ ```
158
+ <br>
159
+
160
+ #### totalSize()
161
+ ```js
162
+ await client.totalSize()
163
+ ```
164
+ <br>
165
+
166
+ #### totalTransactions()
167
+ ```js
168
+ await client.totalTransactions()
169
+ ```
170
+ <br>
171
+
172
+ #### totalBlocks()
173
+ ```js
174
+ await client.totalBlocks()
175
+ ```
176
+ <br>
177
+
178
+ #### nativeCalls()
179
+ ```js
180
+ await client.nativeCalls()
181
+ ```
182
+ <br>
183
+
184
+ #### participating()
185
+ ```js
186
+ await client.participating()
187
+ ```
188
+ <br>
package/exports/http.js CHANGED
@@ -2,11 +2,21 @@ import koa from 'koa'
2
2
  import cors from '@koa/cors'
3
3
  import Router from '@koa/router'
4
4
  import {formatUnits} from '@leofcoin/utils'
5
+ import {readFile} from 'fs/promises'
6
+ import Showdown from 'showdown'
5
7
 
6
8
  const api = new koa()
7
9
  const router = new Router()
8
10
 
11
+ const converter = new showdown.Converter()
12
+ const apiFile = await readFile('./api.md')
13
+
9
14
  export default (chain, port, networkVersion) => {
15
+ // api routes
16
+ router.get('/', ctx => {
17
+ ctx.body = converter.makeHtml(apiFile.toString())
18
+ })
19
+
10
20
  router.get('/network', ctx => {
11
21
  ctx.body = networkVersion
12
22
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/endpoints",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "exports": {
@@ -26,6 +26,7 @@
26
26
  "@koa/router": "^12.0.0",
27
27
  "@leofcoin/utils": "^1.1.5",
28
28
  "koa": "^2.14.1",
29
+ "showdown": "^2.1.0",
29
30
  "socket-request-server": "^1.6.3"
30
31
  }
31
32
  }
@@ -0,0 +1,30 @@
1
+ import resolve from '@rollup/plugin-node-resolve'
2
+ import commonjs from '@rollup/plugin-commonjs'
3
+ import json from '@rollup/plugin-json'
4
+ import wasm from '@rollup/plugin-wasm'
5
+ import rimraf from 'rimraf'
6
+
7
+ rimraf.sync('./exports/**')
8
+
9
+
10
+ export default [{
11
+ input: ['./src/peernet.ts', './node_modules/@leofcoin/storage/exports/browser-store.js'],
12
+ output: {
13
+ format: 'es',
14
+ dir: './exports/browser'
15
+ },
16
+ plugins: [
17
+ json(),
18
+ wasm(),
19
+ commonjs(),
20
+ resolve({
21
+ mainFields: ["browser", "module", "main"]
22
+ })
23
+ ]
24
+ }, {
25
+ input: ['./src/peernet.ts', './node_modules/@leofcoin/storage/exports/store.js'],
26
+ output: {
27
+ format: 'es',
28
+ dir: './exports'
29
+ }
30
+ }]
package/tsconfig.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "ES2022",
4
+ "target": "es2022",
5
+ // "noImplicitAny": true,
6
+ "removeComments": true,
7
+ "preserveConstEnums": true,
8
+ "outDir": ".build/",
9
+ "moduleResolution":"NodeNext",
10
+ "sourceMap": true,
11
+ "allowJs": true
12
+ },
13
+ "include": [
14
+ "./src/**/*"
15
+ ],
16
+ "exclude": ["node_modules"]
17
+ }