stellar_base-rails 1.0.1 → 1.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: 85622b9e76b031dbafdc257c00b4761fa6ab00bc765a775519fde9e95896c310
4
- data.tar.gz: e63257b33b6e9a6f14b0956560ee9f51c3f18a91c8578b79cd14a2167b7b0260
3
+ metadata.gz: 9984061158609a2ece395e4b1da289274c610862e518c9f5230153ffe56508ec
4
+ data.tar.gz: 702cdfe31899188c796aef0728ef98ca274e6e48aadf068d56f2c688576b6881
5
5
  SHA512:
6
- metadata.gz: a8b2bc1d551481662b9315be992114d6611b9b04413faf0a64588808b79b8640003bfbea9ca2b408b1bd0cb92cd31b87956a85486f4c085719316b28fec53fe1
7
- data.tar.gz: 32ed7adb135d89f72513a4372bd0eed1ede4d7f0b6e20d20a55b3f334f30d02b14f82ba4a47bb5a53607e167f25528a593d1803f702551f934c32f0286c79120
6
+ metadata.gz: 26806d26021794d5afb66b2dce8a72f6664e7b9aeddb7ecf75ad673b23fd21d8790a534b45abca45f906fea79acecc44d660a863e5b86d7d2846255dc5b344ac
7
+ data.tar.gz: f823873a8e6239c54b14fd9eadec7f0ee1c5c4d628953bb19b86310789617bfc6e007d651da3a3b9779ad21ad6f4df5f90f0f8548fc3c2b5068266f9683d19ee
@@ -0,0 +1,49 @@
1
+ module StellarBase
2
+ class StellarOperation
3
+
4
+ include Virtus.model
5
+
6
+ attribute :raw, Object
7
+ attribute :id, String, default: :default_id, lazy: true
8
+ attribute :paging_token, String, default: :default_paging_token, lazy: true
9
+ attribute :source_account, String, default: :default_source_account, lazy: true
10
+ attribute :type, String, default: :default_type, lazy: true
11
+ attribute :type_i, Integer, default: :default_type_i, lazy: true
12
+ attribute :created_at, DateTime, default: :default_created_at, lazy: true
13
+ attribute :transaction_hash, String, default: :default_transaction_hash, lazy: true
14
+ attribute :asset_type, String, default: :default_asset_type, lazy: true
15
+ attribute :asset_code, String, default: :default_asset_code, lazy: true
16
+ attribute :asset_issuer, String, default: :default_asset_issuer, lazy: true
17
+ attribute :from, String, default: :default_from, lazy: true
18
+ attribute :to, String, default: :default_to, lazy: true
19
+ attribute :amount, BigDecimal, default: :default_amount, lazy: true
20
+ attribute :starting_balance, BigDecimal, default: :default_starting_balance, lazy: true
21
+ attribute :funder, String, default: :default_funder, lazy: true
22
+ attribute :account, String, default: :default_account, lazy: true
23
+
24
+ private
25
+
26
+ %i[
27
+ id
28
+ paging_token
29
+ source_account
30
+ type
31
+ type_i
32
+ created_at
33
+ transaction_hash
34
+ starting_balance
35
+ funder
36
+ account
37
+ asset_type
38
+ asset_code
39
+ asset_issuer
40
+ from
41
+ to
42
+ amount
43
+ ].each do |attr|
44
+ define_method :"default_#{attr}" do
45
+ raw.to_hash[attr.to_s]
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,50 @@
1
+ module StellarBase
2
+ class StellarTransaction
3
+
4
+ include Virtus.model
5
+
6
+ attribute :raw, Object
7
+ attribute :id, String, default: :default_id, lazy: true
8
+ attribute :paging_token, String, default: :default_paging_token, lazy: true
9
+ attribute :ledger, Integer, default: :default_ledger, lazy: true
10
+ attribute :created_at, DateTime, default: :default_created_at, lazy: true
11
+ attribute :source_account, String, default: :default_source_account, lazy: true
12
+ attribute :source_account_sequence, String, default: :default_source_account_sequence, lazy: true
13
+ attribute :fee_paid, Integer, default: :default_fee_paid, lazy: true
14
+ attribute :operation_count, Integer, default: :default_operation_count, lazy: true
15
+ attribute :envelope_xdr, String, default: :default_envelope_xdr, lazy: true
16
+ attribute :result_xdr, String, default: :default_result_xdr, lazy: true
17
+ attribute :result_meta_xdr, String, default: :default_result_meta_xdr, lazy: true
18
+ attribute :fee_meta_xdr, String, default: :default_fee_meta_xdr, lazy: true
19
+ attribute :memo_type, String, default: :default_memo_type, lazy: true
20
+ attribute :memo, String, default: :default_memo, lazy: true
21
+ attribute :signatures, Array, default: :default_signatures, lazy: true
22
+ attribute :valid_after, DateTime, default: :default_valid_after, lazy: true
23
+
24
+ private
25
+
26
+ %i[
27
+ id
28
+ paging_token
29
+ ledger
30
+ created_at
31
+ source_account
32
+ source_account_sequence
33
+ fee_paid
34
+ operation_count
35
+ envelope_xdr
36
+ result_xdr
37
+ result_meta_xdr
38
+ fee_meta_xdr
39
+ memo_type
40
+ memo
41
+ signatures
42
+ valid_after
43
+ ].each do |attr|
44
+ define_method :"default_#{attr}" do
45
+ raw.to_hash[attr.to_s]
46
+ end
47
+ end
48
+
49
+ end
50
+ end
@@ -14,9 +14,14 @@ module StellarBase
14
14
  executed do |c|
