tezos_client 1.4.3 → 1.4.5

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: fd58876a037528bff5019e089ead07ea6eaa2f4e68ec029f33c73735d4710370
4
- data.tar.gz: 588d6eb55a1a226cb824968033f181296572886cf08aae029d6227e824350db2
3
+ metadata.gz: 5ef43c07cdb05752ac0547f94ca3977cb78fc02d1b8395090577156009a2c003
4
+ data.tar.gz: 40d3bc0b42568d339ba5eec78654448c5b0257dfe40d44e2540723f9cd14d170
5
5
  SHA512:
6
- metadata.gz: d6bdd249d4606aac1c18aad5acead48d4a2296816942e42b1cbe77ae4e5202efd4ce73fcaa088e17db500d7874988ae7452bc70d6dd1ee48485af0674f7362fb
7
- data.tar.gz: 88bb21809370468db816e00267ad93b6a727c90dbea8afe6a7f2aa67881acf120beb085287d8964e1217b605b9a1c05fbb0d7740ce65dd086e96d11e0b792621
6
+ metadata.gz: f1c552679ecad0ff4b7945903c019dbe1055fb7d05ee51d5af4d362f14f7bf2d0cc40a5add0e86c4672a7bbd920e39dd9a06e464c3a228a01360551e70d0e8bd
7
+ data.tar.gz: 7f52897c55d933a6034fe0b17255ec6f570dc57a5464e5b2d2341dd8743781362fb101daca8aabac9969aa55e8f4aed4dbf15877cba65081eed10316d575f40e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tezos_client (1.4.2)
4
+ tezos_client (1.4.5)
5
5
  active_interaction (>= 3.8)
6
6
  activesupport (~> 6.0.0)
7
7
  base58 (~> 0.2.3)
@@ -14,15 +14,15 @@ PATH
14
14
  GEM
15
15
  remote: https://rubygems.org/
16
16
  specs:
17
- actionpack (6.0.4.4)
18
- actionview (= 6.0.4.4)
19
- activesupport (= 6.0.4.4)
17
+ actionpack (6.0.6)
18
+ actionview (= 6.0.6)
19
+ activesupport (= 6.0.6)
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.4.4)
25
- activesupport (= 6.0.4.4)
24
+ actionview (6.0.6)
25
+ activesupport (= 6.0.6)
26
26
  builder (~> 3.1)
27
27
  erubi (~> 1.4)
28
28
  rails-dom-testing (~> 2.0)
@@ -30,9 +30,9 @@ GEM
30
30
  active_interaction (4.1.0)
31
31
  activemodel (>= 5, < 8)
32
32
  activesupport (>= 5, < 8)
33
- activemodel (6.0.4.4)
34
- activesupport (= 6.0.4.4)
35
- activesupport (6.0.4.4)
33
+ activemodel (6.0.6)
34
+ activesupport (= 6.0.6)
35
+ activesupport (6.0.6)
36
36
  concurrent-ruby (~> 1.0, >= 1.0.2)
37
37
  i18n (>= 0.7, < 2)
38
38
  minitest (~> 5.1)
@@ -45,56 +45,59 @@ GEM
45
45
  bip_mnemonic (0.0.4)
46
46
  builder (3.2.4)
47
47
  coderay (1.1.3)
48
- concurrent-ruby (1.1.9)
48
+ concurrent-ruby (1.1.10)
49
49
  crack (0.4.5)
50
50
  rexml
51
51
  crass (1.0.6)
52
52
  diff-lcs (1.5.0)
53
53
  domain_name (0.5.20190701)
54
54
  unf (>= 0.0.5, < 1.0.0)
55
- erubi (1.10.0)
55
+ erubi (1.11.0)
56
56
  ffi (1.15.5)
57
57
  hashdiff (1.0.1)
58
- http-cookie (1.0.4)
58
+ http-cookie (1.0.5)
59
59
  domain_name (~> 0.5)
60
60
  httparty (0.17.3)
61
61
  mime-types (~> 3.0)
