tezos_client 0.4.14 → 0.4.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 462e81ddcbebfb1cecb9c99b577810e47aa7b657b5cc3f88b3e2ffd8e23fc326
4
- data.tar.gz: 1c87b82243cac80fcde31551471f25d98623c0bfa323f4eccd238ee3f776f93e
3
+ metadata.gz: 6918aa7a0020b8bc535f58720f2a330cd5842821f9fe4106ad6a419a3a2144f6
4
+ data.tar.gz: 92ea0ac98411dbaf325ba5a4de15b9d7e20c0fdc2f2a39c8385a68316a9be62d
5
5
  SHA512:
6
- metadata.gz: 8ab7ba2e5e37024370536a0f31d0e6da53c31a74227d6f903b79d83e9ad700f3be4c710aac1135237ad287e99c1fbb93860ff37d8f0f4cc8dffe89a43ed81cc2
7
- data.tar.gz: e1e0c5752ed8d64fe2b83b24779262d52d0c9b7136c7df6ca8cddc0d278aada1476df47efa7254188872f3684b7295834fbd979191b7788c22be2e0f79862a2f
6
+ metadata.gz: 73c784ec8610a4134a06e3eafe65e35f898ec319da10b55f4eb843ad081e0a7420782dee94913ba24cfe38cb136646b8df86de3cdb6ccf548a65f656f5386f46
7
+ data.tar.gz: e05b46acbc78a971de657dd85a8f20eb4b964958309df343a4c78950f246300123591592778870a2826d80b8bab116bca53c34d894f1dabd19f4de9bfe310171
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tezos_client (0.4.13)
4
+ tezos_client (0.4.15)
5
5
  activesupport (~> 6.0.0)
6
6
  base58 (~> 0.2.3)
7
7
  bip_mnemonic (~> 0.0.2)
@@ -47,7 +47,7 @@ GEM
47
47
  domain_name (0.5.20190701)
48
48
  unf (>= 0.0.5, < 1.0.0)
49
49
  erubi (1.9.0)
50
- ffi (1.11.1)
50
+ ffi (1.11.3)
51
51
  hashdiff (1.0.0)
52
52
  http-cookie (1.0.3)
53
53
  domain_name (~> 0.5)
@@ -57,7 +57,7 @@ GEM
57
57
  i18n (1.7.0)
58
58
  concurrent-ruby (~> 1.0)
59
59
  jaro_winkler (1.5.3)
60
- loofah (2.3.0)
60
+ loofah (2.3.1)
61
61
  crass (~> 1.0.2)
62
62
  nokogiri (>= 1.5.9)
63
63
  method_source (0.9.2)
@@ -70,7 +70,7 @@ GEM
70
70
  ffi
71
71
  multi_xml (0.6.0)
72
72
  netrc (0.11.0)
73
- nokogiri (1.10.4)
73
+ nokogiri (1.10.5)
74
74
  mini_portile2 (~> 2.4.0)
75
75
  parallel (1.18.0)
76
76
  parser (2.6.5.0)
@@ -5,9 +5,9 @@ class TezosClient
5
5
  # Commands managing keys and accounts
6
6
  module BlockContextual
7
7
  def transfer(quantity:, from:, to:, dry_run: false, arg: nil)
8
- cmd = "transfer #{quantity} from #{from} to #{to}"
9
- cmd = "#{cmd} --dry-run" if dry_run
10
- cmd = "#{cmd} --arg #{arg}" unless arg.nil?
8
+ cmd = ["transfer", quantity, "from", from, "to", to]
9
+ cmd << "--dry-run" if dry_run
10
+ cmd += ["--arg", "#{arg}"] unless arg.nil?
11
11
 
12
12
  res = call_client(cmd)
13
13
  end
@@ -5,8 +5,8 @@ class TezosClient
5
5
  # Wrapper used to call the tezos-client binary
6
6
  module ClientWrapper
7
7
  def call_client(command)
8
- cmd = "#{client_cmd} #{command}"
9
- Open3.popen3(cmd) do |_stdin, stdout, stderr, wait_thr|
8
+ cmd = client_cmd + command
9
+ Open3.popen3(*cmd) do |_stdin, stdout, stderr, wait_thr|
10
10
  err = stderr.read
11
11
  status = wait_thr.value.exitstatus
12
12
 
@@ -26,9 +26,9 @@ class TezosClient
26
26
  end
27
27
 
28
28
  def client_cmd
29
- res = "tezos-client -l"
29
+ res = ["tezos-client", "-l"]
30
30
  if config_file
31
- res = "#{res} -c #{config_file}"
31
+ res += ["-c", config_file]
32
32
  end
