stellar-base 0.31.0 → 0.32.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 (40) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/generated/stellar/account_entry_extension_v2/ext.rb +4 -0
  4. data/generated/stellar/account_entry_extension_v2.rb +2 -0
  5. data/generated/stellar/account_entry_extension_v3.rb +28 -0
  6. data/generated/stellar/allow_trust_result_code.rb +3 -3
  7. data/generated/stellar/change_trust_result_code.rb +5 -3
  8. data/generated/stellar/crypto_key_type.rb +6 -4
  9. data/generated/stellar/extension_point.rb +22 -0
  10. data/generated/stellar/inner_transaction_result/result.rb +6 -2
  11. data/generated/stellar/inner_transaction_result.rb +2 -0
  12. data/generated/stellar/ledger_bounds.rb +20 -0
  13. data/generated/stellar/liquidity_pool_constant_product_parameters.rb +1 -1
  14. data/generated/stellar/liquidity_pool_deposit_op.rb +4 -4
  15. data/generated/stellar/liquidity_pool_deposit_result.rb +1 -2
  16. data/generated/stellar/liquidity_pool_entry/body/constant_product.rb +2 -1
  17. data/generated/stellar/liquidity_pool_entry/body.rb +2 -1
  18. data/generated/stellar/liquidity_pool_entry.rb +2 -1
  19. data/generated/stellar/liquidity_pool_withdraw_op.rb +3 -3
  20. data/generated/stellar/liquidity_pool_withdraw_result.rb +1 -2
  21. data/generated/stellar/liquidity_pool_withdraw_result_code.rb +8 -8
  22. data/generated/stellar/message_type.rb +4 -1
  23. data/generated/stellar/offer_entry_flags.rb +2 -1
  24. data/generated/stellar/precondition_type.rb +24 -0
  25. data/generated/stellar/preconditions.rb +30 -0
  26. data/generated/stellar/preconditions_v2.rb +51 -0
  27. data/generated/stellar/send_more.rb +18 -0
  28. data/generated/stellar/signer_key/ed25519_signed_payload.rb +24 -0
  29. data/generated/stellar/signer_key.rb +20 -6
  30. data/generated/stellar/signer_key_type.rb +6 -4
  31. data/generated/stellar/stellar_message.rb +4 -0
  32. data/generated/stellar/transaction.rb +3 -3
  33. data/generated/stellar/transaction_result_code.rb +6 -1
  34. data/generated/stellar-base-generated.rb +8 -0
  35. data/lib/stellar/transaction.rb +1 -1
  36. data/lib/stellar/transaction_builder.rb +115 -2
  37. data/lib/stellar/transaction_v0.rb +5 -1
  38. data/lib/stellar/util/strkey.rb +15 -1
  39. data/lib/stellar/version.rb +1 -1
  40. metadata +14 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aec1ef3949346ac5f45c7337753938f2ca424566e8b630429bc3c645a9184f06
4
- data.tar.gz: 6657ae69d9d257cda03a58c65fb8e20308f04826f384d7e7ca4e73e6d3308c8b
3
+ metadata.gz: 37d725fa4d77fd25c02397c7d25f6798b537ebe3f7eb8fe84715fc134b0304fd
4
+ data.tar.gz: 577ca9cb0b37d98f3b631a85125cd1b5732285827b33eb61990949aed810dc73
5
5
  SHA512:
6
- metadata.gz: 4c63bdf6d1a0d9d201c73d56be579e0850cf749a9553d5a7b99b4fd75f8ec2b485a88963946fb2832e58da1fbd0819af8cbf0ae863728580849bd80dfbb236c0
7
- data.tar.gz: f808809b911435a72ae55e540ea275e4b3a1b8bd7e492ca2be365c0eaf8a96d26d6c90e8859dc55307499e1dab61c3108a2c9777413a904816c2a8300f2f1070
6
+ metadata.gz: 767697d1e7f98af39da13ec28205b169e24de30f4f11a16c784cb56407c254ec5a484109908537aa2c2b301d134ac0c028fcc94a864dc6359dac6c5fb2f58c93
7
+ data.tar.gz: 520ebf0c69bd20e314e4c8d38ccb77b4711cbacb5de20e87e870c52442e1e4bc02889a9bac3e8180c6c3380a7be08bfffe7e05e46009649072f3301ce69cf58d
data/CHANGELOG.md CHANGED
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
7
7
  As this project is pre 1.0, breaking changes may happen for minor version
8
8
  bumps. A breaking change will get clearly notified in this log.
9
9
 
