istox 0.1.81.pre.test7 → 0.1.81.pre.test8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 729001e75a3aabdc46971845276748d609b0bc3a7fd7fb9443c7557ee88f5e46
4
- data.tar.gz: ba491528fe2bbcb6e61fdafe5b279cc8860b80a8f5173f5d5890916a92001b19
3
+ metadata.gz: 6914180beb5936e43d978d38460627b21ea6ea1d5d7673fd30626cf8450e6208
4
+ data.tar.gz: 4685dd98e263b7fc0e0365747d80db3aee98bd729135203077eba4089e97848c
5
5
  SHA512:
6
- metadata.gz: 96e334e27ad0feb1b293895eb65daa3b2ec838625cab5ca04496d8c27292a468696ee621e737b85b39536cbe20b3fdce49c69e6735b20cb1bd95cbf02293d1c7
7
- data.tar.gz: 0f62ea109c1607ca23841381837fcb19d5e6365d0fff8c8a42a367dcf705b08276bfbf75693bb6077c08fadbe4b9312924056fcfd42265570a38c93975fffe22
6
+ metadata.gz: cd3cf29e6a37c6c2d6d89d33becdd9e425b9133f97b2c4600bf29b4ac14829759e006ae0d9e9deb385de57d296492c801683a6dd943494dc7dc0eb8a13faba15
7
+ data.tar.gz: d74fff382c493301cde5d299fa925483f1b38823fe2df151f53f1a9607f7c485dc38b578d6a72c9c2a0e09ac2f3baa95661edfa7c7489edd6e9bcd283c1bbca0
@@ -3,20 +3,25 @@ module Istox
3
3
  class << self
4
4
  # format of transaction
5
5
  # {
6
- # uuid: "XXXXXX"
7
- # status: "confirmed/failed"
6
+ # type: 'CHAINHUB_RESPONSE_EVENT',
7
+ # uuid:'123', //original request uuid sent from backend
8
+ # success:true, //status of the whole request in true/false
9
+ # message:'', //In case of error, the message contain the error reason
10
+ # txnCount:1, //Number of blockchain transactions from the original request
11
+ # txnHashes:[] //Hashes for all transactions that has been submitted and mined by the blockchain for verification purpose
8
12
  # }
9
13
 
10
- def txn_status_changed(transaction)
14
+ def chainhub_response_event(transaction)
11
15
  receipt = ::Istox::BlockchainReceipt.where(txid: transaction.uuid).first
12
16
  if receipt.blank?
13
17
  puts 'Transaction doesn\'t belong to this backend, skipping...'
14
18
  return
15
19
  end
16
20
 
17
- return unless %w[failed confirmed].include?(transaction.status)
21
+ status = transaction.success ? 'confirmed' : 'failed'
18
22
 
19
- receipt.update!(status: transaction.status)
23
+ receipt.update!(status: status, message: transaction.message,
24
+ txhash: transaction.txnHashes.present? ? transaction.txnHashes.join(',') : nil)
20
25
 
21
26
  resource = begin
22
27
  class_eval("::#{receipt.resource_name}", __FILE__, __LINE__).find(receipt.resource_id)
@@ -27,13 +32,13 @@ module Istox
27
32
 
28
33
  return if resource_handled?(receipt)
29
34
 
30
- if transaction.status == 'confirmed'
35
+ if status == 'confirmed'
31
36
  resource.handle_confirm(receipt)
32
37
 
33
38
  mark_resource_handled(receipt)
34
39
  publish_to_frontend(resource, true, receipt, receipt.sid)
35
40
 
36
- elsif transaction.status == 'failed'
41
+ elsif status == 'failed'
37
42
  resource.handle_fail(receipt)
38
43
 
39
44
  mark_resource_handled(receipt)
@@ -58,7 +63,8 @@ module Istox
58
63
  sid,
59
64
  data: {
60
65
  success: success,
61
- purpose: receipt.activity
66
+ purpose: receipt.activity,
67
+ message: receipt.message
62
68
  }
63
69
  )
64
70
  rescue StandardError => e
@@ -22,7 +22,7 @@ module Istox
22
22
  def start(sid:, action:, before:, execute:, is_request: false)
23
23
  # create blockchain receipt first
24
24
  klass = blockchain_receipt_class
25
- uuid = :: SecureRandom.uuid
25
+ uuid = ::SecureRandom.uuid
26
26
  @receipt = klass.create!(
27
27
  txid: uuid,
28
28
  sid: sid,
@@ -17,6 +17,7 @@ module Istox
17
17
  t.timestamps
18
18
  t.string :sid
19
19
  t.string :status, default: 'pending'
20
+ t.text :message
20
21
  t.boolean :is_request, default: false
21
22
  t.integer :lock_version
22
23
  end
data/lib/istox/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Istox
2
- VERSION = '0.1.81-test7'.freeze
2
+ VERSION = '0.1.81-test8'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: istox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.81.pre.test7
4
+ version: 0.1.81.pre.test8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Siong Leng
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-10 00:00:00.000000000 Z
11
+ date: 2019-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny