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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d7c9a8f80386d8ae7e790f4cd5198968433c692417c2de7fd87d8d934d966e6a
4
- data.tar.gz: d31590ea3a3a2d469f4f0fc5fe59232696c7d090a4ab70415d823fed3a9228b1
3
+ metadata.gz: 3da720d62d3ed03b2eba1ac3e1bcc733da7013952120bcbc2feb31ec53c2eb90
4
+ data.tar.gz: d23901b3e1d9b6d3107cdeae940dda89ca19c180efd3c63be07823493c5c147e
5
5
  SHA512:
6
- metadata.gz: 45d62b035a05bdcdf5f93bf696e67e490a7f87df4b4e64b43503eb7e91a0b7dcfe7d4b8556119a0db9021ed32c8f2bf98684470bf58dae383d78fb44e67f8324
7
- data.tar.gz: 919b5641f08bd77ada6f39b0eac25e89a4aa8b66d27c7b32bdbfa2efe26b701551612d7b997750185124f6de3252a5013390982032c771a26103d3e2dc367b66
6
+ metadata.gz: c944e5f554aa13148f1268d6a7d5adaf1f61f942234ae6c87eebce880cc9f419edbfecb384bb76129ef41782c6647667ece34b5bb9fab8b18e04a6e7de068532
7
+ data.tar.gz: dc25b0c39c815dd3817272547d98df7400ad97f55c70e7adc1b72b55661f16d62ea733413b0375c77562586cb025dcbc1b67b049418ac4bb9224e1ae977eaad8
File without changes
data/README.md CHANGED
@@ -7,19 +7,18 @@ This library helps you to integrate your application into the [Stellar network](
7
7
 
8
8
  ## Installation
9
9
 
10
- Add this line to your application's Gemfile:
10
+ Add this lines to your application's Gemfile:
11
11
 
12
12
  ```ruby
13
13
  gem 'stellar-sdk'
14
+ gem 'xdr', git: 'https://github.com/stellar/ruby-xdr.git', tag: 'v3.0.1'
14
15
  ```
15
16
 
16
17
  And then execute:
17
18
 
18
19
  $ bundle
19
-
20
- Or install it yourself as:
21
-
22
- $ gem install stellar-sdk
20
+
21
+ **Note** we need to add such explicit `xdr` dependency, because version 3.0.1 is not on RubyGems yet. When it's published, you can remove this line
23
22
 
24
23
  Also requires libsodium. Installable via `brew install libsodium` on OS X.
25
24
 
@@ -1,8 +1,7 @@
1
- require 'stellar-base'
2
- require 'contracts'
1
+ require "stellar-base"
2
+ require_relative "./stellar/version"
3
3
 
4
4
  module Stellar
5
-
6
5
  autoload :Account
7
6
  autoload :Amount
8
7
  autoload :Client
@@ -1,12 +1,10 @@
1
- require 'toml-rb'
2
- require 'uri'
3
- require 'faraday'
4
- require 'json'
1
+ require "toml-rb"
2
+ require "uri"
3
+ require "faraday"
4
+ require "json"
5
5
 
6
6
  module Stellar
7
7
  class Account
8
- include Contracts
9
-
10
8
  delegate :address, to: :keypair
11
9
 
12
10
  def self.random
@@ -25,7 +23,7 @@ module Stellar
25
23
  end
26
24
 
27
25
  def self.lookup(federated_name)
28
- _, domain = federated_name.split('*')
26
+ _, domain = federated_name.split("*")
29
27
  if domain.nil?
30
28
  raise InvalidFederationAddress.new
31
29
  end
@@ -33,25 +31,25 @@ module Stellar
33
31
  domain_req = Faraday.new("https://#{domain}/.well-known/stellar.toml").get
34
32
 
35
33
  unless domain_req.status == 200
36
- raise InvalidStellarDomain.new('Domain does not contain stellar.toml file')
34
+ raise InvalidStellarDomain.new("Domain does not contain stellar.toml file")
37
35
  end
38
-
36
+
39
37
  fed_server_url = TomlRB.parse(domain_req.body)["FEDERATION_SERVER"]
40
38
  if fed_server_url.nil?
41
- raise InvalidStellarTOML.new('Invalid Stellar TOML file')
39
+ raise InvalidStellarTOML.new("Invalid Stellar TOML file")
42
40
  end
43
41
 
44
- unless fed_server_url =~ URI::regexp
45
- raise InvalidFederationURL.new('Invalid Federation Server URL')
42
+ unless fed_server_url&.match?(URI::DEFAULT_PARSER.make_regexp)
43
+ raise InvalidFederationURL.new("Invalid Federation Server URL")
46
44
  end
47
45
 
48
- lookup_req = Faraday.new(fed_server_url).get do |req|
46
+ lookup_req = Faraday.new(fed_server_url).get { |req|
49
47
  req.params[:q] = federated_name
50
- req.params[:type] = 'name'
51
- end
48
+ req.params[:type] = "name"
49
+ }
52
50
 
53
51
  unless lookup_req.status == 200
54
- raise AccountNotFound.new('Account not found')
52
+ raise AccountNotFound.new("Account not found")
55
53
  end
56
54
 
57
55
  JSON.parse(lookup_req.body)["account_id"]
@@ -64,7 +62,7 @@ module Stellar
64
62
 
65
63
  attr_reader :keypair
66
64
 
67
- Contract Stellar::KeyPair => Any
65
+ # @param [Stellar::KeyPair] keypair
68
66
  def initialize(keypair)
69
67
  @keypair = keypair
70
68
  end
@@ -84,4 +82,4 @@ module Stellar
84
82
 
85
83
  class InvalidFederationURL < StandardError
86
84
  end
87
- end
85
+ end
@@ -1,25 +1,21 @@
1
1
  module Stellar
2
2
  class Amount
3
- include Contracts
4
-
5
3
  attr_reader :amount
6
4
  attr_reader :asset
7
5
 
8
- Contract Pos, Asset => Any
9
- def initialize(amount, asset=Stellar::Asset.native())
6
+ # @param [Fixnum] amount
7
+ # @param [Stellar::Asset] asset
8
+ def initialize(amount, asset = Stellar::Asset.native)
10
9
  # TODO: how are we going to handle decimal considerations?
11
-
10
+
12
11
  @amount = amount
13
- @asset = asset
12
+ @asset = asset
14
13
  end
15
14
 
16
-
17
- Contract None => Or[
18
- [Or[:alphanum4, :alphanum12], String, KeyPair, Pos],
19
- [:native, Pos],
20
- ]
15
+ # @return [Array(Symbol, Fixnum)] in case of a native asset
16
+ # @return [Array(Symbol, String, Stellar::KeyPair, Fixnum)] in case of alphanum asset
21
17
  def to_payment
22
- case asset.type
18
+ case asset.type
23
19
  when AssetType.asset_type_native
24
20
  [:native, amount]
25
21
  when AssetType.asset_type_credit_alphanum4
@@ -34,7 +30,7 @@ module Stellar
34
30
  end
35
31
 
36
32
  def inspect
37
- "#<Stellar::Amount #{asset}(#{amount})>"
33
+ "#<Stellar::Amount #{asset}(#{amount})>"
38
34
  end
39
35
  end
40
36
  end
@@ -1,35 +1,40 @@
1
- require 'hyperclient'
1
+ require "hyperclient"
2
2
  require "active_support/core_ext/object/blank"
3
- require 'securerandom'
3
+ require "securerandom"
4
4
 
5
5
  module Stellar
6
- class InvalidSep10ChallengeError < StandardError; end
6
+ class AccountRequiresMemoError < StandardError
7
+ attr_reader :account_id, :operation_index
7
8
 
8
- class Client
9
- include Contracts
10
- C = Contracts
9
+ def initialize(message, account_id, operation_index)
10
+ super(message)
11
+ @account_id = account_id
12
+ @operation_index = operation_index
13
+ end
14
+ end
11
15
 
16
+ class Client
12
17
  DEFAULT_FEE = 100
13
18
 
14
- HORIZON_LOCALHOST_URL = 'http://127.0.0.1:8000'
15
- HORIZON_MAINNET_URL = 'https://horizon.stellar.org'
16
- HORIZON_TESTNET_URL = 'https://horizon-testnet.stellar.org'
17
- FRIENDBOT_URL = 'https://friendbot.stellar.org'.freeze
19
+ HORIZON_LOCALHOST_URL = "http://127.0.0.1:8000"
20
+ HORIZON_MAINNET_URL = "https://horizon.stellar.org"
21
+ HORIZON_TESTNET_URL = "https://horizon-testnet.stellar.org"
22
+ FRIENDBOT_URL = "https://friendbot.stellar.org".freeze
18
23
 
19
- def self.default(options={})
24
+ def self.default(options = {})
20
25
  new options.merge(
21
26
  horizon: HORIZON_MAINNET_URL
22
27
  )
23
28
  end
24
29
 
25
- def self.default_testnet(options={})
30
+ def self.default_testnet(options = {})
26
31
  new options.merge(
27
- horizon: HORIZON_TESTNET_URL,
28
- friendbot: HORIZON_TESTNET_URL,
32
+ horizon: HORIZON_TESTNET_URL,
33
+ friendbot: HORIZON_TESTNET_URL
29
34
  )
30
35
  end
31
36
 
32
- def self.localhost(options={})
37
+ def self.localhost(options = {})
33
38
  new options.merge(
34
39
  horizon: HORIZON_LOCALHOST_URL
35
40
  )
@@ -37,10 +42,10 @@ module Stellar
37
42
 
38
43
  attr_reader :horizon
39
44
 
40
- Contract ({horizon: String}) => Any
45
+ # @option options [String] :horizon The Horizon server URL.
41
46
  def initialize(options)
42
47
  @options = options
43
- @horizon = Hyperclient.new(options[:horizon]) do |client|
48
+ @horizon = Hyperclient.new(options[:horizon]) { |client|
44
49
  client.faraday_block = lambda do |conn|
45
50
  conn.use Faraday::Response::RaiseError
46
51
  conn.use FaradayMiddleware::FollowRedirects
@@ -49,40 +54,39 @@ module Stellar
49
54
  conn.adapter :excon
50
55
  end
51
56
  client.headers = {
52
- 'Accept' => 'application/hal+json,application/problem+json,application/json',
57
+ "Accept" => "application/hal+json,application/problem+json,application/json",
53
58
  "X-Client-Name" => "ruby-stellar-sdk",
54
- "X-Client-Version" => VERSION,
59
+ "X-Client-Version" => VERSION
55
60
  }
56
- end
61
+ }
57
62
  end
58
63
 
59
- Contract Or[Stellar::Account, String] => Any
64
+ # @param [Stellar::Account|String] account_or_address
60
65
  def account_info(account_or_address)
61
- if account_or_address.is_a?(Stellar::Account)
62
- account_id = account_or_address.address
66
+ account_id = if account_or_address.is_a?(Stellar::Account)
67
+ account_or_address.address
63
68
  else
64
- account_id = account_or_address
69
+ account_or_address
65
70
  end
66
- @horizon.account(account_id:account_id)._get
71
+ @horizon.account(account_id: account_id)._get
67
72
  end
68
73
 
69
- Contract ({
70
- account: Stellar::Account,
71
- destination: Stellar::Account
72
- }) => Any
73
- def account_merge(options={})
74
- account = options[:account]
74
+ # @option options [Stellar::Account] :account
75
+ # @option options [Stellar::Account] :destination
76
+ def account_merge(options = {})
77
+ account = options[:account]
75
78
  destination = options[:destination]
76
- sequence = options[:sequence] || (account_info(account).sequence.to_i + 1)
79
+ sequence = options[:sequence] || (account_info(account).sequence.to_i + 1)
77
80
 
78
- transaction = Stellar::Transaction.account_merge({
79
- account: account.keypair,
80
- destination: destination.keypair,
81
- sequence: sequence
82
- })
81
+ transaction = Stellar::TransactionBuilder.new(
82
+ source_account: destination.keypair,
83
+ sequence_number: sequence
84
+ ).add_operation(
85
+ Stellar::Operation.account_merge(destination: destination.keypair)
86
+ ).set_timeout(0).build
83
87
 
84
- envelope_base64 = transaction.to_envelope(account.keypair).to_xdr(:base64)
85
- @horizon.transactions._post(tx: envelope_base64)
88
+ envelope = transaction.to_envelope(account.keypair)
89
+ submit_transaction(tx_envelope: envelope)
86
90
  end
87
91
 
88
92
  def friendbot(account)
@@ -91,70 +95,65 @@ module Stellar
91
95
  Faraday.post(uri.to_s)
92
96
  end
93
97
 
94
- Contract ({
95
- account: Stellar::Account,
96
- funder: Stellar::Account,
97
- starting_balance: Integer
98
- }) => Any
99
- def create_account(options={})
100
- funder = options[:funder]
98
+ # @option options [Stellar::Account] :account
99
+ # @option options [Stellar::Account] :funder
100
+ # @option options [Integer] :starting_balance
101
+ def create_account(options = {})
102
+ funder = options[:funder]
101
103
  sequence = options[:sequence] || (account_info(funder).sequence.to_i + 1)
102
104
  # In the future, the fee should be grabbed from the network's last transactions,
103
105
  # instead of using a hard-coded default value.
104
106
  fee = options[:fee] || DEFAULT_FEE
105
107
 
106
- payment = Stellar::Transaction.create_account({
107
- account: funder.keypair,
108
- destination: options[:account].keypair,
109
- sequence: sequence,
110
- starting_balance: options[:starting_balance],
111
- fee: fee,
112
- })
113
-
114
- envelope_base64 = payment.to_envelope(funder.keypair).to_xdr(:base64)
115
- @horizon.transactions._post(tx: envelope_base64)
108
+ payment = Stellar::TransactionBuilder.new(
109
+ source_account: funder.keypair,
110
+ sequence_number: sequence,
111
+ base_fee: fee
112
+ ).add_operation(
113
+ Stellar::Operation.create_account({
114
+ destination: options[:account].keypair,
115
+ starting_balance: options[:starting_balance]
116
+ })
117
+ ).set_timeout(0).build
118
+
119
+ envelope = payment.to_envelope(funder.keypair)
120
+ submit_transaction(tx_envelope: envelope)
116
121
  end
117
122
 
118
- Contract ({
119
- from: Stellar::Account,
120
- to: Stellar::Account,
121
- amount: Stellar::Amount
122
- }) => Any
123
- def send_payment(options={})
124
- from_account = options[:from]
123
+ # @option options [Stellar::Account] :from The source account
124
+ # @option options [Stellar::Account] :to The destination account
125
+ # @option options [Stellar::Amount] :amount The amount to send
126
+ def send_payment(options = {})
127
+ from_account = options[:from]
125
128
  tx_source_account = options[:transaction_source] || from_account
126
129
  op_source_account = from_account if tx_source_account.present?
127
130
 
128
131
  sequence = options[:sequence] ||
129
132
  (account_info(tx_source_account).sequence.to_i + 1)
130
133
 
131
- payment_details = {
132
- destination: options[:to].keypair,
133
- sequence: sequence,
134
- amount: options[:amount].to_payment,
135
- memo: options[:memo],
136
- }
137
-
138
- payment_details[:account] = tx_source_account.keypair
139
- if op_source_account.present?
140
- payment_details[:source_account] = op_source_account.keypair
141
- end
142
-
143
- payment = Stellar::Transaction.payment(payment_details)
134
+ payment = Stellar::TransactionBuilder.new(
135
+ source_account: tx_source_account.keypair,
136
+ sequence_number: sequence
137
+ ).add_operation(
138
+ Stellar::Operation.payment(
139
+ source_account: op_source_account.keypair,
140
+ destination: options[:to].keypair,
141
+ amount: options[:amount].to_payment
142
+ )
143
+ ).set_memo(options[:memo]).set_timeout(0).build
144
144
 
145
145
  signers = [tx_source_account, op_source_account].uniq(&:address)
146
146
  to_envelope_args = signers.map(&:keypair)
147
147
 
148
- envelope_base64 = payment.to_envelope(*to_envelope_args).to_xdr(:base64)
149
- @horizon.transactions._post(tx: envelope_base64)
148
+ envelope = payment.to_envelope(*to_envelope_args)
149
+ submit_transaction(tx_envelope: envelope)
150
150
  end
151
151
 
152
- Contract ({
153
- account: Maybe[Stellar::Account],
154
- limit: Maybe[Pos],
155
- cursor: Maybe[String]
156
- }) => TransactionPage
157
- def transactions(options={})
152
+ # @option options [Stellar::Account] :account
153
+ # @option options [Integer] :limit
154
+ # @option options [Integer] :cursor
155
+ # @return [Stellar::TransactionPage]
156
+ def transactions(options = {})
158
157
  args = options.slice(:limit, :cursor)
159
158
 
160
159
  resource = if options[:account]
@@ -167,13 +166,11 @@ module Stellar
167
166
  TransactionPage.new(resource)
168
167
  end
169
168
 
170
- Contract(C::KeywordArgs[
171
- asset: [Symbol, String, Xor[Stellar::KeyPair, Stellar::Account]],
172
- source: Stellar::Account,
173
- sequence: Maybe[Integer],
174
- fee: Maybe[Integer],
175
- limit: Maybe[Integer],
176
- ] => Any)
169
+ # @param [Array(Symbol,String,Stellar::KeyPair|Stellar::Account)] asset
170
+ # @param [Stellar::Account] source
171
+ # @param [Integer] sequence
172
+ # @param [Integer] fee
173
+ # @param [Integer] limit
177
174
  def change_trust(
178
175
  asset:,
179
176
  source:,
@@ -186,27 +183,79 @@ module Stellar
186
183
  args = {
187
184
  account: source.keypair,
188
185
  sequence: sequence,
189
- line: asset,
186
+ line: asset
190
187
  }
191
- args[:limit] = limit if !limit.nil?
188
+ args[:limit] = limit unless limit.nil?
192
189
 
193
190
  tx = Stellar::Transaction.change_trust(args)
194
191
 
195
- envelope_base64 = tx.to_envelope(source.keypair).to_xdr(:base64)
196
- horizon.transactions._post(tx: envelope_base64)
192
+ envelope = tx.to_envelope(source.keypair)
193
+ submit_transaction(tx_envelope: envelope)
194
+ end
195
+
196
+ # @param [Stellar::TransactionEnvelope] tx_envelope
197
+ # @option options [Boolean] :skip_memo_required_check (false)
198
+ def submit_transaction(tx_envelope:, options: {skip_memo_required_check: false})
199
+ unless options[:skip_memo_required_check]
200
+ check_memo_required(tx_envelope)
201
+ end
202
+ @horizon.transactions._post(tx: Base64.encode64(tx_envelope.to_xdr))
203
+ end
204
+
205
+ # Required by SEP-0029
206
+ # @param [Stellar::TransactionEnvelope] tx_envelope
207
+ def check_memo_required(tx_envelope)
208
+ tx = tx_envelope.tx
209
+
210
+ if tx.is_a?(Stellar::FeeBumpTransaction)
211
+ tx = tx.inner_tx.v1!.tx
212
+ end
213
+
214
+ # Check transactions where the .memo field is nil or of type MemoType.memo_none
215
+ if !tx.memo.nil? && tx.memo.type != Stellar::MemoType.memo_none
216
+ return
217
+ end
218
+
219
+ destinations = Set.new
220
+ ot = Stellar::OperationType
221
+
222
+ tx.operations.each_with_index do |op, idx|
223
+ destination = case op.body.type
224
+ when ot.payment, ot.path_payment_strict_receive, ot.path_payment_strict_send
225
+ op.body.value.destination
226
+ when ot.account_merge
227
+ # There is no AccountMergeOp, op.body is an Operation object
228
+ # and op.body.value is a PublicKey (or AccountID) object.
229
+ op.body.value
230
+ else
231
+ next
232
+ end
233
+
234
+ if destinations.include?(destination) || destination.switch == Stellar::CryptoKeyType.key_type_muxed_ed25519
235
+ next
236
+ end
237
+
238
+ destinations.add(destination)
239
+ kp = Stellar::KeyPair.from_public_key(destination.value)
240
+
241
+ begin
242
+ info = account_info(kp.address)
243
+ rescue Faraday::ResourceNotFound
244
+ # Don't raise an error if its a 404, but throw one otherwise
245
+ next
246
+ end
247
+ if info.data["config.memo_required"] == "MQ=="
248
+ # MQ== is the base64 encoded string for the string "1"
249
+ raise AccountRequiresMemoError.new("account requires memo", destination, idx)
250
+ end
251
+ end
197
252
  end
198
253
 
199
- Contract(C::KeywordArgs[
200
- server: Stellar::KeyPair,
201
- client: Stellar::KeyPair,
202
- anchor_name: String,
203
- timeout: C::Optional[Integer]
204
- ] => String)
205
254
  # DEPRECATED: this function has been moved Stellar::SEP10.build_challenge_tx and
206
255
  # will be removed in the next major version release.
207
256
  #
208
257
  # A wrapper function for Stellar::SEP10::build_challenge_tx.
209
- #
258
+ #
210
259
  # @param server [Stellar::KeyPair] Keypair for server's signing account.
211
260
  # @param client [Stellar::KeyPair] Keypair for the account whishing to authenticate with the server.
212
261
  # @param anchor_name [String] Anchor's name to be used in the manage_data key.
@@ -219,10 +268,6 @@ module Stellar
219
268
  )
220
269
  end
221
270
 
222
- Contract(C::KeywordArgs[
223
- challenge: String,
224
- server: Stellar::KeyPair
225
- ] => C::Bool)
226
271
  # DEPRECATED: this function has been moved to Stellar::SEP10::read_challenge_tx and
227
272
  # will be removed in the next major version release.
228
273
  #
@@ -233,18 +278,14 @@ module Stellar
233
278
  #
234
279
  # @return [Boolean]
235
280
  def verify_challenge_tx(challenge:, server:)
236
- Stellar::SEP10.verify_challenge_tx(challenge_tx: challenge, server: server)
281
+ Stellar::SEP10.verify_challenge_tx(challenge_xdr: challenge, server: server)
237
282
  true
238
283
  end
239
284
 
240
- Contract(C::KeywordArgs[
241
- transaction_envelope: Stellar::TransactionEnvelope,
242
- keypair: Stellar::KeyPair
243
- ] => C::Bool)
244
285
  # DEPRECATED: this function has been moved to Stellar::SEP10::verify_tx_signed_by and
245
286
  # will be removed in the next major version release.
246
287
  #
247
- # @param transaction_envelope [Stellar::TransactionEnvelope]
288
+ # @param transaction_envelope [Stellar::TransactionEnvelope]
248
289
  # @param keypair [Stellar::KeyPair]
249
290
  #
250
291
  # @return [Boolean]
@@ -254,6 +295,5 @@ module Stellar
254
295
  tx_envelope: transaction_envelope, keypair: keypair
255
296
  )
256
297
  end
257
-
258
298
  end
259
299
  end