tezos_client 0.4.16 → 0.4.17

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: 79c72fa7b67051d75e1fce3b9c5cc24a8078bbf8e027f344d0d47cff2455c715
4
- data.tar.gz: f98b436a87cbe436ee48f2ea92b4dfaa0be42481677773805b250d1404398f0f
3
+ metadata.gz: 77e64070f9d16862fe3ea855743decfd8177b364643e52166efd959cac713997
4
+ data.tar.gz: f6393e2ee64d200169e1ffa47c2b9bb65cf5cd1b5c3507d7bf9d812f6aa1daac
5
5
  SHA512:
6
- metadata.gz: cbb290b67bbd4bc9077949ec9527c815e65db2917863408f74aa3b1a7db5ddd265c396f668c0cb3afa00f654b81546e590e9751bbcb8b652326b8f59d223221f
7
- data.tar.gz: d30036573558a14950b79c5a64c450324d4c65381aadb8237fce67ae954907ddbf4a9c1e2944d52e2839a2d7d37da9e397eb045524bdc8dd94920e53c8922564
6
+ metadata.gz: 37f86d63ec3aab4310e6328ef7e5f4a9e935e693e98eef92ccdd640a562667692ed7850230a7014386f5030ee962cc8e74f1d3c6171c0b595f9b26000ddd41d7
7
+ data.tar.gz: ca437a9e9a68bef967f10b5621582f10b28a3ee6ae5e23033509b950bd686a1b1a617188088a2eb0463fdfacd2fb9ad82bb4396b1726eb042f255b6854d75f61
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tezos_client (0.4.16)
4
+ tezos_client (0.4.17)
5
5
  activesupport (~> 6.0.0)
6
6
  base58 (~> 0.2.3)
7
7
  bip_mnemonic (~> 0.0.2)
@@ -47,11 +47,11 @@ GEM
47
47
  domain_name (0.5.20190701)
48
48
  unf (>= 0.0.5, < 1.0.0)
49
49
  erubi (1.9.0)
50
- ffi (1.11.3)
50
+ ffi (1.12.2)
51
51
  hashdiff (1.0.0)
52
52
  http-cookie (1.0.3)
53
53
  domain_name (~> 0.5)
54
- httparty (0.17.1)
54
+ httparty (0.17.3)
55
55
  mime-types (~> 3.0)
56
56
  multi_xml (>= 0.5.2)
57
57
  i18n (1.7.0)
@@ -61,7 +61,7 @@ GEM
61
61
  crass (~> 1.0.2)
62
62
  nokogiri (>= 1.5.9)
63
63
  method_source (0.9.2)
64
- mime-types (3.3)
64
+ mime-types (3.3.1)
65
65
  mime-types-data (~> 3.2015)
66
66
  mime-types-data (3.2019.1009)
67
67
  mini_portile2 (2.4.0)
@@ -79,7 +79,7 @@ GEM
79
79
  coderay (~> 1.1.0)
80
80
  method_source (~> 0.9.0)
81
81
  public_suffix (4.0.1)
82
- rack (2.0.7)
82
+ rack (2.0.8)
83
83
  rack-test (1.1.0)
84
84
  rack (>= 1.0, < 3)
85
85
  rails-dom-testing (2.0.3)
@@ -101,4 +101,6 @@ class TezosClient
101
101
  super
102
102
  end
103
103
  end
104
+
105
+ class UnknownTransactionError < Exception; end
104
106
  end
@@ -168,18 +168,39 @@ class TezosClient
168
168
 
169
169
  def ensure_applied!(rpc_responses)
170
170
  metadatas = rpc_responses.map { |response| response[:metadata] }
171
- operation_results = metadatas.map { |metadata| metadata[:operation_result] }
171
+ operation_full_results = metadatas.map do |metadata|
172
+ { op_result: metadata[:operation_result], internal_operation_results: metadata[:internal_operation_results]}
173
+ end
172
174
 
173
- failed = operation_results.detect do |operation_result|
175
+ failed = operation_full_results.map{|op_res| op_res[:op_result]}.detect do |operation_result|
174
176
  operation_result != nil && operation_result[:status] != "applied"
175
177
  end
176
178
 
177
179
  return metadatas if failed.nil?
178
180
 
179
- failed_operation_result = operation_results.detect do |operation_result|
180
- operation_result[:status] == "failed"
181
+ process_transaction_errors!(operation_full_results)
182
+ end
183
+
184
+ def process_transaction_errors!(operations_full_results)
185
+ detect_operation = ->(op_full_results, status: "failed") do
186
+ op_full_results.detect do |operation_result|
187
+ operation_result[:op_result][:status] == status
188
+ end
189
+ end
190
+
191
+ failed_operation_result = detect_operation.call(operations_full_results)
192
+
193
+ if failed_operation_result.nil?
194
+ backtracked_operation_result = detect_operation.call(operations_full_results, status: "backtracked")
195
+ raise UnknownTransactionError if backtracked_operation_result.nil?
196
+
197
+ internal_operations_results = backtracked_operation_result[:internal_operation_results].map{|op| op[:result]}
198
+ failed_operation_result = internal_operations_results.detect { |op_result| op_result[:status] == "failed" }
199
+ else
200
+ failed_operation_result = failed_operation_result[:op_result]
181
201
  end
182
202
 
203
+ operation_results = operations_full_results.map { |full_result| full_result[:op_result] }
183
204
  failed!("failed", failed_operation_result[:errors], operation_results)
184
205
  end
185
206
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class TezosClient
4
- VERSION = "0.4.16"
4
+ VERSION = "0.4.17"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tezos_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.16
4
+ version: 0.4.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pierre Michard
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-05 00:00:00.000000000 Z
11
+ date: 2020-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler