stellar-base 0.26.0 → 0.30.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 (111) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +54 -32
  3. data/README.md +3 -3
  4. data/generated/stellar/account_flags.rb +9 -4
  5. data/generated/stellar/account_merge_result.rb +1 -1
  6. data/generated/stellar/allow_trust_op.rb +3 -18
  7. data/generated/stellar/allow_trust_result_code.rb +4 -1
  8. data/generated/stellar/alpha_num12.rb +20 -0
  9. data/generated/stellar/alpha_num4.rb +20 -0
  10. data/generated/stellar/asset.rb +2 -15
  11. data/generated/stellar/asset_code.rb +30 -0
  12. data/generated/stellar/asset_type.rb +3 -1
  13. data/generated/stellar/begin_sponsoring_future_reserves_result.rb +2 -1
  14. data/generated/stellar/change_trust_asset.rb +39 -0
  15. data/generated/stellar/change_trust_op.rb +2 -2
  16. data/generated/stellar/change_trust_result_code.rb +13 -7
  17. data/generated/stellar/claim_atom.rb +31 -0
  18. data/generated/stellar/claim_atom_type.rb +24 -0
  19. data/generated/stellar/claim_liquidity_atom.rb +30 -0
  20. data/generated/stellar/claim_offer_atom_v0.rb +33 -0
  21. data/generated/stellar/claimable_balance_entry/ext.rb +4 -0
  22. data/generated/stellar/claimable_balance_entry.rb +2 -0
  23. data/generated/stellar/{asset/alpha_num12.rb → claimable_balance_entry_extension_v1/ext.rb} +9 -7
  24. data/generated/stellar/{operation_id.rb → claimable_balance_entry_extension_v1.rb} +12 -14
  25. data/generated/stellar/claimable_balance_flags.rb +22 -0
  26. data/generated/stellar/clawback_claimable_balance_op.rb +18 -0
  27. data/generated/stellar/clawback_claimable_balance_result.rb +26 -0
  28. data/generated/stellar/clawback_claimable_balance_result_code.rb +29 -0
  29. data/generated/stellar/clawback_op.rb +22 -0
  30. data/generated/stellar/clawback_result.rb +25 -0
  31. data/generated/stellar/clawback_result_code.rb +31 -0
  32. data/generated/stellar/create_passive_sell_offer_op.rb +1 -1
  33. data/generated/stellar/end_sponsoring_future_reserves_result.rb +2 -1
  34. data/generated/stellar/envelope_type.rb +10 -8
  35. data/generated/stellar/{operation_id/id.rb → hash_id_preimage/operation_id.rb} +4 -4
  36. data/generated/stellar/hash_id_preimage/revoke_id.rb +28 -0
  37. data/generated/stellar/hash_id_preimage.rb +44 -0
  38. data/generated/stellar/ledger_entry/data.rb +4 -0
  39. data/generated/stellar/ledger_entry.rb +2 -0
  40. data/generated/stellar/ledger_entry_type.rb +3 -1
  41. data/generated/stellar/ledger_header/ext.rb +4 -0
  42. data/generated/stellar/ledger_header.rb +2 -0
  43. data/generated/stellar/ledger_header_extension_v1/ext.rb +24 -0
  44. data/generated/stellar/ledger_header_extension_v1.rb +30 -0
  45. data/generated/stellar/ledger_header_flags.rb +24 -0
  46. data/generated/stellar/{asset/alpha_num4.rb → ledger_key/liquidity_pool.rb} +4 -6
  47. data/generated/stellar/ledger_key/trust_line.rb +2 -2
  48. data/generated/stellar/ledger_key.rb +10 -1
  49. data/generated/stellar/ledger_upgrade.rb +4 -0
  50. data/generated/stellar/ledger_upgrade_type.rb +3 -1
  51. data/generated/stellar/liquidity_pool_constant_product_parameters.rb +22 -0
  52. data/generated/stellar/liquidity_pool_deposit_op.rb +26 -0
  53. data/generated/stellar/liquidity_pool_deposit_result.rb +26 -0
  54. data/generated/stellar/liquidity_pool_deposit_result_code.rb +41 -0
  55. data/generated/stellar/liquidity_pool_entry/body/constant_product.rb +31 -0
  56. data/generated/stellar/liquidity_pool_entry/body.rb +37 -0
  57. data/generated/stellar/liquidity_pool_entry.rb +38 -0
  58. data/generated/stellar/liquidity_pool_parameters.rb +23 -0
  59. data/generated/stellar/liquidity_pool_type.rb +20 -0
  60. data/generated/stellar/liquidity_pool_withdraw_op.rb +24 -0
  61. data/generated/stellar/liquidity_pool_withdraw_result.rb +26 -0
  62. data/generated/stellar/liquidity_pool_withdraw_result_code.rb +36 -0
  63. data/generated/stellar/manage_offer_success_result.rb +2 -2
  64. data/generated/stellar/operation/body.rb +20 -0
  65. data/generated/stellar/operation.rb +10 -0
  66. data/generated/stellar/operation_result/tr.rb +20 -0
  67. data/generated/stellar/operation_result.rb +10 -0
  68. data/generated/stellar/operation_type.rb +11 -1
  69. data/generated/stellar/path_payment_strict_receive_result/success.rb +2 -2
  70. data/generated/stellar/path_payment_strict_receive_result.rb +1 -1
  71. data/generated/stellar/path_payment_strict_send_result/success.rb +2 -2
  72. data/generated/stellar/path_payment_strict_send_result.rb +1 -1
  73. data/generated/stellar/payment_result_code.rb +1 -1
  74. data/generated/stellar/revoke_sponsorship_op.rb +1 -2
  75. data/generated/stellar/revoke_sponsorship_result_code.rb +3 -1
  76. data/generated/stellar/scp_quorum_set.rb +2 -2
  77. data/generated/stellar/set_options_result_code.rb +14 -11
  78. data/generated/stellar/set_trust_line_flags_op.rb +25 -0
  79. data/generated/stellar/set_trust_line_flags_result.rb +25 -0
  80. data/generated/stellar/set_trust_line_flags_result_code.rb +34 -0
  81. data/generated/stellar/transaction_result_code.rb +1 -1
  82. data/generated/stellar/trust_line_asset.rb +39 -0
  83. data/generated/stellar/trust_line_entry/ext/v1/ext.rb +4 -0
  84. data/generated/stellar/trust_line_entry/ext/v1.rb +2 -0
  85. data/generated/stellar/trust_line_entry/ext.rb +2 -0
  86. data/generated/stellar/trust_line_entry.rb +7 -5
  87. data/generated/stellar/trust_line_entry_extension_v2/ext.rb +24 -0
  88. data/generated/stellar/trust_line_entry_extension_v2.rb +30 -0
  89. data/generated/stellar/trust_line_flags.rb +5 -1
  90. data/generated/stellar-base-generated.rb +40 -1
  91. data/lib/stellar/account.rb +59 -0
  92. data/lib/stellar/account_flags.rb +1 -1
  93. data/lib/stellar/amount.rb +36 -0
  94. data/lib/stellar/asset.rb +8 -0
  95. data/lib/stellar/compat.rb +6 -3
  96. data/lib/stellar/concerns/transaction.rb +4 -2
  97. data/lib/stellar/dsl.rb +26 -0
  98. data/lib/stellar/ledger_key.rb +5 -3
  99. data/lib/stellar/liquidity_pool/base_pool.rb +47 -0
  100. data/lib/stellar/liquidity_pool/constant_product_pool.rb +15 -0
  101. data/lib/stellar/liquidity_pool.rb +12 -0
  102. data/lib/stellar/operation.rb +357 -386
  103. data/lib/stellar/price.rb +13 -7
  104. data/lib/stellar/transaction_builder.rb +27 -11
  105. data/lib/stellar/trust_line_flags.rb +53 -0
  106. data/lib/stellar/util/strkey.rb +15 -7
  107. data/lib/stellar/version.rb +3 -0
  108. data/lib/stellar-base.rb +5 -2
  109. metadata +61 -16
  110. data/generated/stellar/allow_trust_op/asset.rb +0 -33
  111. data/lib/stellar/base/version.rb +0 -5
