tezos_client 1.3.5 → 1.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 51e427c6e828b0dcfbe66daccac99c8881d155230b4d0efd0be253af2b1a3b99
4
- data.tar.gz: 8b2ef9adcfd62f92ef9b0b98ec44964e8425e43074729c8f0a8a48949b8ae6e9
3
+ metadata.gz: fd58876a037528bff5019e089ead07ea6eaa2f4e68ec029f33c73735d4710370
4
+ data.tar.gz: 588d6eb55a1a226cb824968033f181296572886cf08aae029d6227e824350db2
5
5
  SHA512:
6
- metadata.gz: b02cacf6f37704e03a2df7c6400ce4bed6cb74bfdbec7b4ff25ff7045f9ba4d3d51350637320522d9508291de300dbe68f23ffc249f980f4e1d6c332e61e8fa7
7
- data.tar.gz: c19c93b09dd4943fd5d8b054538361d53b813aafba033b91280ac6a6383256c2139253b370d798c4ada43dd794cfdd7318156c261bb1022b18b61b37b9672526
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.3.5)
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,158 +14,164 @@ PATH
14
14
  GEM
15
15
  remote: https://rubygems.org/
16
16
  specs:
17
- actionpack (6.0.3.5)
18
- actionview (= 6.0.3.5)
19
- activesupport (= 6.0.3.5)
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.5)
25
- activesupport (= 6.0.3.5)
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.0)
31
- activemodel (>= 5, < 7)
32
- activemodel (6.0.3.5)
33
- activesupport (= 6.0.3.5)
34
- activesupport (6.0.3.5)
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.14.2)
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.9)
63
+ i18n (1.9.1)
63
64
  concurrent-ruby (~> 1.0)
64
- loofah (2.9.0)
65
+ loofah (2.13.0)
65
66
  crass (~> 1.0.2)
66
67
  nokogiri (>= 1.5.9)
67
- method_source (0.9.2)
68
- mime-types (3.3.1)
68
+ method_source (1.0.0)
69
+ mime-types (3.4.1)
69
70
  mime-types-data (~> 3.2015)
70
- mime-types-data (3.2021.0225)
71
- mini_portile2 (2.5.0)
72
- minitest (5.14.4)
71
+ mime-types-data (3.2022.0105)
72
+ minitest (5.15.0)
73
73
  money-tree (0.10.0)
74
74
  ffi
75
75
  multi_xml (0.6.0)
76
76
  netrc (0.11.0)
77
- nokogiri (1.11.1)
78
- mini_portile2 (~> 2.5.0)
77
+ nokogiri (1.13.1-x86_64-darwin)
79
78
  racc (~> 1.4)
80
- parallel (1.20.1)
81
- parser (3.0.0.0)
79
+ parallel (1.21.0)
80
+ parser (3.1.0.0)
82
81
  ast (~> 2.4.1)
83
- pry (0.12.2)
84
- coderay (~> 1.1.0)
85
- method_source (~> 0.9.0)
82
+ pry (0.14.1)
83
+ coderay (~> 1.1)
84
+ method_source (~> 1.0)
86
85
  public_suffix (4.0.6)
87
- racc (1.5.2)
86
+ racc (1.6.0)
88
87
  rack (2.2.3)
89
88
  rack-test (1.1.0)
90
89
  rack (>= 1.0, < 3)
91
90
  rails-dom-testing (2.0.3)
92
91
  activesupport (>= 4.2.0)
93
92
  nokogiri (>= 1.6)
94
- rails-html-sanitizer (1.3.0)
93
+ rails-html-sanitizer (1.4.2)
95
94
  loofah (~> 2.3)
96
- railties (6.0.3.5)
97
- actionpack (= 6.0.3.5)
98
- activesupport (= 6.0.3.5)
95
+ railties (6.0.4.4)
96
+ actionpack (= 6.0.4.4)
97
+ activesupport (= 6.0.4.4)
99
98
  method_source
100
99
  rake (>= 0.8.7)
101
100
  thor (>= 0.20.3, < 2.0)
102
- rainbow (3.0.0)
103
- rake (13.0.1)
101
+ rainbow (3.1.1)
102
+ rake (13.0.6)
104
103
  rbnacl (5.0.0)