62
62
  multi_xml (>= 0.5.2)
63
- i18n (1.9.1)
63
+ i18n (1.12.0)
64
64
  concurrent-ruby (~> 1.0)
65
- loofah (2.13.0)
65
+ json (2.6.2)
66
+ loofah (2.19.0)
66
67
  crass (~> 1.0.2)
67
68
  nokogiri (>= 1.5.9)
68
69
  method_source (1.0.0)
69
70
  mime-types (3.4.1)
70
71
  mime-types-data (~> 3.2015)
71
72
  mime-types-data (3.2022.0105)
72
- minitest (5.15.0)
73
+ minitest (5.16.3)
73
74
  money-tree (0.10.0)
74
75
  ffi
75
76
  multi_xml (0.6.0)
76
77
  netrc (0.11.0)
77
- nokogiri (1.13.1-x86_64-darwin)
78
+ nokogiri (1.13.8-x86_64-darwin)
78
79
  racc (~> 1.4)
79
- parallel (1.21.0)
80
- parser (3.1.0.0)
80
+ nokogiri (1.13.8-x86_64-linux)
81
+ racc (~> 1.4)
82
+ parallel (1.22.1)
83
+ parser (3.1.2.1)
81
84
  ast (~> 2.4.1)
82
85
  pry (0.14.1)
83
86
  coderay (~> 1.1)
84
87
  method_source (~> 1.0)
85
88
  public_suffix (4.0.6)
86
89
  racc (1.6.0)
87
- rack (2.2.3)
88
- rack-test (1.1.0)
89
- rack (>= 1.0, < 3)
90
+ rack (2.2.4)
91
+ rack-test (2.0.2)
92
+ rack (>= 1.3)
90
93
  rails-dom-testing (2.0.3)
91
94
  activesupport (>= 4.2.0)
92
95
  nokogiri (>= 1.6)
93
- rails-html-sanitizer (1.4.2)
96
+ rails-html-sanitizer (1.4.3)
94
97
  loofah (~> 2.3)
95
- railties (6.0.4.4)
96
- actionpack (= 6.0.4.4)
97
- activesupport (= 6.0.4.4)
98
+ railties (6.0.6)
99
+ actionpack (= 6.0.6)
100
+ activesupport (= 6.0.6)
98
101
  method_source
99
102
  rake (>= 0.8.7)
100
103
  thor (>= 0.20.3, < 2.0)
@@ -102,7 +105,7 @@ GEM
102
105
  rake (13.0.6)
103
106
  rbnacl (5.0.0)
104
107
  ffi
105
- regexp_parser (2.2.0)
108
+ regexp_parser (2.5.0)
106
109
  rest-client (2.0.2)
107
110
  http-cookie (>= 1.0.2, < 2.0)
108
111
  mime-types (>= 1.16, < 4.0)
@@ -121,17 +124,18 @@ GEM
121
124
  diff-lcs (>= 1.2.0, < 2.0)
122
125
  rspec-support (~> 3.11.0)
123
126
  rspec-support (3.11.0)
124
- rubocop (1.25.1)
127
+ rubocop (1.36.0)
128
+ json (~> 2.3)
125
129
  parallel (~> 1.10)
126
- parser (>= 3.1.0.0)
130
+ parser (>= 3.1.2.1)
127
131
  rainbow (>= 2.2.2, < 4.0)
128
132
  regexp_parser (>= 1.8, < 3.0)
129
- rexml
130
- rubocop-ast (>= 1.15.1, < 2.0)
133
+ rexml (>= 3.2.5, < 4.0)
134
+ rubocop-ast (>= 1.20.1, < 2.0)
131
135
  ruby-progressbar (~> 1.7)
132
136
  unicode-display_width (>= 1.4.0, < 3.0)
133
- rubocop-ast (1.15.1)
134
- parser (>= 3.0.1.1)
137
+ rubocop-ast (1.21.0)
138
+ parser (>= 3.1.1.0)
135
139
  rubocop-minitest (0.17.1)
136
140
  rubocop (>= 0.90, < 2.0)