10
+ ## [0.32.0](https://github.com/astroband/ruby-stellar-sdk/compare/v0.31.0...v0.32.0) (2022-05-17)
11
+
12
+ ### Added
13
+ * **protocol** support Stellar protocol 19 ([#265](https://github.com/astroband/ruby-stellar-sdk/issues/265)) ([fead030](https://github.com/astroband/ruby-stellar-sdk/commit/fead030fdf6159cc184d5337a0f6f14fa61de963))
14
+
10
15
  ## [0.31.0](https://github.com/astroband/ruby-stellar-sdk/compare/v0.30.0...v0.31.0) (2022-02-20)
11
16
 
12
17
  ### ⚠ BREAKING CHANGES
@@ -9,6 +9,8 @@ require 'xdr'
9
9
  # {
10
10
  # case 0:
11
11
  # void;
12
+ # case 3:
13
+ # AccountEntryExtensionV3 v3;
12
14
  # }
13
15
  #
14
16
  # ===========================================================================
@@ -18,7 +20,9 @@ module Stellar
18
20
  switch_on XDR::Int, :v
19
21
 
20
22
  switch 0
23
+ switch 3, :v3
21
24
 
25
+ attribute :v3, AccountEntryExtensionV3
22
26
  end
23
27
  end
24
28
  end
@@ -15,6 +15,8 @@ require 'xdr'
15
15
  # {
16
16
  # case 0:
17
17
  # void;
18
+ # case 3:
19
+ # AccountEntryExtensionV3 v3;
18
20
  # }
19
21
  # ext;
20
22
  # };
@@ -0,0 +1,28 @@
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 AccountEntryExtensionV3
9
+ # {
10
+ # // We can use this to add more fields, or because it is first, to
11
+ # // change AccountEntryExtensionV3 into a union.
12
+ # ExtensionPoint ext;
13
+ #
14
+ # // Ledger number at which `seqNum` took on its present value.
15
+ # uint32 seqLedger;
16
+ #
17
+ # // Time at which `seqNum` took on its present value.
18
+ # TimePoint seqTime;
19
+ # };
20
+ #
21
+ # ===========================================================================
22
+ module Stellar
23
+ class AccountEntryExtensionV3 < XDR::Struct
24
+ attribute :ext, ExtensionPoint
25
+ attribute :seq_ledger, Uint32
26
+ attribute :seq_time, TimePoint
27
+ end
28
+ end
@@ -14,10 +14,10 @@ require 'xdr'
14
14
  # ALLOW_TRUST_NO_TRUST_LINE = -2, // trustor does not have a trustline
15
15
  # // source account does not require trust
16
16
  # ALLOW_TRUST_TRUST_NOT_REQUIRED = -3,
17
- # ALLOW_TRUST_CANT_REVOKE = -4, // source account can't revoke trust,
17
+ # ALLOW_TRUST_CANT_REVOKE = -4, // source account can't revoke trust,
18
18
  # ALLOW_TRUST_SELF_NOT_ALLOWED = -5, // trusting self is not allowed
19
- # ALLOW_TRUST_LOW_RESERVE = -6 // claimable balances can't be created
20
- # // on revoke due to low reserves
19
+ # ALLOW_TRUST_LOW_RESERVE = -6 // claimable balances can't be created
20
+ # // on revoke due to low reserves
21
21
  # };
22
22
  #
23
23
  # ===========================================================================
@@ -16,10 +16,12 @@ require 'xdr'
16
16
  # // cannot create with a limit of 0
17
17
  # CHANGE_TRUST_LOW_RESERVE =
18
18
  # -4, // not enough funds to create a new trust line,
19
- # CHANGE_TRUST_SELF_NOT_ALLOWED = -5, // trusting self is not allowed
19
+ # CHANGE_TRUST_SELF_NOT_ALLOWED = -5, // trusting self is not allowed
20
20
  # CHANGE_TRUST_TRUST_LINE_MISSING = -6, // Asset trustline is missing for pool
21
- # CHANGE_TRUST_CANNOT_DELETE = -7, // Asset trustline is still referenced in a pool
22
- # CHANGE_TRUST_NOT_AUTH_MAINTAIN_LIABILITIES = -8 // Asset trustline is deauthorized
21
+ # CHANGE_TRUST_CANNOT_DELETE =
22
+ # -7, // Asset trustline is still referenced in a pool
23
+ # CHANGE_TRUST_NOT_AUTH_MAINTAIN_LIABILITIES =
24
+ # -8 // Asset trustline is deauthorized
23
25
  # };
24
26
  #
25
27
  # ===========================================================================
@@ -10,6 +10,7 @@ require 'xdr'
10
10
  # KEY_TYPE_ED25519 = 0,
11
11
  # KEY_TYPE_PRE_AUTH_TX = 1,
12
12
  # KEY_TYPE_HASH_X = 2,
13
+ # KEY_TYPE_ED25519_SIGNED_PAYLOAD = 3,
13
14
  # // MUXED enum values for supported type are derived from the enum values
14
15
  # // above by ORing them with 0x100
15
16
  # KEY_TYPE_MUXED_ED25519 = 0x100
@@ -18,10 +19,11 @@ require 'xdr'
18
19
  # ===========================================================================
19
20
  module Stellar
20
21
  class CryptoKeyType < XDR::Enum
21
- member :key_type_ed25519, 0
22
- member :key_type_pre_auth_tx, 1
23
- member :key_type_hash_x, 2
24
- member :key_type_muxed_ed25519, 256
22
+ member :key_type_ed25519, 0
23
+ member :key_type_pre_auth_tx, 1
24
+ member :key_type_hash_x, 2
25
+ member :key_type_ed25519_signed_payload, 3
26
+ member :key_type_muxed_ed25519, 256
25
27
 
26
28
  seal
27
29
  end
@@ -0,0 +1,22 @@
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 ExtensionPoint switch (int v)
9
+ # {
10
+ # case 0:
11
+ # void;
12
+ # };
13
+ #
14
+ # ===========================================================================
15
+ module Stellar
16
+ class ExtensionPoint < XDR::Union
17
+ switch_on XDR::Int, :v
18
+
19
+ switch 0
20
+
21
+ end
22
+ end
@@ -24,6 +24,8 @@ require 'xdr'
24
24
  # case txNOT_SUPPORTED:
25
25
  # // txFEE_BUMP_INNER_FAILED is not included
26
26
  # case txBAD_SPONSORSHIP:
27
+ # case txBAD_MIN_SEQ_AGE_OR_GAP:
28
+ # case txMALFORMED:
27
29
  # void;
28
30
  # }
29
31
  #
@@ -33,8 +35,8 @@ module Stellar
33
35
  class Result < XDR::Union
34
36
  switch_on TransactionResultCode, :code
35
37
 
36
- switch :tx_success, :results
37
- switch :tx_failed, :results
38
+ switch :tx_success, :results
39
+ switch :tx_failed, :results
38
40
  switch :tx_too_early
39
41
  switch :tx_too_late
40
42
  switch :tx_missing_operation
@@ -47,6 +49,8 @@ module Stellar
47
49
  switch :tx_internal_error
48
50
  switch :tx_not_supported
49
51
  switch :tx_bad_sponsorship
52
+ switch :tx_bad_min_seq_age_or_gap
53
+ switch :tx_malformed
50
54
 
51
55
  attribute :results, XDR::VarArray[OperationResult]
52
56
  end
@@ -29,6 +29,8 @@ require 'xdr'
29
29
  # case txNOT_SUPPORTED:
30
30
  # // txFEE_BUMP_INNER_FAILED is not included
31
31
  # case txBAD_SPONSORSHIP:
32
+ # case txBAD_MIN_SEQ_AGE_OR_GAP:
33
+ # case txMALFORMED:
32
34
  # void;
33
35
  # }
34
36
  # result;
@@ -0,0 +1,20 @@
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 LedgerBounds
9
+ # {
10
+ # uint32 minLedger;
11
+ # uint32 maxLedger; // 0 here means no maxLedger
12
+ # };
13
+ #
14
+ # ===========================================================================
15
+ module Stellar
16
+ class LedgerBounds < XDR::Struct
17
+ attribute :min_ledger, Uint32
18
+ attribute :max_ledger, Uint32
19
+ end
20
+ end
@@ -9,7 +9,7 @@ require 'xdr'
9
9
  # {
10
10
  # Asset assetA; // assetA < assetB
11
11
  # Asset assetB;
12
- # int32 fee; // Fee is in basis points, so the actual rate is (fee/100)%
12
+ # int32 fee; // Fee is in basis points, so the actual rate is (fee/100)%
13
13
  # };
14
14
  #
15
15
  # ===========================================================================
@@ -8,10 +8,10 @@ require 'xdr'
8
8
  # struct LiquidityPoolDepositOp
9
9
  # {
10
10
  # PoolID liquidityPoolID;
11
- # int64 maxAmountA; // maximum amount of first asset to deposit
12
- # int64 maxAmountB; // maximum amount of second asset to deposit
13
- # Price minPrice; // minimum depositA/depositB
14
- # Price maxPrice; // maximum depositA/depositB
11
+ # int64 maxAmountA; // maximum amount of first asset to deposit
12
+ # int64 maxAmountB; // maximum amount of second asset to deposit
13
+ # Price minPrice; // minimum depositA/depositB
14
+ # Price maxPrice; // maximum depositA/depositB
15
15
  # };
16
16
  #
17
17
  # ===========================================================================
@@ -5,8 +5,7 @@ require 'xdr'
5
5
 
6
6
  # === xdr source ============================================================
7
7
  #
8
- # union LiquidityPoolDepositResult switch (
9
- # LiquidityPoolDepositResultCode code)
8
+ # union LiquidityPoolDepositResult switch (LiquidityPoolDepositResultCode code)
10
9
  # {
11
10
  # case LIQUIDITY_POOL_DEPOSIT_SUCCESS:
12
11
  # void;
@@ -12,7 +12,8 @@ require 'xdr'
12
12
  # int64 reserveA; // amount of A in the pool
13
13
  # int64 reserveB; // amount of B in the pool
14
14
  # int64 totalPoolShares; // total number of pool shares issued
15
- # int64 poolSharesTrustLineCount; // number of trust lines for the associated pool shares
15
+ # int64 poolSharesTrustLineCount; // number of trust lines for the
16
+ # // associated pool shares
16
17
  # }
17
18
  #
18
19
  # ===========================================================================
@@ -15,7 +15,8 @@ require 'xdr'
15
15
  # int64 reserveA; // amount of A in the pool
16
16
  # int64 reserveB; // amount of B in the pool
17
17
  # int64 totalPoolShares; // total number of pool shares issued
18
- # int64 poolSharesTrustLineCount; // number of trust lines for the associated pool shares
18
+ # int64 poolSharesTrustLineCount; // number of trust lines for the
19
+ # // associated pool shares
19
20
  # } constantProduct;
20
21
  # }
21
22
  #
@@ -19,7 +19,8 @@ require 'xdr'
19
19
  # int64 reserveA; // amount of A in the pool
20
20
  # int64 reserveB; // amount of B in the pool
21
21
  # int64 totalPoolShares; // total number of pool shares issued
22
- # int64 poolSharesTrustLineCount; // number of trust lines for the associated pool shares
22
+ # int64 poolSharesTrustLineCount; // number of trust lines for the
23
+ # // associated pool shares
23
24
  # } constantProduct;
24
25
  # }
25
26
  # body;
@@ -8,9 +8,9 @@ require 'xdr'
8
8
  # struct LiquidityPoolWithdrawOp
9
9
  # {
10
10
  # PoolID liquidityPoolID;
11
- # int64 amount; // amount of pool shares to withdraw
12
- # int64 minAmountA; // minimum amount of first asset to withdraw
13
- # int64 minAmountB; // minimum amount of second asset to withdraw
11
+ # int64 amount; // amount of pool shares to withdraw
12
+ # int64 minAmountA; // minimum amount of first asset to withdraw
13
+ # int64 minAmountB; // minimum amount of second asset to withdraw
14
14
  # };
15
15
  #
16
16
  # ===========================================================================
@@ -5,8 +5,7 @@ require 'xdr'
5
5
 
6
6
  # === xdr source ============================================================
7
7
  #
8
- # union LiquidityPoolWithdrawResult switch (
9
- # LiquidityPoolWithdrawResultCode code)
8
+ # union LiquidityPoolWithdrawResult switch (LiquidityPoolWithdrawResultCode code)
10
9
  # {
11
10
  # case LIQUIDITY_POOL_WITHDRAW_SUCCESS:
12
11
  # void;
@@ -11,14 +11,14 @@ require 'xdr'
11
11
  # LIQUIDITY_POOL_WITHDRAW_SUCCESS = 0,
12
12
  #
13
13
  # // codes considered as "failure" for the operation
14
- # LIQUIDITY_POOL_WITHDRAW_MALFORMED = -1, // bad input
15
- # LIQUIDITY_POOL_WITHDRAW_NO_TRUST = -2, // no trust line for one of the
16
- # // assets
17
- # LIQUIDITY_POOL_WITHDRAW_UNDERFUNDED = -3, // not enough balance of the
18
- # // pool share
19
- # LIQUIDITY_POOL_WITHDRAW_LINE_FULL = -4, // would go above limit for one
20
- # // of the assets
21
- # LIQUIDITY_POOL_WITHDRAW_UNDER_MINIMUM = -5 // didn't withdraw enough
14
+ # LIQUIDITY_POOL_WITHDRAW_MALFORMED = -1, // bad input
15
+ # LIQUIDITY_POOL_WITHDRAW_NO_TRUST = -2, // no trust line for one of the
16
+ # // assets
17
+ # LIQUIDITY_POOL_WITHDRAW_UNDERFUNDED = -3, // not enough balance of the
18
+ # // pool share
19
+ # LIQUIDITY_POOL_WITHDRAW_LINE_FULL = -4, // would go above limit for one
20
+ # // of the assets
21
+ # LIQUIDITY_POOL_WITHDRAW_UNDER_MINIMUM = -5 // didn't withdraw enough
22
22
  # };
23
23
  #
24
24
  # ===========================================================================
@@ -29,7 +29,9 @@ require 'xdr'
29
29
  # HELLO = 13,
30
30
  #
31
31
  # SURVEY_REQUEST = 14,
32
- # SURVEY_RESPONSE = 15
32
+ # SURVEY_RESPONSE = 15,
33
+ #
34
+ # SEND_MORE = 16
33
35
  # };
34
36
  #
35
37
  # ===========================================================================
@@ -50,6 +52,7 @@ module Stellar
50
52
  member :hello, 13
51
53
  member :survey_request, 14
52
54
  member :survey_response, 15
55
+ member :send_more, 16
53
56
 
54
57
  seal
55
58
  end
@@ -7,7 +7,8 @@ require 'xdr'
7
7
  #
8
8
  # enum OfferEntryFlags
9
9
  # {
10
- # // issuer has authorized account to perform transactions with its credit
10
+ # // an offer with this flag will not act on and take a reverse offer of equal
11
+ # // price
11
12
  # PASSIVE_FLAG = 1
12
13
  # };
13
14
  #
@@ -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
+ # enum PreconditionType
9
+ # {
10
+ # PRECOND_NONE = 0,
11
+ # PRECOND_TIME = 1,
12
+ # PRECOND_V2 = 2
13
+ # };
14
+ #
15
+ # ===========================================================================
16
+ module Stellar
17
+ class PreconditionType < XDR::Enum
18
+ member :precond_none, 0
19
+ member :precond_time, 1
20
+ member :precond_v2, 2
21
+
22
+ seal
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
+ # union Preconditions switch (PreconditionType type)
9
+ # {
10
+ # case PRECOND_NONE:
11
+ # void;
12
+ # case PRECOND_TIME:
13
+ # TimeBounds timeBounds;
14
+ # case PRECOND_V2:
15
+ # PreconditionsV2 v2;
16
+ # };
17
+ #
18
+ # ===========================================================================
19
+ module Stellar
20
+ class Preconditions < XDR::Union
21
+ switch_on PreconditionType, :type
22
+
23
+ switch :precond_none
24
+ switch :precond_time, :time_bounds
25
+ switch :precond_v2, :v2
26
+
27
+ attribute :time_bounds, TimeBounds
28
+ attribute :v2, PreconditionsV2
29
+ end
30
+ end
@@ -0,0 +1,51 @@
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 PreconditionsV2
9
+ # {
10
+ # TimeBounds* timeBounds;
11
+ #
12
+ # // Transaction only valid for ledger numbers n such that
13
+ # // minLedger <= n < maxLedger (if maxLedger == 0, then
14
+ # // only minLedger is checked)
15
+ # LedgerBounds* ledgerBounds;
16
+ #
17
+ # // If NULL, only valid when sourceAccount's sequence number
18
+ # // is seqNum - 1. Otherwise, valid when sourceAccount's
19
+ # // sequence number n satisfies minSeqNum <= n < tx.seqNum.
20
+ # // Note that after execution the account's sequence number
21
+ # // is always raised to tx.seqNum, and a transaction is not
22
+ # // valid if tx.seqNum is too high to ensure replay protection.
23
+ # SequenceNumber* minSeqNum;
24
+ #
25
+ # // For the transaction to be valid, the current ledger time must
26
+ # // be at least minSeqAge greater than sourceAccount's seqTime.
27
+ # Duration minSeqAge;
28
+ #
29
+ # // For the transaction to be valid, the current ledger number
30
+ # // must be at least minSeqLedgerGap greater than sourceAccount's
31
+ # // seqLedger.
32
+ # uint32 minSeqLedgerGap;
33
+ #
34
+ # // For the transaction to be valid, there must be a signature
35
+ # // corresponding to every Signer in this array, even if the
36
+ # // signature is not otherwise required by the sourceAccount or
37
+ # // operations.
38
+ # SignerKey extraSigners<2>;
39
+ # };
40
+ #
41
+ # ===========================================================================
42
+ module Stellar
43
+ class PreconditionsV2 < XDR::Struct
44
+ attribute :time_bounds, XDR::Option[TimeBounds]
45
+ attribute :ledger_bounds, XDR::Option[LedgerBounds]
46
+ attribute :min_seq_num, XDR::Option[SequenceNumber]
47
+ attribute :min_seq_age, Duration
48
+ attribute :min_seq_ledger_gap, Uint32
49
+ attribute :extra_signers, XDR::VarArray[SignerKey, 2]
50
+ end
51
+ end
@@ -0,0 +1,18 @@
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 SendMore
9
+ # {
10
+ # uint32 numMessages;
11
+ # };
12
+ #
13
+ # ===========================================================================
14
+ module Stellar
15
+ class SendMore < XDR::Struct
16
+ attribute :num_messages, Uint32
17
+ end
18
+ end
@@ -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
+ # struct
9
+ # {
10
+ # /* Public key that must sign the payload. */
11
+ # uint256 ed25519;
12
+ # /* Payload to be raw signed by ed25519. */
13
+ # opaque payload<64>;
14
+ # }
15
+ #
16
+ # ===========================================================================
17
+ module Stellar
18
+ class SignerKey
19
+ class Ed25519SignedPayload < XDR::Struct
20
+ attribute :ed25519, Uint256
21
+ attribute :payload, XDR::VarOpaque[64]
22
+ end
23
+ end
24
+ end
@@ -15,19 +15,33 @@ require 'xdr'
15
15
  # case SIGNER_KEY_TYPE_HASH_X:
16
16
  # /* Hash of random 256 bit preimage X */
17
17
  # uint256 hashX;
18
+ # case SIGNER_KEY_TYPE_ED25519_SIGNED_PAYLOAD:
19
+ # struct
20
+ # {
21
+ # /* Public key that must sign the payload. */
22
+ # uint256 ed25519;
23
+ # /* Payload to be raw signed by ed25519. */
24
+ # opaque payload<64>;
25
+ # } ed25519SignedPayload;
18
26
  # };
19
27
  #
20
28
  # ===========================================================================
21
29
  module Stellar
22
30
  class SignerKey < XDR::Union
31
+ include XDR::Namespace
32
+
33
+ autoload :Ed25519SignedPayload
34
+
23
35
  switch_on SignerKeyType, :type
24
36
 
25
- switch :signer_key_type_ed25519, :ed25519
26
- switch :signer_key_type_pre_auth_tx, :pre_auth_tx
27
- switch :signer_key_type_hash_x, :hash_x
37
+ switch :signer_key_type_ed25519, :ed25519
38
+ switch :signer_key_type_pre_auth_tx, :pre_auth_tx
39
+ switch :signer_key_type_hash_x, :hash_x
40
+ switch :signer_key_type_ed25519_signed_payload, :ed25519_signed_payload
28
41
 
29
- attribute :ed25519, Uint256
30
- attribute :pre_auth_tx, Uint256
31
- attribute :hash_x, Uint256
42
+ attribute :ed25519, Uint256
43
+ attribute :pre_auth_tx, Uint256
44
+ attribute :hash_x, Uint256
45
+ attribute :ed25519_signed_payload, Ed25519SignedPayload
32
46
  end
33
47
  end
@@ -9,15 +9,17 @@ require 'xdr'
9
9
  # {
10
10
  # SIGNER_KEY_TYPE_ED25519 = KEY_TYPE_ED25519,
11
11
  # SIGNER_KEY_TYPE_PRE_AUTH_TX = KEY_TYPE_PRE_AUTH_TX,
12
- # SIGNER_KEY_TYPE_HASH_X = KEY_TYPE_HASH_X
12
+ # SIGNER_KEY_TYPE_HASH_X = KEY_TYPE_HASH_X,
13
+ # SIGNER_KEY_TYPE_ED25519_SIGNED_PAYLOAD = KEY_TYPE_ED25519_SIGNED_PAYLOAD
13
14
  # };
14
15
  #
15
16
  # ===========================================================================
16
17
  module Stellar
17
18
  class SignerKeyType < XDR::Enum
18
- member :signer_key_type_ed25519, 0
19
- member :signer_key_type_pre_auth_tx, 1
20
- member :signer_key_type_hash_x, 2
19
+ member :signer_key_type_ed25519, 0
20
+ member :signer_key_type_pre_auth_tx, 1
21
+ member :signer_key_type_hash_x, 2
22
+ member :signer_key_type_ed25519_signed_payload, 3
21
23
 
22
24
  seal
23
25
  end
@@ -43,6 +43,8 @@ require 'xdr'
43
43
  # SCPEnvelope envelope;
44
44
  # case GET_SCP_STATE:
45
45
  # uint32 getSCPLedgerSeq; // ledger seq requested ; if 0, requests the latest
46
+ # case SEND_MORE:
47
+ # SendMore sendMoreMessage;
46
48
  # };
47
49
  #
48
50
  # ===========================================================================
@@ -65,6 +67,7 @@ module Stellar
65
67
  switch :scp_quorumset, :q_set
66
68
  switch :scp_message, :envelope
67
69
  switch :get_scp_state, :get_scp_ledger_seq
70
+ switch :send_more, :send_more_message
68
71
 
69
72
  attribute :error, Error
70
73
  attribute :hello, Hello
@@ -80,5 +83,6 @@ module Stellar
80
83
  attribute :q_set, SCPQuorumSet
81
84
  attribute :envelope, SCPEnvelope
82
85
  attribute :get_scp_ledger_seq, Uint32
86
+ attribute :send_more_message, SendMore
83
87
  end
84
88
  end
@@ -16,8 +16,8 @@ require 'xdr'
16
16
  # // sequence number to consume in the account
17
17
  # SequenceNumber seqNum;
18
18
  #
19
- # // validity range (inclusive) for the last ledger close time
20
- # TimeBounds* timeBounds;
19
+ # // validity conditions
20
+ # Preconditions cond;
21
21
  #
22
22
  # Memo memo;
23
23
  #
@@ -42,7 +42,7 @@ module Stellar
42
42
  attribute :source_account, MuxedAccount
43
43
  attribute :fee, Uint32
44
44
  attribute :seq_num, SequenceNumber
45
- attribute :time_bounds, XDR::Option[TimeBounds]
45
+ attribute :cond, Preconditions
46
46
  attribute :memo, Memo
47
47
  attribute :operations, XDR::VarArray[Operation, MAX_OPS_PER_TX]
48
48
  attribute :ext, Ext
@@ -26,7 +26,10 @@ require 'xdr'
26
26
  #
27
27
  # txNOT_SUPPORTED = -12, // transaction type not supported
28
28
  # txFEE_BUMP_INNER_FAILED = -13, // fee bump inner transaction failed
29
- # txBAD_SPONSORSHIP = -14 // sponsorship not confirmed
29
+ # txBAD_SPONSORSHIP = -14, // sponsorship not confirmed
30
+ # txBAD_MIN_SEQ_AGE_OR_GAP =
31
+ # -15, // minSeqAge or minSeqLedgerGap conditions not met
32
+ # txMALFORMED = -16 // precondition is invalid
30
33
  # };
31
34
  #
32
35
  # ===========================================================================
@@ -48,6 +51,8 @@ module Stellar
48
51
  member :tx_not_supported, -12
49
52
  member :tx_fee_bump_inner_failed, -13
50
53
  member :tx_bad_sponsorship, -14
54
+ member :tx_bad_min_seq_age_or_gap, -15
55
+ member :tx_malformed, -16
51
56
 
52
57
  seal
53
58
  end
@@ -12,6 +12,7 @@ module Stellar
12
12
  Int32 = XDR::Int
13
13
  Uint64 = XDR::UnsignedHyper
14
14
  Int64 = XDR::Hyper
15
+ autoload :ExtensionPoint
15
16
  autoload :CryptoKeyType
16
17
  autoload :PublicKeyType
17
18
  autoload :SignerKeyType
@@ -34,6 +35,7 @@ module Stellar
34
35
  String64 = XDR::String[64]
35
36
  SequenceNumber = Int64
36
37
  TimePoint = Uint64
38
+ Duration = Uint64
37
39
  DataValue = XDR::VarOpaque[64]
38
40
  PoolID = Hash
39
41
  AssetCode4 = XDR::Opaque[4]
@@ -53,6 +55,7 @@ module Stellar
53
55
  MASK_ACCOUNT_FLAGS_V17 = 0xF
54
56
  MAX_SIGNERS = 20
55
57
  SponsorshipDescriptor = XDR::Option[AccountID]
58
+ autoload :AccountEntryExtensionV3
56
59
  autoload :AccountEntryExtensionV2
57
60
  autoload :AccountEntryExtensionV1
58
61
  autoload :AccountEntry
@@ -121,6 +124,10 @@ module Stellar
121
124
  autoload :MemoType
122
125
  autoload :Memo
123
126
  autoload :TimeBounds
127
+ autoload :LedgerBounds
128
+ autoload :PreconditionsV2
129
+ autoload :PreconditionType
130
+ autoload :Preconditions
124
131
  MAX_OPS_PER_TX = 100
125
132
  autoload :TransactionV0
126
133
  autoload :TransactionV0Envelope
@@ -234,6 +241,7 @@ module Stellar
234
241
 
235
242
  autoload :ErrorCode
236
243
  autoload :Error
244
+ autoload :SendMore
237
245
  autoload :AuthCert
238
246
  autoload :Hello
239
247
  autoload :Auth
@@ -15,7 +15,7 @@ module Stellar
15
15
  operations: operations,
16
16
  fee: fee,
17
17
  memo: memo,
18
- time_bounds: time_bounds,
18
+ time_bounds: cond.v2&.time_bounds || cond.time_bounds,
19
19
  ext: ext
20
20
  )
21
21
  end
@@ -2,7 +2,18 @@ module Stellar
2
2
  class TransactionBuilder
3
3
  include Stellar::DSL
4
4
 
5
- attr_reader :source_account, :sequence_number, :base_fee, :time_bounds, :memo, :operations
5
+ attr_reader :source_account, :sequence_number, :base_fee,
6
+ :time_bounds, :memo, :operations, :ledger_bounds
7
+
8
+ # If you want to prepare a transaction which will be valid only while the
9
+ # account sequence number is
10
+ #
11
+ # min_account_sequence <= source_account_sequence < tx.seq_num
12
+ #
13
+ # you can set min_account_sequence attribute
14
+ #
15
+ # Note that after execution the account's sequence number is always raised to `tx.seq_num`
16
+ attr_accessor :min_account_sequence
6
17
 
7
18
  class << self
8
19
  # This enable user to call shortcut methods, like
@@ -33,7 +44,12 @@ module Stellar
33
44
  sequence_number:,
34
45
  base_fee: 100,
35
46
  time_bounds: nil,
47
+ ledger_bounds: nil,
36
48
  memo: nil,
49
+ min_account_sequence: nil,
50
+ min_account_sequence_age: nil,
51
+ min_account_sequence_ledger_gap: nil,
52
+ extra_signers: [],
37
53
  **_ # ignore any additional parameters without errors
38
54
  )
