tezos_client 1.4.2 → 1.4.3

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: 1c8d4619d5d7e8e2284ffeaabf6246eaf8d820f9bd6254531fab3e8d91ccaa34
4
- data.tar.gz: 7e1af738f349993d04fb2927f74997c97b450ec237be00da00beba3493537318
3
+ metadata.gz: fd58876a037528bff5019e089ead07ea6eaa2f4e68ec029f33c73735d4710370
4
+ data.tar.gz: 588d6eb55a1a226cb824968033f181296572886cf08aae029d6227e824350db2
5
5
  SHA512:
6
- metadata.gz: 12cb96c43a471b6b95bbff5bd08ffa881625665c8a8b3f1cf863f3e689e56943fcab60da963800a5f1d41c1e7d232a1082123b87dc617369eba6660b54982385
7
- data.tar.gz: a6aac981053e825b65802caca8855113068f9a8e9a9cfdcc4fcd57c594083c9b6b65563ea61874ae145f6e9ee528b78edefc1c1ecee8161c5135fab7d196b8fd
6
+ metadata.gz: d6bdd249d4606aac1c18aad5acead48d4a2296816942e42b1cbe77ae4e5202efd4ce73fcaa088e17db500d7874988ae7452bc70d6dd1ee48485af0674f7362fb
7
+ data.tar.gz: 88bb21809370468db816e00267ad93b6a727c90dbea8afe6a7f2aa67881acf120beb085287d8964e1217b605b9a1c05fbb0d7740ce65dd086e96d11e0b792621
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tezos_client (1.4.1)
4
+ tezos_client (1.4.2)
5
5
  active_interaction (>= 3.8)
6
6
  activesupport (~> 6.0.0)
7
7
  base58 (~> 0.2.3)
@@ -14,154 +14,158 @@ PATH
14
14
  GEM
15
15
  remote: https://rubygems.org/
16
16
  specs:
17
- actionpack (6.0.3.7)
18
- actionview (= 6.0.3.7)
19
- activesupport (= 6.0.3.7)
17
+ actionpack (6.0.4.4)
18
+ actionview (= 6.0.4.4)
19
+ activesupport (= 6.0.4.4)
20
20
  rack (~> 2.0, >= 2.0.8)
21
21
  rack-test (>= 0.6.3)
22
22
  rails-dom-testing (~> 2.0)
23
23
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
24
- actionview (6.0.3.7)
25
- activesupport (= 6.0.3.7)
24
+ actionview (6.0.4.4)
25
+ activesupport (= 6.0.4.4)
26
26
  builder (~> 3.1)
27
27
  erubi (~> 1.4)
28
28
  rails-dom-testing (~> 2.0)
29
29
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
30
- active_interaction (4.0.1)
31
- activemodel (>= 5, < 7)
32
- activemodel (6.0.3.7)
33
- activesupport (= 6.0.3.7)
34
- activesupport (6.0.3.7)
30
+ active_interaction (4.1.0)
31
+ activemodel (>= 5, < 8)
32
+ activesupport (>= 5, < 8)
33
+ activemodel (6.0.4.4)
34
+ activesupport (= 6.0.4.4)
35
+ activesupport (6.0.4.4)
35
36
  concurrent-ruby (~> 1.0, >= 1.0.2)
36
37
  i18n (>= 0.7, < 2)
37
38
  minitest (~> 5.1)
38
39
  tzinfo (~> 1.1)
39
40
  zeitwerk (~> 2.2, >= 2.2.2)
40
- addressable (2.7.0)
41
+ addressable (2.8.0)
41
42
  public_suffix (>= 2.0.2, < 5.0)
42
43
  ast (2.4.2)
43
44
  base58 (0.2.3)
44
45
  bip_mnemonic (0.0.4)
45
46
  builder (3.2.4)
46
47
  coderay (1.1.3)
47
- concurrent-ruby (1.1.8)
48
+ concurrent-ruby (1.1.9)
48
49
  crack (0.4.5)
49
50
  rexml
50
51
  crass (1.0.6)
