stellar-base 0.0.9 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6a47723e2d9150d6aea05202da7fb79397f38b41
4
- data.tar.gz: 6fe5b0dda6af9aac8f9932115f6a955cfa4cef9e
3
+ metadata.gz: bf4158b0f95f7338c96416a0398e13dbf91ae047
4
+ data.tar.gz: 6df5ab1153e3b0ed2f23d30c061d5065bccc2663
5
5
  SHA512:
6
- metadata.gz: fac3fc2d37981496c6988302c736ae5c2860b47bbed7dac258a3bdeef3f8d9d2bd4dedc6ba5d41db0526cb12cd98fc6429b55cbc1aac5a74df633459d4820a42
7
- data.tar.gz: 49dcadf00e391dc2ed30182a17f7c53fb619710debef5631d3e11876e6c291aba0b820b95db26037168d7661f2dc75f2608471a6a266b911acf0ece590bda8e5
6
+ metadata.gz: be53f549d08cba214888be4658913ec604881a3bc7ebe5afbe154ef060797389b31385f5ad37c796e2ee92c9e6215ee9aa7d14878f35af7e51cc443ec6cc681e
7
+ data.tar.gz: dd3d97061fc6ade77de67c6a47af1c9d7f23e81b45575fc3dafa473f6aab05bba0a326969488219aabeada7f5e326f927889c7c78afbd69ca06c7de4e770fba2
@@ -16,13 +16,11 @@ destination = Stellar::KeyPair.random
16
16
  tx = Stellar::Transaction.create_account({
17
17
  account: master,
18
18
  destination: destination,
19
- sequence: 1,
20
- starting_balance: 50_0000000
19
+ sequence: 2,
20
+ starting_balance: 50 * Stellar::ONE
21
21
  })
22
22
 
23
23
  hex = tx.to_envelope(master).to_xdr(:hex)
24
24
 
25
25
  result = $server.get('tx', blob: hex)
26
26
  p result.body
27
- raw = [result.body["result"]].pack("H*")
28
- p Stellar::TransactionResult.from_xdr(raw)
@@ -2,7 +2,7 @@
2
2
 
3
3
  # This is an example of using the raw xdr objects to post a transaction
4
4
  # notice that we must manually hash/sign the structures and we must manually
5
- # fill out all the fields.
5
+ # fill out all the fields.
6
6
  #
7
7
  # Look at mid_level_transaction_post.rb to see a friendlier form
8
8
 
@@ -22,7 +22,7 @@ tx.seq_num = 1
22
22
  payment = Stellar::PaymentOp.new
23
23
  payment.destination = destination.verify_key.to_bytes
24
24
  payment.currency = Stellar::Currency.new(:native)
25
- payment.amount = 200_000000
25
+ payment.amount = 200 * Stellar::ONE
26
26
 
27
27
  op = Stellar::Operation.new
28
28
  op.body = Stellar::Operation::Body.new(:payment, payment)
@@ -36,7 +36,7 @@ signature = master.sign(tx_hash)
36
36
  env = Stellar::TransactionEnvelope.new
37
37
  env.tx = tx
38
38
  env.signatures = [Stellar::DecoratedSignature.new({
39
- hint:master.verify_key.to_bytes[0...4],
39
+ hint:master.verify_key.to_bytes[0...4],
40
40
  signature:signature
41
41
  })]
42
42
 
@@ -44,4 +44,3 @@ env_hex = env.to_xdr.unpack("H*").first
44
44
 
45
45
  result = Faraday.get('http://localhost:39132/tx', blob: env_hex)
46
46
  puts result.body
47
-
@@ -24,11 +24,10 @@ tx = Stellar::Transaction.payment({
24
24
  account: master,
25
25
  destination: destination,
26
26
  sequence: 1,
27
- amount: [:native, 20_000000]
27
+ amount: [:native, 20 * Stellar::ONE]
28
28
  })
29
29
 
30
30
  hex = tx.to_envelope(master).to_xdr(:hex)
31
31
 
32
32
  result = $server.get('tx', blob: hex)