@@ -7,7 +7,7 @@ require 'xdr'
7
7
  #
8
8
  # struct
9
9
  # {
10
- # ClaimOfferAtom offers<>;
10
+ # ClaimAtom offers<>;
11
11
  # SimplePaymentResult last;
12
12
  # }
13
13
  #
@@ -15,7 +15,7 @@ require 'xdr'
15
15
  module Stellar
16
16
  class PathPaymentStrictSendResult
17
17
  class Success < XDR::Struct
18
- attribute :offers, XDR::VarArray[ClaimOfferAtom]
18
+ attribute :offers, XDR::VarArray[ClaimAtom]
19
19
  attribute :last, SimplePaymentResult
20
20
  end
21
21
  end
@@ -10,7 +10,7 @@ require 'xdr'
10
10
  # case PATH_PAYMENT_STRICT_SEND_SUCCESS:
11
11
  # struct
12
12
  # {
13
- # ClaimOfferAtom offers<>;
13
+ # ClaimAtom offers<>;
14
14
  # SimplePaymentResult last;
15
15
  # } success;
16
16
  # case PATH_PAYMENT_STRICT_SEND_NO_ISSUER:
@@ -8,7 +8,7 @@ require 'xdr'
8
8
  # enum PaymentResultCode
9
9
  # {
