istox 0.1.81.pre.test7 → 0.1.81.pre.test8
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6914180beb5936e43d978d38460627b21ea6ea1d5d7673fd30626cf8450e6208
|
4
|
+
data.tar.gz: 4685dd98e263b7fc0e0365747d80db3aee98bd729135203077eba4089e97848c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
#
|
7
|
-
#
|
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
|
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
|
-
|
21
|
+
status = transaction.success ? 'confirmed' : 'failed'
|
18
22
|
|
19
|
-
receipt.update!(status: transaction.
|
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
|
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
|
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 = ::
|
25
|
+
uuid = ::SecureRandom.uuid
|
26
26
|
@receipt = klass.create!(
|
27
27
|
txid: uuid,
|
28
28
|
sid: sid,
|
data/lib/istox/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2019-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bunny
|