33
- raw = [result.body["result"]].pack("H*")
34
- p Stellar::TransactionResult.from_xdr(raw)
33
+ p result.body
@@ -7,7 +7,7 @@
7
7
  # You can see where these helpers are defined in the files underneath /lib,
8
8
  # which is where we extend the xdrgen generated source files with our higher
9
9
  # level api.
10
- #
10
+ #
11
11
  # NOTE: due to the way that sequence number for a new account are set, this
12
12
  # example is pretty cumbersome to run. It is only used for illustrative purposes
13
13
  # of the flow
@@ -25,7 +25,7 @@ def submit(key, tx)
25
25
  hex = tx.to_envelope(key).to_xdr(:hex)
26
26
  response = $server.get('tx', blob: hex)
27
27
  raw = [response.body["result"]].pack("H*")
28
- p Stellar::TransactionResult.from_xdr(raw)
28
+ p response.body
29
29
  end
30
30
 
31
31
  master = Stellar::KeyPair.from_raw_seed("allmylifemyhearthasbeensearching")
@@ -35,20 +35,20 @@ submit master, Stellar::Transaction.payment({
35
35
  account: master,
36
36
  destination: destination,
37
37
  sequence: 1,
38
- amount: [:native, 2000_000000]
38
+ amount: [:native, 2000 * Stellar::ONE]
39
39
  })
40
40
 
41
41
  # NOTE: after this step, you need to get the sequence number for destination
42
42
  # Which is based off of the ledger sequence number it was funded in.
43
43
  gets # pause to get the account's sequence from the hayashi db
44
44
 
45
- destination_sequence = FILL_ME_IN
45
+ destination_sequence = FILL_ME_IN
46
46
  # destination_sequence = 17179869185
47
47
 
48
48
  submit destination, Stellar::Transaction.change_trust({
49
49
  account: destination,
50
50
  sequence: destination_sequence,
51
- line: [:iso4217, "USD\x00", master],
51
+ line: [:alphanum, "USD\x00", master],
52
52
  limit: 1000
53
53
  })
54
54
 
@@ -56,5 +56,5 @@ submit master, Stellar::Transaction.payment({
56
56
  account: master,
57
57
  destination: destination,
58
58
  sequence: 3,
59
- amount: [:iso4217, "USD\x00", master, 100]
59
+ amount: [:alphanum, "USD\x00", master, 100]
60
60
  })
@@ -7,7 +7,7 @@
7
7
  # You can see where these helpers are defined in the files underneath /lib,
8
8
  # which is where we extend the xdrgen generated source files with our higher
9
9
  # level api.
10
- #
10
+ #
11
11
  # NOTE: due to the way that sequence number for a new account are set, this
12
12
  # example is pretty cumbersome to run. It is only used for illustrative purposes
13
13
  # of the flow
@@ -24,8 +24,7 @@ end
24
24
  def submit(key, tx)
25
25
  hex = tx.to_envelope(key).to_xdr(:hex)
26
26
  response = $server.get('tx', blob: hex)
27
- raw = [response.body["result"]].pack("H*")
28
- p Stellar::TransactionResult.from_xdr(raw)
27
+ p response.body
29
28
  end
30
29
 
31
30
  master = Stellar::KeyPair.from_raw_seed("allmylifemyhearthasbeensearching")
@@ -35,27 +34,27 @@ submit master, Stellar::Transaction.payment({
35
34
  account: master,
36
35
  destination: destination,
37
36
  sequence: 1,
38
- amount: [:native, 2000_000000]
37
+ amount: [:native, 2000 * Stellar::ONE]
39
38
  })
40
39
 
41
40
  # NOTE: after this step, you need to get the sequence number for destination
42
41
  # Which is based off of the ledger sequence number it was funded in.
43
42
  gets # pause to get the account's sequence from the hayashi db
44
43
 
45
- destination_sequence = FILL_ME_IN
44
+ destination_sequence = FILL_ME_IN
46
45
  # destination_sequence = 17179869185
47
46
 