137
141
  rubocop-packaging (0.5.1)
@@ -139,10 +143,10 @@ GEM
139
143
  rubocop-performance (1.13.2)
140
144
  rubocop (>= 1.7.0, < 2.0)
141
145
  rubocop-ast (>= 0.4.0)
142
- rubocop-rails (2.13.2)
146
+ rubocop-rails (2.16.1)
143
147
  activesupport (>= 4.2.0)
144
148
  rack (>= 1.1)
145
- rubocop (>= 1.7.0, < 2.0)
149
+ rubocop (>= 1.33.0, < 2.0)
146
150
  rubocop-rails_config (1.8.2)
147
151
  railties (>= 5.0)
148
152
  rubocop (>= 1.19)
@@ -154,21 +158,22 @@ GEM
154
158
  ruby-progressbar (1.11.0)
155
159
  thor (1.2.1)
156
160
  thread_safe (0.3.6)
157
- tzinfo (1.2.9)
161
+ tzinfo (1.2.10)
158
162
  thread_safe (~> 0.1)
159
163
  unf (0.1.4)
160
164
  unf_ext
161
- unf_ext (0.0.8)
162
- unicode-display_width (2.1.0)
165
+ unf_ext (0.0.8.2)
166
+ unicode-display_width (2.3.0)
163
167
  vcr (4.0.0)
164
168
  webmock (3.14.0)
165
169
  addressable (>= 2.8.0)
166
170
  crack (>= 0.3.2)
167
171
  hashdiff (>= 0.4.0, < 2.0.0)
168
- zeitwerk (2.5.4)
172
+ zeitwerk (2.6.0)
169
173
 
170
174
  PLATFORMS
171
175
  x86_64-darwin-19
176
+ x86_64-linux
172
177
 
173
178
  DEPENDENCIES
174
179
  bundler (~> 2.1)
