stellar-sdk 0.4.0 → 0.9.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -2
  3. data/{LICENSE.txt → LICENSE} +0 -0
  4. data/README.md +17 -11
  5. data/lib/stellar-sdk.rb +3 -4
  6. data/lib/stellar/account.rb +16 -18
  7. data/lib/stellar/amount.rb +9 -13
  8. data/lib/stellar/client.rb +255 -74
  9. data/lib/stellar/horizon/problem.rb +14 -16
  10. data/lib/stellar/sep10.rb +347 -0
  11. data/lib/stellar/transaction_page.rb +4 -6
  12. data/lib/stellar/version.rb +1 -1
  13. metadata +17 -203
  14. data/.gitignore +0 -16
  15. data/.travis.yml +0 -13
  16. data/.yardopts +0 -7
  17. data/CONTRIBUTING.md +0 -48
  18. data/Gemfile +0 -14
  19. data/Guardfile +0 -5
  20. data/Rakefile +0 -3
  21. data/examples/01_get_funded.rb +0 -37
  22. data/examples/02_payment.rb +0 -15
  23. data/examples/03_transaction_history.rb +0 -21
  24. data/examples/04_setting_trust.rb +0 -12
  25. data/examples/05_fiat_payment.rb +0 -13
  26. data/examples/06_fund_testnet_friendbot.rb +0 -15
  27. data/ruby-stellar-sdk.gemspec +0 -36
  28. data/spec/config.yml.sample +0 -10
  29. data/spec/fixtures/vcr_cassettes/Stellar_Account/_lookup/should_handle_404_request_when_performing_federation_lookup.yml +0 -133
  30. data/spec/fixtures/vcr_cassettes/Stellar_Account/_lookup/should_handle_domains_that_are_not_federation_servers.yml +0 -44
  31. data/spec/fixtures/vcr_cassettes/Stellar_Account/_lookup/should_peforms_federation_lookup.yml +0 -85
  32. data/spec/fixtures/vcr_cassettes/Stellar_Client/_account_info/returns_the_current_details_for_the_account.yml +0 -190
  33. data/spec/fixtures/vcr_cassettes/Stellar_Client/_create_account/creates_the_account.yml +0 -323
  34. data/spec/fixtures/vcr_cassettes/Stellar_Client/_send_payment/alphanum12_asset/sends_a_alphanum12_asset_to_the_destination.yml +0 -448
  35. data/spec/fixtures/vcr_cassettes/Stellar_Client/_send_payment/alphanum4_asset/sends_a_alphanum4_asset_to_the_destination.yml +0 -448
  36. data/spec/fixtures/vcr_cassettes/Stellar_Client/_send_payment/native_asset/sends_a_native_payment_to_the_account.yml +0 -469
  37. data/spec/fixtures/vcr_cassettes/Stellar_Client/_transactions/account_transactions/accepts_a_cursor_to_return_less_data.yml +0 -94
  38. data/spec/fixtures/vcr_cassettes/Stellar_Client/_transactions/account_transactions/returns_a_list_of_transaction_for_an_account.yml +0 -94
  39. data/spec/fixtures/vcr_cassettes/Stellar_Client/_transactions/all_transactions/accepts_a_cursor_to_return_less_data.yml +0 -94
  40. data/spec/fixtures/vcr_cassettes/Stellar_Client/_transactions/all_transactions/returns_a_list_of_transactions.yml +0 -94
  41. data/spec/lib/stellar/account_spec.rb +0 -59
  42. data/spec/lib/stellar/amount_spec.rb +0 -70
  43. data/spec/lib/stellar/client_spec.rb +0 -173
  44. data/spec/spec_helper.rb +0 -14
  45. data/spec/support/config.rb +0 -3
  46. data/spec/support/vcr.rb +0 -10
  47. data/tasks/rspec.rake +0 -6
  48. data/tasks/travis.rake +0 -1