48
47
  submit destination, Stellar::Transaction.change_trust({
49
48
  account: destination,
50
49
  sequence: destination_sequence,
51
- line: [:iso4217, "USD\x00", master],
50
+ line: [:alphanum, "USD\x00", master],
52
51
  limit: 1000
53
52
  })
54
53
 
55
54
  submit destination, Stellar::Transaction.change_trust({
56
55
  account: destination,
57
56
  sequence: destination_sequence + 1,
58
- line: [:iso4217, "EUR\x00", master],
57
+ line: [:alphanum, "EUR\x00", master],
59
58
  limit: 1000
60
59
  })
61
60
 
@@ -63,14 +62,14 @@ submit master, Stellar::Transaction.payment({
63
62
  account: master,
64
63
  destination: destination,
65
64
  sequence: destination_sequence + 2,
66
- amount: [:iso4217, "USD\x00", master, 1000]
65
+ amount: [:alphanum, "USD\x00", master, 1000]
67
66
  })
68
67
 
69
68
  submit master, Stellar::Transaction.create_offer({
70
69
  account: destination,
71
70
  sequence: destination_sequence + 3
72
- taker_gets: [:iso4217, "USD\x00", usd_gateway],
73
- taker_pays: [:iso4217, "EUR\x00", eur_gateway],
71
+ taker_gets: [:alphanum, "USD\x00", usd_gateway],
72
+ taker_pays: [:alphanum, "EUR\x00", eur_gateway],
74
73
  amount: 100,
75
74
  price: 2.0,
76
75
  })
@@ -9,14 +9,14 @@ tx1 = Stellar::Transaction.payment({
9
9
  account: master,
10
10
  destination: destination,
11
11
  sequence: 1,
12
- amount: [:native, 20_000000]
12
+ amount: [:native, 20 * Stellar::ONE]
13
13
  })
14
14
 
15
15
  tx2 = Stellar::Transaction.payment({
16
16
  account: master,
17
17
  destination: destination,
18
18
  sequence: 2,
19
- amount: [:native, 20_000000]
19
+ amount: [:native, 20 * Stellar::ONE]
20
20
  })
21
21
 
22
22
  hex = tx1.merge(tx2).to_envelope(master).to_xdr(:hex)
@@ -12,15 +12,17 @@ silence_warnings do
12
12
  end
13
13
  Stellar.load_all!
14
14
 
15
+ Stellar::ONE = 1_0000000
16
+
17
+
15
18
  # extensions onto the generated files must be loaded manually, below
16
19
 
17
20
  require_relative './stellar/account_flags'
18
21
  require_relative './stellar/currency'
19
22
  require_relative './stellar/key_pair'
20
23
  require_relative './stellar/operation'
21
- require_relative './stellar/payment_op'
22
24
  require_relative './stellar/price'
23
25
  require_relative './stellar/transaction'
24
26
  require_relative './stellar/transaction_envelope'
25
27
  require_relative './stellar/util/base58'
26
- require_relative './stellar/util/continued_fraction'
28
+ require_relative './stellar/util/continued_fraction'
@@ -1,5 +1,5 @@
1
1
  module Stellar
2
2
  module Base
3
- VERSION = "0.0.9"
3
+ VERSION = "0.0.10"
4
4
  end
5
5
  end
@@ -4,8 +4,9 @@ module Stellar
4
4
  new(:currency_type_native)
5
5
  end
6
6
 
7
- def self.iso4217(code, issuer)
7
+ def self.alphanum(code, issuer)
8
8
  raise ArgumentError, "Bad :issuer" unless issuer.is_a?(KeyPair)
9
+ code = normalize_code(code)
9
10
  an = AlphaNum.new({currency_code:code, issuer:issuer.public_key})
10
11
  new(:currency_type_alphanum, an)
11
12
  end
@@ -28,5 +29,11 @@ module Stellar
28
29
  def code
29
30
  self.alpha_num!.currency_code
30
31
  end