10
10
  # // codes considered as "success" for the operation
11
- # PAYMENT_SUCCESS = 0, // payment successfuly completed
11
+ # PAYMENT_SUCCESS = 0, // payment successfully completed
12
12
  #
13
13
  # // codes considered as "failure" for the operation
14
14
  # PAYMENT_MALFORMED = -1, // bad input
@@ -14,8 +14,7 @@ require 'xdr'
14
14
  # {
15
15
  # AccountID accountID;
16
16
  # SignerKey signerKey;
17
- # }
18
- # signer;
17
+ # } signer;
19
18
  # };
20
19
  #
21
20
  # ===========================================================================
@@ -14,7 +14,8 @@ require 'xdr'
14
14
  # REVOKE_SPONSORSHIP_DOES_NOT_EXIST = -1,
15
15
  # REVOKE_SPONSORSHIP_NOT_SPONSOR = -2,
16
16
  # REVOKE_SPONSORSHIP_LOW_RESERVE = -3,
17
- # REVOKE_SPONSORSHIP_ONLY_TRANSFERABLE = -4
17
+ # REVOKE_SPONSORSHIP_ONLY_TRANSFERABLE = -4,
18
+ # REVOKE_SPONSORSHIP_MALFORMED = -5
18
19
  # };
19
20
  #
20
21
  # ===========================================================================
@@ -25,6 +26,7 @@ module Stellar
25
26
  member :revoke_sponsorship_not_sponsor, -2
26
27
  member :revoke_sponsorship_low_reserve, -3
27
28
  member :revoke_sponsorship_only_transferable, -4
29
+ member :revoke_sponsorship_malformed, -5
28
30
 
29
31
  seal
30
32
  end
@@ -8,7 +8,7 @@ require 'xdr'
8
8
  # struct SCPQuorumSet
9
9
  # {
10
10
  # uint32 threshold;
11
- # PublicKey validators<>;
11
+ # NodeID validators<>;
12
12
  # SCPQuorumSet innerSets<>;
13
13
  # };
14
14
  #
@@ -16,7 +16,7 @@ require 'xdr'
16
16
  module Stellar
17
17
  class SCPQuorumSet < XDR::Struct
18
18
  attribute :threshold, Uint32
19
- attribute :validators, XDR::VarArray[PublicKey]
19
+ attribute :validators, XDR::VarArray[NodeID]
20
20
  attribute :inner_sets, XDR::VarArray[SCPQuorumSet]
21
21
  end
22
22
  end
@@ -18,22 +18,25 @@ require 'xdr'
18
18
  # SET_OPTIONS_UNKNOWN_FLAG = -6, // can't set an unknown flag
19
19
  # SET_OPTIONS_THRESHOLD_OUT_OF_RANGE = -7, // bad value for weight/threshold
20
20
  # SET_OPTIONS_BAD_SIGNER = -8, // signer cannot be masterkey
21
- # SET_OPTIONS_INVALID_HOME_DOMAIN = -9 // malformed home domain
21
+ # SET_OPTIONS_INVALID_HOME_DOMAIN = -9, // malformed home domain
22
+ # SET_OPTIONS_AUTH_REVOCABLE_REQUIRED =
23
+ # -10 // auth revocable is required for clawback
22
24
  # };
23
25
  #
24
26
  # ===========================================================================
25
27
  module Stellar