data/demo_script.json ADDED
@@ -0,0 +1,427 @@
1
+ {
2
+ "code": [
3
+ {
4
+ "prim": "storage",
5
+ "args": [
6
+ {
7
+ "prim": "pair",
8
+ "args": [
9
+ {
10
+ "prim": "big_map",
11
+ "args": [
12
+ {
13
+ "prim": "string"
14
+ },
15
+ {
16
+ "prim": "int"
17
+ }
18
+ ],
19
+ "annots": [
20
+ "%big_map_first"
21
+ ]
22
+ },
23
+ {
24
+ "prim": "big_map",
25
+ "args": [
26
+ {
27
+ "prim": "string"
28
+ },
29
+ {
30
+ "prim": "string"
31
+ }
32
+ ],
33
+ "annots": [
34
+ "%big_map_second"
35
+ ]
36
+ }
37
+ ]
38
+ }
39
+ ]
40
+ },
41
+ {
42
+ "prim": "parameter",
43
+ "args": [
44
+ {
45
+ "prim": "or",
46
+ "args": [
47
+ {
48
+ "prim": "or",
49
+ "args": [
50
+ {
51
+ "prim": "pair",
52
+ "args": [
53
+ {
54
+ "prim": "string",
55
+ "annots": [
56
+ "%key"
57
+ ]
58
+ },
59
+ {
60
+ "prim": "int",
61
+ "annots": [
62
+ "%value"
63
+ ]
64
+ }
65
+ ],
66
+ "annots": [
67
+ "%add_first"
68
+ ]
69
+ },
70
+ {
71
+ "prim": "pair",
72
+ "args": [
73
+ {
74
+ "prim": "string",
75
+ "annots": [
76
+ "%key"
77
+ ]
78
+ },
79
+ {
80
+ "prim": "string",
81
+ "annots": [
82
+ "%value"
83
+ ]
84
+ }
85
+ ],
86
+ "annots": [
87
+ "%add_second"
88
+ ]
89
+ }
90
+ ]
91
+ },
92
+ {
93
+ "prim": "or",
94
+ "args": [
95
+ {
96
+ "prim": "pair",
97
+ "args": [
98
+ {
99
+ "prim": "pair",
100
+ "args": [
101
+ {
102
+ "prim": "string",
103
+ "annots": [
104
+ "%first"
105
+ ]
106
+ },
107
+ {
108
+ "prim": "string",
109
+ "annots": [
110
+ "%key"
111
+ ]
112
+ }
113
+ ]
114
+ },
115
+ {
116
+ "prim": "pair",
117
+ "args": [
118
+ {
119
+ "prim": "string",
120
+ "annots": [
121
+ "%second"
122
+ ]
123
+ },
124
+ {
125
+ "prim": "string",
126
+ "annots": [
127
+ "%third"
128
+ ]
129
+ }
130
+ ]
131
+ }
132
+ ],
133
+ "annots": [
134
+ "%add_third"
135
+ ]
136
+ },
137
+ {
138
+ "prim": "nat",
139
+ "annots": [
140
+ "%always_fail"
141
+ ]
142
+ }
143
+ ]
144
+ }
145
+ ]
146
+ }
147
+ ]
148
+ },
149
+ {
150
+ "prim": "code",
151
+ "args": [
152
+ [
153
+ {
154
+ "prim": "UNPAIR"
155
+ },
156
+ {
157
+ "prim": "IF_LEFT",
158
+ "args": [
159
+ [
160
+ {
161
+ "prim": "IF_LEFT",
162
+ "args": [
163
+ [
164
+ {
165
+ "prim": "SWAP"
166
+ },
167
+ {
168
+ "prim": "UNPAIR"
169
+ },
170
+ {
171
+ "prim": "DUP",
172
+ "args": [
173
+ {
174
+ "int": "3"
175
+ }
176
+ ]
177
+ },
178
+ {
179
+ "prim": "CDR"
180
+ },
181
+ {
182
+ "prim": "SOME"
183
+ },
184
+ {
185
+ "prim": "DIG",
186
+ "args": [
187
+ {
188
+ "int": "3"
189
+ }
190
+ ]
191
+ },
192
+ {
193
+ "prim": "CAR"
194
+ },
195
+ {
196
+ "prim": "UPDATE"
197
+ },
198
+ {
199
+ "prim": "PAIR"
200
+ }
201
+ ],
202
+ [
203
+ {
204
+ "prim": "SWAP"
205
+ },
206
+ {
207
+ "prim": "UNPAIR"
208
+ },
209
+ {
210
+ "prim": "SWAP"
211
+ },
212
+ {
213
+ "prim": "DUP",
214
+ "args": [
215
+ {
216
+ "int": "3"
217
+ }
218
+ ]
219
+ },
220
+ {
221
+ "prim": "CDR"
222
+ },
223
+ {
224
+ "prim": "SOME"
225
+ },
226
+ {
227
+ "prim": "DIG",
228
+ "args": [
229
+ {
230
+ "int": "3"
231
+ }
232
+ ]
233
+ },
234
+ {
235
+ "prim": "CAR"
236
+ },
237
+ {
238
+ "prim": "UPDATE"
239
+ },
240
+ {
241
+ "prim": "SWAP"
242
+ },
243
+ {
244
+ "prim": "PAIR"
245
+ }
246
+ ]
247
+ ]
248
+ }
249
+ ],
250
+ [
251
+ {
252
+ "prim": "IF_LEFT",
253
+ "args": [
254
+ [
255
+ {
256
+ "prim": "SWAP"
257
+ },
258
+ {
259
+ "prim": "UNPAIR"
260
+ },
261
+ {
262
+ "prim": "SWAP"
263
+ },
264
+ {
265
+ "prim": "DIG",
266
+ "args": [
267
+ {
268
+ "int": "2"
269
+ }
270
+ ]
271
+ },
272
+ {
273
+ "prim": "DUP"
274
+ },
275
+ {
276
+ "prim": "GET",
277
+ "args": [
278
+ {
279
+ "int": "4"
280
+ }
281
+ ]
282
+ },
283
+ {
284
+ "prim": "SWAP"
285
+ },
286
+ {
287
+ "prim": "DUP"
288
+ },
289
+ {
290
+ "prim": "GET",
291
+ "args": [
292
+ {
293
+ "int": "3"
294
+ }
295
+ ]
296
+ },
297
+ {
298
+ "prim": "SWAP"
299
+ },
300
+ {
301
+ "prim": "DUP"
302
+ },
303
+ {
304
+ "prim": "DUG",
305
+ "args": [
306
+ {
307
+ "int": "5"
308
+ }
309
+ ]
310
+ },
311
+ {
312
+ "prim": "CAR"
313
+ },
314
+ {
315
+ "prim": "CAR"
316
+ },
317
+ {
318
+ "prim": "CONCAT"
319
+ },
320
+ {
321
+ "prim": "CONCAT"
322
+ },
323
+ {
324
+ "prim": "SOME"
325
+ },
326
+ {
327
+ "prim": "DIG",
328
+ "args": [
329
+ {
330
+ "int": "3"
331
+ }
332
+ ]
333
+ },
334
+ {
335
+ "prim": "CAR"
336
+ },
337
+ {
338
+ "prim": "CDR"
339
+ },
340
+ {
341
+ "prim": "UPDATE"
342
+ },
343
+ {
344
+ "prim": "SWAP"
345
+ },
346
+ {
347
+ "prim": "PAIR"
348
+ }
349
+ ],
350
+ [
351
+ {
352
+ "prim": "PUSH",
353
+ "args": [
354
+ {
355
+ "prim": "nat"
356
+ },
357
+ {
358
+ "int": "0"
359
+ }
360
+ ]
361
+ },
362
+ {
363
+ "prim": "SWAP"
364
+ },
365
+ {
366
+ "prim": "COMPARE"
367
+ },
368
+ {
369
+ "prim": "GE"
370
+ },
371
+ {
372
+ "prim": "IF",
373
+ "args": [
374
+ [
375
+ {
376
+ "prim": "PUSH",
377
+ "args": [
378
+ {
379
+ "prim": "string"
380
+ },
381
+ {
382
+ "string": "I'm failing"
383
+ }
384
+ ]
385
+ },
386
+ {
387
+ "prim": "FAILWITH"
388
+ }
389
+ ],
390
+ [
391
+
392
+ ]
393
+ ]
394
+ }
395
+ ]
396
+ ]
397
+ }
398
+ ]
399
+ ]
400
+ },
401
+ {
402
+ "prim": "NIL",
403
+ "args": [
404
+ {
405
+ "prim": "operation"
406
+ }
407
+ ]
408
+ },
409
+ {
410
+ "prim": "PAIR"
411
+ }
412
+ ]
413
+ ]
414
+ }
415
+ ],
416
+ "storage": {
417
+ "prim": "Pair",
418
+ "args": [
419
+ [
420
+
421
+ ],
422
+ [
423
+
424
+ ]
425
+ ]
426
+ }
427
+ }
@@ -5,16 +5,60 @@ class TezosClient
5
5
  class ConvertToHash < ActiveInteraction::Base