39
55
  raise ArgumentError, "Bad :sequence_number" unless sequence_number.is_a?(Integer) && sequence_number >= 0
@@ -44,6 +60,11 @@ module Stellar
44
60
  @sequence_number = sequence_number
45
61
  @base_fee = base_fee
46
62
  @time_bounds = time_bounds
63
+ @ledger_bounds = ledger_bounds
64
+ @min_account_sequence = min_account_sequence
65
+ @min_account_sequence_age = min_account_sequence_age
66
+ @min_account_sequence_ledger_gap = min_account_sequence_ledger_gap
67
+ @extra_signers = extra_signers.clone
47
68
 
48
69
  set_timeout(0) if time_bounds.nil?
49
70
 
@@ -64,9 +85,9 @@ module Stellar
64
85
  source_account: @source_account.muxed_account,
65
86
  fee: @base_fee * @operations.length,
66
87
  seq_num: @sequence_number,
67
- time_bounds: @time_bounds,
68
88
  memo: @memo,
69
89
  operations: @operations,
90
+ cond: build_preconditions,
70
91
  ext: Stellar::Transaction::Ext.new(0)
71
92
  }
72
93
 
@@ -136,6 +157,70 @@ module Stellar
136
157
  self
137
158
  end
138
159
 
160
+ # If you want to prepare a transaction which will only be valid within some
161
+ # range of ledgers, you can set a `ledger_bounds` precondition.
162
+ def set_ledger_bounds(min_ledger, max_ledger)
163
+ if min_ledger < 0
164
+ raise ArgumentError, "min_ledger cannot be negative"
165
+ end
166
+
167
+ if max_ledger < 0
168
+ raise ArgumentError, "max_ledger cannot be negative"
169
+ end
170
+
171
+ if max_ledger > 0 && min_ledger > max_ledger
172
+ raise ArgumentError, "min_ledger cannot be greater than max_ledger"
173
+ end
174
+
175
+ @ledger_bounds = Stellar::LedgerBounds.new(
176
+ min_ledger: min_ledger,
177
+ max_ledger: max_ledger
178
+ )
179
+
180
+ self
181
+ end
182
+
183
+ # For the transaction to be valid, the current ledger time must be at least
184
+ # `min_account_sequence_age` greater than source account's `sequence_time`
185
+ def min_account_sequence_age=(duration_in_seconds)
186
+ unless duration_in_seconds.is_a?(Integer)
187
+ raise ArgumentError, "min_account_sequence_age must be a number"
188
+ end
189
+
190
+ if duration_in_seconds < 0
191
+ raise ArgumentError, "min_account_sequence_age cannot be negative"
192
+ end
193
+
194
+ @min_account_sequence_age = duration_in_seconds
195
+ end
196
+
197
+ # For the transaction to be valid, the current ledger number must be at least
198
+ # `minAccountSequenceLedgerGap` greater than sourceAccount's ledger sequence.
199
+ def min_account_sequence_ledger_gap=(gap)
200
+ if gap < 0
201
+ raise ArgumentError, "min_account_sequence_ledger_gap cannot be negative"
202
+ end
203
+
204
+ @min_account_sequence_ledger_gap = gap
205
+ end
206
+
207
+ # For the transaction to be valid, there must be a signature corresponding to
208
+ # every Signer in this array, even if the signature is not otherwise required
209
+ # by the sourceAccount or operations
210
+ def set_extra_signers(extra_signers)
211
+ unless extra_signers.is_a?(Array)
212
+ raise ArgumentError, "extra_signers must be an array of strings"
213
+ end
214
+
215
+ if extra_signers.size > 2
216
+ raise ArgumentError, "extra_signers cannot be longer than 2 elements"
217
+ end
218
+
219
+ @extra_signers = extra_signers.clone
220
+
221
+ self
222
+ end
223
+
139
224
  def set_memo(memo)
