stellar_base-rails 0.5.4 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -9
- data/app/concepts/stellar_base/withdrawal_requests/contracts/create.rb +22 -20
- data/app/concepts/stellar_base/withdrawal_requests/operations/create.rb +29 -21
- data/app/controllers/stellar_base/withdraw_controller.rb +4 -1
- data/lib/stellar_base/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b032a3ab1820d7411b5151c7b61350fca291a36c38cf64d84fa9ce11065d2df
|
4
|
+
data.tar.gz: 22c699cd39b19dfb2e96e5b1ea000aa5362cc45bd8393300770a0d2a052f9b2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7702503356c3cf28d2c03f35367d0793d13bde5cc3d45dd87b681840ce1fff444632eccb6a78497ec246b8e767d2fe5a02e900985194aff87346d300ee2fec2a
|
7
|
+
data.tar.gz: ad913b47be20ff81a91b577f55213444e01aa1aa4f0c29a1ee1fd9ae552ff84f85ce729882e68be4cf9ed0c83ed2af748a7eb6051c373ebcced6eec4935161ac
|
data/README.md
CHANGED
@@ -56,17 +56,17 @@ This is the same distribution account that is setup in bridge. Currently, it is
|
|
56
56
|
- Value(s): Hash, follow Stellar's [documentation](https://www.stellar.org/developers/guides/concepts/stellar-toml.html) for `stellar.toml`
|
57
57
|
- Example:
|
58
58
|
```
|
59
|
-
c.stellar_toml = {
|
60
|
-
TRANSFER_SERVER: ...,
|
61
|
-
FEDERATION_SERVER: ...,
|
62
|
-
AUTH_SERVER: ...,
|
63
|
-
}
|
59
|
+
c.stellar_toml = { TRANSFER_SERVER: ... }
|
64
60
|
```
|
65
|
-
-
|
61
|
+
- When adding the URL of the transfer server, make sure not to add `/` at the end as described in the Stellar documentation:
|
66
62
|
```
|
67
|
-
|
68
|
-
|
69
|
-
|
63
|
+
# Correct:
|
64
|
+
https://example.com/stellar
|
65
|
+
https://example.com
|
66
|
+
|
67
|
+
# Bad:
|
68
|
+
https://example.com/stellar/
|
69
|
+
https://example.com/
|
70
70
|
```
|
71
71
|
|
72
72
|
## Installation
|
@@ -7,30 +7,32 @@ module StellarBase
|
|
7
7
|
property :asset_code
|
8
8
|
property :dest
|
9
9
|
property :dest_extra
|
10
|
-
property :issuer
|
11
|
-
property :account_id
|
12
|
-
property :memo_type
|
13
|
-
property :memo
|
14
|
-
property :eta
|
15
|
-
property :min_amount
|
16
|
-
property :max_amount
|
17
|
-
property :fee_fixed
|
18
|
-
property :fee_percent
|
19
10
|
property :fee_network
|
20
11
|
|
21
12
|
validates(
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
account_id
|
28
|
-
fee_network
|
29
|
-
fee_fixed
|
30
|
-
fee_percent
|
31
|
-
],
|
32
|
-
presence: true
|
13
|
+
:asset_type,
|
14
|
+
:asset_code,
|
15
|
+
:dest,
|
16
|
+
:fee_network,
|
17
|
+
presence: true,
|
33
18
|
)
|
19
|
+
validate :check_valid_asset_code
|
20
|
+
|
21
|
+
def check_valid_asset_code
|
22
|
+
asset_codes = StellarBase
|
23
|
+
.configuration
|
24
|
+
.withdrawable_assets
|
25
|
+
&.map do |asset|
|
26
|
+
asset[:asset_code]
|
27
|
+
end
|
28
|
+
|
29
|
+
return if asset_codes.include? asset_code
|
30
|
+
|
31
|
+
errors.add(
|
32
|
+
:asset_code,
|
33
|
+
"invalid asset_code. Valid asset_codes: #{asset_codes.join(', ')}",
|
34
|
+
)
|
35
|
+
end
|
34
36
|
|
35
37
|
end
|
36
38
|
end
|
@@ -7,44 +7,52 @@ module StellarBase
|
|
7
7
|
|
8
8
|
step self::Policy::Pundit(WithdrawalRequestPolicy, :create?)
|
9
9
|
step Model(WithdrawalRequest, :new)
|
10
|
-
step :
|
11
|
-
success :set_defaults!
|
10
|
+
step :setup_params!
|
12
11
|
step Contract::Build(constant: Contracts::Create)
|
13
12
|
step Contract::Validate(key: :withdrawal_request)
|
14
|
-
step Contract::Persist()
|
13
|
+
step Contract::Persist(method: :sync)
|
14
|
+
step :find_withdrawal_asset_details!
|
15
|
+
success :set_defaults!
|
16
|
+
step Contract::Persist(method: :save)
|
15
17
|
|
16
18
|
private
|
17
19
|
|
20
|
+
def setup_params!(options, params:, **)
|
21
|
+
params[:withdrawal_request].merge!({
|
22
|
+
asset_type: params[:withdrawal_request][:type],
|
23
|
+
})
|
24
|
+
end
|
25
|
+
|
18
26
|
def find_withdrawal_asset_details!(options, params:, **)
|
19
27
|
withdrawable_assets = StellarBase.configuration.withdrawable_assets
|
20
28
|
details = withdrawable_assets.find do |e|
|
21
29
|
e[:asset_code] == params[:withdrawal_request][:asset_code]
|
22
30
|
end
|
23
31
|
|
24
|
-
|
25
|
-
|
26
|
-
options["withdrawal_asset_details"] = details
|
27
|
-
return true
|
32
|
+
params[:withdrawal_asset_details] = details.presence || {}
|
28
33
|
end
|
29
34
|
|
30
|
-
def set_defaults!(options,
|
35
|
+
def set_defaults!(options, params:, **)
|
36
|
+
withdrawal_asset_details = params[:withdrawal_asset_details]
|
37
|
+
|
31
38
|
fee_network = DetermineFee.network(
|
32
39
|
withdrawal_asset_details[:network],
|
33
40
|
params[:withdrawal_request][:fee_network],
|
34
41
|
)
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
42
|
+
|
43
|
+
options["model"].issuer = withdrawal_asset_details[:issuer]
|
44
|
+
options["model"].account_id =
|
45
|
+
StellarBase.configuration.distribution_account
|
46
|
+
options["model"].memo_type = "text"
|
47
|
+
options["model"].memo = GenMemo.()
|
48
|
+
options["model"].eta = DEFAULT_ETA
|
49
|
+
options["model"].min_amount = 0.0
|
50
|
+
options["model"].max_amount = nil
|
51
|
+
options["model"].fee_fixed =
|
52
|
+
DetermineFee.(withdrawal_asset_details[:fee_fixed])
|
53
|
+
options["model"].fee_percent =
|
54
|
+
DetermineFee.(withdrawal_asset_details[:fee_percent])
|
55
|
+
options["model"].fee_network = fee_network
|
48
56
|
end
|
49
57
|
|
50
58
|
end
|
@@ -11,7 +11,10 @@ module StellarBase
|
|
11
11
|
representer = WithdrawalRequestRepresenter.new(twin)
|
12
12
|
render json: representer
|
13
13
|
else
|
14
|
-
render
|
14
|
+
render(
|
15
|
+
json: { error: op["contract.default"].errors },
|
16
|
+
status: :unprocessable_entity,
|
17
|
+
)
|
15
18
|
end
|
16
19
|
end
|
17
20
|
end
|
data/lib/stellar_base/version.rb
CHANGED
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.
|
4
|
+
version: 0.5.5
|
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-
|
11
|
+
date: 2018-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: disposable
|
@@ -366,7 +366,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
366
366
|
version: '0'
|
367
367
|
requirements: []
|
368
368
|
rubyforge_project:
|
369
|
-
rubygems_version: 2.7.
|
369
|
+
rubygems_version: 2.7.6
|
370
370
|
signing_key:
|
371
371
|
specification_version: 4
|
372
372
|
summary: Mountable Stellar API Endpoints for Rails
|