26
28
  class SetOptionsResultCode < XDR::Enum
27
- member :set_options_success, 0
28
- member :set_options_low_reserve, -1
29
- member :set_options_too_many_signers, -2
30
- member :set_options_bad_flags, -3
31
- member :set_options_invalid_inflation, -4
32
- member :set_options_cant_change, -5
33
- member :set_options_unknown_flag, -6
34
- member :set_options_threshold_out_of_range, -7
35
- member :set_options_bad_signer, -8
36
- member :set_options_invalid_home_domain, -9
29
+ member :set_options_success, 0
30
+ member :set_options_low_reserve, -1
31
+ member :set_options_too_many_signers, -2
32
+ member :set_options_bad_flags, -3
33
+ member :set_options_invalid_inflation, -4
34
+ member :set_options_cant_change, -5
35
+ member :set_options_unknown_flag, -6
36
+ member :set_options_threshold_out_of_range, -7
37
+ member :set_options_bad_signer, -8
38
+ member :set_options_invalid_home_domain, -9
39
+ member :set_options_auth_revocable_required, -10
37
40
 
38
41
  seal
39
42
  end
@@ -0,0 +1,25 @@
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
+ # struct SetTrustLineFlagsOp
9
+ # {
10
+ # AccountID trustor;
11
+ # Asset asset;
12
+ #
13
+ # uint32 clearFlags; // which flags to clear
14
+ # uint32 setFlags; // which flags to set
15
+ # };
16
+ #
17
+ # ===========================================================================
18
+ module Stellar
19
+ class SetTrustLineFlagsOp < XDR::Struct
20
+ attribute :trustor, AccountID
21
+ attribute :asset, Asset
22
+ attribute :clear_flags, Uint32
23
+ attribute :set_flags, Uint32
24
+ end
25
+ end
@@ -0,0 +1,25 @@
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 SetTrustLineFlagsResult switch (SetTrustLineFlagsResultCode code)
9
+ # {
10
+ # case SET_TRUST_LINE_FLAGS_SUCCESS:
11
+ # void;
12
+ # default:
13
+ # void;
14
+ # };
15
+ #
16
+ # ===========================================================================
17
+ module Stellar
18
+ class SetTrustLineFlagsResult < XDR::Union
19
+ switch_on SetTrustLineFlagsResultCode, :code
20
+
21
+ switch :set_trust_line_flags_success
22
+ switch :default
23
+
24
+ end
25
+ end
@@ -0,0 +1,34 @@
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
+ # enum SetTrustLineFlagsResultCode
9
+ # {
10
+ # // codes considered as "success" for the operation
11
+ # SET_TRUST_LINE_FLAGS_SUCCESS = 0,
12
+ #
13
+ # // codes considered as "failure" for the operation
14
+ # SET_TRUST_LINE_FLAGS_MALFORMED = -1,
15
+ # SET_TRUST_LINE_FLAGS_NO_TRUST_LINE = -2,
16
+ # SET_TRUST_LINE_FLAGS_CANT_REVOKE = -3,
17
+ # SET_TRUST_LINE_FLAGS_INVALID_STATE = -4,
18
+ # SET_TRUST_LINE_FLAGS_LOW_RESERVE = -5 // claimable balances can't be created
19
+ # // on revoke due to low reserves
20
+ # };
21
+ #
22
+ # ===========================================================================
23
+ module Stellar
24
+ class SetTrustLineFlagsResultCode < XDR::Enum
25
+ member :set_trust_line_flags_success, 0
26
+ member :set_trust_line_flags_malformed, -1
27
+ member :set_trust_line_flags_no_trust_line, -2
28
+ member :set_trust_line_flags_cant_revoke, -3
29
+ member :set_trust_line_flags_invalid_state, -4
30
+ member :set_trust_line_flags_low_reserve, -5
31
+
32
+ seal
33
+ end
34
+ end
@@ -22,7 +22,7 @@ require 'xdr'
22
22
  # txNO_ACCOUNT = -8, // source account not found
23
23
  # txINSUFFICIENT_FEE = -9, // fee is too small
24
24
  # txBAD_AUTH_EXTRA = -10, // unused signatures attached to transaction
25
- # txINTERNAL_ERROR = -11, // an unknown error occured
25
+ # txINTERNAL_ERROR = -11, // an unknown error occurred
26
26
  #
