@leofcoin/endpoints 0.1.3 → 0.2.0

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/http.js CHANGED
@@ -30,6 +30,109 @@ export default (chain, port, networkVersion) => {
30
30
  return
31
31
  })
32
32
 
33
+ router.get('/accounts', async ctx => {
34
+ ctx.body = JSON.parse(new TextDecoder().decode((await walletStore.get('accounts'))))
35
+ })
36
+
37
+ router.get('/hasTransactionToHandle', async ctx => {
38
+ ctx.body = await chain.hasTransactionToHandle()
39
+ })
40
+ router.get('/getBlock', ctx => ctx.body = chain.blocks[ctx.query.index])
41
+
42
+ router.get('/blocks', ctx => {
43
+ ctx.body = chain.blocks.slice(ctx.query.amount)
44
+ })
45
+
46
+ router.get('/createTransactionFrom', async ctx => {
47
+ try {
48
+ const tx = await chain.createTransactionFrom(ctx.query.from, ctx.query.to, ctx.query.method, ctx.query.parameters, ctx.query.nonce)
49
+ await tx.wait()
50
+ send(tx)
51
+ } catch (error) {
52
+ send(202)
53
+ }
54
+ })
55
+
56
+ router.get('/peerId', ctx =>
57
+ ctx.body = peernet.peerId
58
+ )
59
+
60
+ router.get('/validators', ctx =>
61
+ ctx.body = chain.validators
62
+ )
63
+
64
+ router.get('/lookup', ctx =>
65
+ ctx.body = chain.lookup(ctx.query.name)
66
+ )
67
+
68
+ router.get('/staticCall', async ctx =>
69
+ ctx.body = await chain.staticCall(ctx.query.contract, ctx.query.method, ctx.query.params)
70
+ )
71
+
72
+ router.get('/nativeBurns', ctx =>
73
+ ctx.body = chain.nativeBurns
74
+ )
75
+
76
+ router.get('/contracts', ctx =>
77
+ ctx.body = chain.contracts
78
+ )
79
+
80
+ router.get('/nativeMints', ctx =>
81
+ ctx.body = chain.nativeMints
82
+ )
83
+
84
+ router.get('/nativeToken', ctx =>
85
+ ctx.body = chain.nativeToken
86
+ )
87
+
88
+ router.get('/nativeTransfers', ctx =>
89
+ ctx.body = chain.nativeTransfers
90
+ )
91
+
92
+ router.get('/totalSize', ctx =>
93
+ ctx.body = chain.totalSize
94
+ )
95
+
96
+ router.get('/totalTransactions', ctx =>
97
+ ctx.body = chain.totalTransactions
98
+ )
99
+
100
+ router.get('/totalBlocks', ctx =>
101
+ ctx.body = chain.blocks.length
102
+ )
103
+
104
+ router.get('/nativeCalls', ctx =>
105
+ ctx.body = chain.nativeCalls
106
+ )
107
+
108
+ router.get('/participating', ctx =>
109
+ ctx.body = chain.participating
110
+ )
111
+
112
+ router.get('participate', async ctx =>
113
+ ctx.body = await chain.participate(ctx.query.address)
114
+ )
115
+
116
+ router.get('/deployContract', async ctx => {
117
+ try {
118
+ const tx = await chain.deployContract(ctx.query.code, ctx.query.params)
119
+ await tx.wait()
120
+ delete tx.wait
121
+ ctx.body = JSON.stringify(tx)
122
+ } catch (error) {
123
+
124
+ }
125
+ })
126
+
127
+ router.get('/createContractAddress', async ctx => {
128
+ try {
129
+ const address = await chain.createContractAddress(ctx.query.owner, ctx.query.code, ctx.query.params)
130
+ ctx.body = address
131
+ } catch (error) {
132
+
133
+ }
134
+ })
135
+
33
136
  // todo finish ...
34
137
  api.use(cors('*'))
35
138
  api.use(router.routes())
package/exports/ws.js CHANGED
@@ -38,7 +38,7 @@ export default (chain, port, protocol) => {
38
38
  peerId: ({send}) =>
39
39
  send(peernet.peerId),
40
40
  peers: ({send}) =>
41
- send(node.peers),
41
+ send(peernet.peers),
42
42
  validators: ({send}) =>
43
43
  send(chain.validators),
44
44
  lookup: async ({name}, {send}) =>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/endpoints",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "exports": {