140
225
  @memo = make_memo(memo)
141
226
  self
@@ -164,5 +249,33 @@ module Stellar
164
249
  raise ArgumentError, "Bad :memo"
165
250
  end
166
251
  end
252
+
253
+ private
254
+
255
+ def has_v2_preconditions?
256
+ !(
257
+ @ledger_bounds.nil? &&
258
+ @min_account_sequence.nil? &&
259
+ @min_account_sequence_age.nil? &&
260
+ @extra_signers.empty? &&
261
+ @min_account_sequence_ledger_gap.nil?
262
+ )
263
+ end
264
+
265
+ def build_preconditions
266
+ return Stellar::Preconditions.new(:precond_time, @time_bounds) unless has_v2_preconditions?
267
+
268
+ Stellar::Preconditions.new(
269
+ :precond_v2,
270
+ Stellar::PreconditionsV2.new(
271
+ time_bounds: @time_bounds,
272
+ ledger_bounds: @ledger_bounds,
273
+ min_seq_num: @min_account_sequence,
274
+ min_seq_age: @min_account_sequence_age,
275
+ min_seq_ledger_gap: @min_account_sequence_ledger_gap,
276
+ extra_signers: @extra_signers.map { |signer| SignerKey(signer) }
277
+ )
278
+ )
279
+ end
167
280
  end