32
+
33
+ def self.normalize_code(code)
34
+ raise ArgumentError, "Invalid currency code: #{code}, must be <= 4 bytes" if code.length > 4
35
+
36
+ code.ljust(4, "\x00")
37
+ end
31
38
  end
32
- end
39
+ end
@@ -2,14 +2,14 @@ module Stellar
2
2
  class Operation
3
3
 
4
4
 
5
- #
5
+ #
6
6
  # Construct a new Stellar::Operation from the provided
7
7
  # source account and body
8
- #
8
+ #
9
9
  # @param [Hash] attributes the attributes to create the operation with
10
10
  # @option attributes [Stellar::KeyPair] :source_account
11
11
  # @option attributes [Stellar::Operation::Body] :body
12
- #
12
+ #
13
13
  # @return [Stellar::Operation] the built operation
14
14
  def self.make(attributes={})
15
15
  source_account = attributes[:source_account]
@@ -26,37 +26,70 @@ module Stellar
26
26
  end
27
27
 
28
28
 
29
- #
29
+ #
30
30
  # Helper method to create a valid PaymentOp, wrapped
31
- # in the necessary XDR structs to be included within a
31
+ # in the necessary XDR structs to be included within a
32
32
  # transactions `operations` array.
33
- #
33
+ #
34
34
  # @see Stellar::Currency
35
- #
35
+ #
36
36
  # @param [Hash] attributes the attributes to create the operation with
37
37
  # @option attributes [Stellar::KeyPair] :destination the receiver of the payment
38
38
  # @option attributes [Array] :amount the amount to pay
39
- # @option attributes [Array<Stellar::Currency>] :path the payment path to use
40
- #
41
- # @return [Stellar::Operation] the built operation, containing a
39
+ # @return [Stellar::Operation] the built operation, containing a
42
40
  # Stellar::PaymentOp body
43
41
  def self.payment(attributes={})
44
42
  destination = attributes[:destination]
45
- amount = attributes[:amount]
46
- # path = attributes[:path] || []
47
- # path = path.map{|p| Stellar::Currency.send(*p)}
43
+ currency, amount = extract_amount(attributes[:amount])
48
44
 
49
45
  raise ArgumentError unless destination.is_a?(KeyPair)
50
46
 
51
- op = PaymentOp.send(*amount)
47
+
48
+ op = PaymentOp.new
49
+ op.currency = currency
50
+ op.amount = amount
52
51
  op.destination = destination.public_key
53
- op.apply_defaults
54
52
 
55
53
  return make(attributes.merge({
56
54
  body:[:payment, op]
57
55
  }))
58
56
  end
59
57
 
58
+ #
59
+ # Helper method to create a valid PathPaymentOp, wrapped
60
+ # in the necessary XDR structs to be included within a
61
+ # transactions `operations` array.
62
+ #
63
+ # @see Stellar::Currency
64
+ #
65
+ # @param [Hash] attributes the attributes to create the operation with
66
+ # @option attributes [Stellar::KeyPair] :destination the receiver of the payment
67
+ # @option attributes [Array] :amount the amount to pay
68
+ # @option attributes [Array] :with the source currency and maximum allowed source amount to pay with
69
+ # @option attributes [Array<Stellar::Currency>] :path the payment path to use
70
+ #
71
+ # @return [Stellar::Operation] the built operation, containing a
72
+ # Stellar::PaymentOp body
73
+ def self.path_payment(attributes={})
74
+ destination = attributes[:destination]
75
+ currency, amount = extract_amount(attributes[:amount])
76
+ send_currency, send_max = extract_amount(attributes[:with])
77
+ path = (attributes[:path] || []).map{|p| Stellar::Currency.send(*p)}
78
+
79
+ raise ArgumentError unless destination.is_a?(KeyPair)
80
+
81
+ op = PathPaymentOp.new
82
+ op.send_currency = send_currency
83
+ op.send_max = send_max
84
+ op.destination = destination.public_key
85
+ op.dest_currency = currency
86
+ op.dest_amount = amount
87
+ op.path = path
88
+
89
+ return make(attributes.merge({
90
+ body:[:path_payment, op]
91
+ }))
92
+ end
60
93
 