27
27
  # txNOT_SUPPORTED = -12, // transaction type not supported
28
28
  # txFEE_BUMP_INNER_FAILED = -13, // fee bump inner transaction failed
@@ -0,0 +1,39 @@
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 TrustLineAsset switch (AssetType type)
9
+ # {
10
+ # case ASSET_TYPE_NATIVE: // Not credit
11
+ # void;
12
+ #
13
+ # case ASSET_TYPE_CREDIT_ALPHANUM4:
14
+ # AlphaNum4 alphaNum4;
15
+ #
16
+ # case ASSET_TYPE_CREDIT_ALPHANUM12:
17
+ # AlphaNum12 alphaNum12;
18
+ #
19
+ # case ASSET_TYPE_POOL_SHARE:
20
+ # PoolID liquidityPoolID;
21
+ #
22
+ # // add other asset types here in the future
23
+ # };
24
+ #
25
+ # ===========================================================================
26
+ module Stellar
27
+ class TrustLineAsset < XDR::Union
28
+ switch_on AssetType, :type
29
+
30
+ switch :asset_type_native
31
+ switch :asset_type_credit_alphanum4, :alpha_num4
32
+ switch :asset_type_credit_alphanum12, :alpha_num12
33
+ switch :asset_type_pool_share, :liquidity_pool_id
34
+
35
+ attribute :alpha_num4, AlphaNum4
36
+ attribute :alpha_num12, AlphaNum12
37
+ attribute :liquidity_pool_id, PoolID
38
+ end
39
+ end
@@ -9,6 +9,8 @@ require 'xdr'
9
9
  # {
10
10
  # case 0:
11
11
  # void;
12
+ # case 2:
13
+ # TrustLineEntryExtensionV2 v2;
12
14
  # }
13
15
  #
14
16
  # ===========================================================================
@@ -20,7 +22,9 @@ module Stellar
20
22
  switch_on XDR::Int, :v
21
23
 
22
24
  switch 0
25
+ switch 2, :v2
23
26
 
27
+ attribute :v2, TrustLineEntryExtensionV2
24
28
  end
25
29
  end
26
30
  end
@@ -13,6 +13,8 @@ require 'xdr'
13
13
  # {
14
14
  # case 0:
15
15
  # void;
16
+ # case 2:
17
+ # TrustLineEntryExtensionV2 v2;
16
18
  # }
17
19
  # ext;
18
20
  # }
@@ -18,6 +18,8 @@ require 'xdr'
18
18
  # {
19
19
  # case 0:
20
20
  # void;
21
+ # case 2:
22
+ # TrustLineEntryExtensionV2 v2;
21
23
  # }
22
24
  # ext;
23
25
  # } v1;
@@ -7,10 +7,10 @@ require 'xdr'
7
7
  #
8
8
  # struct TrustLineEntry
9
9
  # {
10
- # AccountID accountID; // account this trustline belongs to
11
- # Asset asset; // type of asset (with issuer)
12
- # int64 balance; // how much of this asset the user has.
13
- # // Asset defines the unit for this;
10
+ # AccountID accountID; // account this trustline belongs to
11
+ # TrustLineAsset asset; // type of asset (with issuer)
12
+ # int64 balance; // how much of this asset the user has.
13
+ # // Asset defines the unit for this;
14
14
  #
15
15
  # int64 limit; // balance cannot be above this
16
16
  # uint32 flags; // see TrustLineFlags
@@ -29,6 +29,8 @@ require 'xdr'
29
29
  # {
30
30
  # case 0:
31
31
  # void;
32
+ # case 2:
33
+ # TrustLineEntryExtensionV2 v2;
32
34
  # }
33
35
  # ext;
34
36
  # } v1;
@@ -44,7 +46,7 @@ module Stellar
44
46
  autoload :Ext
45
47
 
46
48
  attribute :account_id, AccountID
47
- attribute :asset, Asset
49
+ attribute :asset, TrustLineAsset
48
50
  attribute :balance, Int64
49
51
  attribute :limit, Int64
50
52
  attribute :flags, Uint32