168
281
  end
@@ -3,7 +3,11 @@ module Stellar
3
3
  include Stellar::Concerns::Transaction
4
4
 
5
5
  def to_v1
6
- Transaction.new(**attributes.except(:source_account_ed25519), source_account: source_account)
6
+ Transaction.new(
7
+ **attributes.except(:source_account_ed25519, :time_bounds),
8
+ cond: Stellar::Preconditions.new(:precond_time, time_bounds),
9
+ source_account: source_account
10
+ )
7
11
  end
8
12
 
9
13
  def to_envelope(*key_pairs)
@@ -9,7 +9,8 @@ module Stellar
9
9
  seed: [18 << 3].pack("C"), # Base32-encodes to 'S...'
10
10
  pre_auth_tx: [19 << 3].pack("C"), # Base32-encodes to 'T...'
11
11
  hash_x: [23 << 3].pack("C"), # Base32-encodes to 'X...'
12
- muxed: [12 << 3].pack("C") # Base32-encodes to 'M...'
12
+ muxed: [12 << 3].pack("C"), # Base32-encodes to 'M...'
13
+ signed_payload: [15 << 3].pack("C") # Base32-encodes to 'P...'
13
14
  }
14
15
 
15
16
  def self.check_encode(version, byte_str)
@@ -50,6 +51,19 @@ module Stellar
50
51
  end