51
- diff-lcs (1.4.4)
52
+ diff-lcs (1.5.0)
52
53
  domain_name (0.5.20190701)
53
54
  unf (>= 0.0.5, < 1.0.0)
54
55
  erubi (1.10.0)
55
- ffi (1.15.1)
56
+ ffi (1.15.5)
56
57
  hashdiff (1.0.1)
57
- http-cookie (1.0.3)
58
+ http-cookie (1.0.4)
58
59
  domain_name (~> 0.5)
59
60
  httparty (0.17.3)
60
61
  mime-types (~> 3.0)
61
62
  multi_xml (>= 0.5.2)
62
- i18n (1.8.10)
63
+ i18n (1.9.1)
63
64
  concurrent-ruby (~> 1.0)
64
- loofah (2.9.1)
65
+ loofah (2.13.0)
65
66
  crass (~> 1.0.2)
66
67
  nokogiri (>= 1.5.9)
67
68
  method_source (1.0.0)
68
- mime-types (3.3.1)
69
+ mime-types (3.4.1)
69
70
  mime-types-data (~> 3.2015)
70
- mime-types-data (3.2021.0225)
71
- minitest (5.14.4)
71
+ mime-types-data (3.2022.0105)
72
+ minitest (5.15.0)
72
73
  money-tree (0.10.0)
73
74
  ffi
74
75
  multi_xml (0.6.0)
75
76
  netrc (0.11.0)
76
- nokogiri (1.11.6-x86_64-darwin)
77
+ nokogiri (1.13.1-x86_64-darwin)
77
78
  racc (~> 1.4)
78
- parallel (1.20.1)
79
- parser (3.0.1.1)
79
+ parallel (1.21.0)
80
+ parser (3.1.0.0)
80
81
  ast (~> 2.4.1)
81
82
  pry (0.14.1)
82
83
  coderay (~> 1.1)
83
84
  method_source (~> 1.0)
84
85
  public_suffix (4.0.6)
85
- racc (1.5.2)
86
+ racc (1.6.0)
86
87
  rack (2.2.3)
87
88
  rack-test (1.1.0)
88
89
  rack (>= 1.0, < 3)
89
90
  rails-dom-testing (2.0.3)
90
91
  activesupport (>= 4.2.0)
91
92
  nokogiri (>= 1.6)
92
- rails-html-sanitizer (1.3.0)
93
+ rails-html-sanitizer (1.4.2)
93
94
  loofah (~> 2.3)
94
- railties (6.0.3.7)
95
- actionpack (= 6.0.3.7)
96
- activesupport (= 6.0.3.7)
95
+ railties (6.0.4.4)
96
+ actionpack (= 6.0.4.4)
97
+ activesupport (= 6.0.4.4)
97
98
  method_source
98
99
  rake (>= 0.8.7)
99
100
  thor (>= 0.20.3, < 2.0)
100
- rainbow (3.0.0)
101
- rake (13.0.3)
101
+ rainbow (3.1.1)
102
+ rake (13.0.6)
102
103
  rbnacl (5.0.0)
103
104
  ffi
104
- regexp_parser (2.1.1)
105
+ regexp_parser (2.2.0)
105
106
  rest-client (2.0.2)
106
107
  http-cookie (>= 1.0.2, < 2.0)
107
108
  mime-types (>= 1.16, < 4.0)
108
109
  netrc (~> 0.8)
109
110
  rexml (3.2.5)
110
- rspec (3.10.0)
111
- rspec-core (~> 3.10.0)
112
- rspec-expectations (~> 3.10.0)
113
- rspec-mocks (~> 3.10.0)
114
- rspec-core (3.10.1)
115
- rspec-support (~> 3.10.0)
116
- rspec-expectations (3.10.1)
111
+ rspec (3.11.0)
112
+ rspec-core (~> 3.11.0)
113
+ rspec-expectations (~> 3.11.0)
114
+ rspec-mocks (~> 3.11.0)
115
+ rspec-core (3.11.0)
116
+ rspec-support (~> 3.11.0)
117
+ rspec-expectations (3.11.0)
117
118
  diff-lcs (>= 1.2.0, < 2.0)