105
104
  ffi
106
- regexp_parser (2.1.1)
105
+ regexp_parser (2.2.0)
107
106
  rest-client (2.0.2)
108
107
  http-cookie (>= 1.0.2, < 2.0)
109
108
  mime-types (>= 1.16, < 4.0)
110
109
  netrc (~> 0.8)
111
- rexml (3.2.4)
112
- rspec (3.9.0)
113
- rspec-core (~> 3.9.0)
114
- rspec-expectations (~> 3.9.0)
115
- rspec-mocks (~> 3.9.0)
116
- rspec-core (3.9.3)
117
- rspec-support (~> 3.9.3)
118
- rspec-expectations (3.9.4)
110
+ rexml (3.2.5)
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)
119
118
  diff-lcs (>= 1.2.0, < 2.0)
120
- rspec-support (~> 3.9.0)
121
- rspec-mocks (3.9.1)
119
+ rspec-support (~> 3.11.0)
120
+ rspec-mocks (3.11.0)
122
121
  diff-lcs (>= 1.2.0, < 2.0)
123
- rspec-support (~> 3.9.0)
124
- rspec-support (3.9.4)
125
- rubocop (0.93.1)
122
+ rspec-support (~> 3.11.0)
123
+ rspec-support (3.11.0)
124
+ rubocop (1.25.1)
126
125
  parallel (~> 1.10)
127
- parser (>= 2.7.1.5)
126
+ parser (>= 3.1.0.0)
128
127
  rainbow (>= 2.2.2, < 4.0)
129
- regexp_parser (>= 1.8)
128
+ regexp_parser (>= 1.8, < 3.0)
130
129
  rexml
131
- rubocop-ast (>= 0.6.0)
130
+ rubocop-ast (>= 1.15.1, < 2.0)
132
131
  ruby-progressbar (~> 1.7)
133
- unicode-display_width (>= 1.4.0, < 2.0)
134
- rubocop-ast (1.4.1)
135
- parser (>= 2.7.1.5)
136
- rubocop-performance (1.10.1)
137
- rubocop (>= 0.90.0, < 2.0)
132
+ unicode-display_width (>= 1.4.0, < 3.0)
133
+ rubocop-ast (1.15.1)
134
+ parser (>= 3.0.1.1)
135
+ rubocop-minitest (0.17.1)
136
+ rubocop (>= 0.90, < 2.0)
137
+ rubocop-packaging (0.5.1)
138
+ rubocop (>= 0.89, < 2.0)
139
+ rubocop-performance (1.13.2)
140
+ rubocop (>= 1.7.0, < 2.0)
138
141
  rubocop-ast (>= 0.4.0)
139
- rubocop-rails (2.9.1)
142
+ rubocop-rails (2.13.2)
140
143
  activesupport (>= 4.2.0)
141
144
  rack (>= 1.1)
142
- rubocop (>= 0.90.0, < 2.0)
143
- rubocop-rails_config (0.7.3)
144
- railties (>= 3.0)
145
- rubocop (~> 0.74)
146
- rubocop-performance (~> 1.3)
145
+ rubocop (>= 1.7.0, < 2.0)
146
+ rubocop-rails_config (1.8.2)
147
+ railties (>= 5.0)
148
+ rubocop (>= 1.19)
149
+ rubocop-ast (>= 1.0.1)
150
+ rubocop-minitest (~> 0.15)
151
+ rubocop-packaging (~> 0.5)
152
+ rubocop-performance (~> 1.11)
147
153
  rubocop-rails (~> 2.0)
148
154
  ruby-progressbar (1.11.0)
149
- thor (1.1.0)
155
+ thor (1.2.1)
150
156
  thread_safe (0.3.6)
151
157
  tzinfo (1.2.9)
152
158
  thread_safe (~> 0.1)
153
159
  unf (0.1.4)
154
160
  unf_ext
155
- unf_ext (0.0.7.7)
156
- unicode-display_width (1.7.0)
161
+ unf_ext (0.0.8)
162
+ unicode-display_width (2.1.0)
157
163
  vcr (4.0.0)
158
- webmock (3.7.6)
159
- addressable (>= 2.3.6)
164
+ webmock (3.14.0)
165
+ addressable (>= 2.8.0)
160
166
  crack (>= 0.3.2)
