stellar-base 0.24.0 → 0.28.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +79 -56
- data/README.md +7 -7
- data/generated/stellar-base-generated.rb +15 -0
- data/generated/stellar/account_flags.rb +9 -4
- data/generated/stellar/account_merge_result.rb +1 -1
- data/generated/stellar/allow_trust_op.rb +3 -18
- data/generated/stellar/asset_code.rb +30 -0
- data/generated/stellar/begin_sponsoring_future_reserves_result.rb +2 -1
- data/generated/stellar/claimable_balance_entry.rb +2 -0
- data/generated/stellar/claimable_balance_entry/ext.rb +4 -0
- data/generated/stellar/claimable_balance_entry_extension_v1.rb +30 -0
- data/generated/stellar/claimable_balance_entry_extension_v1/ext.rb +24 -0
- data/generated/stellar/claimable_balance_flags.rb +22 -0
- data/generated/stellar/clawback_claimable_balance_op.rb +18 -0
- data/generated/stellar/clawback_claimable_balance_result.rb +26 -0
- data/generated/stellar/clawback_claimable_balance_result_code.rb +29 -0
- data/generated/stellar/clawback_op.rb +22 -0
- data/generated/stellar/clawback_result.rb +25 -0
- data/generated/stellar/clawback_result_code.rb +31 -0
- data/generated/stellar/create_passive_sell_offer_op.rb +1 -1
- data/generated/stellar/end_sponsoring_future_reserves_result.rb +2 -1
- data/generated/stellar/operation.rb +6 -0
- data/generated/stellar/operation/body.rb +12 -0
- data/generated/stellar/operation_id.rb +1 -1
- data/generated/stellar/operation_id/id.rb +2 -2
- data/generated/stellar/operation_result.rb +6 -0
- data/generated/stellar/operation_result/tr.rb +12 -0
- data/generated/stellar/operation_type.rb +7 -1
- data/generated/stellar/payment_result_code.rb +1 -1
- data/generated/stellar/revoke_sponsorship_op.rb +1 -2
- data/generated/stellar/set_options_result_code.rb +14 -11
- data/generated/stellar/set_trust_line_flags_op.rb +25 -0
- data/generated/stellar/set_trust_line_flags_result.rb +25 -0
- data/generated/stellar/set_trust_line_flags_result_code.rb +31 -0
- data/generated/stellar/transaction_result_code.rb +1 -1
- data/generated/stellar/trust_line_flags.rb +5 -1
- data/lib/stellar-base.rb +6 -2
- data/lib/stellar/account.rb +59 -0
- data/lib/stellar/asset.rb +10 -0
- data/lib/stellar/compat.rb +6 -7
- data/lib/stellar/concerns/transaction.rb +5 -4
- data/lib/stellar/dsl.rb +32 -5
- data/lib/stellar/ext/xdr.rb +8 -7
- data/lib/stellar/key_pair.rb +22 -23
- data/lib/stellar/ledger_key.rb +4 -2
- data/lib/stellar/muxed_account.rb +16 -0
- data/lib/stellar/operation.rb +89 -19
- data/lib/stellar/transaction.rb +1 -1
- data/lib/stellar/transaction_builder.rb +20 -7
- data/lib/stellar/transaction_envelope.rb +6 -16
- data/lib/stellar/transaction_v0.rb +2 -10
- data/lib/stellar/trust_line_flags.rb +53 -0
- data/lib/stellar/util/strkey.rb +15 -7
- data/lib/stellar/version.rb +3 -0
- metadata +34 -16
- data/generated/stellar/allow_trust_op/asset.rb +0 -33
- data/lib/stellar/base/version.rb +0 -5
@@ -48,6 +48,12 @@ require 'xdr'
|
|
48
48
|
# EndSponsoringFutureReservesResult endSponsoringFutureReservesResult;
|
49
49
|
# case REVOKE_SPONSORSHIP:
|
50
50
|
# RevokeSponsorshipResult revokeSponsorshipResult;
|
51
|
+
# case CLAWBACK:
|
52
|
+
# ClawbackResult clawbackResult;
|
53
|
+
# case CLAWBACK_CLAIMABLE_BALANCE:
|
54
|
+
# ClawbackClaimableBalanceResult clawbackClaimableBalanceResult;
|
55
|
+
# case SET_TRUST_LINE_FLAGS:
|
56
|
+
# SetTrustLineFlagsResult setTrustLineFlagsResult;
|
51
57
|
# }
|
52
58
|
# tr;
|
53
59
|
# default:
|
@@ -45,6 +45,12 @@ require 'xdr'
|
|
45
45
|
# EndSponsoringFutureReservesResult endSponsoringFutureReservesResult;
|
46
46
|
# case REVOKE_SPONSORSHIP:
|
47
47
|
# RevokeSponsorshipResult revokeSponsorshipResult;
|
48
|
+
# case CLAWBACK:
|
49
|
+
# ClawbackResult clawbackResult;
|
50
|
+
# case CLAWBACK_CLAIMABLE_BALANCE:
|
51
|
+
# ClawbackClaimableBalanceResult clawbackClaimableBalanceResult;
|
52
|
+
# case SET_TRUST_LINE_FLAGS:
|
53
|
+
# SetTrustLineFlagsResult setTrustLineFlagsResult;
|
48
54
|
# }
|
49
55
|
#
|
50
56
|
# ===========================================================================
|
@@ -72,6 +78,9 @@ module Stellar
|
|
72
78
|
switch :begin_sponsoring_future_reserves, :begin_sponsoring_future_reserves_result
|
73
79
|
switch :end_sponsoring_future_reserves, :end_sponsoring_future_reserves_result
|
74
80
|
switch :revoke_sponsorship, :revoke_sponsorship_result
|
81
|
+
switch :clawback, :clawback_result
|
82
|
+
switch :clawback_claimable_balance, :clawback_claimable_balance_result
|
83
|
+
switch :set_trust_line_flags, :set_trust_line_flags_result
|
75
84
|
|
76
85
|
attribute :create_account_result, CreateAccountResult
|
77
86
|
attribute :payment_result, PaymentResult
|
@@ -92,6 +101,9 @@ module Stellar
|
|
92
101
|
attribute :begin_sponsoring_future_reserves_result, BeginSponsoringFutureReservesResult
|
93
102
|
attribute :end_sponsoring_future_reserves_result, EndSponsoringFutureReservesResult
|
94
103
|
attribute :revoke_sponsorship_result, RevokeSponsorshipResult
|
104
|
+
attribute :clawback_result, ClawbackResult
|
105
|
+
attribute :clawback_claimable_balance_result, ClawbackClaimableBalanceResult
|
106
|
+
attribute :set_trust_line_flags_result, SetTrustLineFlagsResult
|
95
107
|
end
|
96
108
|
end
|
97
109
|
end
|
@@ -25,7 +25,10 @@ require 'xdr'
|
|
25
25
|
# CLAIM_CLAIMABLE_BALANCE = 15,
|
26
26
|
# BEGIN_SPONSORING_FUTURE_RESERVES = 16,
|
27
27
|
# END_SPONSORING_FUTURE_RESERVES = 17,
|
28
|
-
# REVOKE_SPONSORSHIP = 18
|
28
|
+
# REVOKE_SPONSORSHIP = 18,
|
29
|
+
# CLAWBACK = 19,
|
30
|
+
# CLAWBACK_CLAIMABLE_BALANCE = 20,
|
31
|
+
# SET_TRUST_LINE_FLAGS = 21
|
29
32
|
# };
|
30
33
|
#
|
31
34
|
# ===========================================================================
|
@@ -50,6 +53,9 @@ module Stellar
|
|
50
53
|
member :begin_sponsoring_future_reserves, 16
|
51
54
|
member :end_sponsoring_future_reserves, 17
|
52
55
|
member :revoke_sponsorship, 18
|
56
|
+
member :clawback, 19
|
57
|
+
member :clawback_claimable_balance, 20
|
58
|
+
member :set_trust_line_flags, 21
|
53
59
|
|
54
60
|
seal
|
55
61
|
end
|
@@ -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
|
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
|
@@ -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
|
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,
|
28
|
-
member :set_options_low_reserve,
|
29
|
-
member :set_options_too_many_signers,
|
30
|
-
member :set_options_bad_flags,
|
31
|
-
member :set_options_invalid_inflation,
|
32
|
-
member :set_options_cant_change,
|
33
|
-
member :set_options_unknown_flag,
|
34
|
-
member :set_options_threshold_out_of_range,
|
35
|
-
member :set_options_bad_signer,
|
36
|
-
member :set_options_invalid_home_domain,
|
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,31 @@
|
|
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
|
+
# };
|
19
|
+
#
|
20
|
+
# ===========================================================================
|
21
|
+
module Stellar
|
22
|
+
class SetTrustLineFlagsResultCode < XDR::Enum
|
23
|
+
member :set_trust_line_flags_success, 0
|
24
|
+
member :set_trust_line_flags_malformed, -1
|
25
|
+
member :set_trust_line_flags_no_trust_line, -2
|
26
|
+
member :set_trust_line_flags_cant_revoke, -3
|
27
|
+
member :set_trust_line_flags_invalid_state, -4
|
28
|
+
|
29
|
+
seal
|
30
|
+
end
|
31
|
+
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
|
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
|
@@ -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
|
data/lib/stellar-base.rb
CHANGED
@@ -5,6 +5,8 @@ require "active_support/core_ext/object/blank"
|
|
5
5
|
require "active_support/core_ext/enumerable"
|
6
6
|
require "active_support/core_ext/kernel/reporting"
|
7
7
|
require "active_support/core_ext/module/attribute_accessors_per_thread"
|
8
|
+
require "active_support/core_ext/module/delegation"
|
9
|
+
require "active_support/deprecation"
|
8
10
|
|
9
11
|
require_relative "stellar/ext/xdr"
|
10
12
|
|
@@ -14,13 +16,14 @@ silence_warnings do
|
|
14
16
|
end
|
15
17
|
Stellar.load_all!
|
16
18
|
|
17
|
-
require_relative "stellar/
|
18
|
-
Stellar::VERSION = Stellar::Base::VERSION
|
19
|
+
require_relative "stellar/version"
|
19
20
|
|
20
21
|
Stellar::ONE = 1_0000000
|
22
|
+
Stellar::Deprecation = ActiveSupport::Deprecation.new("next release", "stellar-base")
|
21
23
|
|
22
24
|
# extensions onto the generated files must be loaded manually, below
|
23
25
|
|
26
|
+
require_relative "./stellar/account"
|
24
27
|
require_relative "./stellar/account_flags"
|
25
28
|
require_relative "./stellar/asset"
|
26
29
|
require_relative "./stellar/claim_predicate"
|
@@ -32,6 +35,7 @@ require_relative "./stellar/path_payment_strict_receive_result"
|
|
32
35
|
require_relative "./stellar/price"
|
33
36
|
require_relative "./stellar/signer_key"
|
34
37
|
require_relative "./stellar/thresholds"
|
38
|
+
require_relative "./stellar/trust_line_flags"
|
35
39
|
|
36
40
|
require_relative "./stellar/concerns/transaction"
|
37
41
|
require_relative "./stellar/fee_bump_transaction"
|
@@ -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
|
data/lib/stellar/asset.rb
CHANGED
@@ -6,14 +6,24 @@ module Stellar
|
|
6
6
|
new(:asset_type_native)
|
7
7
|
end
|
8
8
|
|
9
|
+
# @param code [String] asset code
|
10
|
+
# @param issuer [#to_keypair] asset issuer
|
11
|
+
#
|
12
|
+
# @return [Stellar::Asset::AlphaNum4] asset4 representation
|
9
13
|
def self.alphanum4(code, issuer)
|
14
|
+
issuer = issuer.to_keypair if issuer.respond_to?(:to_keypair)
|
10
15
|
raise ArgumentError, "Bad :issuer" unless issuer.is_a?(KeyPair)
|
11
16
|
code = normalize_code(code, 4)
|
12
17
|
an = AlphaNum4.new({asset_code: code, issuer: issuer.account_id})
|
13
18
|
new(:asset_type_credit_alphanum4, an)
|
14
19
|
end
|
15
20
|
|
21
|
+
# @param code [String] asset code
|
22
|
+
# @param issuer [#to_keypair] asset issuer
|
23
|
+
#
|
24
|
+
# @return [Stellar::Asset::AlphaNum4] asset4 representation
|
16
25
|
def self.alphanum12(code, issuer)
|
26
|
+
issuer = issuer.to_keypair if issuer.respond_to?(:to_keypair)
|
17
27
|
raise ArgumentError, "Bad :issuer" unless issuer.is_a?(KeyPair)
|
18
28
|
code = normalize_code(code, 12)
|
19
29
|
an = AlphaNum12.new({asset_code: code, issuer: issuer.account_id})
|
data/lib/stellar/compat.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
|
-
require "active_support/deprecation"
|
2
|
-
|
3
|
-
Stellar::Deprecation ||= ActiveSupport::Deprecation.new("next release", "stellar-base")
|
4
|
-
|
5
1
|
class << Stellar::Operation
|
6
2
|
alias_method :manage_offer, :manage_sell_offer
|
7
3
|
alias_method :create_passive_offer, :create_passive_sell_offer
|
8
4
|
|
9
|
-
deprecate
|
10
|
-
|
11
|
-
|
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
|
+
)
|
12
11
|
end
|
@@ -19,7 +19,7 @@ module Stellar::Concerns
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def merge(other)
|
22
|
-
cloned =
|
22
|
+
cloned = from_xdr(to_xdr)
|
23
23
|
cloned.operations += other.to_operations
|
24
24
|
cloned
|
25
25
|
end
|
@@ -32,9 +32,10 @@ module Stellar::Concerns
|
|
32
32
|
#
|
33
33
|
# @return [Array<Operation>] the operations
|
34
34
|
def to_operations
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
codec = XDR::VarArray[Stellar::Operation]
|
36
|
+
ops = respond_to?(:operations) ? operations : inner_tx.value.tx.operations
|
37
|
+
cloned = codec.from_xdr(codec.to_xdr(ops))
|
38
|
+
cloned.each do |op|
|
38
39
|
op.source_account ||= source_account
|
39
40
|
end
|
40
41
|
end
|
data/lib/stellar/dsl.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module Stellar
|
2
2
|
module DSL
|
3
|
+
module_function
|
4
|
+
|
3
5
|
# Constructs a new ClaimPredicate using DSL
|
4
6
|
#
|
5
7
|
# @example fulfilled during [T+5min, T+60min] period, where T refers to claimable balance entry creation time
|
@@ -25,6 +27,28 @@ module Stellar
|
|
25
27
|
)
|
26
28
|
end
|
27
29
|
|
30
|
+
def Account(subject = nil)
|
31
|
+
case subject
|
32
|
+
when Account
|
33
|
+
subject
|
34
|
+
when /^M[A-Z0-9]{68}$/
|
35
|
+
Account.from_address(subject.to_str)
|
36
|
+
when nil
|
37
|
+
Account.random
|
38
|
+
else
|
39
|
+
begin
|
40
|
+
keypair = KeyPair(subject)
|
41
|
+
|
42
|
+
Account.new(keypair)
|
43
|
+
rescue TypeError
|
44
|
+
raise TypeError, "Cannot convert #{subject.inspect} to Stellar::Account"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# @param [Asset, String, nil] subject
|
50
|
+
# @return [Stellar::Asset] instance of the Stellar::Asset
|
51
|
+
# @raise [TypeError] if subject cannot be converted to Stellar::Asset
|
28
52
|
def Asset(subject = nil)
|
29
53
|
case subject
|
30
54
|
when Asset
|
@@ -43,18 +67,21 @@ module Stellar
|
|
43
67
|
# Generates Stellar::Keypair from subject, use Stellar::Client.to_keypair as shortcut.
|
44
68
|
# @param subject [String|Stellar::Account|Stellar::PublicKey|Stellar::SignerKey|Stellar::Keypair] subject.
|
45
69
|
# @return [Stellar::Keypair] Stellar::Keypair instance.
|
70
|
+
# @raise [TypeError] if subject cannot be converted to Stellar::KeyPair
|
46
71
|
def KeyPair(subject = nil)
|
47
72
|
case subject
|
48
73
|
when ->(subj) { subj.respond_to?(:to_keypair) }
|
49
74
|
subject.to_keypair
|
50
|
-
when /G[A-Z0-9]{55}/
|
51
|
-
KeyPair.from_address(subject)
|
52
|
-
when /S[A-Z0-9]{55}/
|
53
|
-
KeyPair.from_seed(subject)
|
54
75
|
when PublicKey
|
55
76
|
KeyPair.from_public_key(subject.value)
|
56
77
|
when SignerKey
|
57
78
|
KeyPair.from_raw_seed(subject.value)
|
79
|
+
when /^G[A-Z0-9]{55}$/
|
80
|
+
KeyPair.from_address(subject.to_str)
|
81
|
+
when /^S[A-Z0-9]{55}$/
|
82
|
+
KeyPair.from_seed(subject.to_str)
|
83
|
+
when /^.{32}$/
|
84
|
+
KeyPair.from_raw_seed(subject.to_str)
|
58
85
|
when nil
|
59
86
|
KeyPair.random
|
60
87
|
else
|
@@ -81,5 +108,5 @@ module Stellar
|
|
81
108
|
end
|
82
109
|
end
|
83
110
|
|
84
|
-
|
111
|
+
include DSL
|
85
112
|
end
|