61
94
  def self.create_account(attributes={})
62
95
  destination = attributes[:destination]
@@ -73,16 +106,16 @@ module Stellar
73
106
  }))
74
107
  end
75
108
 
76
- #
109
+ #
77
110
  # Helper method to create a valid ChangeTrustOp, wrapped
78
- # in the necessary XDR structs to be included within a
111
+ # in the necessary XDR structs to be included within a
79
112
  # transactions `operations` array.
80
- #
113
+ #
81
114
  # @param [Hash] attributes the attributes to create the operation with
82
115
  # @option attributes [Stellar::Currrency] :line the currency to trust
83
116
  # @option attributes [Fixnum] :limit the maximum amount to trust
84
- #
85
- # @return [Stellar::Operation] the built operation, containing a
117
+ #
118
+ # @return [Stellar::Operation] the built operation, containing a
86
119
  # Stellar::ChangeTrustOp body
87
120
  def self.change_trust(attributes={})
88
121
  line = Currency.send(*attributes[:line])
@@ -105,31 +138,31 @@ module Stellar
105
138
  price = Price.from_f(attributes[:price])
106
139
 
107
140
  op = CreateOfferOp.new({
108
- taker_pays: taker_pays,
141
+ taker_pays: taker_pays,
109
142
  taker_gets: taker_gets,
110
143
  amount: amount,
111
144
  price: price,
112
145
  offer_id: offer_id
113
146
  })
114
-
147
+
115
148
  return make(attributes.merge({
116
149
  body:[:create_offer, op]
117
150
  }))
118
151
  end
119
152
 
120
- #
153
+ #
121
154
  # Helper method to create a valid SetOptionsOp, wrapped
122
- # in the necessary XDR structs to be included within a
155
+ # in the necessary XDR structs to be included within a
123
156
  # transactions `operations` array.
124
- #
157
+ #
125
158
  # @param [Hash] attributes the attributes to create the operation with
126
159
  # @option attributes [Stellar::KeyPair] :inflation_dest
127
160
  # @option attributes [Array<Stellar::AccountFlags>] :set flags to set
128
161
  # @option attributes [Array<Stellar::AccountFlags>] :clear flags to clear
129
162
  # @option attributes [String] :thresholds
130
163
  # @option attributes [Stellar::Signer] :signer
131
- #
132
- # @return [Stellar::Operation] the built operation, containing a
164
+ #
165
+ # @return [Stellar::Operation] the built operation, containing a
133
166
  # Stellar::SetOptionsOp body
134
167
  def self.set_options(attributes={})
135
168
  op = SetOptionsOp.new()
@@ -145,35 +178,35 @@ module Stellar
145
178
  op.inflation_dest = inflation_dest.public_key
146
179
  end
147
180
 
148
-
181
+
149
182
  return make(attributes.merge({
150
183
  body:[:set_options, op]
151
184
  }))
152
185
  end
153
186
 
154
- #
187
+ #
155
188
  # Helper method to create a valid AllowTrustOp, wrapped
156
- # in the necessary XDR structs to be included within a
189
+ # in the necessary XDR structs to be included within a
157
190
  # transactions `operations` array.
158
- #
191
+ #
159
192
  # @param [Hash] attributes the attributes to create the operation with
160
193
  # @option attributes [Stellar::KeyPair] :trustor
161
194
  # @option attributes [Stellar::Currency] :currency
162
- #
163
- # @return [Stellar::Operation] the built operation, containing a
195
+ #
196
+ # @return [Stellar::Operation] the built operation, containing a
164
197
  # Stellar::AllowTrustOp body
165
198
  def self.allow_trust(attributes={})
166
199
  op = AllowTrustOp.new()
167
-
200
+
168
201
  trustor = attributes[:trustor]
169
202
  authorize = attributes[:authorize]
170
203
  currency = Currency.send(*attributes[:currency])
171
204
 
172
205
  raise ArgumentError, "Bad :trustor" unless trustor.is_a?(Stellar::KeyPair)