51
52
  end
52
53
 
54
+ # @param payload [Stellar::SignerKey::Ed25519SignedPayload]
55
+ # @return [String] "P.."-like address
56
+ def self.encode_signed_payload(payload)
57
+ check_encode(:signed_payload, payload.to_xdr)
58
+ end
59
+
60
+ # @param strkey [String] address string to decode
61
+ # @return [Stellar::SignerKey::Ed25519SignedPayload]
62
+ def self.decode_signed_payload(strkey)
63
+ raw = check_decode(:signed_payload, strkey)
64
+ Stellar::SignerKey::Ed25519SignedPayload.from_xdr(raw, :raw)
65
+ end
66
+
53
67
  def self.check_decode(expected_version, str)
54
68
  decoded = begin
55
69
  Base32.decode(str)
@@ -1,3 +1,3 @@
1
1
  module Stellar
2
- VERSION = "0.31.0".freeze
2
+ VERSION = "0.32.0".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stellar-base
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.31.0
4
+ version: 0.32.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Fleckenstein
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2022-02-21 00:00:00.000000000 Z
13
+ date: 2022-05-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -133,6 +133,7 @@ files:
133
133
  - generated/stellar/account_entry_extension_v1/ext.rb
134
134
  - generated/stellar/account_entry_extension_v2.rb