15
15
  address = c.account_subscription.address
16
16
 
17
- c.operations = c.stellar_sdk_client.horizon
17
+ c.operations = c.stellar_sdk_client
18
+ .horizon
18
19
  .account(account_id: address)
19
- .operations(order: "asc", limit: c.operation_limit).records
20
+ .operations(order: "asc", limit: c.operation_limit)
21
+ .records
22
+ .map do |op|
23
+ StellarOperation.new(op)
24
+ end
20
25
 
21
26
  if c.operations.empty?
22
27
  c.fail_and_return! "No operations found for #{address}"
@@ -8,7 +8,8 @@ module StellarBase
8
8
 
9
9
  executed do |c|
10
10
  hash = c.operation.transaction_hash
11
- c.tx = c.stellar_sdk_client.horizon.transaction(hash: hash)
11
+ tx_json = c.stellar_sdk_client.horizon.transaction(hash: hash)
12
+ c.tx = StellarTransaction.new(tx_json)
12
13
  end
13
14
 
14
15
  end
@@ -0,0 +1,21 @@
1
+ FactoryBot.define do
2
+ factory(:stellar_base_stellar_operation, {
3
+ class: "StellarBase::StellarOperation"
4
+ }) do
5
+ id "id"
6
+ paging_token "1234"
7
+ source_account "G-TEST"
8
+ type "payment"
9
+ type_i { 1 }
10
+ created_at { Time.zone.now }
11
+ transaction_hash "tx1234"
12
+ asset_type "native"
13
+ asset_code nil
14
+ asset_issuer nil
15
+ from "G-SOURCE"
16
+ to "G-RECIPIENT"
17
+ amount 10.0
18
+
19
+ skip_create
20
+ end
21
+ end
@@ -0,0 +1,27 @@
1
+ FactoryBot.define do
2
+ factory :stellar_base_stellar_transaction, class: "StellarBase::StellarTransaction" do
3
+ id { "1234" }
4
+ paging_token { "1234" }
5
+ ledger { 120 }
6
+ created_at { DateTime.parse("2018-10-04T09:36:18Z") }
7
+ source_account { "G-SOURCE" }
8
+ source_account_sequence { "1" }
9
+ fee_paid { 1000 }
10
+ operation_count { 10 }
11
+ envelope_xdr { "AAA" }
12
+ result_xdr { "BBB" }
13
+ result_meta_xdr { "CCC" }
14
+ fee_meta_xdr { "DDD" }
15
+ memo_type { "none" }
16
+ signatures do
17
+ [
18
+ "SIG1===",
19
+ "SIG2===",
20
+ "SIG3===",
21
+ "SIG4===",
22
+ ]
23
+ end
24
+
25
+ skip_create
26
+ end
27
+ end
@@ -1,3 +1,3 @@
1
1
  module StellarBase