@@ -0,0 +1,24 @@
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 (int v)
9
+ # {
10
+ # case 0:
11
+ # void;
12
+ # }
13
+ #
14
+ # ===========================================================================
15
+ module Stellar
16
+ class TrustLineEntryExtensionV2
17
+ class Ext < XDR::Union
18
+ switch_on XDR::Int, :v
19
+
20
+ switch 0
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,30 @@
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
+ # struct TrustLineEntryExtensionV2
9
+ # {
10
+ # int32 liquidityPoolUseCount;
11
+ #
12
+ # union switch (int v)
13
+ # {
14
+ # case 0:
15
+ # void;
16
+ # }
17
+ # ext;
18
+ # };
19
+ #
20
+ # ===========================================================================
21
+ module Stellar
22
+ class TrustLineEntryExtensionV2 < XDR::Struct
23
+ include XDR::Namespace
24
+
25
+ autoload :Ext
26
+
27
+ attribute :liquidity_pool_use_count, Int32
28
+ attribute :ext, Ext
29
+ end
30
+ end
@@ -11,7 +11,10 @@ require 'xdr'
11
11
  # AUTHORIZED_FLAG = 1,
12
12
  # // issuer has authorized account to maintain and reduce liabilities for its
13
13
  # // credit
14
- # AUTHORIZED_TO_MAINTAIN_LIABILITIES_FLAG = 2
14
+ # AUTHORIZED_TO_MAINTAIN_LIABILITIES_FLAG = 2,
15
+ # // issuer has specified that it may clawback its credit, and that claimable
16
+ # // balances created with its credit may also be clawed back
17
+ # TRUSTLINE_CLAWBACK_ENABLED_FLAG = 4
15
18
  # };
16
19
  #
17
20
  # ===========================================================================
@@ -19,6 +22,7 @@ module Stellar
19
22
  class TrustLineFlags < XDR::Enum
20
23
  member :authorized_flag, 1
21
24
  member :authorized_to_maintain_liabilities_flag, 2
25
+ member :trustline_clawback_enabled_flag, 4
22
26
 
23
27
  seal
24
28
  end
@@ -35,9 +35,13 @@ module Stellar
35
35
  SequenceNumber = Int64
36
36
  TimePoint = Uint64
37
37
  DataValue = XDR::VarOpaque[64]
38
+ PoolID = Hash
38
39
  AssetCode4 = XDR::Opaque[4]
39
40
  AssetCode12 = XDR::Opaque[12]
40
41
  autoload :AssetType
42
+ autoload :AssetCode
43
+ autoload :AlphaNum4
44
+ autoload :AlphaNum12
41
45
  autoload :Asset
42
46
  autoload :Price
43
47
  autoload :Liabilities
@@ -46,6 +50,7 @@ module Stellar
46
50
  autoload :Signer
47
51
  autoload :AccountFlags
48
52
  MASK_ACCOUNT_FLAGS = 0x7
53
+ MASK_ACCOUNT_FLAGS_V17 = 0xF
49
54
  MAX_SIGNERS = 20
50
55
  SponsorshipDescriptor = XDR::Option[AccountID]
51
56
  autoload :AccountEntryExtensionV2
@@ -54,6 +59,10 @@ module Stellar
54
59
  autoload :TrustLineFlags
55
60
  MASK_TRUSTLINE_FLAGS = 1
56
61
  MASK_TRUSTLINE_FLAGS_V13 = 3
62
+ MASK_TRUSTLINE_FLAGS_V17 = 7
63
+ autoload :LiquidityPoolType
64
+ autoload :TrustLineAsset
65
+ autoload :TrustLineEntryExtensionV2
57
66
  autoload :TrustLineEntry
58
67
  autoload :OfferEntryFlags
59
68
  MASK_OFFERENTRY_FLAGS = 1
@@ -65,7 +74,12 @@ module Stellar
65
74
  autoload :Claimant
66
75
  autoload :ClaimableBalanceIDType
67
76
  autoload :ClaimableBalanceID
77
+ autoload :ClaimableBalanceFlags
78
+ MASK_CLAIMABLE_BALANCE_FLAGS = 0x1
79
+ autoload :ClaimableBalanceEntryExtensionV1
68
80
  autoload :ClaimableBalanceEntry
81
+ autoload :LiquidityPoolConstantProductParameters
82
+ autoload :LiquidityPoolEntry
69
83
  autoload :LedgerEntryExtensionV1
70
84
  autoload :LedgerEntry
71
85
  autoload :LedgerKey
@@ -74,6 +88,7 @@ end
74
88
  module Stellar
