stellar-sdk 0.3.0 → 0.4.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
- SHA1:
3
- metadata.gz: d4aaec9c5a35f4373484c41fcc22795572e4a8a8
4
- data.tar.gz: 80ac0dd562f6f4cc5e14a2a99d0ffb3c50a65dfd
2
+ SHA256:
3
+ metadata.gz: f3c1d917a218343ba852380651053255ddc4aa0293d96cfee5ef4856d5aa9fe2
4
+ data.tar.gz: 69f8d0f5e220140e02527ff284877a424c284065e3f397a88f28221d2c73af69
5
5
  SHA512:
6
- metadata.gz: 30e977ea4ee7ef94b1403432354c97798df61d941a802dba6bb39aedb6fb61e044a754c145b081020b2be5753f51ab0a6a4c9eefe2a61a170de36db5eb4970c2
7
- data.tar.gz: 5348ac5e5adf3b01a70ac4748795c9fbcb428465d355060e94a3995be80dd098930ff64c1f081fee5da58e70c640f8669395310e06cc6683e0786d089754f38a
6
+ metadata.gz: e4cb249129ec6e825c83d54a095e255f27e91ef7d3202efd66bceab1fd6fb06095feb82b6a1f5f56210c7c87e6db0a2e030dd285364152ea904c65c95cb46fd1
7
+ data.tar.gz: 5e0a36fdd2c0de489a39d8582d54f4495db4dbbaf8079c6656d1e96bac19fac3febc08eb19566f75d12c38b4929f2d76e196a374499bc89246c36a84df43d7c3
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
+ /.ruby-version
3
4
  /Gemfile.lock
4
5
  /_yardoc/
5
6
  /coverage/
@@ -1,7 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.3.1
4
- - 2.2.5
4
+ - 2.4.1
5
+ - 2.5.1
5
6
  - jruby-9.1.6.0
6
7
  cache: bundler
7
8
  script: LD_LIBRARY_PATH=lib bundle exec rake travis
data/README.md CHANGED
@@ -41,7 +41,7 @@ recipient = Stellar::Account.random
41
41
  client.send_payment({
42
42
  from: account,
43
43
  to: recipient,
44
- amount: Stellar::Amount.new(100_000000)
44
+ amount: Stellar::Amount.new(100_000_000)
45
45
  })
