stellar-sdk 0.8.0 → 0.9.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/{LICENSE.txt → LICENSE} +0 -0
  3. data/README.md +4 -5
  4. data/lib/stellar-sdk.rb +2 -3
  5. data/lib/stellar/account.rb +16 -18
  6. data/lib/stellar/amount.rb +9 -13
  7. data/lib/stellar/client.rb +153 -113
  8. data/lib/stellar/horizon/problem.rb +14 -16
  9. data/lib/stellar/sep10.rb +56 -93
  10. data/lib/stellar/transaction_page.rb +4 -6
  11. data/lib/stellar/version.rb +1 -1
  12. metadata +13 -217
  13. data/.github/CODEOWNERS +0 -2
  14. data/.gitignore +0 -17
  15. data/.travis.yml +0 -20
  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 -1
  25. data/examples/05_fiat_payment.rb +0 -13
  26. data/examples/06_fund_testnet_friendbot.rb +0 -15
  27. data/examples/07_sep10.rb +0 -125
  28. data/ruby-stellar-sdk.gemspec +0 -35
  29. data/spec/config.yml.sample +0 -12
  30. data/spec/fixtures/vcr_cassettes/Stellar_Account/_lookup/should_handle_404_request_when_performing_federation_lookup.yml +0 -133
  31. data/spec/fixtures/vcr_cassettes/Stellar_Account/_lookup/should_handle_domains_that_are_not_federation_servers.yml +0 -44
  32. data/spec/fixtures/vcr_cassettes/Stellar_Account/_lookup/should_peforms_federation_lookup.yml +0 -85
  33. data/spec/fixtures/vcr_cassettes/Stellar_Client/_account_info/returns_the_current_details_for_the_account.yml +0 -190
  34. data/spec/fixtures/vcr_cassettes/Stellar_Client/_account_merge/merges_source_account_into_destination.yml +0 -714
  35. data/spec/fixtures/vcr_cassettes/Stellar_Client/_change_trust/given_an_asset_described_as_an_array/creates_updates_or_deletes_a_trustline.yml +0 -1156
  36. data/spec/fixtures/vcr_cassettes/Stellar_Client/_create_account/creates_the_account.yml +0 -323
  37. data/spec/fixtures/vcr_cassettes/Stellar_Client/_friendbot/requests_for_XLM_from_a_friendbot.yml +0 -246
  38. data/spec/fixtures/vcr_cassettes/Stellar_Client/_load_account/loads_successfully.yml +0 -226
  39. data/spec/fixtures/vcr_cassettes/Stellar_Client/_send_payment/alphanum12_asset/sends_a_alphanum12_asset_to_the_destination.yml +0 -747
  40. data/spec/fixtures/vcr_cassettes/Stellar_Client/_send_payment/alphanum4_asset/sends_a_alphanum4_asset_to_the_destination.yml +0 -747
  41. data/spec/fixtures/vcr_cassettes/Stellar_Client/_send_payment/memo/accepts_the_memo_attribute.yml +0 -725
  42. data/spec/fixtures/vcr_cassettes/Stellar_Client/_send_payment/native_asset/sends_a_native_payment_to_the_account.yml +0 -562
  43. data/spec/fixtures/vcr_cassettes/Stellar_Client/_send_payment/using_a_payment_channel/sends_a_payment_account_through_a_channel_account.yml +0 -757
  44. data/spec/fixtures/vcr_cassettes/Stellar_Client/_send_payment/using_a_payment_channel/sends_a_payment_when_the_channel_is_the_same_as_from_.yml +0 -642
  45. data/spec/fixtures/vcr_cassettes/Stellar_Client/_transactions/account_transactions/accepts_a_cursor_to_return_less_data.yml +0 -94
  46. data/spec/fixtures/vcr_cassettes/Stellar_Client/_transactions/account_transactions/returns_a_list_of_transaction_for_an_account.yml +0 -94
  47. data/spec/fixtures/vcr_cassettes/Stellar_Client/_transactions/all_transactions/accepts_a_cursor_to_return_less_data.yml +0 -94
  48. data/spec/fixtures/vcr_cassettes/Stellar_Client/_transactions/all_transactions/returns_a_list_of_transactions.yml +0 -94
  49. data/spec/lib/stellar/account_spec.rb +0 -59
  50. data/spec/lib/stellar/amount_spec.rb +0 -70
  51. data/spec/lib/stellar/client_spec.rb +0 -430
  52. data/spec/lib/stellar/sep10_spec.rb +0 -1148
  53. data/spec/spec_helper.rb +0 -14
  54. data/spec/support/config.rb +0 -3
  55. data/spec/support/vcr.rb +0 -10
  56. data/tasks/rspec.rake +0 -6
  57. data/tasks/travis.rake +0 -1