75
89
  include XDR::Namespace
76
90
 
91
+ autoload :LiquidityPoolParameters
77
92
  autoload :MuxedAccount
78
93
  autoload :DecoratedSignature
79
94
  autoload :OperationType
@@ -85,6 +100,7 @@ module Stellar
85
100
  autoload :ManageBuyOfferOp
86
101
  autoload :CreatePassiveSellOfferOp
87
102
  autoload :SetOptionsOp
103
+ autoload :ChangeTrustAsset
88
104
  autoload :ChangeTrustOp
89
105
  autoload :AllowTrustOp
90
106
  autoload :ManageDataOp
@@ -94,8 +110,14 @@ module Stellar
94
110
  autoload :BeginSponsoringFutureReservesOp
95
111
  autoload :RevokeSponsorshipType
96
112
  autoload :RevokeSponsorshipOp
113
+ autoload :ClawbackOp
114
+ autoload :ClawbackClaimableBalanceOp
115
+ autoload :SetTrustLineFlagsOp
116
+ LIQUIDITY_POOL_FEE_V18 = 30
117
+ autoload :LiquidityPoolDepositOp
118
+ autoload :LiquidityPoolWithdrawOp
97
119
  autoload :Operation
98
- autoload :OperationID
120
+ autoload :HashIDPreimage
99
121
  autoload :MemoType
100
122
  autoload :Memo
101
123
  autoload :TimeBounds
@@ -108,7 +130,11 @@ module Stellar
108
130
  autoload :FeeBumpTransactionEnvelope
109
131
  autoload :TransactionEnvelope
110
132
  autoload :TransactionSignaturePayload
133
+ autoload :ClaimAtomType
134
+ autoload :ClaimOfferAtomV0
111
135
  autoload :ClaimOfferAtom
136
+ autoload :ClaimLiquidityAtom
137
+ autoload :ClaimAtom
112
138
  autoload :CreateAccountResultCode
113
139
  autoload :CreateAccountResult
114
140
  autoload :PaymentResultCode
@@ -149,6 +175,16 @@ module Stellar
149
175
  autoload :EndSponsoringFutureReservesResult
150
176
  autoload :RevokeSponsorshipResultCode
151
177
  autoload :RevokeSponsorshipResult
178
+ autoload :ClawbackResultCode
179
+ autoload :ClawbackResult
180
+ autoload :ClawbackClaimableBalanceResultCode
181
+ autoload :ClawbackClaimableBalanceResult
182
+ autoload :SetTrustLineFlagsResultCode
183
+ autoload :SetTrustLineFlagsResult
184
+ autoload :LiquidityPoolDepositResultCode
185
+ autoload :LiquidityPoolDepositResult
186
+ autoload :LiquidityPoolWithdrawResultCode
187
+ autoload :LiquidityPoolWithdrawResult
152
188
  autoload :OperationResultCode
153
189
  autoload :OperationResult
154
190
  autoload :TransactionResultCode
@@ -163,6 +199,9 @@ module Stellar
163
199
  autoload :StellarValueType
164
200
  autoload :LedgerCloseValueSignature
165
201
  autoload :StellarValue
202
+ MASK_LEDGER_HEADER_FLAGS = 0x7
203
+ autoload :LedgerHeaderFlags
204
+ autoload :LedgerHeaderExtensionV1
166
205
  autoload :LedgerHeader
167
206
  autoload :LedgerUpgradeType
168
207
  autoload :LedgerUpgrade
