stellar_base-rails 0.9.4 → 0.9.5

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: daf57d4638bce982bb6b23643076ff41a55736075cc25f2d63aaa017734aee75
4
- data.tar.gz: 109f46abe1d4ad4d67eed41da9f9aea91fe58dd4ef304f7766c752173c2b48eb
3
+ metadata.gz: 7d46d85f2dc7b2aae1b07e4a4a8e14438492daed928984280164d555e14dd867
4
+ data.tar.gz: 75f22ebee9475714b891fa8bfc3c76bfe224d5236b81ac82a0be403117f4d8b3
5
5
  SHA512:
6
- metadata.gz: 4d5e0a3825cb8d458d3a3c0809c2bb2fcc1cef1d5b8f57d02c00e563bc8c6888c715679a36d7742877f4622567031335537d39148fff9a59e74816db79954c1e
7
- data.tar.gz: 2270ff9426d82c80d32e6fcffefde2c120cffc63b3fa849d8387eaccad177fb149be300471015d568f5377b3159bf0ed69daf51f15e0f189dccc2b3a1e80aa19
6
+ metadata.gz: 00af460fe3e90e786c68e8854b877eb8b74ded926238f00feccbde764c8c8cd05ec26083b079e922227342cddfd6f8f6ea32f866a989567292cd1b110fcf75a8
7
+ data.tar.gz: 63701fb3cbb3bc43c7c92f4b20d6efda1c0cc6b13fcaa8173fadeaecca0105273de7745776ab55e8d7dac4aa49a0ede6b71d40373e56feee2b7c212aa4524a28
@@ -4,8 +4,10 @@ module StellarBase
4
4
  class Create < ApplicationOperation
5
5
 
6
6
  DEFAULT_ETA = (10 * 60).freeze
7
+ POLICY_ERROR_MESSAGE = "You are unauthorized to request withdrawal details"
7
8
 
8
9
  step self::Policy::Pundit(WithdrawalRequestPolicy, :create?)
10
+ failure :set_policy_error!
9
11
  step Model(WithdrawalRequest, :new)
10
12
  step :setup_params!
11
13
  step Contract::Build(constant: Contracts::Create)
@@ -17,6 +19,10 @@ module StellarBase
17
19
 
18
20
  private
19
21
 
22
+ def set_policy_error!(options, params:, **)
23
+ options["result.policy.message"] = POLICY_ERROR_MESSAGE
24
+ end
25
+
20
26
  def setup_params!(options, params:, **)
21
27
  params[:withdrawal_request].merge!({
22
28
  asset_type: params[:withdrawal_request][:type],
@@ -13,7 +13,7 @@ module StellarBase
13
13
  render json: representer
14
14
  else
15
15
  render(
16
- json: { error: op["contract.default"].errors },
16
+ json: { error: op["result.policy.message"] || op["contract.default"].errors },
17
17
  status: :unprocessable_entity,
18
18
  )
19
19
  end
@@ -12,13 +12,14 @@ module StellarBase
12
12
  promises :operations
13
13
 
14
14
  executed do |c|
15
+ address = c.account_subscription.address
16
+
15
17
  c.operations = c.stellar_sdk_client.horizon
16
- .account(account_id: c.account_subscription.address)
18
+ .account(account_id: address)
17
19
  .operations(order: "asc", limit: c.operation_limit).records
18
20
 
19
21
  if c.operations.empty?
20
- c.fail_and_return! "No operations found " \
21
- "for #{c.account_subscription.address}"
22
+ c.fail_and_return! "No operations found for #{address}"
22
23
  end
23
24
  rescue Faraday::ClientError => e
24
25
  c.fail_and_return! "Skipping fetching operations of #{address} " \
@@ -34,9 +34,8 @@ module StellarBase
34
34
 
35
35
  c.stellar_tx_id = response.to_hash["hash"]
36
36
  rescue Faraday::ClientError => e
37
- c.fail!
38
- c.skip_remaining! "Error sending the asset. " \
39
- "Faraday::ClientError: #{e.message}"
37
+ c.fail_and_return! "Error sending the asset. " \
38
+ "Faraday::ClientError: #{e.inspect}"
40
39
  end
41
40
  end
42
41
 
@@ -0,0 +1,10 @@
1
+ class CreateStellarBaseAccountSubscriptions < ActiveRecord::Migration[5.2]
2
+ def change
3
+ create_table :stellar_base_account_subscriptions do |t|
4
+ t.string :address, null: false
5
+ t.string :cursor
6
+ t.index :address, unique: true
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module StellarBase
2
- VERSION = "0.9.4".freeze
2
+ VERSION = "0.9.5".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.9.4
4
+ version: 0.9.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-10-08 00:00:00.000000000 Z
11
+ date: 2018-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: disposable
@@ -430,6 +430,7 @@ files:
430
430
  - db/migrate/20180925045927_create_stellar_base_deposit_requests.rb
431
431
  - db/migrate/20181001070647_create_stellar_base_deposits.rb
432
432
  - db/migrate/20181003072138_create_stellar_base_account_subscriptions.rb
433
+ - db/migrate/20181013072141_ensure_deposits_tx_id_uniqueness.rb
433
434
  - lib/stellar_base-rails.rb
434
435
  - lib/stellar_base.rb
435
436
  - lib/stellar_base/engine.rb
@@ -463,7 +464,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
463
464
  version: '0'
464
465
  requirements: []
465
466
  rubyforge_project:
466
- rubygems_version: 2.7.6
467
+ rubygems_version: 2.7.7
467
468
  signing_key:
468
469
  specification_version: 4
469
470
  summary: Mountable Stellar API Endpoints for Rails