173
206
  raise ArgumentError, "Bad :authorize" unless authorize == !!authorize # check boolean
174
- raise ArgumentError, "Bad :currency" unless currency.type == Stellar::CurrencyType.iso4217
207
+ raise ArgumentError, "Bad :currency" unless currency.type == Stellar::CurrencyType.alphanum
175
208
 
176
- atc = AllowTrustOp::Currency.new(:iso4217, currency.code)
209
+ atc = AllowTrustOp::Currency.new(:alphanum, currency.code)
177
210
 
178
211
  op.trustor = trustor.public_key
179
212
  op.authorize = authorize
@@ -184,12 +217,12 @@ module Stellar
184
217
  }))
185
218
  end
186
219
 
187
- #
220
+ #
188
221
  # Helper method to create an account merge operation
189
- #
222
+ #
190
223
  # @param [Hash] attributes the attributes to create the operation with
191
224
  # @option attributes [Stellar::KeyPair] :destination
192
- #
225
+ #
193
226
  # @return [Stellar::Operation] the built operation
194
227
  def self.account_merge(attributes={})
195
228
  destination = attributes[:destination]
@@ -202,12 +235,12 @@ module Stellar
202
235
  }))
203
236
  end
204
237
 
205
- #
238
+ #
206
239
  # Helper method to create an inflation operation
207
- #
240
+ #
208
241
  # @param [Hash] attributes the attributes to create the operation with
209
242
  # @option attributes [Integer] :sequence
210
- #
243
+ #
211
244
  # @return [Stellar::Operation] the built operation
212
245
  def self.inflation(attributes={})
213
246
  sequence = attributes[:sequence]
@@ -219,5 +252,13 @@ module Stellar
219
252
  body:[:inflation, sequence]
220
253
  }))
221
254
  end
255
+
256
+ private
257
+ def self.extract_amount(a)
258
+ amount = a.last
259
+ currency = Stellar::Currency.send(*a[0...-1])
260
+
261
+ return currency, amount
262
+ end
222
263
  end
223
- end
264
+ end
@@ -1,65 +1,71 @@
1
1
  module Stellar
2
2
  class Transaction
3
3
 
4
- #
4
+ #
5
5
  # @see Stellar::Operation.payment
6
6
  def self.payment(attributes={})
7
7
  make :payment, attributes
8
8
  end
9
9
 
10
- #
10
+ #
11
+ # @see Stellar::Operation.path_payment
12
+ def self.path_payment(attributes={})
13
+ make :path_payment, attributes
14
+ end
15
+
16
+ #
11
17
  # @see Stellar::Operation.create_account
12
18
  def self.create_account(attributes={})
13
19
  make :create_account, attributes
14
20
  end
15
21
 
16
- #
22
+ #
17
23
  # @see Stellar::Operation.change_trust
18
24
  def self.change_trust(attributes={})
19
25
  make :change_trust, attributes
20
26
  end
21
27
 
22
- #
28
+ #
23
29
  # @see Stellar::Operation.create_offer
24
30
  def self.create_offer(attributes={})
25
31
  make :create_offer, attributes
26
32
  end
27
33
 
28
- #
34
+ #
29
35
  # @see Stellar::Operation.set_options
30
36
  def self.set_options(attributes={})
31
37
  make :set_options, attributes
32
38
  end
33
39
 
34
- #
40
+ #
35
41
  # @see Stellar::Operation.allow_trust
36
42
  def self.allow_trust(attributes={})
37
43
  make :allow_trust, attributes
38
44
  end
39
-
40
- #
45
+
46
+ #
41
47
  # @see Stellar::Operation.account_merge
42
48
  def self.account_merge(attributes={})
43
49
  make :account_merge, attributes
44
50
  end
45
-
46
- #
51
+
52
+ #
47
53
  # @see Stellar::Operation.inflation
48
54
  def self.inflation(attributes={})
49
55
  make :inflation, attributes
50
56
  end
51
57
 
52
- #
58
+ #
53
59
  # Helper method to create a transaction with a single