2
- VERSION = "1.0.1".freeze
2
+ VERSION = "1.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: 1.0.1
4
+ version: 1.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: 2018-12-11 00:00:00.000000000 Z
11
+ date: 2018-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: disposable
@@ -249,21 +249,21 @@ dependencies:
249
249
  - !ruby/object:Gem::Version
250
250
  version: '0'
251
251
  - !ruby/object:Gem::Dependency
252
- name: rspec-rails
252
+ name: dotenv
253
253
  requirement: !ruby/object:Gem::Requirement
254
254
  requirements:
255
- - - ">="
255
+ - - "~>"
256
256
  - !ruby/object:Gem::Version
257
- version: '0'
257
+ version: '2.5'
258
258
  type: :development
259
259
  prerelease: false
260
260
  version_requirements: !ruby/object:Gem::Requirement
261
261
  requirements:
262
- - - ">="
262
+ - - "~>"
263
263
  - !ruby/object:Gem::Version
264
- version: '0'
264
+ version: '2.5'
265
265
  - !ruby/object:Gem::Dependency
266
- name: sqlite3
266
+ name: factory_bot_rails
267
267
  requirement: !ruby/object:Gem::Requirement
268
268
  requirements:
269
269
  - - ">="
@@ -277,21 +277,21 @@ dependencies:
277
277
  - !ruby/object:Gem::Version
278
278
  version: '0'
279
279
  - !ruby/object:Gem::Dependency
280
- name: stellar-sdk
280
+ name: rspec-rails
281
281
  requirement: !ruby/object:Gem::Requirement
282
282
  requirements:
283
283
  - - ">="
284
284
  - !ruby/object:Gem::Version
285
- version: 0.6.0
285
+ version: '0'
286
286
  type: :development
287
287
  prerelease: false
288
288
  version_requirements: !ruby/object:Gem::Requirement
289
289
  requirements:
290
290
  - - ">="
291
291
  - !ruby/object:Gem::Version
292
- version: 0.6.0
292
+ version: '0'
293
293
  - !ruby/object:Gem::Dependency
294
- name: factory_bot_rails
294
+ name: rspec-sidekiq
295
295
  requirement: !ruby/object:Gem::Requirement
296
296
  requirements:
297
297
  - - ">="
@@ -305,21 +305,7 @@ dependencies:
305
305
  - !ruby/object:Gem::Version
306
306
  version: '0'
307
307
  - !ruby/object:Gem::Dependency
308
- name: vcr
309
- requirement: !ruby/object:Gem::Requirement
310
- requirements:
311
- - - "~>"
312
- - !ruby/object:Gem::Version
313
- version: '4.0'
314
- type: :development
315
- prerelease: false
316
- version_requirements: !ruby/object:Gem::Requirement
317
- requirements:
318
- - - "~>"
319
- - !ruby/object:Gem::Version
320
- version: '4.0'
321
- - !ruby/object:Gem::Dependency
322
- name: webmock
308
+ name: sqlite3
323
309
  requirement: !ruby/object:Gem::Requirement
324
310
  requirements:
325
311
  - - ">="
@@ -333,19 +319,19 @@ dependencies:
333
319
  - !ruby/object:Gem::Version
334
320
  version: '0'
