tezos_client 0.3.1 → 0.3.3
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/Gemfile.lock +1 -1
- data/lib/tezos_client.rb +21 -1
- data/lib/tezos_client/operations/transactions_operation.rb +29 -0
- data/lib/tezos_client/rpc_interface/helper.rb +23 -3
- data/lib/tezos_client/rpc_interface/request_manager.rb +1 -0
- data/lib/tezos_client/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4aa1db24bd40a81a56e7ae68975a143518c0cf57c336b2730af4d594b4ac1b37
|
4
|
+
data.tar.gz: d405e80590bdbbef3008ce472ce56f903af70fdd18b00eb58280c8689c6ae545
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 234b4f946357dc3bb5f8c55b6b4ac93b2e62d4fa40505fe67a5585cbd8025d814bffafdf74bb0a1f0630b46c0edd3ac6263a75228156618e535020d26ae98ac8
|
7
|
+
data.tar.gz: 464c118dc38b4a2686c90c5b2fe4d693e5c9ceb7222b8500e162fa7d641dea81544ea044b6e97279824bc7be8f7074d9a2730fcd4c73e2505076ed1077617ec6
|
data/Gemfile.lock
CHANGED
data/lib/tezos_client.rb
CHANGED
@@ -15,6 +15,7 @@ require "tezos_client/encode_utils"
|
|
15
15
|
require "tezos_client/operation"
|
16
16
|
require "tezos_client/operations/origination_operation"
|
17
17
|
require "tezos_client/operations/transaction_operation"
|
18
|
+
require "tezos_client/operations/transactions_operation"
|
18
19
|
|
19
20
|
require "tezos_client/client_interface"
|
20
21
|
require "tezos_client/rpc_interface"
|
@@ -104,6 +105,17 @@ class TezosClient
|
|
104
105
|
).test_and_broadcast
|
105
106
|
end
|
106
107
|
|
108
|
+
def transfer_to_many(from:, amounts:, secret_key:, **args)
|
109
|
+
TransactionsOperation.new(
|
110
|
+
liquidity_interface: liquidity_interface,
|
111
|
+
rpc_interface: rpc_interface,
|
112
|
+
from: from,
|
113
|
+
amounts: amounts,
|
114
|
+
secret_key: secret_key,
|
115
|
+
**args
|
116
|
+
).test_and_broadcast
|
117
|
+
end
|
118
|
+
|
107
119
|
def call_contract(args)
|
108
120
|
parameters = args.fetch(:parameters)
|
109
121
|
|
@@ -123,6 +135,7 @@ class TezosClient
|
|
123
135
|
monitoring_thread = rpc_interface.monitor_block do |block_header|
|
124
136
|
log "recently received block: #{block_header.pretty_inspect}"
|
125
137
|
hash = block_header["hash"]
|
138
|
+
|
126
139
|
if block_include_operation?(operation_id, hash)
|
127
140
|
log "operations #{operation_id} found in block #{hash}"
|
128
141
|
including_block = hash
|
@@ -132,11 +145,18 @@ class TezosClient
|
|
132
145
|
Timeout.timeout(timeout) do
|
133
146
|
loop do
|
134
147
|
sleep(0.1)
|
148
|
+
break unless monitoring_thread.alive?
|
135
149
|
break unless including_block.nil?
|
136
150
|
end
|
137
151
|
end
|
138
152
|
|
139
|
-
monitoring_thread.
|
153
|
+
if monitoring_thread.status.nil?
|
154
|
+
# when thread raise an Exception, reraise it
|
155
|
+
log "monitoring thread raised an exception"
|
156
|
+
monitoring_thread.value
|
157
|
+
else
|
158
|
+
monitoring_thread.terminate
|
159
|
+
end
|
140
160
|
|
141
161
|
including_block
|
142
162
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class TezosClient
|
2
|
+
class TransactionsOperation < Operation
|
3
|
+
include EncodeUtils
|
4
|
+
|
5
|
+
def initialize_operation_args
|
6
|
+
@operation_args = default_args.merge(
|
7
|
+
**@init_args,
|
8
|
+
operation_kind: operation_kind,
|
9
|
+
branch: branch,
|
10
|
+
counter: counter
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
def operation_kind
|
16
|
+
:transactions
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def default_args
|
22
|
+
{
|
23
|
+
gas_limit: 0.1,
|
24
|
+
storage_limit: 0.006,
|
25
|
+
fee: 0.05
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -20,6 +20,21 @@ class TezosClient
|
|
20
20
|
operation
|
21
21
|
end
|
22
22
|
|
23
|
+
def transactions_operation(args)
|
24
|
+
args[:amounts].map.with_index do |(destination, amount), index|
|
25
|
+
{
|
26
|
+
kind: "transaction",
|
27
|
+
amount: amount.to_satoshi.to_s,
|
28
|
+
source: args.fetch(:from),
|
29
|
+
destination: destination,
|
30
|
+
gas_limit: args.fetch(:gas_limit).to_satoshi.to_s,
|
31
|
+
storage_limit: args.fetch(:storage_limit).to_satoshi.to_s,
|
32
|
+
counter: (args.fetch(:counter) + index).to_s,
|
33
|
+
fee: args.fetch(:fee).to_satoshi.to_s
|
34
|
+
}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
23
38
|
def origination_operation(args)
|
24
39
|
operation = {
|
25
40
|
kind: "origination",
|
@@ -65,7 +80,7 @@ class TezosClient
|
|
65
80
|
content = {
|
66
81
|
protocol: args.fetch(:protocol),
|
67
82
|
branch: args.fetch(:branch),
|
68
|
-
contents:
|
83
|
+
contents: contents(args),
|
69
84
|
signature: args.fetch(:signature)
|
70
85
|
}
|
71
86
|
|
@@ -77,7 +92,7 @@ class TezosClient
|
|
77
92
|
def run_operation(args)
|
78
93
|
content = {
|
79
94
|
branch: args.fetch(:branch),
|
80
|
-
contents:
|
95
|
+
contents: contents(args),
|
81
96
|
signature: args.fetch(:signature)
|
82
97
|
}
|
83
98
|
res = post("chains/main/blocks/head/helpers/scripts/run_operation", content)
|
@@ -87,7 +102,7 @@ class TezosClient
|
|
87
102
|
def forge_operation(args)
|
88
103
|
content = {
|
89
104
|
branch: args.fetch(:branch),
|
90
|
-
contents:
|
105
|
+
contents: contents(args)
|
91
106
|
}
|
92
107
|
post("chains/main/blocks/head/helpers/forge/operations", content)
|
93
108
|
end
|
@@ -95,6 +110,11 @@ class TezosClient
|
|
95
110
|
def broadcast_operation(data)
|
96
111
|
post("injection/operation?chain=main", data)
|
97
112
|
end
|
113
|
+
|
114
|
+
def contents(args)
|
115
|
+
operation = operation(args)
|
116
|
+
(operation.is_a?(Array)) ? operation : [operation]
|
117
|
+
end
|
98
118
|
end
|
99
119
|
end
|
100
120
|
end
|
data/lib/tezos_client/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tezos_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pierre Michard
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -229,6 +229,7 @@ files:
|
|
229
229
|
- lib/tezos_client/operation.rb
|
230
230
|
- lib/tezos_client/operations/origination_operation.rb
|
231
231
|
- lib/tezos_client/operations/transaction_operation.rb
|
232
|
+
- lib/tezos_client/operations/transactions_operation.rb
|
232
233
|
- lib/tezos_client/rpc_interface.rb
|
233
234
|
- lib/tezos_client/rpc_interface/blocks.rb
|
234
235
|
- lib/tezos_client/rpc_interface/context.rb
|