118
- rspec-support (~> 3.10.0)
119
- rspec-mocks (3.10.2)
119
+ rspec-support (~> 3.11.0)
120
+ rspec-mocks (3.11.0)
120
121
  diff-lcs (>= 1.2.0, < 2.0)
121
- rspec-support (~> 3.10.0)
122
- rspec-support (3.10.2)
123
- rubocop (1.15.0)
122
+ rspec-support (~> 3.11.0)
123
+ rspec-support (3.11.0)
124
+ rubocop (1.25.1)
124
125
  parallel (~> 1.10)
125
- parser (>= 3.0.0.0)
126
+ parser (>= 3.1.0.0)
126
127
  rainbow (>= 2.2.2, < 4.0)
127
128
  regexp_parser (>= 1.8, < 3.0)
128
129
  rexml
129
- rubocop-ast (>= 1.5.0, < 2.0)
130
+ rubocop-ast (>= 1.15.1, < 2.0)
130
131
  ruby-progressbar (~> 1.7)
131
132
  unicode-display_width (>= 1.4.0, < 3.0)
132
- rubocop-ast (1.6.0)
133
+ rubocop-ast (1.15.1)
133
134
  parser (>= 3.0.1.1)
135
+ rubocop-minitest (0.17.1)
136
+ rubocop (>= 0.90, < 2.0)
134
137
  rubocop-packaging (0.5.1)
135
138
  rubocop (>= 0.89, < 2.0)
136
- rubocop-performance (1.11.3)
139
+ rubocop-performance (1.13.2)
137
140
  rubocop (>= 1.7.0, < 2.0)
138
141
  rubocop-ast (>= 0.4.0)
139
- rubocop-rails (2.10.1)
142
+ rubocop-rails (2.13.2)
140
143
  activesupport (>= 4.2.0)
141
144
  rack (>= 1.1)
142
145
  rubocop (>= 1.7.0, < 2.0)
143
- rubocop-rails_config (1.5.3)
146
+ rubocop-rails_config (1.8.2)
144
147
  railties (>= 5.0)
145
- rubocop (>= 1.13)
148
+ rubocop (>= 1.19)
146
149
  rubocop-ast (>= 1.0.1)
150
+ rubocop-minitest (~> 0.15)
147
151
  rubocop-packaging (~> 0.5)
148
152
  rubocop-performance (~> 1.11)
149
153
  rubocop-rails (~> 2.0)
150
154
  ruby-progressbar (1.11.0)
151
- thor (1.1.0)
155
+ thor (1.2.1)
152
156
  thread_safe (0.3.6)
153
157
  tzinfo (1.2.9)
154
158
  thread_safe (~> 0.1)
155
159
  unf (0.1.4)
156
160
  unf_ext
157
- unf_ext (0.0.7.7)
158
- unicode-display_width (2.0.0)
161
+ unf_ext (0.0.8)
162
+ unicode-display_width (2.1.0)
159
163
  vcr (4.0.0)
160
- webmock (3.13.0)
161
- addressable (>= 2.3.6)
164
+ webmock (3.14.0)
165
+ addressable (>= 2.8.0)
162
166
  crack (>= 0.3.2)
163
167
  hashdiff (>= 0.4.0, < 2.0.0)
164
- zeitwerk (2.4.2)
168
+ zeitwerk (2.5.4)
165
169
 
166
170
  PLATFORMS
167
171
  x86_64-darwin-19
data/README.md CHANGED
@@ -59,9 +59,9 @@ client = TezosClient.new
59
59
  key = subject.generate_key
60
60
  expect(key[:address]).to eq "tz1RfnzRopJXH32SSDap2wMYGULBAnmHxdP1"
61
61
  # => {