6
6
  class Pair < Base
7
7
  def decode
8
- raise "Not a 'Pair' type" unless data[:prim] == "Pair"
9
- raise "Difference detected between data and type \nDATA: #{data} \nTYPE:#{type} " unless data[:args].size == type[:args].size
8
+ raise "Not a 'Pair' type" unless normalized_data[:prim] == "Pair"
9
+ raise "Difference detected between data and type \nDATA: #{normalized_data} \nTYPE:#{normalized_type} " unless normalized_data[:args].size == normalized_type[:args].size
10
10
 
11
- (data[:args]).zip(type[:args]).map do |data_n, type_n|
11
+ (normalized_data[:args]).zip(normalized_type[:args]).map do |data_n, type_n|
12
12
  TezosClient::Tools::ConvertToHash::Base.new(
13
13
  data: data_n,
14
14
  type: type_n
15
15
  ).value
16
16
  end.reduce({}, &:merge)
17
17
  end
18
+
19
+ private
20
+
21
+ def normalized_type
22
+ if type[:args].size > 2
23
+ {
24
+ prim: "pair",
25
+ args: [
26
+ type[:args][0],
27
+ {
28
+ prim: "pair",
29
+ args: type[:args][1..]
30
+ }
31
+ ]
32
+ }
33
+ else
34
+ type
35
+ end
36
+ end
37
+
38
+ def expanded_data
39
+ if data.is_a?(Array)
40
+ {prim: "Pair", args: data}
41
+ else
42
+ data
43
+ end
44
+ end
45
+
46
+ def normalized_data
47
+ if expanded_data[:args].size > 2
48
+ {
49
+ prim: "Pair",
50
+ args: [
51
+ expanded_data[:args][0],
52
+ {
53
+ prim: "Pair",
54
+ args: expanded_data[:args][1..]
55
+ }
56
+ ]
57
+ }
58
+ else
59
+ expanded_data
60
+ end
61
+ end
18
62
  end