@@ -1,94 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: https://horizon-testnet.stellar.org/
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- User-Agent:
11
- - Faraday v0.15.1
12
- Accept:
13
- - application/hal+json,application/problem+json,application/json
14
- response:
15
- status:
16
- code: 200
17
- message: OK
18
- headers:
19
- Date:
20
- - Fri, 18 May 2018 21:08:21 GMT
21
- Content-Type:
22
- - application/hal+json; charset=utf-8
23
- Connection:
24
- - keep-alive
25
- Set-Cookie:
26
- - __cfduid=d1358cdcd615404d320c3085a816645201526677701; expires=Sat, 18-May-19
27
- 21:08:21 GMT; path=/; domain=.stellar.org; HttpOnly
28
- Content-Disposition:
29
- - inline
30
- Vary:
31
- - Origin
32
- X-Ratelimit-Limit:
33
- - '17200'
34
- X-Ratelimit-Remaining:
35
- - '17176'
36
- X-Ratelimit-Reset:
37
- - '1685'
38
- Expect-Ct:
39
- - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
40
- Server:
41
- - cloudflare
42
- Cf-Ray:
43
- - 41d14c719b01b9f4-ATL
44
- body:
45
- encoding: UTF-8
46
- string: |-
47
- {
48
- "_links": {
49
- "account": {
50
- "href": "https://horizon-testnet.stellar.org/accounts/{account_id}",
51
- "templated": true
52
- },
53
- "account_transactions": {
54
- "href": "https://horizon-testnet.stellar.org/accounts/{account_id}/transactions{?cursor,limit,order}",
55
- "templated": true
56
- },
57
- "assets": {
58
- "href": "https://horizon-testnet.stellar.org/assets{?asset_code,asset_issuer,cursor,limit,order}",
59
- "templated": true
60
- },
61
- "friendbot": {
62
- "href": "https://horizon-testnet.stellar.org/friendbot{?addr}",
63
- "templated": true
64
- },
65
- "metrics": {
66
- "href": "https://horizon-testnet.stellar.org/metrics"
67
- },
68
- "order_book": {
69
- "href": "https://horizon-testnet.stellar.org/order_book{?selling_asset_type,selling_asset_code,selling_issuer,buying_asset_type,buying_asset_code,buying_issuer,limit}",
70
- "templated": true
71
- },
72
- "self": {
73
- "href": "https://horizon-testnet.stellar.org/"
74
- },
75
- "transaction": {
76
- "href": "https://horizon-testnet.stellar.org/transactions/{hash}",
77
- "templated": true
78
- },
79
- "transactions": {
80
- "href": "https://horizon-testnet.stellar.org/transactions{?cursor,limit,order}",
81
- "templated": true
82
- }
83
- },
84
- "horizon_version": "snapshot-snapshots-2-g99e33f0",
85
- "core_version": "stellar-core 9.2.0rc6 (b0923f153b86d394a83b2a619db6b23f07ed0700)",
86
- "history_latest_ledger": 9034899,
87
- "history_elder_ledger": 1,
88
- "core_latest_ledger": 9034899,
89
- "network_passphrase": "Test SDF Network ; September 2015",
90
- "protocol_version": 9
91
- }
92
- http_version:
93
- recorded_at: Fri, 18 May 2018 21:08:21 GMT
94
- recorded_with: VCR 3.0.3
@@ -1,94 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: https://horizon-testnet.stellar.org/
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- User-Agent:
11
- - Faraday v0.15.1
12
- Accept:
13
- - application/hal+json,application/problem+json,application/json
14
- response:
15
- status:
16
- code: 200
17
- message: OK
18
- headers:
19
- Date:
20
- - Fri, 18 May 2018 21:05:24 GMT
21
- Content-Type:
22
- - application/hal+json; charset=utf-8
23
- Connection:
24
- - keep-alive
25
- Set-Cookie:
26
- - __cfduid=dd9cd962f0940437aacf5ef980a3ccb091526677524; expires=Sat, 18-May-19
27
- 21:05:24 GMT; path=/; domain=.stellar.org; HttpOnly
28
- Content-Disposition:
29
- - inline
30
- Vary:
31
- - Origin
32
- X-Ratelimit-Limit:
33
- - '17200'
34
- X-Ratelimit-Remaining:
35
- - '17177'
36
- X-Ratelimit-Reset:
37
- - '1861'
38
- Expect-Ct:
39
- - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
40
- Server:
41
- - cloudflare
42
- Cf-Ray:
43
- - 41d1482239c1b9e8-ATL
44
- body:
45
- encoding: UTF-8
46
- string: |-
47
- {
48
- "_links": {
49
- "account": {
50
- "href": "https://horizon-testnet.stellar.org/accounts/{account_id}",
51
- "templated": true
52
- },
53
- "account_transactions": {
54
- "href": "https://horizon-testnet.stellar.org/accounts/{account_id}/transactions{?cursor,limit,order}",
55
- "templated": true
56
- },
57
- "assets": {
58
- "href": "https://horizon-testnet.stellar.org/assets{?asset_code,asset_issuer,cursor,limit,order}",
59
- "templated": true
60
- },
61
- "friendbot": {
62
- "href": "https://horizon-testnet.stellar.org/friendbot{?addr}",
63
- "templated": true
64
- },
65
- "metrics": {
66
- "href": "https://horizon-testnet.stellar.org/metrics"
67
- },
68
- "order_book": {
69
- "href": "https://horizon-testnet.stellar.org/order_book{?selling_asset_type,selling_asset_code,selling_issuer,buying_asset_type,buying_asset_code,buying_issuer,limit}",
70
- "templated": true
71
- },
72
- "self": {
73
- "href": "https://horizon-testnet.stellar.org/"
74
- },
75
- "transaction": {
76
- "href": "https://horizon-testnet.stellar.org/transactions/{hash}",
77
- "templated": true
78
- },
79
- "transactions": {
80
- "href": "https://horizon-testnet.stellar.org/transactions{?cursor,limit,order}",
81
- "templated": true
82
- }
83
- },
84
- "horizon_version": "snapshot-snapshots-2-g99e33f0",
85
- "core_version": "stellar-core 9.2.0rc6 (b0923f153b86d394a83b2a619db6b23f07ed0700)",
86
- "history_latest_ledger": 9034864,
87
- "history_elder_ledger": 1,
88
- "core_latest_ledger": 9034864,
89
- "network_passphrase": "Test SDF Network ; September 2015",
90
- "protocol_version": 9
91
- }
92
- http_version:
93
- recorded_at: Fri, 18 May 2018 21:05:24 GMT
94
- recorded_with: VCR 3.0.3
@@ -1,94 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: https://horizon-testnet.stellar.org/
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- User-Agent:
11
- - Faraday v0.15.1
12
- Accept:
13
- - application/hal+json,application/problem+json,application/json
14
- response:
15
- status:
16
- code: 200
17
- message: OK
18
- headers:
19
- Date:
20
- - Fri, 18 May 2018 21:32:24 GMT
21
- Content-Type:
22
- - application/hal+json; charset=utf-8
23
- Connection:
24
- - keep-alive
25
- Set-Cookie:
26
- - __cfduid=d9519f3eef6e4e8eb00700cd062f9854a1526679144; expires=Sat, 18-May-19
27
- 21:32:24 GMT; path=/; domain=.stellar.org; HttpOnly
28
- Content-Disposition:
29
- - inline
30
- Vary:
31
- - Origin
32
- X-Ratelimit-Limit:
33
- - '17200'
34
- X-Ratelimit-Remaining:
35
- - '17170'
36
- X-Ratelimit-Reset:
37
- - '242'
38
- Expect-Ct:
39
- - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
40
- Server:
41
- - cloudflare
42
- Cf-Ray:
43
- - 41d16fae3d85b9d0-ATL
44
- body:
45
- encoding: UTF-8
46
- string: |-
47
- {
48
- "_links": {
49
- "account": {
50
- "href": "https://horizon-testnet.stellar.org/accounts/{account_id}",
51
- "templated": true
52
- },
53
- "account_transactions": {
54
- "href": "https://horizon-testnet.stellar.org/accounts/{account_id}/transactions{?cursor,limit,order}",
55
- "templated": true
56
- },
57
- "assets": {
58
- "href": "https://horizon-testnet.stellar.org/assets{?asset_code,asset_issuer,cursor,limit,order}",
59
- "templated": true
60
- },
61
- "friendbot": {
62
- "href": "https://horizon-testnet.stellar.org/friendbot{?addr}",
63
- "templated": true
64
- },
65
- "metrics": {
66
- "href": "https://horizon-testnet.stellar.org/metrics"
67
- },
68
- "order_book": {
69
- "href": "https://horizon-testnet.stellar.org/order_book{?selling_asset_type,selling_asset_code,selling_issuer,buying_asset_type,buying_asset_code,buying_issuer,limit}",
70
- "templated": true
71
- },
72
- "self": {
73
- "href": "https://horizon-testnet.stellar.org/"
74
- },
75
- "transaction": {
76
- "href": "https://horizon-testnet.stellar.org/transactions/{hash}",
77
- "templated": true
78
- },
79
- "transactions": {
80
- "href": "https://horizon-testnet.stellar.org/transactions{?cursor,limit,order}",
81
- "templated": true
82
- }
83
- },
84
- "horizon_version": "snapshot-snapshots-2-g99e33f0",
85
- "core_version": "stellar-core 9.2.0rc6 (b0923f153b86d394a83b2a619db6b23f07ed0700)",
86
- "history_latest_ledger": 9035188,
87
- "history_elder_ledger": 1,
88
- "core_latest_ledger": 9035188,
89
- "network_passphrase": "Test SDF Network ; September 2015",
90
- "protocol_version": 9
91
- }
92
- http_version:
93
- recorded_at: Fri, 18 May 2018 21:32:24 GMT
94
- recorded_with: VCR 3.0.3
@@ -1,94 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: https://horizon-testnet.stellar.org/
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- User-Agent:
11
- - Faraday v0.15.1
12
- Accept:
13
- - application/hal+json,application/problem+json,application/json
14
- response:
15
- status:
16
- code: 200
17
- message: OK
18
- headers:
19
- Date:
20
- - Fri, 18 May 2018 21:32:24 GMT
21
- Content-Type:
22
- - application/hal+json; charset=utf-8
23
- Connection:
24
- - keep-alive
25
- Set-Cookie:
26
- - __cfduid=d64b3b4f7b1e989c1cb221b3ba0ca543e1526679144; expires=Sat, 18-May-19
27
- 21:32:24 GMT; path=/; domain=.stellar.org; HttpOnly
28
- Content-Disposition:
29
- - inline
30
- Vary:
31
- - Origin
32
- X-Ratelimit-Limit:
33
- - '17200'
34
- X-Ratelimit-Remaining:
35
- - '17177'
36
- X-Ratelimit-Reset:
37
- - '525'
38
- Expect-Ct:
39
- - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
40
- Server:
41
- - cloudflare
42
- Cf-Ray:
43
- - 41d16fac6868b9d6-ATL
44
- body:
45
- encoding: UTF-8
46
- string: |-
47
- {
48
- "_links": {
49
- "account": {
50
- "href": "https://horizon-testnet.stellar.org/accounts/{account_id}",
51
- "templated": true
52
- },
53
- "account_transactions": {
54
- "href": "https://horizon-testnet.stellar.org/accounts/{account_id}/transactions{?cursor,limit,order}",
55
- "templated": true
56
- },
57
- "assets": {
58
- "href": "https://horizon-testnet.stellar.org/assets{?asset_code,asset_issuer,cursor,limit,order}",
59
- "templated": true
60
- },
61
- "friendbot": {
62
- "href": "https://horizon-testnet.stellar.org/friendbot{?addr}",
63
- "templated": true
64
- },
65
- "metrics": {
66
- "href": "https://horizon-testnet.stellar.org/metrics"
67
- },
68
- "order_book": {
69
- "href": "https://horizon-testnet.stellar.org/order_book{?selling_asset_type,selling_asset_code,selling_issuer,buying_asset_type,buying_asset_code,buying_issuer,limit}",
70
- "templated": true
71
- },
72
- "self": {
73
- "href": "https://horizon-testnet.stellar.org/"
74
- },
75
- "transaction": {
76
- "href": "https://horizon-testnet.stellar.org/transactions/{hash}",
77
- "templated": true
78
- },
79
- "transactions": {
80
- "href": "https://horizon-testnet.stellar.org/transactions{?cursor,limit,order}",
81
- "templated": true
82
- }
83
- },
84
- "horizon_version": "snapshot-snapshots-2-g99e33f0",
85
- "core_version": "stellar-core 9.2.0rc6 (b0923f153b86d394a83b2a619db6b23f07ed0700)",
86
- "history_latest_ledger": 9035188,
87
- "history_elder_ledger": 1,
88
- "core_latest_ledger": 9035188,
89
- "network_passphrase": "Test SDF Network ; September 2015",
90
- "protocol_version": 9
91
- }
92
- http_version:
93
- recorded_at: Fri, 18 May 2018 21:32:24 GMT
94
- recorded_with: VCR 3.0.3
@@ -1,59 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Stellar
4
- RSpec.describe Account do
5
-
6
- describe ".random" do
7
- it "generates a Stellar account with a random keypair" do
8
- account = described_class.random
9
- expect(account.address).to match account.keypair.address
10
- end
11
- end
12
-
13
- describe ".from_seed" do
14
- let(:random_account) { described_class.random }
15
- subject(:account) do
16
- described_class.from_seed(random_account.keypair.seed)
17
- end
18
-
19
- it "generates an account from a seed" do
20
- expect(account.keypair.seed).to eq random_account.keypair.seed
21
- end
22
- end
23
-
24
- describe ".from_address" do
25
- let(:random_account) { described_class.random }
26
- subject(:account) do
27
- described_class.from_address(random_account.address)
28
- end
29
-
30
- it "generates an account from an address" do
31
- expect(account.address).to eq random_account.address
32
- end
33
- end
34
-
35
- describe ".lookup" do
36
- it "should peforms federation lookup", vcr: {record: :once, match_requests_on: [:method]} do
37
- account_id = described_class.lookup('john@email.com*stellarfed.org')
38
- expect(account_id).to eq 'GDSRO6H2YM6MC6ZO7KORPJXSTUMBMT3E7MZ66CFVNMUAULFG6G2OP32I'
39
- end
40
-
41
- it "should handle 404 request when performing federation lookup", vcr: {record: :once, match_requests_on: [:method]} do
42
- expect { described_class.lookup('jane@email.com*stellarfed.org') }.to raise_error(AccountNotFound)
43
- end
44
-
45
- it "should handle domains that are not federation servers", vcr: {record: :once, match_requests_on: [:method]} do
46
- expect { described_class.lookup('john*stellar.org') }.to raise_error(InvalidStellarDomain)
47
- end
48
- end
49
-
50
-
51
- describe "#keypair" do
52
- it "generates a Stellar account with a random keypair" do
53
- account = described_class.random
54
- expect(account.keypair).to be_a KeyPair
55
- end
56
- end
57
-
58
- end
59
- end
@@ -1,70 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Stellar
4
- RSpec.describe Amount do
5
-
6
- describe "#to_payment" do
7
- context "when asset is the native type" do
8
- it "returns an array of values" do
9
- amount = described_class.new(100)
10
- payment = amount.to_payment
11
- expect(payment[0]).to eq :native
12
- expect(payment[1]).to eq 100
13
- end
14
- end
15
-
16
- context "when asset is alphanum4" do
17
- let(:issuer_account) { Stellar::Account.random }
18
-
19
- it "returns an array of values" do
20
- asset = Stellar::Asset.alphanum4("BTC", issuer_account.keypair)
21
- amount = described_class.new(100, asset)
22
-
23
- payment = amount.to_payment
24
- expect(payment[0]).to eq :alphanum4
25
- expect(payment[1]).to include "BTC"
26
- expect(payment[2].public_key.value).
27
- to eq issuer_account.keypair.public_key.value
28
- expect(payment[3]).to eq 100
29
- end
30
- end
31
-
32
- context "when asset is alphanum12" do
33
- let(:issuer_account) { Stellar::Account.random }
34
-
35
- it "returns an array of values" do
36
- asset = Stellar::Asset.alphanum12("LONGNAME", issuer_account.keypair)
37
- amount = described_class.new(100, asset)
38
-
39
- payment = amount.to_payment
40
- expect(payment[0]).to eq :alphanum12
41
- expect(payment[1]).to include "LONGNAME"
42
- expect(payment[2].public_key.value).
43
- to eq issuer_account.keypair.public_key.value
44
- expect(payment[3]).to eq 100
45
- end
46
- end
47
- end
48
-
49
- describe "#inspect" do
50
- context "when asset is not explicitly supplied" do
51
- it "uses the native asset type" do
52
- amount = described_class.new(200)
53
- expect(amount.inspect).to eq "#<Stellar::Amount native(200)>"
54
- end
55
- end
56
-
57
- context "when asset is supplied" do
58
- let(:issuer_account) { Stellar::Account.random }
59
-
60
- it "uses the supplied asset type" do
61
- asset = Stellar::Asset.alphanum4("BTC", issuer_account.keypair)
62
- address = issuer_account.address
63
- amount = described_class.new(1_000000, asset)
64
- expect(amount.inspect).to eq "#<Stellar::Amount #{asset}(1000000)>"
65
- end
66
- end
67
- end
68
-
69
- end
70
- end