tezos_client 1.3.5 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +80 -74
- data/README.md +11 -11
- data/lib/tezos_client/compute_operation_args_counters.rb +2 -2
- data/lib/tezos_client/exceptions.rb +1 -1
- data/lib/tezos_client/operations/transaction_operation.rb +1 -3
- data/lib/tezos_client/operations/transactions_operation.rb +1 -3
- data/lib/tezos_client/smartpy_interface.rb +45 -13
- data/lib/tezos_client/tools/annots_to_type.rb +1 -1
- data/lib/tezos_client/tools/convert_to_hash/big_map.rb +13 -6
- data/lib/tezos_client/tools/convert_to_hash/key.rb +11 -11
- data/lib/tezos_client/tools/convert_to_hash/key_hash.rb +13 -0
- data/lib/tezos_client/tools/convert_to_hash/option.rb +1 -1
- data/lib/tezos_client/tools/convert_to_hash/set.rb +13 -0
- data/lib/tezos_client/tools/hash_to_micheline/base.rb +0 -2
- data/lib/tezos_client/tools/hash_to_micheline/pair.rb +23 -24
- data/lib/tezos_client/version.rb +1 -1
- data/lib/tezos_client.rb +3 -3
- data/tezos_client.gemspec +4 -4
- metadata +11 -6
- data/lib/tezos_client/smartpy_inteface/micheline_serializer_wrapper.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd58876a037528bff5019e089ead07ea6eaa2f4e68ec029f33c73735d4710370
|
4
|
+
data.tar.gz: 588d6eb55a1a226cb824968033f181296572886cf08aae029d6227e824350db2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
+
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.
|
18
|
-
actionview (= 6.0.
|
19
|
-
activesupport (= 6.0.
|
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.
|
25
|
-
activesupport (= 6.0.
|
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.
|
31
|
-
activemodel (>= 5, <
|
32
|
-
|
33
|
-
|
34
|
-
|
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.
|
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.
|
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.
|
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.
|
56
|
+
ffi (1.15.5)
|
56
57
|
hashdiff (1.0.1)
|
57
|
-
http-cookie (1.0.
|
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.
|
63
|
+
i18n (1.9.1)
|
63
64
|
concurrent-ruby (~> 1.0)
|
64
|
-
loofah (2.
|
65
|
+
loofah (2.13.0)
|
65
66
|
crass (~> 1.0.2)
|
66
67
|
nokogiri (>= 1.5.9)
|
67
|
-
method_source (0.
|
68
|
-
mime-types (3.
|
68
|
+
method_source (1.0.0)
|
69
|
+
mime-types (3.4.1)
|
69
70
|
mime-types-data (~> 3.2015)
|
70
|
-
mime-types-data (3.
|
71
|
-
|
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.
|
78
|
-
mini_portile2 (~> 2.5.0)
|
77
|
+
nokogiri (1.13.1-x86_64-darwin)
|
79
78
|
racc (~> 1.4)
|
80
|
-
parallel (1.
|
81
|
-
parser (3.
|
79
|
+
parallel (1.21.0)
|
80
|
+
parser (3.1.0.0)
|
82
81
|
ast (~> 2.4.1)
|
83
|
-
pry (0.
|
84
|
-
coderay (~> 1.1
|
85
|
-
method_source (~>
|
82
|
+
pry (0.14.1)
|
83
|
+
coderay (~> 1.1)
|
84
|
+
method_source (~> 1.0)
|
86
85
|
public_suffix (4.0.6)
|
87
|
-
racc (1.
|
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.
|
93
|
+
rails-html-sanitizer (1.4.2)
|
95
94
|
loofah (~> 2.3)
|
96
|
-
railties (6.0.
|
97
|
-
actionpack (= 6.0.
|
98
|
-
activesupport (= 6.0.
|
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.
|
103
|
-
rake (13.0.
|
101
|
+
rainbow (3.1.1)
|
102
|
+
rake (13.0.6)
|
104
103
|
rbnacl (5.0.0)
|
105
104
|
ffi
|
106
|
-
regexp_parser (2.
|
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.
|
112
|
-
rspec (3.
|
113
|
-
rspec-core (~> 3.
|
114
|
-
rspec-expectations (~> 3.
|
115
|
-
rspec-mocks (~> 3.
|
116
|
-
rspec-core (3.
|
117
|
-
rspec-support (~> 3.
|
118
|
-
rspec-expectations (3.
|
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.
|
121
|
-
rspec-mocks (3.
|
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.
|
124
|
-
rspec-support (3.
|
125
|
-
rubocop (
|
122
|
+
rspec-support (~> 3.11.0)
|
123
|
+
rspec-support (3.11.0)
|
124
|
+
rubocop (1.25.1)
|
126
125
|
parallel (~> 1.10)
|
127
|
-
parser (>=
|
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 (>=
|
130
|
+
rubocop-ast (>= 1.15.1, < 2.0)
|
132
131
|
ruby-progressbar (~> 1.7)
|
133
|
-
unicode-display_width (>= 1.4.0, <
|
134
|
-
rubocop-ast (1.
|
135
|
-
parser (>=
|
136
|
-
rubocop-
|
137
|
-
rubocop (>= 0.90
|
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.
|
142
|
+
rubocop-rails (2.13.2)
|
140
143
|
activesupport (>= 4.2.0)
|
141
144
|
rack (>= 1.1)
|
142
|
-
rubocop (>=
|
143
|
-
rubocop-rails_config (
|
144
|
-
railties (>=
|
145
|
-
rubocop (
|
146
|
-
rubocop-
|
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
|
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.
|
156
|
-
unicode-display_width (1.
|
161
|
+
unf_ext (0.0.8)
|
162
|
+
unicode-display_width (2.1.0)
|
157
163
|
vcr (4.0.0)
|
158
|
-
webmock (3.
|
159
|
-
addressable (>= 2.
|
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
|
168
|
+
zeitwerk (2.5.4)
|
163
169
|
|
164
170
|
PLATFORMS
|
165
|
-
|
171
|
+
x86_64-darwin-19
|
166
172
|
|
167
173
|
DEPENDENCIES
|
168
|
-
bundler (~> 1
|
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
|
-
|
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/
|
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
|
-
# :
|
63
|
-
# :
|
64
|
-
# :
|
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
|
-
# :
|
75
|
-
# :
|
76
|
-
# :
|
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
|
-
# :
|
88
|
-
# :
|
89
|
-
# :
|
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
|
-
.
|
35
|
-
|
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 =
|
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
|
@@ -3,14 +3,12 @@
|
|
3
3
|
class TezosClient
|
4
4
|
class TransactionsOperation < Operation
|
5
5
|
def rpc_operation_args
|
6
|
-
@rpc_operation_args ||=
|
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 =
|
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
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
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
|
@@ -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
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
32
|
-
|
33
|
-
|
34
|
-
data
|
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
|
38
|
+
data
|
37
39
|
end
|
38
|
-
else
|
39
|
-
data
|
40
40
|
end
|
41
|
-
end
|
42
41
|
end
|
43
42
|
end
|
44
43
|
end
|
data/lib/tezos_client/version.rb
CHANGED
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:
|
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 = "
|
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
|
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
|
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:
|
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
|
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
|
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:
|
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
|