54
60
  # operation of the provided type. See class methods
55
- # on Stellar::Operation for available values for
61
+ # on Stellar::Operation for available values for
56
62
  # operation_type.
57
- #
63
+ #
58
64
  # @see Stellar::Operation
59
- #
65
+ #
60
66
  # @param operation_type [Symbol] the operation to use
61
67
  # @param attributes={} [Hash] attributes to use for both the transaction and the operation
62
- #
68
+ #
63
69
  # @return [Stellar::Transaction] the resulting transaction
64
70
  def self.make(operation_type, attributes={})
65
71
  for_account(attributes).tap do |result|
@@ -68,20 +74,20 @@ module Stellar
68
74
  end
69
75
 
70
76
 
71
- #
72
- # Helper method to create the skeleton of a transaction.
77
+ #
78
+ # Helper method to create the skeleton of a transaction.
73
79
  # The resulting transaction will have its source account,
74
- # sequence, fee, min ledger and max ledger set.
75
- #
76
- #
80
+ # sequence, fee, min ledger and max ledger set.
81
+ #
82
+ #
77
83
  # @param attributes={} [type] [description]
78
- #
84
+ #
79
85
  # @return [Stellar::Transaction] the resulting skeleton
80
86
  def self.for_account(attributes={})
81
87
  account = attributes[:account]
82
88
  sequence = attributes[:sequence]
83
89
  fee = attributes[:fee]
84
-
90
+
85
91
  raise ArgumentError, "Bad :account" unless account.is_a?(KeyPair) && account.sign?
86
92
  raise ArgumentError, "Bad :sequence #{sequence}" unless sequence.is_a?(Integer)
87
93
  raise ArgumentError, "Bad :fee #{sequence}" if fee.present? && !fee.is_a?(Integer)
@@ -108,7 +114,7 @@ module Stellar
108
114
 
109
115
  def to_envelope(*key_pairs)
110
116
  signatures = key_pairs.map(&method(:sign_decorated))
111
-
117
+
112
118
  TransactionEnvelope.new({
113
119
  :signatures => signatures,
114
120
  :tx => self
@@ -122,12 +128,12 @@ module Stellar
122
128
  end
123
129
 
124
130
 
125
- #
131
+ #
126
132
  # Extracts the operations from this single transaction,
127
133
  # setting the source account on the extracted operations.
128
- #
134
+ #
129
135
  # Useful for merging transactions.
130
- #
136
+ #
131
137
  # @return [Array<Operation>] the operations
132
138
  def to_operations
133
139
  cloned = Marshal.load Marshal.dump(operations)
@@ -142,4 +148,4 @@ module Stellar
142
148
  self.memo ||= Memo.new(:memo_none)
143
149
  end
144
150
  end
145
- end
151
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stellar-base
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Fleckenstein
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-14 00:00:00.000000000 Z
11
+ date: 2015-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xdr
@@ -299,7 +299,6 @@ files:
299
299
  - lib/stellar/currency.rb
300
300
  - lib/stellar/key_pair.rb
301
301
  - lib/stellar/operation.rb
302
- - lib/stellar/payment_op.rb
303
302
  - lib/stellar/price.rb
304
303
  - lib/stellar/transaction.rb
305
304
  - lib/stellar/transaction_envelope.rb
@@ -1,28 +0,0 @@
1
- module Stellar
2
- class PaymentOp
3
-
4
- def self.native(amount)
5
- currency = Stellar::Currency.native
6
- with_currency(currency).tap do |result|
7
- result.amount = amount
8
- end
9
- end
10
-
11
- def self.iso4217(code, issuer, amount)
12
- currency = Stellar::Currency.iso4217(code, issuer)
13
- with_currency(currency).tap do |result|
14
- result.amount = amount
15
- end
16
- end
17
-
18
- def self.with_currency(currency)
19
- new.tap do |result|
20
- result.currency = currency
21
- end
22
- end
23
-
24
- def apply_defaults
25
- end
26
-
27
- end
28
- end