19
63
  end
20
64
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class TezosClient
4
- VERSION = "1.4.3"
4
+ VERSION = "1.4.5"
5
5
  end
data/lib/tezos_client.rb CHANGED
@@ -166,23 +166,23 @@ class TezosClient
166
166
  broadcast_operation(operation: operation, dry_run: dry_run)
167
167
  end
168
168
 
169
- def call_contract(dry_run: false, entrypoint:, params:, params_type:, **args)
170
- _entrypoint = select_entrypoint(
171
- contract_address: args[:to],
172
- entrypoint: entrypoint
173
- )
169
+ def build_transaction(dry_run: false, entrypoint:, params:, params_type:, **args)
170
+ transfer_args = transfer_args(dry_run: dry_run, entrypoint: entrypoint, params: params, params_type:params_type, **args)
174
171
 
175
- json_params = micheline_params(
176
- params: params,
177
- entrypoint: _entrypoint,
178
- params_type: params_type
172
+ transaction = TransactionOperation.new(
173
+ rpc_interface: rpc_interface,
174
+ **transfer_args
179
175
  )
180
176
 
181
- transfer_args = args.merge(
182
- entrypoint: _entrypoint,
183
- parameters: json_params,
184
- dry_run: dry_run
185
- )
177
+ transaction.rpc_operation_args
178
+ end
179
+
180
+ def call_contract(dry_run: false, entrypoint:, params:, params_type:, **args)
181
+ transfer_args = transfer_args(dry_run: dry_run,
182
+ entrypoint: entrypoint,
183
+ params: params,
184
+ params_type:params_type,
185
+ **args)
186
186
 
187
187
  transfer(transfer_args)
188
188
  end
@@ -266,6 +266,26 @@ class TezosClient
266
266
  end
267
267
 
268
268
  private
269
+ def transfer_args(dry_run: false, entrypoint:, params:, params_type:, **args)
270
+ _entrypoint = select_entrypoint(
271
+ contract_address: args[:to],
272
+ entrypoint: entrypoint
273
+ )
274
+
275
+ json_params = micheline_params(
276
+ params: params,
277
+ entrypoint: _entrypoint,
278
+ params_type: params_type
279
+ )
280
+
281
+ args.merge(
282
+ entrypoint: _entrypoint,
283
+ parameters: json_params,
284
+ dry_run: dry_run
285
+ )
286
+ end
287
+
288
+
269
289
  def broadcast_operation(operation:, dry_run:)
270
290
  res = if dry_run
271
291
  operation.simulate
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.3
4
+ version: 1.4.5
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: 2022-02-10 00:00:00.000000000 Z
13
+ date: 2022-09-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -244,6 +244,7 @@ files:
244
244
  - Rakefile
245
245
  - bin/console
246
246
  - bin/setup
247
+ - demo_script.json
247
248
  - lib/tezos_client.rb
248
249
  - lib/tezos_client/client_interface/block_contextual.rb
249
250
  - lib/tezos_client/client_interface/client_wrapper.rb