stellar_base-rails 0.10.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -0
- data/app/services/stellar_base/deposit_requests/send_asset.rb +2 -2
- data/app/services/stellar_base/deposit_requests/trigger.rb +11 -2
- data/app/services/stellar_base/init_asset_sending_client.rb +21 -0
- data/lib/stellar_base.rb +1 -0
- data/lib/stellar_base/version.rb +1 -1
- metadata +36 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe6ab9692dc15944adea8f2affafcab9609080fa16175e95a1a1cb367202b6b4
|
4
|
+
data.tar.gz: 59bb102aa75f2572234d6f1c014ec35352fee2028f2e8e7b792f063ed7fa6202
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a572745d496c2b637385b5a64148575e8a4834d9bac7aec469666296663dc6e2b0e9cba7377266cbf8b713c6e76952182ba10cc21cada936508e5033adaff1de
|
7
|
+
data.tar.gz: 850fca96dead1e7d409ca7f8001751412d7f9b37e3dedc1b12690345158fc12c4879aaa7a7767da37871407d24f0420a4d9c62962e754ef7166d1058c6c29915
|
data/README.md
CHANGED
@@ -76,6 +76,21 @@ https://example.com/stellar/
|
|
76
76
|
https://example.com/
|
77
77
|
```
|
78
78
|
|
79
|
+
#### c.sending_strategy
|
80
|
+
|
81
|
+
By default, this engine uses [ruby-stellar-sdk](https://github.com/stellar/ruby-stellar-sdk) to send assets. This does not have support for multi-process friendly distribution of assets.
|
82
|
+
|
83
|
+
One may opt to use [stellar_spectrum](https://github.com/bloom-solutions/stellar_spectrum-ruby) that allows sending of assets through multiple payment channels.
|
84
|
+
|
85
|
+
To configure this:
|
86
|
+
|
87
|
+
```ruby
|
88
|
+
config = {redis_url: "redis://redis", seeds: %w(S1 S2)}
|
89
|
+
c.sending_strategy = [:stellar_spectrum, config]
|
90
|
+
```
|
91
|
+
|
92
|
+
In the code above, `config` is the [configuration in StellarSpectrum](https://github.com/bloom-solutions/stellar_spectrum-ruby#usage), **except** the `horizon_url`. The value for `horizon_url` will be taken from `c.horizon_url`.
|
93
|
+
|
79
94
|
## Installation
|
80
95
|
Add this line to your application's Gemfile:
|
81
96
|
|
@@ -9,7 +9,7 @@ module StellarBase
|
|
9
9
|
:issuer_account,
|
10
10
|
:recipient_account,
|
11
11
|
:stellar_amount,
|
12
|
-
:
|
12
|
+
:asset_sending_client,
|
13
13
|
)
|
14
14
|
promises :stellar_tx_id
|
15
15
|
|
@@ -25,7 +25,7 @@ module StellarBase
|
|
25
25
|
Rails.logger.info(msg)
|
26
26
|
|
27
27
|
begin
|
28
|
-
response = c.
|
28
|
+
response = c.asset_sending_client.send_payment(
|
29
29
|
from: c.distribution_account,
|
30
30
|
to: c.recipient_account,
|
31
31
|
amount: c.stellar_amount,
|
@@ -4,12 +4,21 @@ module StellarBase
|
|
4
4
|
|
5
5
|
extend LightService::Organizer
|
6
6
|
|
7
|
-
def self.call(
|
7
|
+
def self.call(
|
8
|
+
network,
|
9
|
+
deposit_address,
|
10
|
+
tx_id,
|
11
|
+
amount,
|
12
|
+
horizon_url: StellarBase.configuration.horizon_url,
|
13
|
+
sending_strategy: StellarBase.configuration.sending_strategy
|
14
|
+
)
|
8
15
|
with(
|
9
16
|
network: network,
|
10
17
|
deposit_address: deposit_address,
|
11
18
|
tx_id: tx_id,
|
12
19
|
amount: amount,
|
20
|
+
horizon_url: horizon_url,
|
21
|
+
sending_strategy: sending_strategy,
|
13
22
|
).reduce(actions)
|
14
23
|
end
|
15
24
|
|
@@ -18,7 +27,7 @@ module StellarBase
|
|
18
27
|
FindConfig,
|
19
28
|
FindDepositRequest,
|
20
29
|
FindOrCreateDeposit,
|
21
|
-
|
30
|
+
InitAssetSendingClient,
|
22
31
|
InitStellarIssuerAccount,
|
23
32
|
InitStellarRecipientAccount,
|
24
33
|
InitStellarDistributionAccount,
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module StellarBase
|
2
|
+
class InitAssetSendingClient
|
3
|
+
|
4
|
+
extend LightService::Action
|
5
|
+
expects :sending_strategy, :horizon_url
|
6
|
+
promises :asset_sending_client
|
7
|
+
|
8
|
+
executed do |c|
|
9
|
+
sending_strategy = Array(c.sending_strategy)
|
10
|
+
if sending_strategy.first == :stellar_sdk
|
11
|
+
client = Stellar::Client.new(horizon: c.horizon_url)
|
12
|
+
elsif sending_strategy.first == :stellar_spectrum
|
13
|
+
config = sending_strategy.last.merge(horizon_url: c.horizon_url)
|
14
|
+
client = StellarSpectrum.new(config)
|
15
|
+
end
|
16
|
+
|
17
|
+
c.asset_sending_client = client
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
data/lib/stellar_base.rb
CHANGED
@@ -34,6 +34,7 @@ module StellarBase
|
|
34
34
|
has :stellar_toml, classes: Hash, default: {}
|
35
35
|
has :depositable_assets, classes: [NilClass, Array, String, Pathname]
|
36
36
|
has :withdrawable_assets, classes: [NilClass, Array, String, Pathname]
|
37
|
+
has :sending_strategy, classes: [Array, Symbol], default: [:stellar_sdk]
|
37
38
|
end
|
38
39
|
|
39
40
|
after_configuration_change do
|
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.
|
4
|
+
version: 1.0.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: 2018-11-
|
11
|
+
date: 2018-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: disposable
|
@@ -170,14 +170,14 @@ dependencies:
|
|
170
170
|
requirements:
|
171
171
|
- - ">="
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: 0.
|
173
|
+
version: 0.18.0
|
174
174
|
type: :runtime
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
178
|
- - ">="
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: 0.
|
180
|
+
version: 0.18.0
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: toml-rb
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -220,6 +220,20 @@ dependencies:
|
|
220
220
|
- - ">="
|
221
221
|
- !ruby/object:Gem::Version
|
222
222
|
version: '0'
|
223
|
+
- !ruby/object:Gem::Dependency
|
224
|
+
name: reform-rails
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - ">="
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '0'
|
230
|
+
type: :runtime
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - ">="
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: '0'
|
223
237
|
- !ruby/object:Gem::Dependency
|
224
238
|
name: virtus
|
225
239
|
requirement: !ruby/object:Gem::Requirement
|
@@ -268,14 +282,14 @@ dependencies:
|
|
268
282
|
requirements:
|
269
283
|
- - ">="
|
270
284
|
- !ruby/object:Gem::Version
|
271
|
-
version:
|
285
|
+
version: 0.6.0
|
272
286
|
type: :development
|
273
287
|
prerelease: false
|
274
288
|
version_requirements: !ruby/object:Gem::Requirement
|
275
289
|
requirements:
|
276
290
|
- - ">="
|
277
291
|
- !ruby/object:Gem::Version
|
278
|
-
version:
|
292
|
+
version: 0.6.0
|
279
293
|
- !ruby/object:Gem::Dependency
|
280
294
|
name: factory_bot_rails
|
281
295
|
requirement: !ruby/object:Gem::Requirement
|
@@ -332,6 +346,20 @@ dependencies:
|
|
332
346
|
- - ">="
|
333
347
|
- !ruby/object:Gem::Version
|
334
348
|
version: '0'
|
349
|
+
- !ruby/object:Gem::Dependency
|
350
|
+
name: stellar_spectrum
|
351
|
+
requirement: !ruby/object:Gem::Requirement
|
352
|
+
requirements:
|
353
|
+
- - "~>"
|
354
|
+
- !ruby/object:Gem::Version
|
355
|
+
version: '1.0'
|
356
|
+
type: :development
|
357
|
+
prerelease: false
|
358
|
+
version_requirements: !ruby/object:Gem::Requirement
|
359
|
+
requirements:
|
360
|
+
- - "~>"
|
361
|
+
- !ruby/object:Gem::Version
|
362
|
+
version: '1.0'
|
335
363
|
description: API Endpoints for the Stellar Protocol
|
336
364
|
email:
|
337
365
|
- ace.subido@gmail.com
|
@@ -415,6 +443,7 @@ files:
|
|
415
443
|
- app/services/stellar_base/deposit_requests/update_deposit.rb
|
416
444
|
- app/services/stellar_base/gen_memo_for.rb
|
417
445
|
- app/services/stellar_base/gen_random_string.rb
|
446
|
+
- app/services/stellar_base/init_asset_sending_client.rb
|
418
447
|
- app/services/stellar_base/init_stellar_client.rb
|
419
448
|
- app/services/stellar_base/subscribe_account.rb
|
420
449
|
- app/services/stellar_base/withdrawal_requests/call_on_withdraw.rb
|
@@ -469,7 +498,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
469
498
|
version: '0'
|
470
499
|
requirements: []
|
471
500
|
rubyforge_project:
|
472
|
-
rubygems_version: 2.7.
|
501
|
+
rubygems_version: 2.7.3
|
473
502
|
signing_key:
|
474
503
|
specification_version: 4
|
475
504
|
summary: Mountable Stellar API Endpoints for Rails
|