33
33
  res
34
34
  end
@@ -5,7 +5,7 @@ class TezosClient
5
5
  # Commands managing keys and accounts
6
6
  module Contract
7
7
  def known_contracts
8
- res = call_client("list known contracts")
8
+ res = call_client(["list", "known", "contracts"])
9
9
  res.lines.reduce({}) do |acc, contract_output|
10
10
  address_format = /([^:]+): (\w+)/
11
11
  res = address_format.match(contract_output)
@@ -5,11 +5,11 @@ class TezosClient
5
5
  # Commands managing keys and accounts
6
6
  module Key
7
7
  def gen_keys(name)
8
- call_client("gen keys #{name}")
8
+ call_client(["gen", "keys", name])
9
9
  end
10
10
 
11
11
  def addresses
12
- output = call_client("list known addresses")
12
+ output = call_client(["list", "known", "addresses"])
13
13
  output.lines.reduce({}) do |acc, address_output|
14
14
  address_format = /([^:]+): (\w+) /
15
15
  res = address_format.match(address_output)
@@ -18,15 +18,15 @@ class TezosClient
18
18
  end
19
19
 
20
20
  def import_public_key(name, public_key, force: false)
21
- cmd = "import public key #{name} #{public_key}"
22
- cmd = "#{cmd} --force" if force
21
+ cmd = ["import", "public", "key", name, public_key]
22
+ cmd << "--force" if force
23
23
 
24
24
  call_client(cmd)
25
25
  end
26
26
 
27
27
  def import_secret_key(name, secret_key, force: false)
28
- cmd = "import secret key #{name} #{secret_key}"
29
- cmd = "#{cmd} --force" if force
28
+ cmd = ["import", "secret", "key", name, secret_key]
29
+ cmd << "--force" if force
30
30
 
31
31
  call_client(cmd)
32
32
  end
@@ -7,7 +7,7 @@ class TezosClient
7
7
  class ClientInterface
8
8
  module Misc
9
9
  def bootstrapped
10
- call_client("bootstrapped") do |output|
10
+ call_client(["bootstrapped"]) do |output|
11
11
  output_format = /Current head: ([^ ]+) \(timestamp: ([^,]+), validation: (.+)\)/
12
12
  res = output_format.match(output)
13
13
  head = res[1]
@@ -5,17 +5,17 @@ class TezosClient
5
5
  # Wrapper used to call the tezos-client binary
6
6
  module LiquidityWrapper
7
7
  def call_liquidity(command, verbose: false)
8
- cmd = "#{liquidity_cmd(verbose: verbose)} #{command}"
9
- log cmd
10
- Open3.popen3(cmd) do |_stdin, stdout, stderr, wait_thr|
8
+ cmd = liquidity_cmd(verbose: verbose).concat command
9
+ log cmd.to_s
10
+ Open3.popen3(*cmd) do |_stdin, stdout, stderr, wait_thr|
11
11
  err = stderr.read
12
12
  status = wait_thr.value.exitstatus
13
+ log err
13
14
 
14
15
  if status != 0
15
16
  raise "command '#{cmd}' existed with status #{status}: #{err}"
16
17
  end
17
18
 
18
- log err
19
19
  output = stdout.read
20
20
 
21
21
  if block_given?
@@ -27,8 +27,11 @@ class TezosClient
27
27
  end
28
28
 
29
29
  def liquidity_cmd(verbose:)
30
- verbose_option = verbose ? "--verbose" : ""
31
- "liquidity #{verbose_option} --tezos-node #{tezos_node}"
30
+ liquidity_request = ["liquidity"]
31
+ liquidity_request << "--verbose" if verbose
32
+ liquidity_request << "--tezos-node"
33
+ liquidity_request << tezos_node.to_s
34
+ liquidity_request
32
35
  end
33
36
  end
34
37
  end
@@ -16,10 +16,10 @@ class TezosClient
16
16
  end
17
17
 
18
18
  def format_params(params)
19
- return "" if params.nil?
19
+ return [] if params.nil?
20
+ return [params] if params.is_a? String
20
21
 
21
- params = [params] if params.is_a? String
22
- params.map { |s| "'#{s}'" }.join(" ")
22
+ params
23
23
  end
24
24
 
25
25
  def initial_storage(args)
@@ -29,7 +29,9 @@ class TezosClient
29
29
  init_params = format_params(init_params)
30
30
 
31
31
  with_tempfile(".json") do |json_file|
