stellar_base-rails 0.5.5 → 0.5.6

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: 1b032a3ab1820d7411b5151c7b61350fca291a36c38cf64d84fa9ce11065d2df
4
- data.tar.gz: 22c699cd39b19dfb2e96e5b1ea000aa5362cc45bd8393300770a0d2a052f9b2b
3
+ metadata.gz: b42873b418f519fda036560eef2596c0f75835247bf43d6680f9b3c82b6cb5b9
4
+ data.tar.gz: 892c7e80de8320d7bc137cacdfb72bd6e31a813d446c67b8e8676ccb4ef6b09e
5
5
  SHA512:
6
- metadata.gz: 7702503356c3cf28d2c03f35367d0793d13bde5cc3d45dd87b681840ce1fff444632eccb6a78497ec246b8e767d2fe5a02e900985194aff87346d300ee2fec2a
7
- data.tar.gz: ad913b47be20ff81a91b577f55213444e01aa1aa4f0c29a1ee1fd9ae552ff84f85ce729882e68be4cf9ed0c83ed2af748a7eb6051c373ebcced6eec4935161ac
6
+ metadata.gz: 7cfeddf2e1766828779c2635afc3fdf13b17f081aab34a797977d1a2798c11f058d6541c891a144de89c7d15faa5a71e9b86e77dcb7dca65abee4cca0d818a05
7
+ data.tar.gz: 01c19269320076cb8e8636aa4a5a855a51a02e0371695afd014b84e4a0710b14df7c39eed13b664e21219cb572c7737c25d0a92e52db97da74c9d271ee723056
@@ -19,9 +19,7 @@ module StellarBase
19
19
  validate :check_valid_asset_code
20
20
 
21
21
  def check_valid_asset_code
22
- asset_codes = StellarBase
23
- .configuration
24
- .withdrawable_assets
22
+ asset_codes = StellarBase.configuration.withdrawable_assets
25
23
  &.map do |asset|
26
24
  asset[:asset_code]
27
25
  end
@@ -24,10 +24,8 @@ module StellarBase
24
24
  end
25
25
 
26
26
  def find_withdrawal_asset_details!(options, params:, **)
27
- withdrawable_assets = StellarBase.configuration.withdrawable_assets
28
- details = withdrawable_assets.find do |e|
29
- e[:asset_code] == params[:withdrawal_request][:asset_code]
30
- end
27
+ details = FindWithdrawableAsset
28
+ .(params[:withdrawal_request][:asset_code])
31
29
 
32
30
  params[:withdrawal_asset_details] = details.presence || {}
33
31
  end
@@ -47,7 +45,8 @@ module StellarBase
47
45
  options["model"].memo = GenMemo.()
48
46
  options["model"].eta = DEFAULT_ETA
49
47
  options["model"].min_amount = 0.0
50
- options["model"].max_amount = nil
48
+ options["model"].max_amount =
49
+ DetermineMaxAmount.(withdrawal_asset_details[:max_amount_from])
51
50
  options["model"].fee_fixed =
52
51
  DetermineFee.(withdrawal_asset_details[:fee_fixed])
53
52
  options["model"].fee_percent =
@@ -55,6 +54,14 @@ module StellarBase
55
54
  options["model"].fee_network = fee_network
56
55
  end
57
56
 
57
+ def get_balance_from(balance_checker_class)
58
+ if balance_checker_present?
59
+ return balance_checker_class.constantize.send(:call)
60
+ end
61
+
62
+ nil
63
+ end
64
+
58
65
  end
59
66
  end
60
67
  end
@@ -0,0 +1,14 @@
1
+ module StellarBase
2
+ module WithdrawalRequests
3
+ class DetermineMaxAmount
4
+
5
+ DEFAULT = nil
6
+
7
+ def self.call(class_name)
8
+ return class_name.constantize.send(:call) if class_name.present?
9
+ DEFAULT
10
+ end
11
+
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,12 @@
1
+ module StellarBase
2
+ module WithdrawalRequests
3
+ class FindWithdrawableAsset
4
+
5
+ def self.call(asset_code)
6
+ withdrawable_assets = StellarBase.configuration.withdrawable_assets
7
+ withdrawable_assets.find {|asset| asset[:asset_code] == asset_code }
8
+ end
9
+
10
+ end
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
1
  module StellarBase
2
- VERSION = "0.5.5".freeze
2
+ VERSION = "0.5.6".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stellar_base-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ace Subido
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-06 00:00:00.000000000 Z
11
+ date: 2018-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: disposable
@@ -325,6 +325,8 @@ files:
325
325
  - app/services/stellar_base/gen_random_string.rb
326
326
  - app/services/stellar_base/withdrawal_requests/call_on_withdraw.rb
327
327
  - app/services/stellar_base/withdrawal_requests/determine_fee.rb
328
+ - app/services/stellar_base/withdrawal_requests/determine_max_amount.rb
329
+ - app/services/stellar_base/withdrawal_requests/find_withdrawable_asset.rb
328
330
  - app/services/stellar_base/withdrawal_requests/find_withdrawal_request.rb
329
331
  - app/services/stellar_base/withdrawal_requests/gen_memo.rb
330
332
  - app/services/stellar_base/withdrawal_requests/process.rb