stellar-base 0.0.20 → 0.1.0

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.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -14
  3. data/examples/low_level_transaction_post.rb +1 -1
  4. data/examples/non_native_payment.rb +2 -2
  5. data/examples/offer.rb +5 -5
  6. data/generated/stellar-base-generated.rb +4 -5
  7. data/generated/stellar/account_flags.rb +1 -1
  8. data/generated/stellar/allow_trust_op.rb +11 -8
  9. data/generated/stellar/allow_trust_op/asset.rb +33 -0
  10. data/generated/stellar/allow_trust_result_code.rb +1 -1
  11. data/generated/stellar/asset.rb +47 -0
  12. data/generated/stellar/{currency/alpha_num.rb → asset/alpha_num12.rb} +5 -5
  13. data/generated/stellar/asset/alpha_num4.rb +22 -0
  14. data/generated/stellar/asset_type.rb +24 -0
  15. data/generated/stellar/change_trust_op.rb +2 -2
  16. data/generated/stellar/claim_offer_atom.rb +10 -10
  17. data/generated/stellar/create_passive_offer_op.rb +8 -8
  18. data/generated/stellar/crypto_key_type.rb +2 -2
  19. data/generated/stellar/ledger_key.rb +2 -2
  20. data/generated/stellar/ledger_key/offer.rb +3 -3
  21. data/generated/stellar/ledger_key/trust_line.rb +2 -2
  22. data/generated/stellar/manage_offer_op.rb +9 -9
  23. data/generated/stellar/offer_entry.rb +11 -11
  24. data/generated/stellar/{currency_type.rb → operation_meta.rb} +4 -8
  25. data/generated/stellar/path_payment_op.rb +10 -10
  26. data/generated/stellar/path_payment_result_code.rb +2 -2
  27. data/generated/stellar/payment_op.rb +2 -2
  28. data/generated/stellar/payment_result_code.rb +2 -2
  29. data/generated/stellar/public_key.rb +2 -2
  30. data/generated/stellar/simple_payment_result.rb +2 -2
  31. data/generated/stellar/transaction_meta.rb +17 -4
  32. data/generated/stellar/transaction_meta/v0.rb +22 -0
  33. data/generated/stellar/trust_line_entry.rb +4 -4
  34. data/lib/stellar-base.rb +2 -2
  35. data/lib/stellar/asset.rb +38 -0
  36. data/lib/stellar/base/version.rb +1 -1
  37. data/lib/stellar/convert.rb +1 -5
  38. data/lib/stellar/key_pair.rb +6 -6
  39. data/lib/stellar/operation.rb +24 -24
  40. data/lib/stellar/path_payment_result.rb +2 -2
  41. data/lib/stellar/util/strkey.rb +43 -0
  42. data/ruby-stellar-base.gemspec +2 -0
  43. data/spec/lib/stellar/key_pair_spec.rb +12 -12
  44. data/spec/lib/stellar/path_payment_result_spec.rb +7 -7
  45. data/spec/lib/stellar/transaction_spec.rb +1 -1
  46. data/spec/lib/stellar/util/strkey_spec.rb +46 -0
  47. data/spec/support/matchers/be_strkey.rb +9 -0
  48. data/tasks/xdr.rake +7 -8
  49. data/xdr/Stellar-SCP.x +1 -1
  50. data/xdr/Stellar-ledger-entries.x +26 -18
  51. data/xdr/Stellar-ledger.x +17 -5
  52. data/xdr/Stellar-overlay.x +1 -1
  53. data/xdr/Stellar-transaction.x +39 -36
  54. data/xdr/Stellar-types.x +2 -3
  55. metadata +43 -13
  56. data/generated/stellar/allow_trust_op/currency.rb +0 -28
  57. data/generated/stellar/currency.rb +0 -37
  58. data/lib/stellar/currency.rb +0 -39
  59. data/lib/stellar/util/base58.rb +0 -127
  60. data/spec/lib/stellar/util/base58_spec.rb +0 -74
  61. data/spec/support/matchers/be_base58_check.rb +0 -9
  62. data/xdr/StellarXDR.x +0 -11