@@ -1,173 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Stellar::Client do
4
-
5
- subject(:client) { Stellar::Client.default_testnet }
6
-
7
- describe "#create_account" do
8
- let(:source) { Stellar::Account.from_seed(CONFIG[:source_seed]) }
9
- let(:destination) { Stellar::Account.random }
10
-
11
- it "creates the account", vcr: {record: :once, match_requests_on: [:method]} do
12
- client.create_account(
13
- funder: source,
14
- account: destination,
15
- starting_balance: 100,
16
- )
17
-
18
- destination_info = client.account_info(destination)
19
- balances = destination_info.balances
20
- expect(balances).to_not be_empty
21
- native_asset_balance_info = balances.find do |b|
22
- b["asset_type"] == "native"
23
- end
24
- expect(native_asset_balance_info["balance"].to_f).to eq 100.0
25
- end
26
- end
27
-
28
- describe "#account_info" do
29
- let(:account) { Stellar::Account.from_seed(CONFIG[:source_seed]) }
30
- let(:client) { Stellar::Client.default_testnet }
31
-
32
- it "returns the current details for the account", vcr: { record: :once, match_requests_on: [:method]} do
33
- response = client.account_info(account)
34
-
35
- expect(response.id).to eq "GCQSESW66AX4ZRZB7QWCIXSPX2BD7KLOYSS33IUGDCLO4XCPURZEEC6R"
36
- expect(response.paging_token).to be_empty
37
- expect(response.sequence).to eq "346973227974715"
38
- expect(response.subentry_count).to eq 0
39
- expect(response.thresholds).to include("low_threshold" => 0, "med_threshold" => 0, "high_threshold" => 0)
40
- expect(response.flags).to include("auth_required" => false, "auth_revocable" => false)
41
- expect(response.balances).to include("balance" => "3494.9997500", "asset_type" => "native")
42
- expect(response.signers).to include(
43
- "public_key" => "GCQSESW66AX4ZRZB7QWCIXSPX2BD7KLOYSS33IUGDCLO4XCPURZEEC6R",
44
- "weight" => 1,
45
- "type" => "ed25519_public_key",
46
- "key"=>"GCQSESW66AX4ZRZB7QWCIXSPX2BD7KLOYSS33IUGDCLO4XCPURZEEC6R"
47
- )
48
- expect(response.data).to be_empty
49
- end
50
- end
51
-
52
- describe "#send_payment" do
53
- let(:source) { Stellar::Account.from_seed(CONFIG[:source_seed]) }
54
-
55
- context "native asset" do
56
- let(:destination) { Stellar::Account.random }
57
-
58
- it "sends a native payment to the account", vcr: {record: :once, match_requests_on: [:method]} do
59
- client.create_account(
60
- funder: source,
61
- account: destination,
62
- starting_balance: 100,
63
- )
64
-
65
- amount = Stellar::Amount.new(150)
66
-
67
- client.send_payment(
68
- from: source,
69
- to: destination,
70
- amount: amount,
71
- )
72
-
73
- destination_info = client.account_info(destination)
74
- balances = destination_info.balances
75
- expect(balances).to_not be_empty
76
- native_asset_balance_info = balances.find do |b|
77
- b["asset_type"] == "native"
78
- end
79
- expect(native_asset_balance_info["balance"].to_f).to eq 250.0
80
- end
81
- end
82
-
83
- context "alphanum4 asset" do
84
- let(:destination) { Stellar::Account.from_seed(CONFIG[:destination_seed]) }
85
-
86
- it "sends a alphanum4 asset to the destination", vcr: {record: :once, match_requests_on: [:method]} do
87
- destination_info = client.account_info(destination)
88
- old_balances = destination_info.balances
89
- old_btc_balance = old_balances.find do |b|
90
- b["asset_code"] == "BTC"
91
- end["balance"].to_f
92
-
93
- asset = Stellar::Asset.alphanum4("BTC", source.keypair)
94
- amount = Stellar::Amount.new(150, asset)
95
-
96
- client.send_payment(
97
- from: source,
98
- to: destination,
99
- amount: amount,
100
- )
101
-
102
- destination_info = client.account_info(destination)
103
- new_balances = destination_info.balances
104
- new_btc_balance = new_balances.find do |b|
105
- b["asset_code"] == "BTC"
106
- end["balance"].to_f
107
-
108
- expect(new_btc_balance - old_btc_balance).to eq 150.0
109
- end
110
- end
111
-
112
- context "alphanum12 asset" do
113
- let(:destination) { Stellar::Account.from_seed(CONFIG[:destination_seed]) }
114
-
115
- it "sends a alphanum12 asset to the destination", vcr: {record: :once, match_requests_on: [:method]} do
116
- destination_info = client.account_info(destination)
117
- old_balances = destination_info.balances
118
- old_btc_balance = old_balances.find do |b|
119
- b["asset_code"] == "LONGNAME"
120
- end["balance"].to_f
121
-
122
- asset = Stellar::Asset.alphanum12("LONGNAME", source.keypair)
123
- amount = Stellar::Amount.new(150, asset)
124
-
125
- client.send_payment(
126
- from: source,
127
- to: destination,
128
- amount: amount,
129
- )
130
-
131
- destination_info = client.account_info(destination)
132
- new_balances = destination_info.balances
133
- new_btc_balance = new_balances.find do |b|
134
- b["asset_code"] == "LONGNAME"
135
- end["balance"].to_f
136
-
137
- expect(new_btc_balance - old_btc_balance).to eq 150.0
138
- end
139
- end
140
- end
141
-
142
- describe "#transactions" do
143
- let(:cursor) { '348403452088320' }
144
-
145
- context "account transactions" do
146
- let(:account) { Stellar::Account.from_seed(CONFIG[:source_seed]) }
147
-
148
- it "returns a list of transaction for an account", vcr: {record: :once, match_requests_on: [:method]} do
149
- response = client.transactions(account: account)
150
- expect(response).to be_a(Stellar::TransactionPage)
151
- end
152
-
153
- it "accepts a cursor to return less data", vcr: {record: :once, match_requests_on: [:method]} do
154
- response = client.transactions(account: account,
155
- cursor: cursor)
156
- expect(response).to be_a(Stellar::TransactionPage)
157
- end
158
- end
159
-
160
- context "all transactions" do
161
- it "returns a list of transactions", vcr: {record: :once, match_requests_on: [:method]} do
162
- response = client.transactions
163
- expect(response).to be_a(Stellar::TransactionPage)
164
- end
165
-
166
- it "accepts a cursor to return less data", vcr: {record: :once, match_requests_on: [:method]} do
167
- response = client.transactions(cursor: cursor)
168
- expect(response).to be_a(Stellar::TransactionPage)
169
- end
170
- end
171
- end
172
-
173
- end
@@ -1,14 +0,0 @@
1
- require 'simplecov'
2
- SimpleCov.start
3
-
4
- require 'pry'
5
- require 'stellar-sdk'
6
- require "pathname"
7
-
8
- SPEC_ROOT = Pathname.new(File.dirname(__FILE__))
9
-
10
- Dir["#{SPEC_ROOT}/support/**/*.rb"].each { |f| require f }
11
-
12
- RSpec.configure do |config|
13
-
14
- end
@@ -1,3 +0,0 @@
1
- require "yaml"
2
-
3
- CONFIG = YAML.load_file(SPEC_ROOT.join("config.yml")).with_indifferent_access
@@ -1,10 +0,0 @@
1
- require "vcr"
2
-
3
- VCR.configure do |config|
4
- config.cassette_library_dir = "spec/fixtures/vcr_cassettes"
5
- config.hook_into :webmock
6
- config.configure_rspec_metadata!
7
- %i[source_address destination_address].each do |var|
8
- config.filter_sensitive_data("[#{var}]") { CONFIG[var] }
9
- end
10
- end
@@ -1,6 +0,0 @@
1
- begin
2
- require 'rspec/core/rake_task'
3
- RSpec::Core::RakeTask.new(:spec)
4
- task :default => :spec
5
- rescue LoadError
6
- end
@@ -1 +0,0 @@
1
- task :travis => %w(spec)