tezos_client 1.4.1 → 1.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +61 -57
- data/README.md +9 -9
- data/demo_script.json +427 -0
- 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 +36 -36
- data/lib/tezos_client/tools/annots_to_type.rb +1 -1
- 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/pair.rb +47 -3
- 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
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ed76e36473e1470004f6e0b00e22be33b3d53a209d5864d50d6dbbf767912e7
|
4
|
+
data.tar.gz: 9ac9e6b31f46f5fc6fb9147a7394f9fc73b2131228342ed0ecfa74c7c9c3d2dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a0e8a4c78f84ee1ddad295860ebe2e50dbeaa885c490b35f76bf80d89bb8d848e5750981e8e9a8279e1b37121ff75c6efe42af39cb68d4c7a3d80e435797959
|
7
|
+
data.tar.gz: 9a2f2eec3f07caae8be2e274e74d2118e37312b38cedccc99ac7cfc643583617c1b45671efd03c0feccc135538ce781e8dc35d1273bce458f55a3440355119c4
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
tezos_client (1.4.
|
4
|
+
tezos_client (1.4.4)
|
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.
|
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.0
|
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.15.
|
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
68
|
method_source (1.0.0)
|
68
|
-
mime-types (3.
|
69
|
+
mime-types (3.4.1)
|
69
70
|
mime-types-data (~> 3.2015)
|
70
|
-
mime-types-data (3.
|
71
|
-
minitest (5.
|
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.
|
77
|
+
nokogiri (1.13.1-x86_64-darwin)
|
77
78
|
racc (~> 1.4)
|
78
|
-
parallel (1.
|
79
|
-
parser (3.0.
|
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.
|
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.
|
93
|
+
rails-html-sanitizer (1.4.2)
|
93
94
|
loofah (~> 2.3)
|
94
|
-
railties (6.0.
|
95
|
-
actionpack (= 6.0.
|
96
|
-
activesupport (= 6.0.
|
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.
|
101
|
-
rake (13.0.
|
101
|
+
rainbow (3.1.1)
|
102
|
+
rake (13.0.6)
|
102
103
|
rbnacl (5.0.0)
|
103
104
|
ffi
|
104
|
-
regexp_parser (2.
|
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.
|
111
|
-
rspec-core (~> 3.
|
112
|
-
rspec-expectations (~> 3.
|
113
|
-
rspec-mocks (~> 3.
|
114
|
-
rspec-core (3.
|
115
|
-
rspec-support (~> 3.
|
116
|
-
rspec-expectations (3.
|
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.
|
119
|
-
rspec-mocks (3.
|
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.
|
122
|
-
rspec-support (3.
|
123
|
-
rubocop (1.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
146
|
+
rubocop-rails_config (1.8.2)
|
144
147
|
railties (>= 5.0)
|
145
|
-
rubocop (>= 1.
|
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
|
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.
|
158
|
-
unicode-display_width (2.
|
161
|
+
unf_ext (0.0.8)
|
162
|
+
unicode-display_width (2.1.0)
|
159
163
|
vcr (4.0.0)
|
160
|
-
webmock (3.
|
161
|
-
addressable (>= 2.
|
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
|
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
|
-
# :
|
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
|
|
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
|
+
}
|
@@ -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
|
@@ -28,50 +28,50 @@ class TezosClient
|
|
28
28
|
end
|
29
29
|
|
30
30
|
private
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
-
|
42
|
+
call_smartpy cmd_line
|
43
43
|
|
44
|
-
|
44
|
+
yield(script_path + "default/" + contract_script_filename, script_path + "default/" + init_script_filename)
|
45
|
+
end
|
45
46
|
end
|
46
|
-
end
|
47
47
|
|
48
|
-
|
49
|
-
|
48
|
+
def optional_inputs(flags, init_params)
|
49
|
+
inputs = []
|
50
50
|
|
51
|
-
|
52
|
-
|
51
|
+
inputs.concat(optional_flags(flags))
|
52
|
+
inputs.concat(optional_args(init_params))
|
53
53
|
|
54
|
-
|
55
|
-
|
54
|
+
inputs
|
55
|
+
end
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
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
|
-
|
68
|
-
|
67
|
+
def optional_args(init_params = [])
|
68
|
+
return [] if init_params.count.zero?
|
69
69
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
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
|
@@ -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
|
9
|
-
raise "Difference detected between data and type \nDATA: #{
|
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
|
-
(
|
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
|
@@ -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
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.
|
4
|
+
version: 1.4.4
|
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:
|
13
|
+
date: 2022-04-12 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
|
@@ -285,11 +286,13 @@ files:
|
|
285
286
|
- lib/tezos_client/tools/convert_to_hash/bytes.rb
|
286
287
|
- lib/tezos_client/tools/convert_to_hash/int.rb
|
287
288
|
- lib/tezos_client/tools/convert_to_hash/key.rb
|
289
|
+
- lib/tezos_client/tools/convert_to_hash/key_hash.rb
|
288
290
|
- lib/tezos_client/tools/convert_to_hash/list.rb
|
289
291
|
- lib/tezos_client/tools/convert_to_hash/map.rb
|
290
292
|
- lib/tezos_client/tools/convert_to_hash/nat.rb
|
291
293
|
- lib/tezos_client/tools/convert_to_hash/option.rb
|
292
294
|
- lib/tezos_client/tools/convert_to_hash/pair.rb
|
295
|
+
- lib/tezos_client/tools/convert_to_hash/set.rb
|
293
296
|
- lib/tezos_client/tools/convert_to_hash/signature.rb
|
294
297
|
- lib/tezos_client/tools/convert_to_hash/string.rb
|
295
298
|
- lib/tezos_client/tools/convert_to_hash/timestamp.rb
|
@@ -332,7 +335,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
332
335
|
- !ruby/object:Gem::Version
|
333
336
|
version: '0'
|
334
337
|
requirements: []
|
335
|
-
rubygems_version: 3.0.
|
338
|
+
rubygems_version: 3.0.3
|
336
339
|
signing_key:
|
337
340
|
specification_version: 4
|
338
341
|
summary: Wrapper to the tezos client.
|