62
- # :secret_key=>"edsk4T2fHv5RLL3VSXHz82SQiyFx7vZ4wwtA2u67AvAaw5yqNEvuU2",
63
- # :public_key=>"edpkuncp7KSVhV57Qg7odwhMFcnAHnNrMppbitBPKBfvdg6fFVeNjr",
64
- # :address=>"tz1a97x7GAvMDyrwwKTLQo131CoidXyUef48"
62
+ # secret_key: "edsk4T2fHv5RLL3VSXHz82SQiyFx7vZ4wwtA2u67AvAaw5yqNEvuU2",
63
+ # public_key: "edpkuncp7KSVhV57Qg7odwhMFcnAHnNrMppbitBPKBfvdg6fFVeNjr",
64
+ # address: "tz1a97x7GAvMDyrwwKTLQo131CoidXyUef48"
65
65
  # }
66
66
  ```
67
67
 
@@ -71,9 +71,9 @@ Generate a key pair from a seed and a BIP 44 Path:
71
71
  key = subject.generate_key(wallet_seed:"000102030405060708090a0b0c0d0e0f", path: "m/44'/1729'/0'/0'/0'")
72
72
  expect(key[:address]).to eq "tz1RfnzRopJXH32SSDap2wMYGULBAnmHxdP1"
73
73
  # => {
74
- # :secret_key=>"edsk4T2fHv5RLL3VSXHz82SQiyFx7vZ4wwtA2u67AvAaw5yqNEvuU2",
75
- # :public_key=>"edpkuncp7KSVhV57Qg7odwhMFcnAHnNrMppbitBPKBfvdg6fFVeNjr",
76
- # :address=>"tz1a97x7GAvMDyrwwKTLQo131CoidXyUef48"
74
+ # secret_key: "edsk4T2fHv5RLL3VSXHz82SQiyFx7vZ4wwtA2u67AvAaw5yqNEvuU2",
75
+ # public_key: "edpkuncp7KSVhV57Qg7odwhMFcnAHnNrMppbitBPKBfvdg6fFVeNjr",
76
+ # address: "tz1a97x7GAvMDyrwwKTLQo131CoidXyUef48"
77
77
  # }
78
78
  ```
79
79
  Generate a key pair from a BIP-39 mnemonic sentence and a BIP 44 Path:
@@ -84,9 +84,9 @@ key = subject.generate_key(
84
84
  path: "m/44'/1729'/0'/0'/0'")
85
85
  expect(key[:address]).to eq "tz1RfnzRopJXH32SSDap2wMYGULBAnmHxdP1"
86
86
  # => {
87
- # :secret_key=>"edsk4T2fHv5RLL3VSXHz82SQiyFx7vZ4wwtA2u67AvAaw5yqNEvuU2",
88
- # :public_key=>"edpkuncp7KSVhV57Qg7odwhMFcnAHnNrMppbitBPKBfvdg6fFVeNjr",
89
- # :address=>"tz1a97x7GAvMDyrwwKTLQo131CoidXyUef48"
87
+ # secret_key: "edsk4T2fHv5RLL3VSXHz82SQiyFx7vZ4wwtA2u67AvAaw5yqNEvuU2",
88
+ # public_key: "edpkuncp7KSVhV57Qg7odwhMFcnAHnNrMppbitBPKBfvdg6fFVeNjr",
89
+ # address: "tz1a97x7GAvMDyrwwKTLQo131CoidXyUef48"
90
90
  # }
