stellar_base-rails 1.0.0 → 1.0.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/services/stellar_base/deposit_requests/create_deposit.rb +35 -0
- data/app/services/stellar_base/deposit_requests/trigger.rb +1 -1
- data/db/migrate/20181210043919_add_unique_index_to_deposits.rb +11 -0
- data/lib/stellar_base/version.rb +1 -1
- data/lib/stellar_base.rb +7 -0
- metadata +19 -5
- data/app/services/stellar_base/deposit_requests/find_or_create_deposit.rb +0 -28
- data/db/migrate/20181013072141_ensure_deposits_tx_id_uniqueness.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85622b9e76b031dbafdc257c00b4761fa6ab00bc765a775519fde9e95896c310
|
4
|
+
data.tar.gz: e63257b33b6e9a6f14b0956560ee9f51c3f18a91c8578b79cd14a2167b7b0260
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8b2bc1d551481662b9315be992114d6611b9b04413faf0a64588808b79b8640003bfbea9ca2b408b1bd0cb92cd31b87956a85486f4c085719316b28fec53fe1
|
7
|
+
data.tar.gz: 32ed7adb135d89f72513a4372bd0eed1ede4d7f0b6e20d20a55b3f334f30d02b14f82ba4a47bb5a53607e167f25528a593d1803f702551f934c32f0286c79120
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module StellarBase
|
2
|
+
module DepositRequests
|
3
|
+
class CreateDeposit
|
4
|
+
|
5
|
+
extend LightService::Action
|
6
|
+
|
7
|
+
expects :deposit_request, :tx_id, :amount
|
8
|
+
promises :deposit
|
9
|
+
|
10
|
+
executed do |c|
|
11
|
+
deposit_request_id = c.deposit_request.id
|
12
|
+
tx_id = c.tx_id
|
13
|
+
|
14
|
+
deposit = Deposit.find_by(
|
15
|
+
deposit_request_id: deposit_request_id,
|
16
|
+
tx_id: tx_id,
|
17
|
+
)
|
18
|
+
|
19
|
+
if deposit.present?
|
20
|
+
c.deposit = deposit
|
21
|
+
message = "Deposit already created for tx #{tx_id}; " \
|
22
|
+
"it's possible that the asset has been sent out"
|
23
|
+
c.fail_and_return! message
|
24
|
+
end
|
25
|
+
|
26
|
+
c.deposit = Deposit.create(
|
27
|
+
deposit_request_id: deposit_request_id,
|
28
|
+
tx_id: tx_id,
|
29
|
+
amount: c.amount,
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class AddUniqueIndexToDeposits < ActiveRecord::Migration[5.2]
|
2
|
+
|
3
|
+
def up
|
4
|
+
add_index :stellar_base_deposits, %i[deposit_request_id tx_id], unique: true
|
5
|
+
end
|
6
|
+
|
7
|
+
def down
|
8
|
+
add_index :stellar_base_deposits, column: %i[deposit_request_id tx_id]
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
data/lib/stellar_base/version.rb
CHANGED
data/lib/stellar_base.rb
CHANGED
@@ -42,6 +42,7 @@ module StellarBase
|
|
42
42
|
convert_config_deposit!
|
43
43
|
set_stellar_network!
|
44
44
|
configure_sidekiq_death_handler!
|
45
|
+
configure_sending_strategy!
|
45
46
|
end
|
46
47
|
|
47
48
|
def self.on_deposit_trigger(network:, deposit_address:, tx_id:, amount:)
|
@@ -84,6 +85,12 @@ module StellarBase
|
|
84
85
|
convert_config!(withdrawable_assets)
|
85
86
|
end
|
86
87
|
|
88
|
+
def self.configure_sending_strategy!
|
89
|
+
sending_strategy = self.configuration.sending_strategy
|
90
|
+
return if !sending_strategy.is_a?(Symbol)
|
91
|
+
self.configuration.sending_strategy = Array(sending_strategy)
|
92
|
+
end
|
93
|
+
|
87
94
|
def self.convert_config!(asset_config)
|
88
95
|
array_of_hashes = try_from_yaml_file_path(asset_config) ||
|
89
96
|
try_from_json(asset_config)
|
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: 1.0.
|
4
|
+
version: 1.0.1
|
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-11
|
11
|
+
date: 2018-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: disposable
|
@@ -360,6 +360,20 @@ dependencies:
|
|
360
360
|
- - "~>"
|
361
361
|
- !ruby/object:Gem::Version
|
362
362
|
version: '1.0'
|
363
|
+
- !ruby/object:Gem::Dependency
|
364
|
+
name: dotenv
|
365
|
+
requirement: !ruby/object:Gem::Requirement
|
366
|
+
requirements:
|
367
|
+
- - "~>"
|
368
|
+
- !ruby/object:Gem::Version
|
369
|
+
version: '2.5'
|
370
|
+
type: :development
|
371
|
+
prerelease: false
|
372
|
+
version_requirements: !ruby/object:Gem::Requirement
|
373
|
+
requirements:
|
374
|
+
- - "~>"
|
375
|
+
- !ruby/object:Gem::Version
|
376
|
+
version: '2.5'
|
363
377
|
description: API Endpoints for the Stellar Protocol
|
364
378
|
email:
|
365
379
|
- ace.subido@gmail.com
|
@@ -428,11 +442,11 @@ files:
|
|
428
442
|
- app/services/stellar_base/bridge_callbacks/process.rb
|
429
443
|
- app/services/stellar_base/bridge_callbacks/verify_mac_payload.rb
|
430
444
|
- app/services/stellar_base/configured_class_runner.rb
|
445
|
+
- app/services/stellar_base/deposit_requests/create_deposit.rb
|
431
446
|
- app/services/stellar_base/deposit_requests/determine_how.rb
|
432
447
|
- app/services/stellar_base/deposit_requests/find_config.rb
|
433
448
|
- app/services/stellar_base/deposit_requests/find_deposit_request.rb
|
434
449
|
- app/services/stellar_base/deposit_requests/find_depositable_asset.rb
|
435
|
-
- app/services/stellar_base/deposit_requests/find_or_create_deposit.rb
|
436
450
|
- app/services/stellar_base/deposit_requests/init_stellar_amount.rb
|
437
451
|
- app/services/stellar_base/deposit_requests/init_stellar_asset.rb
|
438
452
|
- app/services/stellar_base/deposit_requests/init_stellar_distribution_account.rb
|
@@ -464,7 +478,7 @@ files:
|
|
464
478
|
- db/migrate/20180925045927_create_stellar_base_deposit_requests.rb
|
465
479
|
- db/migrate/20181001070647_create_stellar_base_deposits.rb
|
466
480
|
- db/migrate/20181003072138_create_stellar_base_account_subscriptions.rb
|
467
|
-
- db/migrate/
|
481
|
+
- db/migrate/20181210043919_add_unique_index_to_deposits.rb
|
468
482
|
- lib/stellar_base-rails.rb
|
469
483
|
- lib/stellar_base.rb
|
470
484
|
- lib/stellar_base/engine.rb
|
@@ -498,7 +512,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
498
512
|
version: '0'
|
499
513
|
requirements: []
|
500
514
|
rubyforge_project:
|
501
|
-
rubygems_version: 2.7.
|
515
|
+
rubygems_version: 2.7.6
|
502
516
|
signing_key:
|
503
517
|
specification_version: 4
|
504
518
|
summary: Mountable Stellar API Endpoints for Rails
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module StellarBase
|
2
|
-
module DepositRequests
|
3
|
-
class FindOrCreateDeposit
|
4
|
-
|
5
|
-
extend LightService::Action
|
6
|
-
|
7
|
-
expects :deposit_request, :tx_id, :amount
|
8
|
-
promises :deposit
|
9
|
-
|
10
|
-
executed do |c|
|
11
|
-
c.deposit = Deposit.find_or_create_by(
|
12
|
-
deposit_request_id: c.deposit_request.id,
|
13
|
-
tx_id: c.tx_id,
|
14
|
-
) do |deposit|
|
15
|
-
deposit.amount = c.amount
|
16
|
-
end
|
17
|
-
|
18
|
-
stellar_tx_id = c.deposit.stellar_tx_id
|
19
|
-
|
20
|
-
if stellar_tx_id.present?
|
21
|
-
c.skip_remaining! "Deposit previously made: stellar_tx_id " \
|
22
|
-
"#{stellar_tx_id}, skipping"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,10 +0,0 @@
|
|
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
|