135
135
  - generated/stellar/account_entry_extension_v2/ext.rb
136
+ - generated/stellar/account_entry_extension_v3.rb
136
137
  - generated/stellar/account_flags.rb
137
138
  - generated/stellar/account_merge_result.rb
138
139
  - generated/stellar/account_merge_result_code.rb
@@ -207,6 +208,7 @@ files:
207
208
  - generated/stellar/envelope_type.rb
208
209
  - generated/stellar/error.rb
209
210
  - generated/stellar/error_code.rb
211
+ - generated/stellar/extension_point.rb
210
212
  - generated/stellar/fee_bump_transaction.rb
211
213
  - generated/stellar/fee_bump_transaction/ext.rb
212
214
  - generated/stellar/fee_bump_transaction/inner_tx.rb
@@ -225,6 +227,7 @@ files:
225
227
  - generated/stellar/inner_transaction_result/result.rb
226
228
  - generated/stellar/inner_transaction_result_pair.rb
227
229
  - generated/stellar/ip_addr_type.rb
230
+ - generated/stellar/ledger_bounds.rb
228
231
  - generated/stellar/ledger_close_meta.rb
229
232
  - generated/stellar/ledger_close_meta_v0.rb
230
233
  - generated/stellar/ledger_close_value_signature.rb
