stellar_base-rails 0.2.0 → 0.2.1
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 +4 -4
- data/app/concepts/stellar_base/bridge_callbacks/contracts/process.rb +5 -0
- data/app/controllers/stellar_base/bridge_callbacks_controller.rb +8 -0
- data/app/services/stellar_base/bridge_callbacks/check.rb +1 -0
- data/app/services/stellar_base/bridge_callbacks/compare.rb +45 -0
- data/app/services/stellar_base/bridge_callbacks/get_operation.rb +2 -0
- data/app/services/stellar_base/bridge_callbacks/get_transaction.rb +2 -0
- data/lib/stellar_base/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecd5d5fc63b0d3fc23adafd92a5e330c1ae47949bc410898565a9efdb4f6726f
|
4
|
+
data.tar.gz: 3d7f60859d18ab5376070d7ec7fbc1281ddc4ff8708927221f146978fe2c96e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fc6a3115718edb85a4a9e43ff75141d96720514e49c2f41a9dae261b29d2f1a1ddc8979d8ef80cf0c871185fefb469c9ac38f23a279997f7b3105890a8b3ad8
|
7
|
+
data.tar.gz: 9d8ed4542c4f85231f68ada991cecbe6e5895d3f2f2590dadf4bba0102822b061d50906f8124531199e405712c5334b63e45e52b433628fb60c97aa7f5041763
|
@@ -14,6 +14,11 @@ module StellarBase
|
|
14
14
|
property :data
|
15
15
|
property :transaction_id
|
16
16
|
|
17
|
+
validates :id, presence: true
|
18
|
+
validates :transaction_id, presence: true
|
19
|
+
validates :from, presence: true
|
20
|
+
validates :amount, presence: true
|
21
|
+
|
17
22
|
validate :check_callback_authenticity
|
18
23
|
|
19
24
|
def check_callback_authenticity
|
@@ -10,6 +10,7 @@ module StellarBase
|
|
10
10
|
if op.success?
|
11
11
|
head :ok
|
12
12
|
else
|
13
|
+
log_unsuccessful_callback(op)
|
13
14
|
head :unprocessable_entity
|
14
15
|
end
|
15
16
|
end
|
@@ -18,6 +19,13 @@ module StellarBase
|
|
18
19
|
|
19
20
|
private
|
20
21
|
|
22
|
+
def log_unsuccessful_callback(op)
|
23
|
+
Rails.logger.warn("Unsuccessful bridge callback #{callback_params.to_s}")
|
24
|
+
|
25
|
+
error_messages = op["contract.default"].errors.full_messages
|
26
|
+
Rails.logger.warn("Details: #{error_messages}")
|
27
|
+
end
|
28
|
+
|
21
29
|
def callback_params
|
22
30
|
params.permit(
|
23
31
|
:id,
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module StellarBase
|
2
|
+
module BridgeCallbacks
|
3
|
+
class Compare
|
4
|
+
extend LightService::Action
|
5
|
+
expects :operation_response, :transaction_response, :params
|
6
|
+
|
7
|
+
executed do |c|
|
8
|
+
operation = c.operation_response
|
9
|
+
transaction = c.transaction_response
|
10
|
+
|
11
|
+
# TODO: implement route check if Compliance server is available
|
12
|
+
hash = {
|
13
|
+
id: operation["id"],
|
14
|
+
from: operation["source_account"],
|
15
|
+
amount: operation["amount"],
|
16
|
+
route: transaction["memo"],
|
17
|
+
asset_code: transaction["asset_code"],
|
18
|
+
asset_issuer: transaction["asset_issuer"],
|
19
|
+
memo: transaction["memo"],
|
20
|
+
memo_type: transaction["memo_type"],
|
21
|
+
transaction_id: transaction["id"],
|
22
|
+
}
|
23
|
+
|
24
|
+
result = compare(hash, c.params)
|
25
|
+
|
26
|
+
if result.any?
|
27
|
+
message = [result.join(", "), "value isn't the same"].join(" ")
|
28
|
+
elsif transaction["id"] != operation["transaction_hash"]
|
29
|
+
message = "Operation#transaction_id and transaction_id not the same"
|
30
|
+
end
|
31
|
+
|
32
|
+
c.fail_and_return! message if message.present?
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.compare(hash, params)
|
36
|
+
# TODO: implement data comparison
|
37
|
+
params.except!(:data)
|
38
|
+
|
39
|
+
params.keys.map do |param_key|
|
40
|
+
param_key if params[param_key] != hash[param_key].to_s
|
41
|
+
end.compact
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/stellar_base/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stellar_base-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ace Subido
|
@@ -203,6 +203,7 @@ files:
|
|
203
203
|
- app/models/stellar_base/application_record.rb
|
204
204
|
- app/models/stellar_base/bridge_callback.rb
|
205
205
|
- app/services/stellar_base/bridge_callbacks/check.rb
|
206
|
+
- app/services/stellar_base/bridge_callbacks/compare.rb
|
206
207
|
- app/services/stellar_base/bridge_callbacks/get_operation.rb
|
207
208
|
- app/services/stellar_base/bridge_callbacks/get_transaction.rb
|
208
209
|
- app/services/stellar_base/bridge_callbacks/initialize_horizon_client.rb
|