161
167
  hashdiff (>= 0.4.0, < 2.0.0)
162
- zeitwerk (2.4.2)
168
+ zeitwerk (2.5.4)
163
169
 
164
170
  PLATFORMS
165
- ruby
171
+ x86_64-darwin-19
166
172
 
167
173
  DEPENDENCIES
168
- bundler (~> 1.16)
174
+ bundler (~> 2.1)
169
175
  pry
170
176
  rake (~> 13.0)
171
177
  rspec (~> 3.0)
@@ -175,4 +181,4 @@ DEPENDENCIES
175
181
  webmock
176
182
 
177
183
  BUNDLED WITH
178
- 1.17.3
184
+ 2.2.18
data/README.md CHANGED
@@ -20,10 +20,10 @@ npm i -g michelson-to-micheline
20
20
  ```
21
21
 
22
22
  ### SmartPy
23
- [SmartPy](https://smartpy.io/)
23
+ [SmartPy](https://smartpy.io/releases/20210317-bc925bb73dc885ac2b4dde9689e805d9b0bc6125/)
24
24
 
25
25
  ```bash
26
- sh <(curl -s https://smartpy.io/dev-20200924-23b26494361d96abf034bdbb1ad1af396f95fd61/cli/SmartPy.sh) local-install-auto
26
+ sh <(curl -s https://smartpy.io/releases/20210317-bc925bb73dc885ac2b4dde9689e805d9b0bc6125/cli/install.sh)
27
27
  export PATH=$PATH:$HOME/smartpy-cli/
28
28
  ```
29
29
 
@@ -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
@@ -1,20 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "smartpy_inteface/smartpy_wrapper"
4
- require_relative "smartpy_inteface/micheline_serializer_wrapper"
5
4
 
6
5
  class TezosClient
7
6
  class SmartpyInterface
8
7
  include Logger
9
8
  include SmartpyWrapper
10
- include MichelineSerializerWrapper
11
9
 
12
10
  attr_reader :options
13
11
 
14
12
  def json_scripts(args)
15
13
  compile_to_michelson(args) do |contract_script_filename, init_script_filename|
16
14
  micheline_contract = File.read(contract_script_filename)
17
- micheline_storage = convert_michelson_to_micheline(File.read(init_script_filename))
15
+ micheline_storage = File.read(init_script_filename)
18
16
 
19
17
  [JSON.parse(micheline_storage), JSON.parse(micheline_contract)]
20
18
  end
@@ -30,16 +28,50 @@ class TezosClient
30
28
  end
31
29
 
32
30
  private
33
- def compile_to_michelson(args)
34
- Tools::TemporaryFile.with_file_copy(args[:script]) do |script_copy_path|
35
- script_basename = script_copy_path.split("/").last.sub(/.py$/, "")
36
- script_path = "/tmp/#{script_basename}/"
37
- init_script_filename = "#{script_basename}_storage_init.tz"
38
- contract_script_filename = "#{script_basename}_compiled.json"
39
- call_smartpy ["compile", script_copy_path, args[:init_params], script_path]
40
-
41
- yield(script_path + contract_script_filename, script_path + init_script_filename)
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
+
42
+ call_smartpy cmd_line
43
+
44
+ yield(script_path + "default/" + contract_script_filename, script_path + "default/" + init_script_filename)
45
+ end
46
+ end
47
+
48
+ def optional_inputs(flags, init_params)
49
+ inputs = []
50
+
51
+ inputs.concat(optional_flags(flags))
52
+ inputs.concat(optional_args(init_params))
53
+
54
+ inputs
55
+ end
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
66
+
67
+ def optional_args(init_params = [])
68
+ return [] if init_params.count.zero?
69
+
70
+ ["--"].concat(
71
+ init_params.map do |init_param|
72
+ init_param.to_json
73
+ end
74
+ )
42
75
  end
43
- end
44
76
  end
45
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
@@ -7,12 +7,19 @@ class TezosClient
7
7
  class ConvertToHash < ActiveInteraction::Base
8
8
  class BigMap < Base
9
9
  def decode
10
- ::TezosClient::BigMap.new(
11
- var_name,
12
- data[:int],
13
- type[:args].second,
14
- type[:args].first
15
- )
10
+ if data.is_a? Hash
11
+ ::TezosClient::BigMap.new(
12
+ var_name,
13
+ data[:int],
14
+ type[:args].second,
15
+ type[:args].first
16
+ )
17
+ else
18
+ TezosClient::Tools::ConvertToHash::Map.new(
19
+ data: data,
20
+ type: type
21
+ ).value[var_name]
22
+ end
16
23
  end
17
24
  end
18
25
  end
@@ -7,20 +7,20 @@ class TezosClient
7
7
  include TezosClient::Crypto
8
8
 
9
9
  def decode
10
- if data.key?(:bytes)
11
- if data[:bytes].start_with?("00")
12
- encode_tz(:edpk, data[:bytes][2..-1])
13
- elsif data[:bytes].start_with?("01")
14
- encode_tz(:sppk, data[:bytes][2..-1])
15
- elsif data[:bytes].start_with?("02")
16
- encode_tz(:p2pk, data[:bytes][2..-1])
17
- else
18
- data[:bytes]
19
- end
10
+ if tmp_data.start_with?("00")
11
+ encode_tz(:edpk, tmp_data[2..-1])
12
+ elsif tmp_data.start_with?("01")
13
+ encode_tz(:sppk, tmp_data[2..-1])
14
+ elsif tmp_data.start_with?("02")
15
+ encode_tz(:p2pk, tmp_data[2..-1])
20
16
  else
21
- data[:string]
17
+ tmp_data
22
18
  end
23
19
  end
20
+
21
+ def tmp_data
22
+ @tmp_data ||= data[:bytes] || data[:string]
23
+ end
24
24
  end
25
25
  end
26
26
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ class TezosClient
4
+ module Tools
5
+ class ConvertToHash < ActiveInteraction::Base
6
+ class KeyHash < Base
7
+ def decode
8
+ Address.new(data: data, type: type).decode
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -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],
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ class TezosClient
4
+ module Tools
5
+ class ConvertToHash < ActiveInteraction::Base
6
+ class Set < Base
7
+ def decode
8
+ List.new(data: data, type: type).decode.to_set
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -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.3.5"
4
+ VERSION = "1.4.3"
5
5
  end
data/lib/tezos_client.rb CHANGED
@@ -82,7 +82,7 @@ class TezosClient
82
82
  #
83
83
  # @return [Hash] result of the origination containing :operation_id, :operation_result and :originated_contract
84
84
  #
85
- def originate_contract(from:, amount:, secret_key: nil, script: nil, init_params: nil, dry_run: false, **args)
85
+ def originate_contract(from:, amount:, secret_key: nil, script: nil, init_params: [], dry_run: false, **args)
86
86
  origination_args = {
87
87
  rpc_interface: rpc_interface,
88
88
  from: from,
@@ -92,9 +92,9 @@ class TezosClient
92
92
  }
93
93
 
94
94
  origination_args[:script] = contract_interface(script).origination_script(
95
- from: from,
96
95
  script: script,
97
- init_params: init_params
96
+ init_params: init_params,
97
+ **args
98
98
  )
99
99
 
100
100
  operation = OriginationOperation.new(origination_args)
data/tezos_client.gemspec CHANGED
@@ -7,12 +7,12 @@ require "tezos_client/version"
7
7
  Gem::Specification.new do |spec|
8
8
  spec.name = "tezos_client"
9
9
  spec.version = TezosClient::VERSION
10
- spec.authors = ["Pierre Michard"]
11
- spec.email = ["pierre@moneytrack.io"]
10
+ spec.authors = ["Pierre Michard", "Sébastien Lauret", "Othmane El Kesri"]
11
+ spec.email = ["pierre@moneytrack.io", "sebastien@moneytrack.io", "othmane@moneytrack.io"]
12
12
 
13
13
  spec.summary = "Wrapper to the tezos client."
14
14
  spec.description = ""
15
- spec.homepage = "http://moneytrack.io"
15
+ spec.homepage = "https://moneytrack.io"
16
16
  spec.license = "MIT"
17
17
 
18
18
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
33
33
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
34
34
  spec.require_paths = ["lib"]
35
35
 
36
- spec.add_development_dependency "bundler", "~> 1.16"
36
+ spec.add_development_dependency "bundler", "~> 2.1"
37
37
  spec.add_development_dependency "rake", "~> 13.0"
38
38
  spec.add_development_dependency "rspec", "~> 3.0"
39
39
  spec.add_development_dependency "rubocop-rails_config"
metadata CHANGED
@@ -1,14 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tezos_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.5
4
+ version: 1.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pierre Michard
8
+ - Sébastien Lauret
9
+ - Othmane El Kesri
8
10
  autorequire:
9
11
  bindir: exe
10
12
  cert_chain: []
11
- date: 2021-03-05 00:00:00.000000000 Z
13
+ date: 2022-02-10 00:00:00.000000000 Z
12
14
  dependencies:
13
15
  - !ruby/object:Gem::Dependency
14
16
  name: bundler
@@ -16,14 +18,14 @@ dependencies:
16
18
  requirements:
17
19
  - - "~>"
18
20
  - !ruby/object:Gem::Version
19
- version: '1.16'
21
+ version: '2.1'
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
23
25
  requirements:
24
26
  - - "~>"
25
27
  - !ruby/object:Gem::Version
26
- version: '1.16'
28
+ version: '2.1'
27
29
  - !ruby/object:Gem::Dependency
28
30
  name: rake
29
31
  requirement: !ruby/object:Gem::Requirement
@@ -223,6 +225,8 @@ dependencies:
223
225
  description: ''
224
226
  email:
225
227
  - pierre@moneytrack.io
228
+ - sebastien@moneytrack.io
229
+ - othmane@moneytrack.io
226
230
  executables: []
227
231
  extensions: []
228
232
  extra_rdoc_files: []
@@ -270,7 +274,6 @@ files:
270
274
  - lib/tezos_client/rpc_interface/monitor.rb
271
275
  - lib/tezos_client/rpc_interface/operations.rb
272
276
  - lib/tezos_client/rpc_interface/request_manager.rb
273
- - lib/tezos_client/smartpy_inteface/micheline_serializer_wrapper.rb
274
277
  - lib/tezos_client/smartpy_inteface/smartpy_wrapper.rb
275
278
  - lib/tezos_client/smartpy_interface.rb
276
279
  - lib/tezos_client/string_utils.rb
@@ -282,11 +285,13 @@ files:
282
285
  - lib/tezos_client/tools/convert_to_hash/bytes.rb
283
286
  - lib/tezos_client/tools/convert_to_hash/int.rb
284
287
  - lib/tezos_client/tools/convert_to_hash/key.rb
288
+ - lib/tezos_client/tools/convert_to_hash/key_hash.rb
285
289
  - lib/tezos_client/tools/convert_to_hash/list.rb
286
290
  - lib/tezos_client/tools/convert_to_hash/map.rb
287
291
  - lib/tezos_client/tools/convert_to_hash/nat.rb
288
292
  - lib/tezos_client/tools/convert_to_hash/option.rb
289
293
  - lib/tezos_client/tools/convert_to_hash/pair.rb
294
+ - lib/tezos_client/tools/convert_to_hash/set.rb
290
295
  - lib/tezos_client/tools/convert_to_hash/signature.rb
291
296
  - lib/tezos_client/tools/convert_to_hash/string.rb
292
297
  - lib/tezos_client/tools/convert_to_hash/timestamp.rb
@@ -309,7 +314,7 @@ files:
309
314
  - lib/tezos_client/version.rb
310
315
  - tezos_client.gemspec
311
316
  - travis-scripts/prepare-ubuntu.sh
312
- homepage: http://moneytrack.io
317
+ homepage: https://moneytrack.io
313
318
  licenses:
314
319
  - MIT
315
320
  metadata:
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class TezosClient
4
- class SmartpyInterface
5
- module MichelineSerializerWrapper
6
- def convert_michelson_to_micheline(script)
7
- cmd = ["michelson-to-micheline", script]
8
-
9
- Tools::SystemCall.execute(cmd)
10
- end
11
-
12
- def actual_project_path
13
- TezosClient.root_path
14
- end
15
- end
16
- end
17
- end