335
321
  - !ruby/object:Gem::Dependency
336
- name: rspec-sidekiq
322
+ name: stellar-sdk
337
323
  requirement: !ruby/object:Gem::Requirement
338
324
  requirements:
339
325
  - - ">="
340
326
  - !ruby/object:Gem::Version
341
- version: '0'
327
+ version: 0.6.0
342
328
  type: :development
343
329
  prerelease: false
344
330
  version_requirements: !ruby/object:Gem::Requirement
345
331
  requirements:
346
332
  - - ">="
347
333
  - !ruby/object:Gem::Version
348
- version: '0'
334
+ version: 0.6.0
349
335
  - !ruby/object:Gem::Dependency
350
336
  name: stellar_spectrum
351
337
  requirement: !ruby/object:Gem::Requirement
@@ -361,19 +347,47 @@ dependencies:
361
347
  - !ruby/object:Gem::Version
362
348
  version: '1.0'
363
349
  - !ruby/object:Gem::Dependency
364
- name: dotenv
350
+ name: vcr
365
351
  requirement: !ruby/object:Gem::Requirement
366
352
  requirements:
367
353
  - - "~>"
368
354
  - !ruby/object:Gem::Version
369
- version: '2.5'
355
+ version: '4.0'
370
356
  type: :development
371
357
  prerelease: false
372
358
  version_requirements: !ruby/object:Gem::Requirement
373
359
  requirements:
374
360
  - - "~>"
375
361
  - !ruby/object:Gem::Version
376
- version: '2.5'
362
+ version: '4.0'
363
+ - !ruby/object:Gem::Dependency
364
+ name: virtus-matchers
365
+ requirement: !ruby/object:Gem::Requirement
366
+ requirements:
367
+ - - '='
368
+ - !ruby/object:Gem::Version
369
+ version: 0.4.0
370
+ type: :development
371
+ prerelease: false
372
+ version_requirements: !ruby/object:Gem::Requirement
373
+ requirements:
374
+ - - '='
375
+ - !ruby/object:Gem::Version
376
+ version: 0.4.0
377
+ - !ruby/object:Gem::Dependency
378
+ name: webmock
379
+ requirement: !ruby/object:Gem::Requirement
380
+ requirements:
381
+ - - ">="
382
+ - !ruby/object:Gem::Version
383
+ version: '0'
384
+ type: :development
385
+ prerelease: false
386
+ version_requirements: !ruby/object:Gem::Requirement
387
+ requirements:
388
+ - - ">="
389
+ - !ruby/object:Gem::Version
390
+ version: '0'
377
391
  description: API Endpoints for the Stellar Protocol
378
392
  email:
379
393
  - ace.subido@gmail.com
@@ -418,7 +432,9 @@ files:
418
432
  - app/models/stellar_base/bridge_callback.rb
419
433
  - app/models/stellar_base/deposit.rb
420
434
  - app/models/stellar_base/deposit_request.rb
435
+ - app/models/stellar_base/stellar_operation.rb
421
436
  - app/models/stellar_base/stellar_toml.rb
437
+ - app/models/stellar_base/stellar_transaction.rb
422
438
  - app/models/stellar_base/withdrawal_request.rb
423
439
  - app/representers/stellar_base/application_representer.rb
424
440
  - app/representers/stellar_base/balance_representer.rb
@@ -487,6 +503,8 @@ files:
487
503
  - lib/stellar_base/factories/bridge_callbacks.rb
488
504
  - lib/stellar_base/factories/deposit_requests.rb
489
505
  - lib/stellar_base/factories/deposits.rb
506
+ - lib/stellar_base/factories/stellar_operations.rb
507
+ - lib/stellar_base/factories/stellar_transactions.rb
490
508
  - lib/stellar_base/factories/withdrawal_requests.rb
491
509
  - lib/stellar_base/horizon_client.rb
492
510
  - lib/stellar_base/rails/routes.rb