@@ -307,6 +310,9 @@ files:
307
310
  - generated/stellar/peer_address.rb
308
311
  - generated/stellar/peer_address/ip.rb
309
312
  - generated/stellar/peer_stats.rb
313
+ - generated/stellar/precondition_type.rb
314
+ - generated/stellar/preconditions.rb
315
+ - generated/stellar/preconditions_v2.rb
310
316
  - generated/stellar/price.rb
311
317
  - generated/stellar/public_key.rb
312
318
  - generated/stellar/public_key_type.rb
@@ -327,6 +333,7 @@ files:
327
333
  - generated/stellar/scp_statement/pledges/externalize.rb
328
334
  - generated/stellar/scp_statement/pledges/prepare.rb
329
335
  - generated/stellar/scp_statement_type.rb
336
+ - generated/stellar/send_more.rb
330
337
  - generated/stellar/set_options_op.rb
331
338
  - generated/stellar/set_options_result.rb
332
339
  - generated/stellar/set_options_result_code.rb
@@ -337,6 +344,7 @@ files:
337
344
  - generated/stellar/signed_survey_response_message.rb
338
345
  - generated/stellar/signer.rb
339
346
  - generated/stellar/signer_key.rb
347
+ - generated/stellar/signer_key/ed25519_signed_payload.rb
340
348
  - generated/stellar/signer_key_type.rb
341
349
  - generated/stellar/simple_payment_result.rb
342
350
  - generated/stellar/stellar_message.rb
@@ -421,11 +429,11 @@ licenses:
421
429
  - Apache-2.0
422
430
  metadata:
423
431
  bug_tracker_uri: https://github.com/astroband/ruby-stellar-sdk/issues
424
- changelog_uri: https://github.com/astroband/ruby-stellar-sdk/blob/v0.31.0/base/CHANGELOG.md
425
- documentation_uri: https://rubydoc.info/gems/stellar-base/0.31.0/
432
+ changelog_uri: https://github.com/astroband/ruby-stellar-sdk/blob/v0.32.0/base/CHANGELOG.md
433
+ documentation_uri: https://rubydoc.info/gems/stellar-base/0.32.0/
426
434
  github_repo: ssh://github.com/astroband/ruby-stellar-sdk
427
435
  homepage_uri: https://github.com/astroband/ruby-stellar-sdk/tree/main/base
428
- source_code_uri: https://github.com/astroband/ruby-stellar-sdk/tree/v0.31.0/base
436
+ source_code_uri: https://github.com/astroband/ruby-stellar-sdk/tree/v0.32.0/base
429
437
  post_install_message:
430
438
  rdoc_options: []
431
439
  require_paths:
@@ -442,7 +450,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
442
450
  - !ruby/object:Gem::Version
443
451
  version: '0'
444
452
  requirements: []
445
- rubygems_version: 3.3.5
453
+ rubygems_version: 3.1.6
446
454
  signing_key:
447
455
  specification_version: 4
448
456
  summary: 'Stellar client library: XDR'