@@ -0,0 +1,59 @@
1
+ module Stellar
2
+ class Account
3
+ delegate :address, to: :keypair
4
+
5
+ def self.random
6
+ keypair = Stellar::KeyPair.random
7
+ new(keypair)
8
+ end
9
+
10
+ def self.from_seed(seed)
11
+ keypair = Stellar::KeyPair.from_seed(seed)
12
+ new(keypair)
13
+ end
14
+
15
+ def self.from_address(address)
16
+ muxed_xdr = Util::StrKey.decode_muxed_account(address)
17
+
18
+ if muxed_xdr.ed25519
19
+ new(KeyPair.from_public_key(muxed_xdr.ed25519))
20
+ else
21
+ muxed_xdr = muxed_xdr.med25519!
22
+ new(KeyPair.from_public_key(muxed_xdr.ed25519), muxed_xdr.id)
23
+ end
24
+ end
25
+
26
+ def self.master
27
+ keypair = Stellar::KeyPair.from_raw_seed("allmylifemyhearthasbeensearching")
28
+ new(keypair)
29
+ end
30
+
31
+ attr_reader :keypair, :id
32
+
33
+ # @param [Stellar::KeyPair] keypair
34
+ # @param [Integer] id
35
+ def initialize(keypair, id = nil)
36
+ @keypair = keypair
37
+ @id = id
38
+ end
39
+
40
+ def base_account
41
+ Stellar::MuxedAccount.ed25519(keypair.raw_public_key)
42
+ end
43
+
44
+ def muxed_account
45
+ return base_account unless id
46
+ Stellar::MuxedAccount.med25519(ed25519: keypair.raw_public_key, id: id)
47
+ end
48
+
49
+ def address(force_account_id: true)
50
+ return keypair.address if force_account_id
51
+
52
+ Util::StrKey.check_encode(:muxed, keypair.raw_public_key + [id].pack("Q>"))
53
+ end
54
+
55
+ def to_keypair
56
+ keypair
57
+ end
58
+ end
59
+ end
@@ -4,7 +4,7 @@ module Stellar
4
4
  # Converts an array of Stellar::AccountFlags members into
5
5
  # an Integer suitable for use in a SetOptionsOp.
6
6
  #
7
- # @param flags [Array<Stellar::AccountFlags>] the flags to combine
7
+ # @param flags [Array<Stellar::AccountFlags>, nil] the flags to combine
8
8
  #
9
9
  # @return [Fixnum] the combined result
10
10
  def self.make_mask(flags = nil)
@@ -0,0 +1,36 @@
1
+ module Stellar
2
+ class Amount
3
+ attr_reader :amount
4
+ attr_reader :asset
5
+
6
+ # @param [Fixnum] amount
7
+ # @param [Stellar::Asset] asset
8
+ def initialize(amount, asset = Stellar::Asset.native)
9
+ # TODO: how are we going to handle decimal considerations?
10
+
11
+ @amount = amount
12
+ @asset = asset
13
+ end
14
+
15
+ # @return [Array(Symbol, Fixnum)] in case of a native asset
16
+ # @return [Array(Symbol, String, Stellar::KeyPair, Fixnum)] in case of alphanum asset
17
+ def to_payment
18
+ case asset.type
19
+ when AssetType.asset_type_native
20
+ [:native, amount]
21
+ when AssetType.asset_type_credit_alphanum4
22
+ keypair = KeyPair.from_public_key(asset.issuer.value)
23
+ [:alphanum4, asset.code, keypair, amount]
24
+ when AssetType.asset_type_credit_alphanum12
25
+ keypair = KeyPair.from_public_key(asset.issuer.value)
26
+ [:alphanum12, asset.code, keypair, amount]
27
+ else
28
+ raise "Unknown asset type: #{asset.type}"
29
+ end
30
+ end
31
+
32
+ def inspect
33
+ "#<Stellar::Amount #{asset}(#{amount})>"
34
+ end
35
+ end
36
+ end
data/lib/stellar/asset.rb CHANGED
@@ -30,6 +30,14 @@ module Stellar
30
30
  new(:asset_type_credit_alphanum12, an)
31
31
  end
32
32
 
33
+ def to_change_trust_asset
34
+ ChangeTrustAsset.new(switch, value)
35
+ end
36
+
37
+ def to_trust_line_asset
38
+ TrustLineAsset.new(switch, value)
39
+ end
40
+
33
41
  def to_s
34
42
  case switch
35
43
  when AssetType.asset_type_native
@@ -2,7 +2,10 @@ class << Stellar::Operation
2
2
  alias_method :manage_offer, :manage_sell_offer
3
3
  alias_method :create_passive_offer, :create_passive_sell_offer
4
4
 
5
- deprecate deprecator: Stellar::Deprecation,
6
- manage_offer: :manage_sell_offer,
7
- create_passive_offer: :create_passive_sell_offer
5
+ deprecate(
6
+ deprecator: Stellar::Deprecation,
7
+ manage_offer: :manage_sell_offer,
8
+ create_passive_offer: :create_passive_sell_offer,
9
+ allow_trust: :set_trust_line_flags
10
+ )
8
11
  end