@@ -2,7 +2,7 @@
2
2
  // under the Apache License, Version 2.0. See the COPYING file at the root
3
3
  // of this distribution or at http://www.apache.org/licenses/LICENSE-2.0
4
4
 
5
- %#include "generated/Stellar-transaction.h"
5
+ %#include "xdr/Stellar-transaction.h"
6
6
 
7
7
  namespace stellar
8
8
  {
@@ -102,13 +102,13 @@ case TRUSTLINE:
102
102
  struct
103
103
  {
104
104
  AccountID accountID;
105
- Currency currency;
105
+ Asset asset;
106
106
  } trustLine;
107
107
 
108
108
  case OFFER:
109
109
  struct
110
110
  {
111
- AccountID accountID;
111
+ AccountID sellerID;
112
112
  uint64 offerID;
113
113
  } offer;
114
114
  };
@@ -212,8 +212,20 @@ case LEDGER_ENTRY_REMOVED:
212
212
  LedgerKey removed;
213
213
  };
214
214
 
215
- struct TransactionMeta
215
+ typedef LedgerEntryChange LedgerEntryChanges<>;
216
+
217
+ struct OperationMeta
216
218
  {
217
- LedgerEntryChange changes<>;
219
+ LedgerEntryChanges changes;
220
+ };
221
+
222
+ union TransactionMeta switch (int v)
223
+ {
224
+ case 0:
225
+ struct
226
+ {
227
+ LedgerEntryChanges changes;
228
+ OperationMeta operations<>;
229
+ } v0;
218
230
  };
219
231
  }
@@ -2,7 +2,7 @@
2
2
  // under the Apache License, Version 2.0. See the COPYING file at the root
3
3
  // of this distribution or at http://www.apache.org/licenses/LICENSE-2.0
4
4
 
5
- %#include "generated/Stellar-ledger.h"
5
+ %#include "xdr/Stellar-ledger.h"
6
6
 
7
7
  namespace stellar
