stellar_base-rails 4.0.0 → 4.1.0

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: cff5f415f6a47273028b4ca3624b7438ee2eb31e0ca815869919c0e0636abda9
4
- data.tar.gz: c489e059fb3c85dc83ac5ade58252f5c342b2a09c67971dfda3eb2c4f7cf8451
3
+ metadata.gz: c3ba1fbf0fe9d7db7eed5889e238341a767f77970abd4e75ad2cb91581ff2ab7
4
+ data.tar.gz: d83e78f1b44edc67dd8fa1d91abf63b9b7badae37935bef70177aa3925686f1b
5
5
  SHA512:
6
- metadata.gz: 75a2497469d514931e412bc328d52a8193ce7275d2fddf484c87003a864ffde59c069e54d05e74bb64c21fd23667bd1671a56d9afc5bd9469f6ff4f42e3432be
7
- data.tar.gz: d194dabc8981366ffd174ca1e3f34f5859f47f7b6ea9f9bf9e575e64c21d14b4a845c4acc15f5b1b29e14b898cd54d3cda7b0912b1103345956cec92ec2e3acf
6
+ metadata.gz: bbfcaf41ebd418882dc75f878ad900a9ac39f8ab72566d0e41ca8fb2d4e7f9ec7c49d0624cb70df943be12b9a706c3558ce93eaa1f23e18e7826bd2c40028b08
7
+ data.tar.gz: 141470c4f0642ffc5557f0fc945793a062ac7b35518511e6eb733a18224e90d0e57f75384406070ab1c112923670993115258d3d32f77feee16e165fa21eb43b
@@ -9,6 +9,7 @@ module StellarBase
9
9
  property :memo
10
10
  property :email_address
11
11
  property :deposit_type
12
+ property :extra_info
12
13
 
13
14
  validates(
14
15
  :asset_code,
@@ -7,11 +7,12 @@ module StellarBase
7
7
 
8
8
  step self::Policy::Pundit(DepositRequestPolicy, :create?)
9
9
  step Model(DepositRequest, :new)
10
+ step :find_depositable_asset_details!
10
11
  step :setup_params!
12
+ step :set_extra_info!
11
13
  step Contract::Build(constant: Contracts::Create)
12
14
  step Contract::Validate(key: :deposit_request)
13
15
  step Contract::Persist(method: :sync)
14
- step :find_depositable_asset_details!
15
16
  step :determine_how!
16
17
  step :determine_max_amount!
17
18
  success :set_defaults!
@@ -30,33 +31,34 @@ module StellarBase
30
31
 
31
32
  def find_depositable_asset_details!(options, params:, **)
32
33
  details = FindDepositableAsset.(params[:deposit_request][:asset_code])
33
- params[:deposit_asset_details] = details.presence || {}
34
+ options[:asset_details] = details.presence || {}
34
35
  end
35
36
 
36
- def determine_how!(options, params:, **)
37
- details = params[:deposit_asset_details]
38
- options["model"].deposit_address =
39
- DetermineHow.(details[:how_from], params[:deposit_request])
37
+ def determine_how!(options, params:, asset_details:, model:, **)
38
+ model.deposit_address =
39
+ DetermineHow.(asset_details[:how_from], params[:deposit_request])
40
40
  end
41
41
 
42
- def determine_max_amount!(options, params:, **)
43
- details = params[:deposit_asset_details]
44
- options["model"].max_amount =
45
- ConfiguredClassRunner.(details[:max_amount_from]) || 0
42
+ def set_extra_info!(ctx, params:, asset_details:, **)
43
+ params[:deposit_request][:extra_info] =
44
+ DetermineExtraInfo.(asset_details).to_json
46
45
  end
47
46
 
48
- def set_defaults!(options, params:, **)
49
- details = params[:deposit_asset_details]
47
+ def determine_max_amount!(options, params:, asset_details:, model:, **)
48
+ model.max_amount =
49
+ ConfiguredClassRunner.(asset_details[:max_amount_from]) || 0
50
+ end
50
51
 
51
- options["model"].asset_type = details[:type]
52
- options["model"].issuer = details[:issuer]
53
- options["model"].eta = DEFAULT_ETA
54
- options["model"].min_amount = 0.0
52
+ def set_defaults!(options, params:, model:, asset_details:, **)
53
+ model.asset_type = asset_details[:type]
54
+ model.issuer = asset_details[:issuer]
55
+ model.eta = DEFAULT_ETA
56
+ model.min_amount = 0.0
55
57
 
56
58
  # Make Deposits free unless we want it configured
57
- # TODO: this should come from `CallDepositFeeFrom.(params, details)`
58
- options["model"].fee_fixed = details[:fee_fixed] || 0.0
59
- options["model"].fee_percent = details[:fee_percent] || 0.0
59
+ # TODO: this should come from `CallDepositFeeFrom.(params, asset_details)`
60
+ model.fee_fixed = asset_details[:fee_fixed] || 0.0
61
+ model.fee_percent = asset_details[:fee_percent] || 0.0
60
62
  end
61
63
 
62
64
  def memo_type_from(params)
@@ -7,7 +7,13 @@ module StellarBase
7
7
  property :max_amount
8
8
  property :fee_fixed
9
9
  property :fee_percent
10
- property :extra_info
10
+ property :extra_info, exec_context: :decorator
11
+
12
+ def extra_info
13
+ ::JSON.parse(represented.extra_info)
14
+ rescue
15
+ {}
16
+ end
11
17
 
12
18
  end
13
19
  end
@@ -0,0 +1,14 @@
1
+ module StellarBase
2
+ class DetermineExtraInfo
3
+
4
+ def self.call(asset_details)
5
+ info_from =
6
+ GetCallbackFrom.(asset_details[:extra_info_from])
7
+
8
+ if info_from
9
+ return info_from.(asset_details)
10
+ end
11
+ end
12
+
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module StellarBase
2
- VERSION = "4.0.0".freeze
2
+ VERSION = "4.1.0".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: 4.0.0
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ace Subido
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-08 00:00:00.000000000 Z
11
+ date: 2019-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: disposable
@@ -496,6 +496,7 @@ files:
496
496
  - app/services/stellar_base/deposit_requests/send_asset.rb
497
497
  - app/services/stellar_base/deposit_requests/trigger.rb
498
498
  - app/services/stellar_base/deposit_requests/update_deposit.rb
499
+ - app/services/stellar_base/determine_extra_info.rb
499
500
  - app/services/stellar_base/fee_requests/call_withdraw_fee_fixed_quote_from.rb
500
501
  - app/services/stellar_base/find_asset_details.rb
501
502
  - app/services/stellar_base/gen_memo_for.rb
@@ -561,7 +562,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
561
562
  - !ruby/object:Gem::Version
562
563
  version: '0'
563
564
  requirements: []
564
- rubygems_version: 3.0.1
565
+ rubygems_version: 3.0.4
565
566
  signing_key:
566
567
  specification_version: 4
567
568
  summary: Mountable Stellar API Endpoints for Rails