46
46
  ```
47
47
 
data/Rakefile CHANGED
@@ -1,4 +1,3 @@
1
1
  require "bundler/gem_tasks"
2
- Bundler.setup
3
2
 
4
3
  Dir["tasks/**/*.rake"].each{|f| load f}
@@ -1,7 +1,7 @@
1
- require 'stellar'
1
+ require 'stellar-sdk'
2
2
 
3
3
  # Reference an account from a secret seed
4
- account = Stellar::Account.from_seed("s3fu5vCMrfYouKuk2uB1gCD7EsuuBKY9M4qmnniQMBFMWR6Gaqm")
4
+ account = Stellar::Account.from_seed("SBXH4SEH32PENMMB66P4TY6LXUIFMRVFUMX2LJC3P2STHICBJLNQJOH5")
5
5
 
6
6
  # Further options
7
7
  #
@@ -15,8 +15,8 @@ account = Stellar::Account.from_seed("s3fu5vCMrfYouKuk2uB1gCD7EsuuBKY9M4qmnniQMB
15
15
  #
16
16
  # Reference an account (unauthenticated) from a federation name
17
17
  #
18
- # account = Stellar::Account.lookup("nullstyle") # defaults to stellar.org
19
- # account = Stellar::Account.lookup("nullstyle@stellar.org")
18
+ # account = Stellar::Account.lookup("nullstyle*stellarfed.org")
19
+ # account = Stellar::Account.lookup("nullstyle@gmail.com*stellarfed.org")
20
20
  #
21
21
 
22
22
  # create a connection to the stellar network
@@ -1,6 +1,6 @@
1
- require 'stellar'
1
+ require 'stellar-sdk'
2
2
 
3
- account = Stellar::Account.from_seed("s3fu5vCMrfYouKuk2uB1gCD7EsuuBKY9M4qmnniQMBFMWR6Gaqm")
3
+ account = Stellar::Account.from_seed("SBXH4SEH32PENMMB66P4TY6LXUIFMRVFUMX2LJC3P2STHICBJLNQJOH5")
4
4
  client = Stellar::Client.default_testnet()
5
5
 
6
6
  # create a random recipients
@@ -10,6 +10,6 @@ recipient = Stellar::Account.random
10
10
  client.send_payment({
11
11
  from: account,
12
12
  to: recipient,
13
- amount: Stellar::Amount.new(100_000000)
13
+ amount: Stellar::Amount.new(100_000_000)
14
14
  }) # => #<OK>
15
15
 
@@ -1,6 +1,6 @@
1
- require 'stellar'
1
+ require 'stellar-sdk'
2
2
 
3
- account = Stellar::Account.from_seed("s3fu5vCMrfYouKuk2uB1gCD7EsuuBKY9M4qmnniQMBFMWR6Gaqm")
3
+ account = Stellar::Account.from_seed("SBXH4SEH32PENMMB66P4TY6LXUIFMRVFUMX2LJC3P2STHICBJLNQJOH5")
4
4
  client = Stellar::Client.default_testnet()
5
5
 
6
6
  # load the first page of transactions
@@ -16,8 +16,6 @@ transactions.take(3) # => [...]
16
16
 
17
17
  # ...but also has methods to advance pages
18
18
  newer_transactions = transactions.next_page
19
- older_transactions = transactions.prev_page # => []
20
19
 
21
20
  # we can also just advance the current page in place
22
21
  transactions.next_page!
23
- transactions.prev_page!
@@ -1,12 +1,12 @@
1
- require 'stellar'
1
+ require 'stellar-sdk'
2
2
 
3
- account = Stellar::Account.from_seed("s3fu5vCMrfYouKuk2uB1gCD7EsuuBKY9M4qmnniQMBFMWR6Gaqm")
3
+ account = Stellar::Account.from_seed("SBXH4SEH32PENMMB66P4TY6LXUIFMRVFUMX2LJC3P2STHICBJLNQJOH5")
4
4
  client = Stellar::Client.default_testnet()
5
5
 
6
- issuer = Stellar::Account.lookup("issuer@haste.co.nz"))
7
- asset = Stellar::Asset.credit_alphanum4("USD", issuer)
6
+ issuer = Stellar::Account.lookup("tips*stellarid.io")
7
+ asset = Stellar::Asset.alphanum4("USD", issuer)
8
8
 
9
9
  client.trust({
10
- account: account
10
+ account: account,
11
11
  asset: asset
12
12
  })
@@ -1,10 +1,10 @@
1
- require 'stellar'
1
+ require 'stellar-sdk'
2
2
 
3
- account = Stellar::Account.from_seed("s3fu5vCMrfYouKuk2uB1gCD7EsuuBKY9M4qmnniQMBFMWR6Gaqm")
3
+ account = Stellar::Account.from_seed("SBXH4SEH32PENMMB66P4TY6LXUIFMRVFUMX2LJC3P2STHICBJLNQJOH5")
4
4
  client = Stellar::Client.default_testnet()
5
5
 
6
- issuer = Stellar::Account.lookup("issuer@haste.co.nz"))
7
- asset = Stellar::Asset.credit_alphanum4("USD", issuer)
6
+ issuer = Stellar::Account.lookup("tips*stellarid.io")
7
+ asset = Stellar::Asset.alphanum4("USD", issuer)
8
8
 
9
9
  client.send({
10
10
  from: account,
@@ -1,14 +1,14 @@
1
- require 'stellar'
1
+ require 'stellar-sdk'
2
2
 
3
3
  client = Stellar::Client.default_testnet
4
4
 
5
- friendbot = Stellar::Account.from_seed("s3fu5vCMrfYouKuk2uB1gCD7EsuuBKY9M4qmnniQMBFMWR6Gaqm")
5
+ friendbot = Stellar::Account.from_seed("SBXH4SEH32PENMMB66P4TY6LXUIFMRVFUMX2LJC3P2STHICBJLNQJOH5")
6
6
 
7
7
  # Give 10 million lumens
8
8
  client.create_account({
9
9
  funder: Stellar::Account.master,
10
10
  account: friendbot,
11
- starting_balance: 10_000000 * Stellar::ONE,
11
+ starting_balance: 10_000_000 * Stellar::ONE,
12
12
  sequence: 1,
13
13
  })
14
14
 
@@ -1,5 +1,7 @@
1
1
  require 'toml-rb'
2
2
  require 'uri'
3
+ require 'faraday'
4
+ require 'json'
3
5
 
4
6
  module Stellar
5
7
  class Account
@@ -46,11 +46,10 @@ module Stellar
46
46
  raise NotImplementedError
47
47
  end
48
48
 
49
- # Contract Stellar::Account => Stellar::AccountInfo
50
49
  Contract Stellar::Account => Any
51
50
  def account_info(account)
52
51
  account_id = account.address
53
- @horizon.account(account_id:account_id)
52
+ @horizon.account(account_id:account_id)._get
54
53
  end
55
54
 
56
55
  Contract ({
@@ -81,7 +80,9 @@ module Stellar
81
80
  def create_account(options={})
82
81
  funder = options[:funder]
83
82
  sequence = options[:sequence] || (account_info(funder).sequence.to_i + 1)
84
- fee = options[:fee] || 100 * Stellar::ONE
83
+ # In the future, the fee should be grabbed from the network's last transactions,
84
+ # instead of using a hard-coded default value.
85
+ fee = options[:fee] || 100
85
86
 
86
87
  payment = Stellar::Transaction.create_account({
87
88
  account: funder.keypair,
@@ -97,10 +98,11 @@ module Stellar
97
98
 
98
99
  Contract ({
99
100
  account: Maybe[Stellar::Account],
100
- limit: Maybe[Pos]
101
+ limit: Maybe[Pos],
102
+ cursor: Maybe[String]
101
103
  }) => TransactionPage
102
104
  def transactions(options={})
103
- args = options.slice(:limit)
105
+ args = options.slice(:limit, :cursor)
104
106
 
105
107
  resource = if options[:account]
106
108
  args = args.merge(account_id: options[:account].address)
@@ -1,3 +1,3 @@
1
1
  module Stellar
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -17,14 +17,14 @@ Gem::Specification.new do |spec|
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
  spec.require_paths = ["lib"]
19
19
 
20
- spec.add_dependency "stellar-base", "~> 0.13.0"
21
- spec.add_dependency "hyperclient", "~> 0.7.0"
22
- spec.add_dependency "excon", "~> 0.44.4"
20
+ spec.add_dependency "stellar-base", "~> 0.13"
21
+ spec.add_dependency "hyperclient", "~> 0.7"
22
+ spec.add_dependency "excon", "~> 0.44", ">= 0.44.4"
23
23
  spec.add_dependency "contracts", "~> 0.7"
24
24
  spec.add_dependency "activesupport", ">= 4.2.7"
25
- spec.add_dependency "toml-rb", "~> 1.1.1"
25
+ spec.add_dependency "toml-rb", "~> 1.1", ">= 1.1.1"
26
26
 
27
- spec.add_development_dependency "bundler", "~> 1.7"
27
+ spec.add_development_dependency "bundler", "~> 1.16"
28
28
  spec.add_development_dependency "rake", "~> 10.0"
29
29
  spec.add_development_dependency "rspec", "~> 3.1"
30
30
  spec.add_development_dependency "guard-rspec"
@@ -0,0 +1,190 @@
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.14.0
12
+ Accept:
13
+ - application/hal+json,application/problem+json,application/json
14
+ response:
15
+ status:
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ Content-Disposition:
20
+ - inline
21
+ Content-Type:
22
+ - application/hal+json; charset=utf-8
23
+ Date:
24
+ - Sun, 04 Mar 2018 12:05:19 GMT
25
+ Vary:
26
+ - Origin
27
+ X-Ratelimit-Limit:
28
+ - '18000'
29
+ X-Ratelimit-Remaining:
30
+ - '17975'
31
+ X-Ratelimit-Reset:
32
+ - '277'
33
+ Content-Length:
34
+ - '1509'
35
+ Connection:
36
+ - keep-alive
37
+ body:
38
+ encoding: UTF-8
39
+ string: |-
40
+ {
41
+ "_links": {
42
+ "account": {
43
+ "href": "https://horizon-testnet.stellar.org/accounts/{account_id}",
44
+ "templated": true
45
+ },
46
+ "account_transactions": {
47
+ "href": "https://horizon-testnet.stellar.org/accounts/{account_id}/transactions{?cursor,limit,order}",
48
+ "templated": true
49
+ },
50
+ "assets": {
51
+ "href": "https://horizon-testnet.stellar.org/assets{?asset_code,asset_issuer,cursor,limit,order}",
52
+ "templated": true
53
+ },
54
+ "friendbot": {
55
+ "href": "https://horizon-testnet.stellar.org/friendbot{?addr}",
56
+ "templated": true
57
+ },
58
+ "metrics": {
59
+ "href": "https://horizon-testnet.stellar.org/metrics"
60
+ },
61
+ "order_book": {
62
+ "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}",
63
+ "templated": true
64
+ },
65
+ "self": {
66
+ "href": "https://horizon-testnet.stellar.org/"
67
+ },
68
+ "transaction": {
69
+ "href": "https://horizon-testnet.stellar.org/transactions/{hash}",
70
+ "templated": true
71
+ },
72
+ "transactions": {
73
+ "href": "https://horizon-testnet.stellar.org/transactions{?cursor,limit,order}",
74
+ "templated": true
75
+ }
76
+ },
77
+ "horizon_version": "snapshot-snapshots-5-g0d276af",
78
+ "core_version": "v9.2.0rc2-dirty",
79
+ "history_latest_ledger": 7732527,
80
+ "history_elder_ledger": 1,
81
+ "core_latest_ledger": 7732527,
82
+ "network_passphrase": "Test SDF Network ; September 2015",
83
+ "protocol_version": 9
84
+ }
85
+ http_version:
86
+ recorded_at: Sun, 04 Mar 2018 12:05:19 GMT
87
+ - request:
88
+ method: get
89
+ uri: https://horizon-testnet.stellar.org/accounts/[source_address]
90
+ body:
91
+ encoding: US-ASCII
92
+ string: ''
93
+ headers:
94
+ User-Agent:
95
+ - Faraday v0.14.0
96
+ Accept:
97
+ - application/hal+json,application/problem+json,application/json
98
+ response:
99
+ status:
100
+ code: 200
101
+ message: OK
102
+ headers:
103
+ Content-Disposition:
104
+ - inline
105
+ Content-Type:
106
+ - application/hal+json; charset=utf-8
107
+ Date:
108
+ - Sun, 04 Mar 2018 12:05:20 GMT
109
+ Vary:
110
+ - Origin
111
+ X-Ratelimit-Limit:
112
+ - '18000'
113
+ X-Ratelimit-Remaining:
114
+ - '17971'
115
+ X-Ratelimit-Reset:
116
+ - '208'
117
+ Content-Length:
118
+ - '2263'
119
+ Connection:
120
+ - keep-alive
121
+ body:
122
+ encoding: UTF-8
123
+ string: |-
124
+ {
125
+ "_links": {
126
+ "self": {
127
+ "href": "https://horizon-testnet.stellar.org/accounts/[source_address]"
128
+ },
129
+ "transactions": {
130
+ "href": "https://horizon-testnet.stellar.org/accounts/[source_address]/transactions{?cursor,limit,order}",
131
+ "templated": true
132
+ },
133
+ "operations": {
134
+ "href": "https://horizon-testnet.stellar.org/accounts/[source_address]/operations{?cursor,limit,order}",
135
+ "templated": true
136
+ },
137
+ "payments": {
138
+ "href": "https://horizon-testnet.stellar.org/accounts/[source_address]/payments{?cursor,limit,order}",
139
+ "templated": true
140
+ },
141
+ "effects": {
142
+ "href": "https://horizon-testnet.stellar.org/accounts/[source_address]/effects{?cursor,limit,order}",
143
+ "templated": true
144
+ },
145
+ "offers": {
146
+ "href": "https://horizon-testnet.stellar.org/accounts/[source_address]/offers{?cursor,limit,order}",
147
+ "templated": true
148
+ },
149
+ "trades": {
150
+ "href": "https://horizon-testnet.stellar.org/accounts/[source_address]/trades{?cursor,limit,order}",
151
+ "templated": true
152
+ },
153
+ "data": {
154
+ "href": "https://horizon-testnet.stellar.org/accounts/[source_address]/data/{key}",
155
+ "templated": true
156
+ }
157
+ },
158
+ "id": "[source_address]",
159
+ "paging_token": "",
160
+ "account_id": "[source_address]",
161
+ "sequence": "346973227974715",
162
+ "subentry_count": 0,
163
+ "thresholds": {
164
+ "low_threshold": 0,
165
+ "med_threshold": 0,
166
+ "high_threshold": 0
167
+ },
168
+ "flags": {
169
+ "auth_required": false,
170
+ "auth_revocable": false
171
+ },
172
+ "balances": [
173
+ {
174
+ "balance": "3494.9997500",
175
+ "asset_type": "native"
176
+ }
177
+ ],
178
+ "signers": [
179
+ {
180
+ "public_key": "[source_address]",
181
+ "weight": 1,
182
+ "key": "[source_address]",
183
+ "type": "ed25519_public_key"
184
+ }
185
+ ],
186
+ "data": {}
187
+ }
188
+ http_version:
189
+ recorded_at: Sun, 04 Mar 2018 12:05:20 GMT
190
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,94 @@
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
@@ -0,0 +1,94 @@
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
@@ -0,0 +1,94 @@
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
@@ -0,0 +1,94 @@
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
@@ -3,7 +3,36 @@ require 'spec_helper'
3
3
  module Stellar
4
4
  RSpec.describe Account do
5
5
 
6
- describe "#lookup" do
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
7
36
  it "should peforms federation lookup", vcr: {record: :once, match_requests_on: [:method]} do
8
37
  account_id = described_class.lookup('john@email.com*stellarfed.org')
9
38
  expect(account_id).to eq 'GDSRO6H2YM6MC6ZO7KORPJXSTUMBMT3E7MZ66CFVNMUAULFG6G2OP32I'
@@ -18,5 +47,13 @@ module Stellar
18
47
  end
19
48
  end
20
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
+
21
58
  end
22
59
  end
@@ -25,6 +25,30 @@ describe Stellar::Client do
25
25
  end
26
26
  end
27
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
+
28
52
  describe "#send_payment" do
29
53
  let(:source) { Stellar::Account.from_seed(CONFIG[:source_seed]) }
30
54
 
@@ -115,4 +139,35 @@ describe Stellar::Client do
115
139
  end
116
140
  end
117
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
+
118
173
  end
@@ -1,6 +1,3 @@
1
- require 'bundler/setup'
2
- Bundler.setup
3
-
4
1
  require 'simplecov'
5
2
  SimpleCov.start
6
3
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stellar-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Fleckenstein
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-02 00:00:00.000000000 Z
11
+ date: 2018-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: stellar-base
@@ -16,33 +16,36 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.13.0
19
+ version: '0.13'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.13.0
26
+ version: '0.13'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: hyperclient
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.7.0
33
+ version: '0.7'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.7.0
40
+ version: '0.7'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: excon
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.44'
48
+ - - ">="
46
49
  - !ruby/object:Gem::Version
47
50
  version: 0.44.4
48
51
  type: :runtime
@@ -50,6 +53,9 @@ dependencies:
50
53
  version_requirements: !ruby/object:Gem::Requirement
51
54
  requirements:
52
55
  - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: '0.44'
58
+ - - ">="
53
59
  - !ruby/object:Gem::Version
54
60
  version: 0.44.4
55
61
  - !ruby/object:Gem::Dependency
@@ -85,6 +91,9 @@ dependencies:
85
91
  requirement: !ruby/object:Gem::Requirement
86
92
  requirements:
87
93
  - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '1.1'
96
+ - - ">="
88
97
  - !ruby/object:Gem::Version
89
98
  version: 1.1.1
90
99
  type: :runtime
@@ -92,6 +101,9 @@ dependencies:
92
101
  version_requirements: !ruby/object:Gem::Requirement
93
102
  requirements:
94
103
  - - "~>"
104
+ - !ruby/object:Gem::Version
105
+ version: '1.1'
106
+ - - ">="
95
107
  - !ruby/object:Gem::Version
96
108
  version: 1.1.1
97
109
  - !ruby/object:Gem::Dependency
@@ -100,14 +112,14 @@ dependencies:
100
112
  requirements:
101
113
  - - "~>"
102
114
  - !ruby/object:Gem::Version
103
- version: '1.7'
115
+ version: '1.16'
104
116
  type: :development
105
117
  prerelease: false
106
118
  version_requirements: !ruby/object:Gem::Requirement
107
119
  requirements:
108
120
  - - "~>"
109
121
  - !ruby/object:Gem::Version
110
- version: '1.7'
122
+ version: '1.16'
111
123
  - !ruby/object:Gem::Dependency
112
124
  name: rake
113
125
  requirement: !ruby/object:Gem::Requirement
@@ -214,7 +226,6 @@ extensions: []
214
226
  extra_rdoc_files: []
215
227
  files:
216
228
  - ".gitignore"
217
- - ".ruby-version"
218
229
  - ".travis.yml"
219
230
  - ".yardopts"
220
231
  - CHANGELOG.md
@@ -229,7 +240,7 @@ files:
229
240
  - examples/03_transaction_history.rb
230
241
  - examples/04_setting_trust.rb
231
242
  - examples/05_fiat_payment.rb
232
- - examples/fund_testnet_friendbot.rb
243
+ - examples/06_fund_testnet_friendbot.rb
233
244
  - lib/stellar-sdk.rb
234
245
  - lib/stellar/account.rb
235
246
  - lib/stellar/amount.rb
@@ -242,18 +253,20 @@ files:
242
253
  - spec/fixtures/vcr_cassettes/Stellar_Account/_lookup/should_handle_404_request_when_performing_federation_lookup.yml
243
254
  - spec/fixtures/vcr_cassettes/Stellar_Account/_lookup/should_handle_domains_that_are_not_federation_servers.yml
244
255
  - spec/fixtures/vcr_cassettes/Stellar_Account/_lookup/should_peforms_federation_lookup.yml
256
+ - spec/fixtures/vcr_cassettes/Stellar_Client/_account_info/returns_the_current_details_for_the_account.yml
245
257
  - spec/fixtures/vcr_cassettes/Stellar_Client/_create_account/creates_the_account.yml
246
258
  - spec/fixtures/vcr_cassettes/Stellar_Client/_send_payment/alphanum12_asset/sends_a_alphanum12_asset_to_the_destination.yml
247
259
  - spec/fixtures/vcr_cassettes/Stellar_Client/_send_payment/alphanum4_asset/sends_a_alphanum4_asset_to_the_destination.yml
248
260
  - spec/fixtures/vcr_cassettes/Stellar_Client/_send_payment/native_asset/sends_a_native_payment_to_the_account.yml
261
+ - spec/fixtures/vcr_cassettes/Stellar_Client/_transactions/account_transactions/accepts_a_cursor_to_return_less_data.yml
262
+ - spec/fixtures/vcr_cassettes/Stellar_Client/_transactions/account_transactions/returns_a_list_of_transaction_for_an_account.yml
263
+ - spec/fixtures/vcr_cassettes/Stellar_Client/_transactions/all_transactions/accepts_a_cursor_to_return_less_data.yml
264
+ - spec/fixtures/vcr_cassettes/Stellar_Client/_transactions/all_transactions/returns_a_list_of_transactions.yml
249
265
  - spec/lib/stellar/account_spec.rb
250
266
  - spec/lib/stellar/amount_spec.rb
251
267
  - spec/lib/stellar/client_spec.rb
252
268
  - spec/spec_helper.rb
253
269
  - spec/support/config.rb
254
- - spec/support/matchers/be_base58_check.rb
255
- - spec/support/matchers/eq_bytes.rb
256
- - spec/support/matchers/have_length.rb
257
270
  - spec/support/vcr.rb
258
271
  - tasks/rspec.rake
259
272
  - tasks/travis.rake
@@ -277,7 +290,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
277
290
  version: '0'
278
291
  requirements: []
279
292
  rubyforge_project:
280
- rubygems_version: 2.5.1
293
+ rubygems_version: 2.7.6
281
294
  signing_key:
282
295
  specification_version: 4
283
296
  summary: Stellar client library
@@ -286,17 +299,18 @@ test_files:
286
299
  - spec/fixtures/vcr_cassettes/Stellar_Account/_lookup/should_handle_404_request_when_performing_federation_lookup.yml
287
300
  - spec/fixtures/vcr_cassettes/Stellar_Account/_lookup/should_handle_domains_that_are_not_federation_servers.yml
288
301
  - spec/fixtures/vcr_cassettes/Stellar_Account/_lookup/should_peforms_federation_lookup.yml
302
+ - spec/fixtures/vcr_cassettes/Stellar_Client/_account_info/returns_the_current_details_for_the_account.yml
289
303
  - spec/fixtures/vcr_cassettes/Stellar_Client/_create_account/creates_the_account.yml
290
304
  - spec/fixtures/vcr_cassettes/Stellar_Client/_send_payment/alphanum12_asset/sends_a_alphanum12_asset_to_the_destination.yml
291
305
  - spec/fixtures/vcr_cassettes/Stellar_Client/_send_payment/alphanum4_asset/sends_a_alphanum4_asset_to_the_destination.yml
292
306
  - spec/fixtures/vcr_cassettes/Stellar_Client/_send_payment/native_asset/sends_a_native_payment_to_the_account.yml
307
+ - spec/fixtures/vcr_cassettes/Stellar_Client/_transactions/account_transactions/accepts_a_cursor_to_return_less_data.yml
308
+ - spec/fixtures/vcr_cassettes/Stellar_Client/_transactions/account_transactions/returns_a_list_of_transaction_for_an_account.yml
309
+ - spec/fixtures/vcr_cassettes/Stellar_Client/_transactions/all_transactions/accepts_a_cursor_to_return_less_data.yml
310
+ - spec/fixtures/vcr_cassettes/Stellar_Client/_transactions/all_transactions/returns_a_list_of_transactions.yml
293
311
  - spec/lib/stellar/account_spec.rb
294
312
  - spec/lib/stellar/amount_spec.rb
295
313
  - spec/lib/stellar/client_spec.rb
296
314
  - spec/spec_helper.rb
297
315
  - spec/support/config.rb
298
- - spec/support/matchers/be_base58_check.rb
299
- - spec/support/matchers/eq_bytes.rb
300
- - spec/support/matchers/have_length.rb
301
316
  - spec/support/vcr.rb
302
- has_rdoc:
@@ -1 +0,0 @@
1
- ruby-2.3.1
@@ -1,9 +0,0 @@
1
- RSpec::Matchers.define :be_base58_check do |version_byte|
2
- match do |actual|
3
- begin
4
- Stellar::Util::Base58.stellar.check_decode(version_byte, actual)
5
- rescue ArgumentError
6
- false
7
- end
8
- end
9
- end
@@ -1,5 +0,0 @@
1
- RSpec::Matchers.define :eq_bytes do |expected|
2
- match do |actual|
3
- expected.force_encoding("ASCII-8BIT") == actual.force_encoding("ASCII-8BIT")
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- RSpec::Matchers.define :have_length do |length|
2
- match do |actual|
3
- actual.length == length
4
- end
5
- end