91
91
  ```
92
92
 
@@ -31,8 +31,8 @@ class TezosClient
31
31
  def group_by_max_counter(arr)
32
32
  arr.map(&:with_indifferent_access)
33
33
  .group_by { |hsh| hsh[:source] }
34
- .each_with_object({}) do |(source, contents), acc|
35
- acc[source] = contents.max_by { |content| content[:counter].to_i }[:counter]
34
+ .transform_values do |contents|
35
+ contents.max_by { |content| content[:counter].to_i }[:counter]
36
36
  end
37
37
  end
38
38
  end
@@ -103,7 +103,7 @@ class TezosClient
103
103
  rejection_error = errors.detect { |error| error[:id].match? ERROR_REGEXP }
104
104
 
105
105
  @location = rejection_error[:location]
106
- @contract = first_error[:contractHandle]
106
+ @contract = first_error[:contractHandle]
107
107
  @with = rejection_error[:with]
108
108
  @message = "Script runtime Error when executing #{contract}: #{with} (location: #{location})"
109
109
  super
@@ -5,11 +5,9 @@ class TezosClient
5
5
  include EncodeUtils
6
6
 
7
7
  def rpc_operation_args
8
- @rpc_operation_args ||= begin
9
- rpc_interface.transaction_operation(
8
+ @rpc_operation_args ||= rpc_interface.transaction_operation(
10
9
  operation_args
11
10
  )
12
- end
13
11
  end
14
12
 
15
13
  private
@@ -3,14 +3,12 @@
3
3
  class TezosClient
4
4
  class TransactionsOperation < Operation
5
5
  def rpc_operation_args
6
- @rpc_operation_args ||= begin
7
- OperationArray.new(
6
+ @rpc_operation_args ||= OperationArray.new(
8
7
  operations: operations,
9
8
  secret_key: @args.fetch(:secret_key),
10
9
  from: @args.fetch(:from),
11
10
  rpc_interface: rpc_interface
12
11
  ).rpc_operation_args
13
- end
14
12
  end
15
13
 
16
14
  def operations
@@ -28,50 +28,50 @@ class TezosClient
28
28
  end
29
29
 
30
30
  private
31
- def compile_to_michelson(args)
32
- Tools::TemporaryFile.with_file_copy(args[:script]) do |script_copy_path|
33
- script_basename = script_copy_path.split("/").last.sub(/.py$/, "")
34
- script_path = "/tmp/#{script_basename}/"
35
- init_script_filename = "step_000_cont_0_storage.json"
36
- contract_script_filename = "step_000_cont_0_contract.json"
37
-
38
- cmd_line = ["compile", script_copy_path, script_path].concat(
39
- optional_inputs(args[:smartpy_flags], args[:init_params])
40
- )
31
+ def compile_to_michelson(args)
32
+ Tools::TemporaryFile.with_file_copy(args[:script]) do |script_copy_path|
33
+ script_basename = script_copy_path.split("/").last.sub(/.py$/, "")
34
+ script_path = "/tmp/#{script_basename}/"
35
+ init_script_filename = "step_000_cont_0_storage.json"
36
+ contract_script_filename = "step_000_cont_0_contract.json"
37
+
38
+ cmd_line = ["compile", script_copy_path, script_path].concat(
39
+ optional_inputs(args[:smartpy_flags], args[:init_params])
40
+ )
41
41
 
42
- call_smartpy cmd_line
42
+ call_smartpy cmd_line
43
43
 
44
- yield(script_path + "default/" + contract_script_filename, script_path + "default/" + init_script_filename)
44
+ yield(script_path + "default/" + contract_script_filename, script_path + "default/" + init_script_filename)
45
+ end
45
46
  end
46
- end
47
47
 
48
- def optional_inputs(flags, init_params)
49
- inputs = []
48
+ def optional_inputs(flags, init_params)
49
+ inputs = []
50
50
 
51
- inputs.concat(optional_flags(flags))
52
- inputs.concat(optional_args(init_params))
51
+ inputs.concat(optional_flags(flags))
52
+ inputs.concat(optional_args(init_params))
53
53
 
54
- inputs
55
- end
54
+ inputs
55
+ end
56
56
 
57
- def optional_flags(flags)
58
- (flags || {}).map do |key, value|
59
- if value.is_a?(FalseClass) || value.is_a?(TrueClass)
60
- "--#{key}"
61
- else
62
- ["--#{key}", value.to_s]
63
- end
64
- end.flatten
65
- end
57
+ def optional_flags(flags)
58
+ (flags || {}).map do |key, value|
59
+ if value.is_a?(FalseClass) || value.is_a?(TrueClass)
60
+ "--#{key}"
61
+ else
62
+ ["--#{key}", value.to_s]
63
+ end
64
+ end.flatten
65
+ end
66
66
 
67
- def optional_args(init_params = [])
68
- return [] if init_params.count.zero?
67
+ def optional_args(init_params = [])
68
+ return [] if init_params.count.zero?
69
69
 
70
- ["--"].concat(
71
- init_params.map do |init_param|
72
- init_param.to_json
73
- end
74
- )
75
- end
70
+ ["--"].concat(
71
+ init_params.map do |init_param|
72
+ init_param.to_json
73
+ end
74
+ )
75
+ end
76
76
  end
77
77
  end
@@ -72,7 +72,7 @@ class TezosClient::Tools::AnnotsToType < ActiveInteraction::Base
72
72
 
73
73
  def validate_types
74
74
  allowed_types = TYPES_MAPPING.keys
75
- return if typed_annots.values.map{|type| type.to_s.delete_prefix("optional_").to_sym}.all? { |type| allowed_types.include? type }
75
+ return if typed_annots.values.map { |type| type.to_s.delete_prefix("optional_").to_sym }.all? { |type| allowed_types.include? type }
76
76
 
77
77
  errors.add(:base, "The allowed types are: #{allowed_types.join(', ')}")
78
78
  end
@@ -11,4 +11,3 @@ class TezosClient
11
11
  end
12
12
  end
13
13
  end
14
-
@@ -6,7 +6,7 @@ class TezosClient
6
6
  class Option < Base
7
7
  def decode
8
8
  if data[:prim] == "None"
9
- return nil
9
+ nil
10
10
  elsif data[:prim] == "Some"
11
11
  TezosClient::Tools::ConvertToHash::Base.new(
12
12
  data: data[:args][0],
@@ -11,4 +11,3 @@ class TezosClient
11
11
  end
12
12
  end
13
13
  end
14
-
@@ -22,9 +22,7 @@ class TezosClient
22
22
  data: data,
23
23
  type: type
24
24
  ).encode
25
-
26
25
  rescue NameError
27
- raise
28
26
  raise NotImplementedError, "type '#{type[:prim]}' not implemented"
29
27
  end
30
28
 
@@ -7,38 +7,37 @@ class TezosClient
7
7
  def encode
8
8
  {
9
9
  prim: "Pair",
10
- args: [
11
- TezosClient::Tools::HashToMicheline::Base.new(
12
- data: data_0,
13
- type: type[:args][0]
14
- ).value,
15
- TezosClient::Tools::HashToMicheline::Base.new(
16
- data: data_1,
17
- type: type[:args][1]
18
- ).value
19
- ]
10
+ args: args
20
11
  }
21
12
  end
22
13
 
23
- def data_0
24
- if data.is_a? ::Array
25
- data[0]
26
- else
27
- data
14
+ private
15
+ def args
16
+ type[:args].each_with_index.map do |type, index|
17
+ TezosClient::Tools::HashToMicheline::Base.new(
18
+ data: data_n(index),
19
+ type: type
20
+ ).value
21
+ end
22
+ end
23
+
24
+ def args_count
25
+ type[:args].size
28
26
  end
29
- end
30
27
 
31
- def data_1
32
- if data.is_a? ::Array
33
- if data.size > 2
34
- data.drop(1)
28
+ def data_n(n)
29
+ if data.is_a? ::Array
30
+ is_last_arg = n == (args_count - 1)
31
+ # Handle the case when last arg is i Pair, which arguments are the last elements of the data
32
+ if is_last_arg && data.size > args_count
33
+ data.drop(args_count - 1)
34
+ else
35
+ data[n]
36
+ end
35
37
  else
36
- data[1]
38
+ data
37
39
  end
38
- else
39
- data
40
40
  end
41
- end
42
41
  end
43
42
  end
44
43
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class TezosClient
4
- VERSION = "1.4.2"
4
+ VERSION = "1.4.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tezos_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pierre Michard
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2021-07-19 00:00:00.000000000 Z
13
+ date: 2022-02-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -334,7 +334,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
334
334
  - !ruby/object:Gem::Version
335
335
  version: '0'
336
336
  requirements: []
337
- rubygems_version: 3.0.4
337
+ rubygems_version: 3.0.3
338
338
  signing_key:
339
339
  specification_version: 4
340
340
  summary: Wrapper to the tezos client.