32
- call_liquidity "--source #{from} --json #{script} -o #{json_file.path} --init-storage #{init_params}", verbose: options[:verbose]
32
+ cmd_opt = ["--source", from.to_s,"--json", script.to_s, "-o", json_file.path.to_s, "--init-storage"] + init_params
33
+
34
+ call_liquidity cmd_opt, verbose: options[:verbose]
33
35
  JSON.parse json_file.read.strip
34
36
  end
35
37
  end
@@ -67,7 +69,7 @@ class TezosClient
67
69
  json_init_script_path = "#{script_basename}.initializer.tz.json"
68
70
  json_contract_script_path = "#{script_basename}.tz.json"
69
71
 
70
- call_liquidity "--json #{script_copy_path}"
72
+ call_liquidity ["--json", "#{script_copy_path}"]
71
73
 
72
74
  json_contract_script_file = File.open(json_contract_script_path)
73
75
  json_contract_script = JSON.parse(json_contract_script_file.read)
@@ -110,7 +112,11 @@ class TezosClient
110
112
  script = args.fetch :script
111
113
  init_params = args.fetch :init_params
112
114
 
113
- res = call_liquidity "--source #{source} #{spendable ? '--spendable' : ''} #{delegatable ? '--delegatable' : ''} --amount #{amount}tz #{script} --forge-deploy '#{init_params}'"
115
+ cmd_opt = ["--source", "#{source}"]
116
+ cmd_opt << "--spendable" if spendable
117
+ cmd_opt << "--delegatable" if delegatable
118
+ cmd_opt += ["--amount", "#{amount}tz", "#{script}", "--forge-deploy", init_params]
119
+ res = call_liquidity cmd_opt
114
120
  res.strip
115
121
  end
116
122
 
@@ -119,20 +125,20 @@ class TezosClient
119
125
  end
120
126
 
121
127
  def get_storage(script:, contract_address:)
122
- res = call_liquidity "#{script} --get-storage #{contract_address}"
128
+ res = call_liquidity ["#{script}", "--get-storage", "#{contract_address}"]
123
129
  res.strip
124
130
  end
125
131
 
126
132
  def call_parameters(script:, parameters:)
127
- parameters = format_params(parameters)
133
+ params = format_params parameters
128
134
  with_tempfile(".json") do |json_file|
129
- res = call_liquidity "--json -o #{json_file.path} #{script} --data #{parameters}"
135
+ res = call_liquidity ["--json", "-o", "#{json_file.path}", "#{script}", "--data"] + params
130
136
  JSON.parse res
131
137
  end
132
138
  end
133
139
 
134
140
  def pack_data(data:, type:)
135
- res = call_liquidity "--pack '#{data}' '#{type}'"
141
+ res = call_liquidity ["--pack", "#{data}", "#{type}"]
136
142
  res.strip
137
143
  end
138
144
  end
@@ -71,7 +71,7 @@ class TezosClient
71
71
 
72
72
  def get_error_id(error)
73
73
  error[:id]
74
- rescue TypeError
74
+ rescue TypeError, NoMethodError
75
75
  nil
76
76
  end
77
77
 
@@ -87,7 +87,7 @@ class TezosClient
87
87
  end
88
88
 
89
89
  def failed!(url:, code:, responses:)
90
- error = responses.is_a?(String) ? responses : responses[0]
90
+ error = responses.is_a?(Array) ? responses[0] : responses
91
91
  raise exception_klass(error).new(
92
92
  error: error,
93
93
  url: url,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class TezosClient
4
- VERSION = "0.4.14"
4
+ VERSION = "0.4.15"
5
5
  end
data/lib/tezos_client.rb CHANGED
@@ -229,8 +229,17 @@ class TezosClient
229
229
  end
230
230
 
231
231
  def block_include_operation?(operation_id, block_id)
232
+ retries ||= 0
233
+
232
234
  operations = rpc_interface.get("chains/main/blocks/#{block_id}/operation_hashes")
233
235
  operations.flatten.include? operation_id
236
+ rescue TezosClient::RpcRequestFailure
237
+ if (retries += 1) < 3
238
+ sleep(2)
239
+ retry
240
+ else
241
+ raise
242
+ end
234
243
  end
235
244
 
236
245
  private
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.4.14
4
+ version: 0.4.15
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-10-31 00:00:00.000000000 Z
11
+ date: 2019-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -285,7 +285,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
285
285
  - !ruby/object:Gem::Version
286
286
  version: '0'
287
287
  requirements: []
288
- rubygems_version: 3.0.3
288
+ rubyforge_project:
289
+ rubygems_version: 2.7.6
289
290
  signing_key:
290
291
  specification_version: 4
291
292
  summary: Wrapper to the tezos client.