lisk 0.3.0 → 0.4.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.
- checksums.yaml +4 -4
- data/README.md +19 -28
- data/bin/debug +1 -0
- data/examples/legacy_api.rb +246 -0
- data/examples/payout.rb +3 -12
- data/examples/status.rb +16 -16
- data/lib/lisk/api.rb +190 -0
- data/lib/lisk/client.rb +9 -6
- data/lib/lisk/legacy.rb +377 -25
- data/lib/lisk/version.rb +1 -1
- data/lib/lisk.rb +3 -2
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d527806f8f47279705cb1cfd3e6ce771387fa69
|
4
|
+
data.tar.gz: 0716014534de9e321302f44f8ddfb417279294bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1060e59743ff5d8b476a558af469ba43e37d2ecc1da96b308f3605c3011f8cefd76e0b8e5482e9e55b371f9923fec0d36f84e3523c3dbb1e410ee44959a5985
|
7
|
+
data.tar.gz: ba79a7a558efb74293b4783e020bf4c186ed7aa92dd0f2a8698fdde0d3af5a3a81de4f210496fe3889acc84f0ee4a443e779342349999a09efb91d0f535d5325
|
data/README.md
CHANGED
@@ -6,6 +6,11 @@ A simple Ruby wrapper for the Lisk API. 💎
|
|
6
6
|
|
7
7
|
This is very early work-in-progress. The idea is to publish this `gem` as soon as it is fully compatible with Lisk Core 1.0.0, which, however, is not released yet. The current implementation of the lisk.rb gem is pure minimal by design and barely allows checking the node status.
|
8
8
|
|
9
|
+
API Implemententation Status:
|
10
|
+
|
11
|
+
- `Lisk::Legacy` 48/62 APIs for Lisk Core 0.8.0+ ([#4](https://github.com/4fryn/lisk.rb/issues/4))
|
12
|
+
- `Lisk::API` 0/34 APIs for Lisk Core 1.0.0+ ([#1](https://github.com/4fryn/lisk.rb/issues/1))
|
13
|
+
|
9
14
|
## Installation
|
10
15
|
|
11
16
|
Add this line to your application's Gemfile:
|
@@ -34,16 +39,22 @@ Make sure to include lisk.rb in your scripts.
|
|
34
39
|
require 'lisk'
|
35
40
|
```
|
36
41
|
|
37
|
-
To get started, point the lisk.rb to any Lisk-API endpoint. By default, lisk.rb assumes a running Lisk node on localhost port
|
42
|
+
To get started, point the lisk.rb to any Lisk-API endpoint. By default, lisk.rb assumes a running Lisk testnet node on localhost port 7000.
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
client = Lisk::Client.new "127.0.0.1", 7000
|
46
|
+
```
|
47
|
+
|
48
|
+
Get access to the Lisk-0.8.0 legacy API (see [#4](https://github.com/4fryn/lisk.rb/issues/4)).
|
38
49
|
|
39
50
|
```ruby
|
40
|
-
|
51
|
+
legacy_api = Lisk::Legacy.new client
|
41
52
|
```
|
42
53
|
|
43
54
|
For convenience, check if the Lisk node is connected, fully synchronized, and active by pinging it.
|
44
55
|
|
45
56
|
```ruby
|
46
|
-
if
|
57
|
+
if legacy_api.loader_status_ping
|
47
58
|
# only do stuff if client is connected, fully synchronized, and active ...
|
48
59
|
end
|
49
60
|
```
|
@@ -51,52 +62,32 @@ end
|
|
51
62
|
Get the version of the connected Lisk node.
|
52
63
|
|
53
64
|
```ruby
|
54
|
-
version =
|
65
|
+
version = legacy_api.peers_version
|
55
66
|
p "Lisk node version #{version["version"]} build #{version["build"]}..."
|
56
67
|
```
|
57
68
|
|
58
69
|
Get the status of the connected Lisk node.
|
59
70
|
|
60
71
|
```ruby
|
61
|
-
status =
|
72
|
+
status = legacy_api.loader_status
|
62
73
|
p "Lisk node is connected: #{status["success"]}... Blockchain loaded: #{status["loaded"]}..."
|
63
74
|
```
|
64
75
|
|
65
76
|
Figure out if the node is still synchronizing.
|
66
77
|
|
67
78
|
```ruby
|
68
|
-
syncing =
|
79
|
+
syncing = legacy_api.loader_status_sync
|
69
80
|
p "Lisk node is syncing: #{syncing["syncing"]}... #{syncing["blocks"]} remaining blocks to latest block #{syncing["height"]}..."
|
70
81
|
```
|
71
82
|
|
72
|
-
Let's have a look at the connected peers.
|
73
|
-
|
74
|
-
```ruby
|
75
|
-
peers = client.peers
|
76
|
-
cond = 0
|
77
|
-
disd = 0
|
78
|
-
band = 0
|
79
|
-
peers.each do | peer |
|
80
|
-
case peer["state"]
|
81
|
-
when 0
|
82
|
-
band += 1
|
83
|
-
when 1
|
84
|
-
disd += 1
|
85
|
-
when 2
|
86
|
-
cond += 1
|
87
|
-
end
|
88
|
-
end
|
89
|
-
p "Lisk node saw #{peers.count} peers... #{cond} connected, #{disd} disconnected, #{band} banned..."
|
90
|
-
```
|
91
|
-
|
92
83
|
Get some global Lisk blockchain stats.
|
93
84
|
|
94
85
|
```ruby
|
95
|
-
chain =
|
86
|
+
chain = legacy_api.blocks_get_status
|
96
87
|
p "Lisk chain latest block: #{chain["height"]}... total supply: #{chain["supply"] / 1e8}... block reward: #{chain["reward"] / 1e8}"
|
97
88
|
```
|
98
89
|
|
99
|
-
|
90
|
+
See `examples/*.rb` for more examples implementing the Lisk API.
|
100
91
|
|
101
92
|
## Development
|
102
93
|
|
data/bin/debug
CHANGED
@@ -0,0 +1,246 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'lisk'
|
4
|
+
|
5
|
+
# Try to connect a local Lisk client on test network.
|
6
|
+
# Warning: Think twice and test thoroughly before enabling this on main network!
|
7
|
+
client = Lisk::Client.new "127.0.0.1", 7000
|
8
|
+
legacy_api = Lisk::Legacy.new client
|
9
|
+
|
10
|
+
# Test data
|
11
|
+
_user = "4fryn_lorem_ipsum_42"
|
12
|
+
_secret = "lorem ipsum dolor sit amet et semper aperiam est duo modus zril"
|
13
|
+
_second_secret = "amet aperiam dolor duo est et ipsum lorem modus semper sit zril"
|
14
|
+
_address = "6824694156543443160L"
|
15
|
+
_public_key = "add8d8e3e89183ac34cdfb2631e038c9b0c1e922aa9a67aba71e35aed511bcf1"
|
16
|
+
_votes = {
|
17
|
+
:secret => _secret,
|
18
|
+
:public_key => _public_key,
|
19
|
+
# :secondSecret => _second_secret,
|
20
|
+
:delegates => [
|
21
|
+
"+473c354cdf627b82e9113e02a337486dd3afc5615eb71ffd311c5a0beda37b8c",
|
22
|
+
"+eaa049295d96618c51eb30deffe7fc2cc8bfc13190cb97f3b513dd060b000a46",
|
23
|
+
"+961d1a1057a09f865291873e9ba3d0af7b2a3a1e971bb7576a2aab1c526acbcd",
|
24
|
+
"+71e1e34dd0529d920ee6c38497b028352c57b7130d55737c8a778ff3974ec29f",
|
25
|
+
"+3697a4f8c74cb21949eec31fddde190c16ab2497709fb503c567d3a9e6a6e989",
|
26
|
+
"+3193057832bb1c9782a8e4a32e543b535ed9d750b1b10383f8b6f50853569609",
|
27
|
+
"+fa7bfd3a2dc0ca55b700247aae4694709d6cdfa34c6bfb0237e032d7aae404f0",
|
28
|
+
"+fc4f231b00f72ba93a4778890c5d2b89d3f570e606c04619a0343a3cdddf73c7",
|
29
|
+
"+e683da7b4fe46164b9db3fd599481ad0630d2d892546c1ac63e59a5acb903140",
|
30
|
+
"+d6619d6dd17a23fbd8bfe8aebc7065956feb956b66bb7d2867e190441657e2f4",
|
31
|
+
"+0911107983da4b581a109b5fac9579d89e29f06f10d803370f88a41100c3374e",
|
32
|
+
"+6beaa7c569c1000f4fcef4ce3133b18609aea52adf95d5992970ea5e0cedda87",
|
33
|
+
"+19bdab59b24f7ef2a9d0b1b0942cff450875302e0c59c437a372eb6bb27a0b43",
|
34
|
+
"+279320364fc3edd39b77f1fa29594d442e39220b165956fa729f741150b0dc4d",
|
35
|
+
"+f4871371ff27f467e71087dd6bb38c975c5a49bdff02de6b5ca5e43bbf5b3c3b",
|
36
|
+
"+5fb6b29846e95c88d464e003c835ca4f88260eaa57cd8deded8fc8038dfcbc60",
|
37
|
+
"+8a1a3df89bf87e6c7bd29e06aaf7e3d7f1eef45f2058413a70bed0f4e3cb37f8",
|
38
|
+
"+2dc40508f548b405fa2a64a24e91c9b6ea80ccf28f4cd80686627e55a91efc4b",
|
39
|
+
"+6089206bdd49e8e6c824b4896f5b3c2d71207c30c6bf056d430ba0d8838e7c51",
|
40
|
+
"+e8720600afd888455fe9eea4c859d08efd8122f4f732bba94504cfefc318de55",
|
41
|
+
"+d4ce34592854e06370a79ee95e4bdf8eeb9d0d37dd0c802d9ad2357fd4cb9ec7"
|
42
|
+
]
|
43
|
+
}
|
44
|
+
_tx_filter = {
|
45
|
+
:blockId => "39391848391772781",
|
46
|
+
:senderId => "14815133512790761431L",
|
47
|
+
:recipientId => "10020978176543317477L",
|
48
|
+
:limit => 1, :offset => 0,
|
49
|
+
:orderBy => "blockId"
|
50
|
+
}
|
51
|
+
_raw_tx = {
|
52
|
+
:secret => _secret,
|
53
|
+
:publicKey => _public_key,
|
54
|
+
# :secondSecret => _second_secret,
|
55
|
+
:recipientId => "15709494141295217973L",
|
56
|
+
:amount => 1e7
|
57
|
+
}
|
58
|
+
_tx_id = "17278680718005275020"
|
59
|
+
_peer_filter = {
|
60
|
+
:state => 2,
|
61
|
+
:os => "linux3.10.0-042stab123.6",
|
62
|
+
:version => "0.9.10b",
|
63
|
+
:limit => 10,
|
64
|
+
:offset => 0,
|
65
|
+
:orderBy => "version"
|
66
|
+
}
|
67
|
+
_ip_filter = {
|
68
|
+
:ip => "149.56.108.109",
|
69
|
+
:port => 7000
|
70
|
+
}
|
71
|
+
_block_filter = {
|
72
|
+
:generatorPublicKey => "5ad8b74e39ad7502c8eeea080c8627b3aa9bb28651b988ef38112f21367b132d",
|
73
|
+
:height => 3481431,
|
74
|
+
:previousBlock => "8589373032001092432",
|
75
|
+
:totalAmount => 0,
|
76
|
+
:totalFee => 0,
|
77
|
+
:limit => 1,
|
78
|
+
:offset => 0,
|
79
|
+
:orderBy => "height"
|
80
|
+
}
|
81
|
+
_block_id = "8589373032001092432"
|
82
|
+
_secrets = {
|
83
|
+
:secret => _secret,
|
84
|
+
:secondSecret => _second_secret,
|
85
|
+
:publicKey => _public_key
|
86
|
+
}
|
87
|
+
_ms_secrets = {
|
88
|
+
:secret => _secret,
|
89
|
+
# :secondSecret => _second_secret,
|
90
|
+
:lifetime => 72,
|
91
|
+
:min => 2,
|
92
|
+
:keysgroup => [
|
93
|
+
"+6089206bdd49e8e6c824b4896f5b3c2d71207c30c6bf056d430ba0d8838e7c51",
|
94
|
+
"+e8720600afd888455fe9eea4c859d08efd8122f4f732bba94504cfefc318de55",
|
95
|
+
"+d4ce34592854e06370a79ee95e4bdf8eeb9d0d37dd0c802d9ad2357fd4cb9ec7"
|
96
|
+
]
|
97
|
+
}
|
98
|
+
_ms_signature = {
|
99
|
+
:secret => _secret,
|
100
|
+
:publicKey => _public_key,
|
101
|
+
:transactionId => _tx_id
|
102
|
+
}
|
103
|
+
_delegate = {
|
104
|
+
:secret => _secret,
|
105
|
+
# :secondSecret => _second_secret,
|
106
|
+
:username => _user
|
107
|
+
}
|
108
|
+
_delegate_filter = {
|
109
|
+
:limit => 3,
|
110
|
+
:offset => 0,
|
111
|
+
:orderBy => "username"
|
112
|
+
}
|
113
|
+
_delegate_query = {
|
114
|
+
:q => "4fryn",
|
115
|
+
:orderBy => "producedblocks:desc"
|
116
|
+
}
|
117
|
+
|
118
|
+
# Testing legacy API against https://github.com/4fryn/lisk.rb/issues/4
|
119
|
+
account = legacy_api.accounts_open _secret
|
120
|
+
p account
|
121
|
+
balance = legacy_api.accounts_get_balance _address
|
122
|
+
p balance
|
123
|
+
public_key = legacy_api.accounts_get_public_key _address
|
124
|
+
p public_key
|
125
|
+
public_key = legacy_api.accounts_generate_public_key _secret
|
126
|
+
p public_key
|
127
|
+
account = legacy_api.accounts _address
|
128
|
+
p account
|
129
|
+
delegate = legacy_api.accounts_delegates_get_by_address _address
|
130
|
+
p delegate
|
131
|
+
votes = legacy_api.accounts_delegates_put _votes
|
132
|
+
p votes
|
133
|
+
|
134
|
+
syncing = legacy_api.loader_status_sync
|
135
|
+
p syncing
|
136
|
+
status = legacy_api.loader_status
|
137
|
+
p status
|
138
|
+
ping = legacy_api.loader_status_ping
|
139
|
+
p ping
|
140
|
+
|
141
|
+
transactions = legacy_api.transactions
|
142
|
+
p transactions
|
143
|
+
transactions = legacy_api.transactions _tx_filter
|
144
|
+
p transactions
|
145
|
+
transaction = legacy_api.transactions_put _raw_tx
|
146
|
+
p transaction
|
147
|
+
transaction = legacy_api.transactions_get_by_id _tx_id
|
148
|
+
p transaction
|
149
|
+
transaction = legacy_api.transactions_unconfirmed_get_by_id _tx_id
|
150
|
+
p transaction
|
151
|
+
transaction = legacy_api.transactions_unconfirmed
|
152
|
+
p transaction
|
153
|
+
transaction = legacy_api.transactions_queued
|
154
|
+
p transaction
|
155
|
+
transaction = legacy_api.transactions_queued_get_by_id _tx_id
|
156
|
+
p transaction
|
157
|
+
|
158
|
+
peers = legacy_api.peers
|
159
|
+
p peers
|
160
|
+
peers = legacy_api.peers _peer_filter
|
161
|
+
p peers
|
162
|
+
peer = legacy_api.peers_get _ip_filter
|
163
|
+
p peer
|
164
|
+
version = legacy_api.peers_version
|
165
|
+
p version
|
166
|
+
|
167
|
+
blocks = legacy_api.blocks
|
168
|
+
p blocks
|
169
|
+
blocks = legacy_api.blocks _block_filter
|
170
|
+
p blocks
|
171
|
+
block = legacy_api.blocks_get_by_id _block_id
|
172
|
+
p block
|
173
|
+
fee = legacy_api.blocks_get_fee
|
174
|
+
p fee
|
175
|
+
fees = legacy_api.blocks_get_fees
|
176
|
+
p fees
|
177
|
+
reward = legacy_api.blocks_get_reward
|
178
|
+
p reward
|
179
|
+
supply = legacy_api.blocks_get_supply
|
180
|
+
p supply
|
181
|
+
height = legacy_api.blocks_get_height
|
182
|
+
p height
|
183
|
+
status = legacy_api.blocks_get_status
|
184
|
+
p status
|
185
|
+
nethash = legacy_api.blocks_get_nethash
|
186
|
+
p nethash
|
187
|
+
milestone = legacy_api.blocks_get_milestone
|
188
|
+
p milestone
|
189
|
+
|
190
|
+
fee = legacy_api.signatures_fee
|
191
|
+
p fee
|
192
|
+
transaction = legacy_api.signatures_put _secrets
|
193
|
+
p transaction
|
194
|
+
|
195
|
+
delegate = legacy_api.delegates_put _delegate
|
196
|
+
p delegate
|
197
|
+
delegates = legacy_api.delegates
|
198
|
+
p delegates
|
199
|
+
delegates = legacy_api.delegates _delegate_filter
|
200
|
+
p delegates
|
201
|
+
delegate = legacy_api.delegates_get_by_key _public_key
|
202
|
+
p delegate
|
203
|
+
delegate = legacy_api.delegates_get_by_name _user
|
204
|
+
p delegate
|
205
|
+
delegates = legacy_api.delegates_search _delegate_query
|
206
|
+
p delegates
|
207
|
+
count = legacy_api.delegates_count
|
208
|
+
p count
|
209
|
+
account = legacy_api.accounts_delegates _address
|
210
|
+
p account
|
211
|
+
voters = legacy_api.delegates_voters _public_key
|
212
|
+
p voters
|
213
|
+
address = legacy_api.delegates_forging_enable _secret
|
214
|
+
p address
|
215
|
+
address = legacy_api.delegates_forging_disable _secret
|
216
|
+
p address
|
217
|
+
forged = legacy_api.delegates_forging_get_forged_by_account _public_key
|
218
|
+
p forged
|
219
|
+
forgers = legacy_api.delegates_get_next_forgers
|
220
|
+
p forgers
|
221
|
+
forgers = legacy_api.delegates_get_next_forgers 3
|
222
|
+
p forgers
|
223
|
+
|
224
|
+
#legacy_api.dapps_put ### UNIMPLEMENTED (#4)
|
225
|
+
#legacy_api.dapps filter ### UNIMPLEMENTED (#4)
|
226
|
+
#legacy_api.dapps_get_by_id id ### UNIMPLEMENTED (#4)
|
227
|
+
#legacy_api.dapps_search query ### UNIMPLEMENTED (#4)
|
228
|
+
#legacy_api.dapps_install ### UNIMPLEMENTED (#4)
|
229
|
+
#legacy_api.dapps_installed ### UNIMPLEMENTED (#4)
|
230
|
+
#legacy_api.dapps_installed_ids ### UNIMPLEMENTED (#4)
|
231
|
+
#legacy_api.dapps_uninstall ### UNIMPLEMENTED (#4)
|
232
|
+
#legacy_api.dapps_launch ### UNIMPLEMENTED (#4)
|
233
|
+
#legacy_api.dapps_installing ### UNIMPLEMENTED (#4)
|
234
|
+
#legacy_api.dapps_uninstalling ### UNIMPLEMENTED (#4)
|
235
|
+
#legacy_api.dapps_launched ### UNIMPLEMENTED (#4)
|
236
|
+
#legacy_api.dapps_categories ### UNIMPLEMENTED (#4)
|
237
|
+
#legacy_api.dapps_stop ### UNIMPLEMENTED (#4)
|
238
|
+
|
239
|
+
transaction = legacy_api.multisignatures_put _ms_secrets
|
240
|
+
p transaction
|
241
|
+
accounts = legacy_api.multisignatures_accounts _public_key
|
242
|
+
p accounts
|
243
|
+
transaction = legacy_api.multisignatures_sign _ms_signature
|
244
|
+
p transaction
|
245
|
+
transactions = legacy_api.multisignatures_pending _public_key
|
246
|
+
p transactions
|
data/examples/payout.rb
CHANGED
@@ -10,7 +10,7 @@ client = Lisk::Client.new "127.0.0.1", 7000
|
|
10
10
|
legacy_api = Lisk::Legacy.new client
|
11
11
|
|
12
12
|
# Only proceed if the client is connected, active, and fully synchronized.
|
13
|
-
if legacy_api.
|
13
|
+
if legacy_api.loader_status_ping
|
14
14
|
|
15
15
|
# Get the desired delegate by name.
|
16
16
|
delegate = legacy_api.delegates_get_by_name "4fryn"
|
@@ -54,20 +54,11 @@ if legacy_api.ping
|
|
54
54
|
# @TODO: sending 20% delegate share to her private address
|
55
55
|
p "Sending #{payout_balance * 0.20 / 1e8} LSK to delegate private funds..."
|
56
56
|
|
57
|
-
#
|
57
|
+
# _debug_payout_diff should be 0
|
58
58
|
_debug_payout_sum += payout_balance * 0.20
|
59
59
|
_debug_payout_diff = payout_balance - _debug_payout_sum
|
60
|
-
|
61
|
-
|
60
|
+
p "#{_debug_payout_diff === 0}"
|
62
61
|
|
63
62
|
else
|
64
63
|
p 'Lisk node disconnected, inactive, or not fully synchronized ...'
|
65
64
|
end
|
66
|
-
|
67
|
-
#account = Lisk::Account.new("14524922419337843943L")
|
68
|
-
#client.get_address(account)
|
69
|
-
#block = Lisk::Block.new("11145685198263496703")
|
70
|
-
#delegate = Lisk::Delegate.new("lightcurve")
|
71
|
-
#client.get_address(delegate)
|
72
|
-
#client.get_voters(delegate)
|
73
|
-
#transaction = Lisk::Transaction.new("10153999325502978458")
|
data/examples/status.rb
CHANGED
@@ -2,34 +2,34 @@
|
|
2
2
|
|
3
3
|
require 'lisk'
|
4
4
|
|
5
|
-
# Try to connect a local Lisk client
|
5
|
+
# Try to connect a local Lisk client.
|
6
6
|
client = Lisk::Client.new
|
7
7
|
|
8
|
-
# Configure host and port of the Lisk client
|
8
|
+
# Configure host and port of the Lisk client.
|
9
9
|
client = client.configure "127.0.0.1", 8000
|
10
10
|
|
11
|
-
# Same as above, just in one line
|
12
|
-
client = Lisk::Client.new "127.0.0.1",
|
11
|
+
# Same as above, just in one line, let's stick to test network for now.
|
12
|
+
client = Lisk::Client.new "127.0.0.1", 7000
|
13
13
|
|
14
|
-
# The pre-1.0.0 legacy API connected to the client
|
14
|
+
# The pre-1.0.0 legacy API connected to the client.
|
15
15
|
legacy_api = Lisk::Legacy.new client
|
16
16
|
|
17
|
-
# Only proceed if the client is connected, active, and fully synchronized
|
18
|
-
if legacy_api.
|
17
|
+
# Only proceed if the client is connected, active, and fully synchronized.
|
18
|
+
if legacy_api.loader_status_ping
|
19
19
|
|
20
|
-
# Lisk version API example
|
21
|
-
version = legacy_api.
|
20
|
+
# Lisk version API example.
|
21
|
+
version = legacy_api.peers_version
|
22
22
|
p "Lisk node version #{version["version"]} build #{version["build"]}..."
|
23
23
|
|
24
|
-
# Lisk node status API example
|
25
|
-
status = legacy_api.
|
24
|
+
# Lisk node status API example.
|
25
|
+
status = legacy_api.loader_status
|
26
26
|
p "Lisk node is connected: #{status["success"]}... Blockchain loaded: #{status["loaded"]}..."
|
27
27
|
|
28
|
-
# Lisk node syncing API example
|
29
|
-
syncing = legacy_api.
|
28
|
+
# Lisk node syncing API example.
|
29
|
+
syncing = legacy_api.loader_status_sync
|
30
30
|
p "Lisk node is syncing: #{syncing["syncing"]}... #{syncing["blocks"]} remaining blocks to latest block #{syncing["height"]}..."
|
31
31
|
|
32
|
-
# Lisk node peers API example
|
32
|
+
# Lisk node peers API example.
|
33
33
|
peers = legacy_api.peers
|
34
34
|
cond = 0
|
35
35
|
disd = 0
|
@@ -46,8 +46,8 @@ if legacy_api.ping
|
|
46
46
|
end
|
47
47
|
p "Lisk node saw #{peers.count} peers... #{cond} connected, #{disd} disconnected, #{band} banned..."
|
48
48
|
|
49
|
-
# Lisk blockchain API example
|
50
|
-
chain = legacy_api.
|
49
|
+
# Lisk blockchain API example.
|
50
|
+
chain = legacy_api.blocks_get_status
|
51
51
|
p "Lisk chain latest block: #{chain["height"]}... total supply: #{chain["supply"] / 1e8}... block reward: #{chain["reward"] / 1e8}"
|
52
52
|
|
53
53
|
else
|
data/lib/lisk/api.rb
ADDED
@@ -0,0 +1,190 @@
|
|
1
|
+
# The Lisk API Ruby wrapper gem.
|
2
|
+
module Lisk
|
3
|
+
|
4
|
+
# Implements APIs of the Lisk Core node.
|
5
|
+
class API
|
6
|
+
|
7
|
+
# A "lisk/client" connecting to a Lisk Core API node.
|
8
|
+
attr_accessor :client
|
9
|
+
|
10
|
+
# Initializing the API with a Lisk Core API client.
|
11
|
+
def initialize client
|
12
|
+
if not client.nil?
|
13
|
+
@client = client
|
14
|
+
return self
|
15
|
+
else
|
16
|
+
return nil
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
#############################################
|
21
|
+
# https://github.com/4fryn/lisk.rb/issues/1 #
|
22
|
+
#############################################
|
23
|
+
|
24
|
+
# The "accounts" API
|
25
|
+
def accounts
|
26
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
27
|
+
end
|
28
|
+
|
29
|
+
# The "blocks" API
|
30
|
+
def blocks
|
31
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
32
|
+
end
|
33
|
+
|
34
|
+
# The "dapps" API
|
35
|
+
def dapps
|
36
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
37
|
+
end
|
38
|
+
|
39
|
+
# The "delegates" API
|
40
|
+
def delegates
|
41
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
42
|
+
end
|
43
|
+
|
44
|
+
# The "delegates/forgers" API
|
45
|
+
def delegates_forgers
|
46
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
47
|
+
end
|
48
|
+
|
49
|
+
# The "delegates/forging" API
|
50
|
+
def delegates_forging
|
51
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
52
|
+
end
|
53
|
+
|
54
|
+
# The "node/constants" API
|
55
|
+
def node_constants
|
56
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
57
|
+
end
|
58
|
+
|
59
|
+
# The "node/status" API
|
60
|
+
def node_status
|
61
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
62
|
+
end
|
63
|
+
|
64
|
+
# The "peers" API
|
65
|
+
def peers
|
66
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
67
|
+
end
|
68
|
+
|
69
|
+
# The "signatures" API
|
70
|
+
def signatures
|
71
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
72
|
+
end
|
73
|
+
|
74
|
+
# The "transactions" API
|
75
|
+
def transactions
|
76
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
77
|
+
end
|
78
|
+
|
79
|
+
# The "transactions/unsigned" API
|
80
|
+
def transactions_unsigned
|
81
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
82
|
+
end
|
83
|
+
|
84
|
+
# The "transactions/unconfirmed" API
|
85
|
+
def transactions_unconfirmed
|
86
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
87
|
+
end
|
88
|
+
|
89
|
+
# The "transactions/unprocessed" API
|
90
|
+
def transactions_unprocessed
|
91
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
92
|
+
end
|
93
|
+
|
94
|
+
# The "votes" API
|
95
|
+
def votes
|
96
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
97
|
+
end
|
98
|
+
|
99
|
+
# The "voters" API
|
100
|
+
def voters
|
101
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
102
|
+
end
|
103
|
+
|
104
|
+
# The "accounts" API
|
105
|
+
def accounts
|
106
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
107
|
+
end
|
108
|
+
|
109
|
+
# The "blocks" API
|
110
|
+
def blocks
|
111
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
112
|
+
end
|
113
|
+
|
114
|
+
# The "dapps" API
|
115
|
+
def dapps
|
116
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
117
|
+
end
|
118
|
+
|
119
|
+
# The "delegates" API
|
120
|
+
def delegates
|
121
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
122
|
+
end
|
123
|
+
|
124
|
+
# The "delegates/forgers" API
|
125
|
+
def delegates_forgers
|
126
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
127
|
+
end
|
128
|
+
|
129
|
+
# The "delegates/forging" API
|
130
|
+
def delegates_forging
|
131
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
132
|
+
end
|
133
|
+
|
134
|
+
# The "node/constants" API
|
135
|
+
def node_constants
|
136
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
137
|
+
end
|
138
|
+
|
139
|
+
# The "node/status" API
|
140
|
+
def node_status
|
141
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
142
|
+
end
|
143
|
+
|
144
|
+
# The "peers" API
|
145
|
+
def peers
|
146
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
147
|
+
end
|
148
|
+
|
149
|
+
# The "signatures" API
|
150
|
+
def signatures
|
151
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
152
|
+
end
|
153
|
+
|
154
|
+
# The "transactions" API
|
155
|
+
def transactions
|
156
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
157
|
+
end
|
158
|
+
|
159
|
+
# The "transactions/unsigned" API
|
160
|
+
def transactions_unsigned
|
161
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
162
|
+
end
|
163
|
+
|
164
|
+
# The "transactions/unconfirmed" API
|
165
|
+
def transactions_unconfirmed
|
166
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
167
|
+
end
|
168
|
+
|
169
|
+
# The "transactions/unprocessed" API
|
170
|
+
def transactions_unprocessed
|
171
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
172
|
+
end
|
173
|
+
|
174
|
+
# The "votes" API
|
175
|
+
def votes
|
176
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
177
|
+
end
|
178
|
+
|
179
|
+
# The "voters" API
|
180
|
+
def voters
|
181
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
182
|
+
end
|
183
|
+
|
184
|
+
# Handles unimplemented methods
|
185
|
+
def method_missing name, *args, &block
|
186
|
+
todo "#{self}::#{name} METHOD MISSING"
|
187
|
+
end
|
188
|
+
|
189
|
+
end
|
190
|
+
end
|
data/lib/lisk/client.rb
CHANGED
@@ -11,8 +11,8 @@ module Lisk
|
|
11
11
|
# Host and port of the API endpoint.
|
12
12
|
attr_accessor :host, :port, :ssl
|
13
13
|
|
14
|
-
# Initializes the Lisk HTTP client and defaults to localhost port
|
15
|
-
def initialize host = "127.0.0.1", port =
|
14
|
+
# Initializes the Lisk HTTP client and defaults to localhost port 7000.
|
15
|
+
def initialize host = "127.0.0.1", port = 7000
|
16
16
|
@host = host
|
17
17
|
@port = port
|
18
18
|
@ssl = false
|
@@ -75,9 +75,10 @@ module Lisk
|
|
75
75
|
# fixme "#{self}::#{__method__} Allow HTTPS requests"
|
76
76
|
begin
|
77
77
|
node = ::Net::HTTP.new @host, @port
|
78
|
+
header = {'Content-Type': 'application/json'}
|
78
79
|
uri = URI.parse "http://#{host}:#{port}/api/#{endpoint}"
|
79
|
-
|
80
|
-
request =
|
80
|
+
request = ::Net::HTTP::Post.new uri, header
|
81
|
+
request.body = params.to_json
|
81
82
|
response = node.request request
|
82
83
|
result = JSON::parse response.body
|
83
84
|
rescue Timeout::Error => e
|
@@ -96,9 +97,11 @@ module Lisk
|
|
96
97
|
# fixme "#{self}::#{__method__} Allow HTTPS requests"
|
97
98
|
begin
|
98
99
|
node = ::Net::HTTP.new @host, @port
|
100
|
+
header = {'Content-Type': 'application/json'}
|
99
101
|
uri = URI.parse "http://#{host}:#{port}/api/#{endpoint}"
|
100
102
|
uri.query = URI.encode_www_form params
|
101
|
-
request = ::Net::HTTP::Put.new uri
|
103
|
+
request = ::Net::HTTP::Put.new uri, header
|
104
|
+
request.body = params.to_json
|
102
105
|
response = node.request request
|
103
106
|
result = JSON::parse response.body
|
104
107
|
rescue Timeout::Error => e
|
@@ -112,7 +115,7 @@ module Lisk
|
|
112
115
|
end
|
113
116
|
|
114
117
|
# Handles unimplemented methods
|
115
|
-
def method_missing
|
118
|
+
def method_missing name, *args, &block
|
116
119
|
todo "#{self}::#{name} METHOD MISSING"
|
117
120
|
end
|
118
121
|
|
data/lib/lisk/legacy.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# The Lisk API Ruby wrapper gem.
|
2
2
|
module Lisk
|
3
3
|
|
4
|
-
# Implements legacy APIs of the Lisk Core pre-1.0.0 node
|
4
|
+
# Implements legacy APIs of the Lisk Core pre-1.0.0 node.
|
5
5
|
class Legacy
|
6
6
|
|
7
7
|
# A "lisk/client" connecting to a Lisk Core API node.
|
@@ -17,26 +17,132 @@ module Lisk
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
+
# Request information about an account.
|
21
|
+
# `POST /accounts/open`
|
22
|
+
def accounts_open secret
|
23
|
+
params = { :secret => secret }
|
24
|
+
account = @client.query_post "accounts/open", params
|
25
|
+
if account["success"]
|
26
|
+
return account["account"]
|
27
|
+
else
|
28
|
+
return nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Request the balance of an account.
|
33
|
+
# `GET /accounts/getBalance?address=address`
|
34
|
+
def accounts_get_balance address
|
35
|
+
params = { :address => address }
|
36
|
+
balance = @client.query_get "accounts/getBalance", params
|
37
|
+
end
|
38
|
+
|
39
|
+
# Get the public key of an account. If the account does not exist the API call will return an error.
|
40
|
+
# `GET /accounts/getPublicKey?address=address`
|
41
|
+
def accounts_get_public_key address
|
42
|
+
params = { :address => address }
|
43
|
+
public_key = @client.query_get "accounts/getPublicKey", params
|
44
|
+
end
|
45
|
+
|
46
|
+
# Returns the public key of the provided secret key.
|
47
|
+
# `POST /accounts/generatePublicKey`
|
48
|
+
def accounts_generate_public_key secret
|
49
|
+
params = { :secret => secret }
|
50
|
+
public_key = @client.query_post "accounts/generatePublicKey", params
|
51
|
+
end
|
52
|
+
|
53
|
+
# Returns account information of an address.
|
54
|
+
# `GET /accounts?address=address`
|
55
|
+
def accounts address
|
56
|
+
params = { :address => address }
|
57
|
+
account = @client.query_get "accounts", params
|
58
|
+
end
|
59
|
+
|
60
|
+
# Returns delegate vote accounts by address.
|
61
|
+
# `GET /accounts/delegates?address=address`
|
62
|
+
def accounts_delegates_get_by_address address
|
63
|
+
params = { :address => address }
|
64
|
+
delegate = @client.query_get "accounts/delegates", params
|
65
|
+
end
|
66
|
+
|
67
|
+
# Vote for the selected delegates. Maximum of 33 delegates at once.
|
68
|
+
# `PUT /accounts/delegates`
|
69
|
+
def accounts_delegates_put votes
|
70
|
+
delegate = @client.query_put "accounts/delegates", votes
|
71
|
+
end
|
72
|
+
|
73
|
+
# Get the synchronization status of the client.
|
74
|
+
# `GET /loader/status`
|
75
|
+
def loader_status_sync
|
76
|
+
sync = @client.query_get "loader/status/sync"
|
77
|
+
end
|
78
|
+
|
79
|
+
# Returns the sync status of the blockchain.
|
80
|
+
# `GET /loader/status/sync`
|
81
|
+
def loader_status
|
82
|
+
status = @client.query_get "loader/status"
|
83
|
+
end
|
84
|
+
|
20
85
|
# Get the status of last received block.
|
21
86
|
# Returns true if block was received in the past 120 seconds.
|
22
|
-
|
87
|
+
# `GET /loader/status/ping`
|
88
|
+
def loader_status_ping
|
23
89
|
ping = @client.query_get "loader/status/ping"
|
24
|
-
ping["success"]
|
25
90
|
end
|
26
91
|
|
27
|
-
#
|
28
|
-
|
29
|
-
|
92
|
+
# List of transactions matched by provided parameters.
|
93
|
+
# `GET /transactions?blockId=blockId&senderId=senderId&recipientId=recipientId&limit=limit&offset=offset&orderBy=field`
|
94
|
+
def transactions filter = nil
|
95
|
+
transactions = @client.query_get "transactions", filter
|
96
|
+
if transactions["success"]
|
97
|
+
return transactions["transactions"]
|
98
|
+
else
|
99
|
+
return nil
|
100
|
+
end
|
30
101
|
end
|
31
102
|
|
32
|
-
#
|
33
|
-
|
34
|
-
|
103
|
+
# Send transaction to broadcast network.
|
104
|
+
# `PUT /transactions`
|
105
|
+
def transactions_put transaction
|
106
|
+
transaction = @client.query_put "transactions", transaction
|
107
|
+
end
|
108
|
+
|
109
|
+
# Get transaction that matches the provided id.
|
110
|
+
# `GET /transactions/get?id=id`
|
111
|
+
def transactions_get_by_id id
|
112
|
+
params = { :id => id }
|
113
|
+
transaction = @client.query_get "transactions/get", params
|
114
|
+
end
|
115
|
+
|
116
|
+
# Get unconfirmed transaction that matches the provided id.
|
117
|
+
# `GET /transactions/unconfirmed/get?id=id`
|
118
|
+
def transactions_unconfirmed_get_by_id id
|
119
|
+
params = { :id => id }
|
120
|
+
transaction = @client.query_get "transactions/unconfirmed/get", params
|
121
|
+
end
|
122
|
+
|
123
|
+
# Gets a list of unconfirmed transactions.
|
124
|
+
# `GET /transactions/unconfirmed`
|
125
|
+
def transactions_unconfirmed
|
126
|
+
transaction = @client.query_get "transactions/unconfirmed"
|
127
|
+
end
|
128
|
+
|
129
|
+
# Gets a list of queued transactions.
|
130
|
+
# `GET /transactions/queued`
|
131
|
+
def transactions_queued
|
132
|
+
transaction = @client.query_get "transactions/queued"
|
133
|
+
end
|
134
|
+
|
135
|
+
# Get queued transaction that matches the provided id.
|
136
|
+
# `GET /transactions/queued/get?id=id`
|
137
|
+
def transactions_queued_get_by_id id
|
138
|
+
params = { :id => id }
|
139
|
+
transaction = @client.query_get "transactions/queued/get", params
|
35
140
|
end
|
36
141
|
|
37
142
|
# Gets list of peers.
|
38
|
-
|
39
|
-
|
143
|
+
# `GET /peers?state=state&os=os&version=version&limit=limit&offset=offset&orderBy=orderBy`
|
144
|
+
def peers filter = nil
|
145
|
+
peers = @client.query_get "peers", filter
|
40
146
|
if peers["success"]
|
41
147
|
return peers["peers"]
|
42
148
|
else
|
@@ -44,28 +150,115 @@ module Lisk
|
|
44
150
|
end
|
45
151
|
end
|
46
152
|
|
153
|
+
# Gets peer by IP address and port.
|
154
|
+
# `GET /peers/get?ip=ip&port=port`
|
155
|
+
def peers_get filter = nil
|
156
|
+
peer = @client.query_get "peers/get", filter
|
157
|
+
end
|
158
|
+
|
47
159
|
# Gets version and build time.
|
48
|
-
|
160
|
+
# `GET /peers/version`
|
161
|
+
def peers_version
|
49
162
|
version = @client.query_get "peers/version"
|
50
163
|
end
|
51
164
|
|
165
|
+
# Gets all blocks by provided filter(s).
|
166
|
+
# `GET /blocks?generatorPublicKey=generatorPublicKey&height=height&previousBlock=previousBlock&totalAmount=totalAmount&totalFee=totalFee&limit=limit&offset=offset&orderBy=orderBy`
|
167
|
+
def blocks filter = nil
|
168
|
+
blocks = @client.query_get "blocks", filter
|
169
|
+
if blocks["success"]
|
170
|
+
return blocks["blocks"]
|
171
|
+
else
|
172
|
+
return nil
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
# Gets block by provided id.
|
177
|
+
# `GET /blocks/get?id=id`
|
178
|
+
def blocks_get_by_id id
|
179
|
+
params = { :id => id }
|
180
|
+
block = @client.query_get "blocks/get", params
|
181
|
+
end
|
182
|
+
|
183
|
+
# Get transaction fee for sending "normal" transactions.
|
184
|
+
# `GET /blocks/getFee`
|
185
|
+
def blocks_get_fee
|
186
|
+
fee = @client.query_get "blocks/getFee"
|
187
|
+
end
|
188
|
+
|
189
|
+
# Get transaction fee for all types of transactions.
|
190
|
+
# `GET /blocks/getFees`
|
191
|
+
def blocks_get_fees
|
192
|
+
fees = @client.query_get "blocks/getFees"
|
193
|
+
end
|
194
|
+
|
195
|
+
# Gets the forging reward for blocks.
|
196
|
+
# `GET /blocks/getReward`
|
197
|
+
def blocks_get_reward
|
198
|
+
reward = @client.query_get "blocks/getReward"
|
199
|
+
end
|
200
|
+
|
201
|
+
# Gets the total amount of Lisk in circulation
|
202
|
+
# `GET /blocks/getSupply`
|
203
|
+
def blocks_get_supply
|
204
|
+
supply = @client.query_get "blocks/getSupply"
|
205
|
+
end
|
206
|
+
|
207
|
+
# Gets the blockchain height of the client.
|
208
|
+
# `GET /blocks/getHeight`
|
209
|
+
def blocks_get_height
|
210
|
+
height = @client.query_get "blocks/getHeight"
|
211
|
+
end
|
212
|
+
|
52
213
|
# Gets status of height, fee, milestone, blockreward and supply.
|
53
|
-
|
54
|
-
|
214
|
+
# `GET /blocks/getStatus`
|
215
|
+
def blocks_get_status
|
216
|
+
status = @client.query_get "blocks/getStatus"
|
55
217
|
end
|
56
218
|
|
57
|
-
# Gets
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
219
|
+
# Gets the nethash of the blockchain on a client.
|
220
|
+
# `GET /blocks/getNethash`
|
221
|
+
def blocks_get_nethash
|
222
|
+
nethash = @client.query_get "blocks/getNethash"
|
223
|
+
end
|
224
|
+
|
225
|
+
# Gets the milestone of the blockchain on a client.
|
226
|
+
# `GET /blocks/getMilestone`
|
227
|
+
def blocks_get_milestone
|
228
|
+
milestone = @client.query_get "blocks/getMilestone"
|
229
|
+
end
|
230
|
+
|
231
|
+
# Gets the second signature status of an account.
|
232
|
+
# `GET /signatures/fee`
|
233
|
+
def signatures_fee
|
234
|
+
fee = @client.query_get "signatures/fee"
|
235
|
+
end
|
236
|
+
|
237
|
+
# Add a second signature to an account.
|
238
|
+
# `PUT /signatures`
|
239
|
+
def signatures_put secrets
|
240
|
+
transaction = @client.query_put "signatures", secrets
|
241
|
+
end
|
242
|
+
|
243
|
+
# Puts request to create a delegate.
|
244
|
+
# `PUT /delegates`
|
245
|
+
def delegates_put delegate
|
246
|
+
delegate = @client.query_put "delegates", delegate
|
247
|
+
end
|
248
|
+
|
249
|
+
# Gets list of delegates by provided filter.
|
250
|
+
# `GET /delegates?limit=limit&offset=offset&orderBy=orderBy`
|
251
|
+
def delegates filter = nil
|
252
|
+
delegates = @client.query_get "delegates", filter
|
253
|
+
if delegates["success"]
|
254
|
+
return delegates["delegates"]
|
63
255
|
else
|
64
256
|
return nil
|
65
257
|
end
|
66
258
|
end
|
67
259
|
|
68
260
|
# Gets delegate by public key.
|
261
|
+
# `GET /delegates/get?publicKey=publicKey`
|
69
262
|
def delegates_get_by_key public_key
|
70
263
|
params = { :publicKey => public_key }
|
71
264
|
delegate = @client.query_get "delegates/get", params
|
@@ -76,7 +269,44 @@ module Lisk
|
|
76
269
|
end
|
77
270
|
end
|
78
271
|
|
272
|
+
# Gets delegate by username.
|
273
|
+
# `GET /delegates/get?username=username`
|
274
|
+
def delegates_get_by_name user_name
|
275
|
+
params = { :username => user_name }
|
276
|
+
delegate = @client.query_get "delegates/get", params
|
277
|
+
if delegate["success"]
|
278
|
+
return delegate["delegate"]
|
279
|
+
else
|
280
|
+
return nil
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
# Search for Delegates by "fuzzy" username.
|
285
|
+
# `GET /delegates/search?q=username&orderBy=producedblocks:desc`
|
286
|
+
def delegates_search query
|
287
|
+
delegates = @client.query_get "delegates/search", query
|
288
|
+
if delegates["success"]
|
289
|
+
return delegates["delegates"]
|
290
|
+
else
|
291
|
+
return nil
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
# Get total count of registered delegates.
|
296
|
+
# `GET /delegates/count`
|
297
|
+
def delegates_count
|
298
|
+
count = @client.query_get "delegates/count"
|
299
|
+
end
|
300
|
+
|
301
|
+
# Get votes by account wallet address.
|
302
|
+
# `GET /accounts/delegates/?address=address`
|
303
|
+
def accounts_delegates address
|
304
|
+
params = { :address => address }
|
305
|
+
account = @client.query_get "accounts/delegates", params
|
306
|
+
end
|
307
|
+
|
79
308
|
# Gets voters of delegate.
|
309
|
+
# `GET /delegates/voters?publicKey=publicKey`
|
80
310
|
def delegates_voters public_key
|
81
311
|
params = { :publicKey => public_key }
|
82
312
|
voters = @client.query_get "delegates/voters", params
|
@@ -87,14 +317,136 @@ module Lisk
|
|
87
317
|
end
|
88
318
|
end
|
89
319
|
|
90
|
-
#
|
91
|
-
|
92
|
-
|
93
|
-
|
320
|
+
# Enables forging for a delegate on the client node.
|
321
|
+
# `POST /delegates/forging/enable`
|
322
|
+
def delegates_forging_enable secret
|
323
|
+
params = { :secret => secret }
|
324
|
+
count = @client.query_post "delegates/forging/enable", params
|
325
|
+
end
|
326
|
+
|
327
|
+
# Disables forging for a delegate on the client node.
|
328
|
+
# `POST /delegates/forging/disable`
|
329
|
+
def delegates_forging_disable secret
|
330
|
+
params = { :secret => secret }
|
331
|
+
count = @client.query_post "delegates/forging/disable", params
|
332
|
+
end
|
333
|
+
|
334
|
+
# Get amount of Lisk forged by an account.
|
335
|
+
# `GET /delegates/forging/getForgedByAccount?generatorPublicKey=generatorPublicKey`
|
336
|
+
def delegates_forging_get_forged_by_account public_key
|
337
|
+
params = { :generatorPublicKey => public_key }
|
338
|
+
forged = @client.query_get "delegates/forging/getForgedByAccount", params
|
339
|
+
end
|
340
|
+
|
341
|
+
# Get next delegate lining up to forge.
|
342
|
+
# `GET /delegates/getNextForgers?limit=limit`
|
343
|
+
def delegates_get_next_forgers limit = 10
|
344
|
+
params = { :limit => limit }
|
345
|
+
forgers = @client.query_get "delegates/getNextForgers", params
|
346
|
+
end
|
347
|
+
|
348
|
+
#############################################
|
349
|
+
# https://github.com/4fryn/lisk.rb/issues/4 #
|
350
|
+
#############################################
|
351
|
+
|
352
|
+
# `PUT /dapps`
|
353
|
+
def dapps_put
|
354
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
355
|
+
end
|
356
|
+
|
357
|
+
# `GET /dapps?category=category&name=name&type=type&link=link&limit=limit&offset=offset&orderBy=orderBy`
|
358
|
+
def dapps filter
|
359
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
360
|
+
end
|
361
|
+
|
362
|
+
# `GET /dapps/get?id=id`
|
363
|
+
def dapps_get_by_id id
|
364
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
365
|
+
end
|
366
|
+
|
367
|
+
# `GET /dapps/search?q=q&category=category&installed=installed`
|
368
|
+
def dapps_search query
|
369
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
370
|
+
end
|
371
|
+
|
372
|
+
# `POST /dapps/install`
|
373
|
+
def dapps_install
|
374
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
375
|
+
end
|
376
|
+
|
377
|
+
# `GET /dapps/installed`
|
378
|
+
def dapps_installed
|
379
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
380
|
+
end
|
381
|
+
|
382
|
+
# `GET /dapps/installedIds`
|
383
|
+
def dapps_installed_ids
|
384
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
385
|
+
end
|
386
|
+
|
387
|
+
# `POST /dapps/uninstall`
|
388
|
+
def dapps_uninstall
|
389
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
390
|
+
end
|
391
|
+
|
392
|
+
# `POST /dapps/launch`
|
393
|
+
def dapps_launch
|
394
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
395
|
+
end
|
396
|
+
|
397
|
+
# `GET /dapps/installing`
|
398
|
+
def dapps_installing
|
399
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
400
|
+
end
|
401
|
+
|
402
|
+
# `GET /dapps/uninstalling`
|
403
|
+
def dapps_uninstalling
|
404
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
405
|
+
end
|
406
|
+
|
407
|
+
# `GET /dapps/launched`
|
408
|
+
def dapps_launched
|
409
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
410
|
+
end
|
411
|
+
|
412
|
+
# `GET /dapps/categories`
|
413
|
+
def dapps_categories
|
414
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
415
|
+
end
|
416
|
+
|
417
|
+
# `POST /dapps/stop`
|
418
|
+
def dapps_stop
|
419
|
+
todo "#{self}::#{__method__} UNIMPLEMENTED"
|
420
|
+
end
|
421
|
+
|
422
|
+
# Create a multi-signature account.
|
423
|
+
# `PUT /multisignatures`
|
424
|
+
def multisignatures_put secrets
|
425
|
+
transaction = @client.query_put "multisignatures", secrets
|
426
|
+
end
|
427
|
+
|
428
|
+
# Gets a list of accounts that belong to a multi-signature account.
|
429
|
+
# `GET /multisignatures/accounts?publicKey=publicKey`
|
430
|
+
def multisignatures_accounts public_key
|
431
|
+
params = { :publicKey => public_key }
|
432
|
+
accounts = @client.query_get "multisignatures/accounts", params
|
433
|
+
end
|
434
|
+
|
435
|
+
# Signs a transaction that is awaiting signature.
|
436
|
+
# `POST /multisignatures/sign`
|
437
|
+
def multisignatures_sign signature
|
438
|
+
transaction = @client.query_post "multisignatures/sign", signature
|
439
|
+
end
|
440
|
+
|
441
|
+
# Returns a list of multi-signature transactions that waiting for signature by publicKey.
|
442
|
+
# `GET /multisignatures/pending?publicKey=publicKey`
|
443
|
+
def multisignatures_pending public_key
|
444
|
+
params = { :publicKey => public_key }
|
445
|
+
transactions = @client.query_get "multisignatures/pending", params
|
94
446
|
end
|
95
447
|
|
96
448
|
# Handles unimplemented methods
|
97
|
-
def method_missing
|
449
|
+
def method_missing name, *args, &block
|
98
450
|
todo "#{self}::#{name} METHOD MISSING"
|
99
451
|
end
|
100
452
|
|
data/lib/lisk/version.rb
CHANGED
data/lib/lisk.rb
CHANGED
@@ -3,11 +3,12 @@ require "todonotes"
|
|
3
3
|
|
4
4
|
# The Lisk API Ruby wrapper gem.
|
5
5
|
module Lisk
|
6
|
+
require "lisk/api"
|
6
7
|
require "lisk/client"
|
7
8
|
require "lisk/legacy"
|
8
9
|
|
9
10
|
# Handles unimplemented methods
|
10
|
-
def
|
11
|
-
todo "#{self}::#{
|
11
|
+
def method_missing name, *args, &block
|
12
|
+
todo "#{self}::#{name} METHOD MISSING"
|
12
13
|
end
|
13
14
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lisk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 4fryn Dings
|
@@ -84,9 +84,11 @@ files:
|
|
84
84
|
- bin/console
|
85
85
|
- bin/debug
|
86
86
|
- bin/setup
|
87
|
+
- examples/legacy_api.rb
|
87
88
|
- examples/payout.rb
|
88
89
|
- examples/status.rb
|
89
90
|
- lib/lisk.rb
|
91
|
+
- lib/lisk/api.rb
|
90
92
|
- lib/lisk/client.rb
|
91
93
|
- lib/lisk/legacy.rb
|
92
94
|
- lib/lisk/version.rb
|