8
8
  {
@@ -2,7 +2,7 @@
2
2
  // under the Apache License, Version 2.0. See the COPYING file at the root
3
3
  // of this distribution or at http://www.apache.org/licenses/LICENSE-2.0
4
4
 
5
- %#include "generated/Stellar-ledger-entries.h"
5
+ %#include "xdr/Stellar-ledger-entries.h"
6
6
 
7
7
  namespace stellar
8
8
  {
@@ -28,7 +28,7 @@ enum OperationType
28
28
  };
29
29
 
30
30
  /* CreateAccount
31
- Funds a new account with the specified starting balance
31
+ Creates and funds a new account with the specified starting balance.
32
32
 
33
33
  Threshold: med
34
34
 
@@ -44,7 +44,7 @@ struct CreateAccountOp
44
44
 
45
45
  /* Payment
46
46
 
47
- send an amount to a destination account.
47
+ Send an amount in specified asset to a destination account.
48
48
 
49
49
  Threshold: med
50
50
 
@@ -53,16 +53,16 @@ struct CreateAccountOp
53
53
  struct PaymentOp
54
54
  {
55
55
  AccountID destination; // recipient of the payment
56
- Currency currency; // what they end up with
56
+ Asset asset; // what they end up with
57
57
  int64 amount; // amount they end up with
58
58
  };
59
59
 
60
60
  /* PathPayment
61
61
 
62
62
  send an amount to a destination account through a path.
63
- (up to sendMax, sendCurrency)
63
+ (up to sendMax, sendAsset)
64
64
  (X0, Path[0]) .. (Xn, Path[n])
65
- (destAmount, destCurrency)
65
+ (destAmount, destAsset)
66
66
 
67
67
  Threshold: med
68
68
 
@@ -70,16 +70,16 @@ Result: PathPaymentResult
70
70
  */
71
71
  struct PathPaymentOp
72
72
  {
73
- Currency sendCurrency; // currency we pay with
74
- int64 sendMax; // the maximum amount of sendCurrency to
73
+ Asset sendAsset; // asset we pay with
74
+ int64 sendMax; // the maximum amount of sendAsset to
75
75
  // send (excluding fees).
76
76
  // The operation will fail if can't be met
77
77
 
78
78
  AccountID destination; // recipient of the payment
79
- Currency destCurrency; // what they end up with
79
+ Asset destAsset; // what they end up with
80
80
  int64 destAmount; // amount they end up with
81
81
 
82
- Currency path<5>; // additional hops it must go through to get there
82
+ Asset path<5>; // additional hops it must go through to get there
83
83
  };
84
84
 
85
85
  /* Creates, updates or deletes an offer
@@ -91,10 +91,10 @@ Result: ManageOfferResult
91
91
  */
92
92
  struct ManageOfferOp
93
93
  {
94
- Currency takerGets;
95
- Currency takerPays;
96
- int64 amount; // amount taker gets. if set to 0, delete the offer
97
- Price price; // =takerPaysAmount/takerGetsAmount
94
+ Asset selling;
95
+ Asset buying;
96
+ int64 amount; // amount being sold. if set to 0, delete the offer
97
+ Price price; // price of thing being sold in terms of what you are buying
98
98
 
99
99
  // 0=create a new offer, otherwise edit an existing offer
100
100
  uint64 offerID;
@@ -109,10 +109,10 @@ Result: CreatePassiveOfferResult
109
109
  */
110
110
  struct CreatePassiveOfferOp
111
111
  {
112
- Currency takerGets;
113
- Currency takerPays;
114
- int64 amount; // amount taker gets. if set to 0, delete the offer
115
- Price price; // =takerPaysAmount/takerGetsAmount
112
+ Asset selling; // A
113
+ Asset buying; // B
114
+ int64 amount; // amount taker gets. if set to 0, delete the offer
115
+ Price price; // cost of A in terms of B
116
116
  };
117
117
 
118
118
  /* Set Account Options
@@ -154,14 +154,14 @@ struct SetOptionsOp
154
154
  */
155
155
  struct ChangeTrustOp
156
156
  {
157
- Currency line;
157
+ Asset line;
158
158
 
159
159
  // if limit is set to 0, deletes the trust line
160
160
  int64 limit;
161
161
  };
162
162
 
163
163
  /* Updates the "authorized" flag of an existing trust line
164
- this is called by the issuer of the related currency.
164
+ this is called by the issuer of the related asset.
165
165
 
166
166
  note that authorize can only be set (and not cleared) if
167
167
  the issuer account does not have the AUTH_REVOCABLE_FLAG set
@@ -172,15 +172,18 @@ struct ChangeTrustOp
172
172
  struct AllowTrustOp
173
173
  {
174
174
  AccountID trustor;
175
- union switch (CurrencyType type)
175
+ union switch (AssetType type)
176
176
  {
177
- // CURRENCY_TYPE_NATIVE is not allowed
178
- case CURRENCY_TYPE_ALPHANUM:
179
- opaque currencyCode[4];
177
+ // ASSET_TYPE_NATIVE is not allowed
178
+ case ASSET_TYPE_CREDIT_ALPHANUM4:
179
+ opaque assetCode4[4];
180
180
 
181
- // add other currency types here in the future
181
+ case ASSET_TYPE_CREDIT_ALPHANUM12:
182
+ opaque assetCode12[12];
183
+
184
+ // add other asset types here in the future
182
185
  }
183
- currency;
186
+ asset;
184
187
 
185
188
  bool authorize;
186
189
  };
@@ -316,12 +319,12 @@ struct ClaimOfferAtom
316
319
  AccountID offerOwner; // Account that owns the offer
317
320
  uint64 offerID;
318
321
 
319
- // amount and currency taken from the owner
320
- Currency currencyClaimed;
322
+ // amount and asset taken from the owner
323
+ Asset assetClaimed;
321
324
  int64 amountClaimed;
322
325
 
323
- // amount and currencysent to the owner
324
- Currency currencySend;
326
+ // amount and assetsent to the owner
327
+ Asset assetSend;
325
328
  int64 amountSend;
326
329
  };
327
330
 
@@ -361,8 +364,8 @@ enum PaymentResultCode
361
364
  PAYMENT_SRC_NO_TRUST = -3, // no trust line on source account
362
365
  PAYMENT_SRC_NOT_AUTHORIZED = -4, // source not authorized to transfer
363
366
  PAYMENT_NO_DESTINATION = -5, // destination account does not exist
364
- PAYMENT_NO_TRUST = -6, // destination missing a trust line for currency
365
- PAYMENT_NOT_AUTHORIZED = -7, // destination not authorized to hold currency
367
+ PAYMENT_NO_TRUST = -6, // destination missing a trust line for asset
368
+ PAYMENT_NOT_AUTHORIZED = -7, // destination not authorized to hold asset
366
369
  PAYMENT_LINE_FULL = -8 // destination would go above their limit
367
370
  };
368
371
 
@@ -387,8 +390,8 @@ enum PathPaymentResultCode
387
390
  PATH_PAYMENT_SRC_NO_TRUST = -3, // no trust line on source account
388
391
  PATH_PAYMENT_SRC_NOT_AUTHORIZED = -4, // source not authorized to transfer
389
392
  PATH_PAYMENT_NO_DESTINATION = -5, // destination account does not exist
390
- PATH_PAYMENT_NO_TRUST = -6, // dest missing a trust line for currency
391
- PATH_PAYMENT_NOT_AUTHORIZED = -7, // dest not authorized to hold currency
393
+ PATH_PAYMENT_NO_TRUST = -6, // dest missing a trust line for asset
394
+ PATH_PAYMENT_NOT_AUTHORIZED = -7, // dest not authorized to hold asset
392
395
  PATH_PAYMENT_LINE_FULL = -8, // dest would go above their limit
393
396
  PATH_PAYMENT_TOO_FEW_OFFERS = -9, // not enough offers to satisfy path
394
397
  PATH_PAYMENT_OVER_SENDMAX = -10 // could not satisfy sendmax
@@ -397,7 +400,7 @@ enum PathPaymentResultCode
397
400
  struct SimplePaymentResult
398
401
  {
399
402
  AccountID destination;
400
- Currency currency;
403
+ Asset asset;
401
404
  int64 amount;
402
405
  };
403
406
 
@@ -521,7 +524,7 @@ enum AllowTrustResultCode
521
524
  // codes considered as "success" for the operation
522
525
  ALLOW_TRUST_SUCCESS = 0,
523
526
  // codes considered as "failure" for the operation
524
- ALLOW_TRUST_MALFORMED = -1, // currency is not CURRENCY_TYPE_ALPHANUM
527
+ ALLOW_TRUST_MALFORMED = -1, // asset is not ASSET_TYPE_ALPHANUM
525
528
  ALLOW_TRUST_NO_TRUST_LINE = -2, // trustor does not have a trustline
526
529
  // source account does not require trust
527
530
  ALLOW_TRUST_TRUST_NOT_REQUIRED = -3,
@@ -16,12 +16,12 @@ typedef hyper int64;
16
16
 
17
17
  enum CryptoKeyType
18
18
  {
19
- KEY_TYPES_ED25519 = 0
19
+ KEY_TYPE_ED25519 = 0
20
20
  };
21
21
 
22
22
  union PublicKey switch (CryptoKeyType type)
23
23
  {
24
- case KEY_TYPES_ED25519:
24
+ case KEY_TYPE_ED25519:
25
25
  uint256 ed25519;
26
26
  };
27
27
 
@@ -31,5 +31,4 @@ typedef opaque Signature<64>;
31
31
  typedef opaque SignatureHint[4];
32
32
 
33
33
  typedef PublicKey NodeID;
34
-
35
34
  }
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.20
4
+ version: 0.1.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: 2015-07-09 00:00:00.000000000 Z
11
+ date: 2015-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xdr
@@ -24,6 +24,34 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.0.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: digest-crc
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: base32
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: rbnacl
29
57
  requirement: !ruby/object:Gem::Requirement
@@ -221,9 +249,13 @@ files:
221
249
  - generated/stellar/account_merge_result.rb
222
250
  - generated/stellar/account_merge_result_code.rb
223
251
  - generated/stellar/allow_trust_op.rb
224
- - generated/stellar/allow_trust_op/currency.rb
252
+ - generated/stellar/allow_trust_op/asset.rb
225
253
  - generated/stellar/allow_trust_result.rb
226
254
  - generated/stellar/allow_trust_result_code.rb
255
+ - generated/stellar/asset.rb
256
+ - generated/stellar/asset/alpha_num12.rb
257
+ - generated/stellar/asset/alpha_num4.rb
258
+ - generated/stellar/asset_type.rb
227
259
  - generated/stellar/bucket_entry.rb
228
260
  - generated/stellar/bucket_entry_type.rb
229
261
  - generated/stellar/change_trust_op.rb
@@ -235,9 +267,6 @@ files:
235
267
  - generated/stellar/create_account_result_code.rb
236
268
  - generated/stellar/create_passive_offer_op.rb
237
269
  - generated/stellar/crypto_key_type.rb
238
- - generated/stellar/currency.rb
239
- - generated/stellar/currency/alpha_num.rb
240
- - generated/stellar/currency_type.rb
241
270
  - generated/stellar/decorated_signature.rb
242
271
  - generated/stellar/dont_have.rb
243
272
  - generated/stellar/envelope_type.rb
@@ -274,6 +303,7 @@ files:
274
303
  - generated/stellar/offer_entry_flags.rb
275
304
  - generated/stellar/operation.rb
276
305
  - generated/stellar/operation/body.rb
306
+ - generated/stellar/operation_meta.rb
277
307
  - generated/stellar/operation_result.rb
278
308
  - generated/stellar/operation_result/tr.rb
279
309
  - generated/stellar/operation_result_code.rb
@@ -316,6 +346,7 @@ files:
316
346
  - generated/stellar/transaction_history_result_entry.rb
317
347
  - generated/stellar/transaction_history_result_entry/ext.rb
318
348
  - generated/stellar/transaction_meta.rb
349
+ - generated/stellar/transaction_meta/v0.rb
319
350
  - generated/stellar/transaction_result.rb
320
351
  - generated/stellar/transaction_result/ext.rb
321
352
  - generated/stellar/transaction_result/result.rb
@@ -328,10 +359,10 @@ files:
328
359
  - generated/stellar/trust_line_flags.rb
329
360
  - lib/stellar-base.rb
330
361
  - lib/stellar/account_flags.rb
362
+ - lib/stellar/asset.rb
331
363
  - lib/stellar/base.rb
332
364
  - lib/stellar/base/version.rb
333
365
  - lib/stellar/convert.rb
334
- - lib/stellar/currency.rb
335
366
  - lib/stellar/key_pair.rb
336
367
  - lib/stellar/operation.rb
337
368
  - lib/stellar/path_payment_result.rb
@@ -339,8 +370,8 @@ files:
339
370
  - lib/stellar/thresholds.rb
340
371
  - lib/stellar/transaction.rb
341
372
  - lib/stellar/transaction_envelope.rb
342
- - lib/stellar/util/base58.rb
343
373
  - lib/stellar/util/continued_fraction.rb
374
+ - lib/stellar/util/strkey.rb
344
375
  - ruby-stellar-base.gemspec
345
376
  - spec/lib/stellar/account_flags_spec.rb
346
377
  - spec/lib/stellar/convert_spec.rb
@@ -350,9 +381,9 @@ files:
350
381
  - spec/lib/stellar/thresholds_spec.rb
351
382
  - spec/lib/stellar/transaction_envelope_spec.rb
352
383
  - spec/lib/stellar/transaction_spec.rb
353
- - spec/lib/stellar/util/base58_spec.rb
384
+ - spec/lib/stellar/util/strkey_spec.rb
354
385
  - spec/spec_helper.rb
355
- - spec/support/matchers/be_base58_check.rb
386
+ - spec/support/matchers/be_strkey.rb
356
387
  - spec/support/matchers/eq_bytes.rb
357
388
  - spec/support/matchers/have_length.rb
358
389
  - tasks/rspec.rake
@@ -364,7 +395,6 @@ files:
364
395
  - xdr/Stellar-overlay.x
365
396
  - xdr/Stellar-transaction.x
366
397
  - xdr/Stellar-types.x
367
- - xdr/StellarXDR.x
368
398
  homepage: https://github.com/stellar/ruby-stellar-base
369
399
  licenses:
370
400
  - Apache 2.0
@@ -399,9 +429,9 @@ test_files:
399
429
  - spec/lib/stellar/thresholds_spec.rb
400
430
  - spec/lib/stellar/transaction_envelope_spec.rb
401
431
  - spec/lib/stellar/transaction_spec.rb
402
- - spec/lib/stellar/util/base58_spec.rb
432
+ - spec/lib/stellar/util/strkey_spec.rb
403
433
  - spec/spec_helper.rb
404
- - spec/support/matchers/be_base58_check.rb
434
+ - spec/support/matchers/be_strkey.rb
405
435
  - spec/support/matchers/eq_bytes.rb
406
436
  - spec/support/matchers/have_length.rb
407
437
  has_rdoc:
@@ -1,28 +0,0 @@
1
- # This code was automatically generated using xdrgen
2
- # DO NOT EDIT or your changes may be overwritten
3
-
4
- require 'xdr'
5
-
6
- # === xdr source ============================================================
7
- #
8
- # union switch (CurrencyType type)
9
- # {
10
- # // CURRENCY_TYPE_NATIVE is not allowed
11
- # case CURRENCY_TYPE_ALPHANUM:
12
- # opaque currencyCode[4];
13
- #
14
- # // add other currency types here in the future
15
- # }
16
- #
17
- # ===========================================================================
18
- module Stellar
19
- class AllowTrustOp
20
- class Currency < XDR::Union
21
- switch_on CurrencyType, :type
22
-
23
- switch :currency_type_alphanum, :currency_code
24
-
25
- attribute :currency_code, XDR::Opaque[4]
26
- end
27
- end
28
- end
@@ -1,37 +0,0 @@
1
- # This code was automatically generated using xdrgen
2
- # DO NOT EDIT or your changes may be overwritten
3
-
4
- require 'xdr'
5
-
6
- # === xdr source ============================================================
7
- #
8
- # union Currency switch (CurrencyType type)
9
- # {
10
- # case CURRENCY_TYPE_NATIVE:
11
- # void;
12
- #
13
- # case CURRENCY_TYPE_ALPHANUM:
14
- # struct
15
- # {
16
- # opaque currencyCode[4];
17
- # AccountID issuer;
18
- # } alphaNum;
19
- #
20
- # // add other currency types here in the future
21
- # };
22
- #
23
- # ===========================================================================
24
- module Stellar
25
- class Currency < XDR::Union
26
- include XDR::Namespace
27
-
28
- autoload :AlphaNum
29
-
30
- switch_on CurrencyType, :type
31
-
32
- switch :currency_type_native
33
- switch :currency_type_alphanum, :alpha_num
34
-
35
- attribute :alpha_num, AlphaNum
36
- end
37
- end