Module: Stellar::DSL
Class Method Summary collapse
-
.Asset(subject = nil) ⇒ Stellar::Asset
Instance of the Stellar::Asset.
- .Claimant(destination, &block) ⇒ Object
-
.ClaimPredicate(&block) ⇒ Object
Constructs a new ClaimPredicate using DSL.
-
.KeyPair(subject = nil) ⇒ Stellar::Keypair
Generates Stellar::Keypair from subject, use Stellar::Client.to_keypair as shortcut.
-
.SignerKey(input = nil) ⇒ Stellar::SignerKey
Provides conversion from different input types into the SignerKey to use in ManageData operation.
Class Method Details
.Asset(subject = nil) ⇒ Stellar::Asset
Returns instance of the Stellar::Asset.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/stellar/dsl.rb', line 33 def Asset(subject = nil) case subject when Asset subject when nil, /^(XLM[-:])?native$/ Asset.native when /^([0-9A-Z]{1,4})[-:](G[A-Z0-9]{55})$/ Asset.alphanum4($1, KeyPair($2)) when /^([0-9A-Z]{5,12})[-:](G[A-Z0-9]{55})$/ Asset.alphanum12($1, KeyPair($2)) else raise TypeError, "Cannot convert #{subject.inspect} to Stellar::Asset" end end |
.Claimant(destination, &block) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/stellar/dsl.rb', line 20 def Claimant(destination, &block) Claimant.new( ClaimantType.claimant_type_v0, Claimant::V0.new( destination: KeyPair(destination).account_id, predicate: ClaimPredicate(&block) ) ) end |
.ClaimPredicate(&block) ⇒ Object
Constructs a new ClaimPredicate using DSL
15 16 17 18 |
# File 'lib/stellar/dsl.rb', line 15 def ClaimPredicate(&block) return ClaimPredicate.unconditional unless block ClaimPredicate.compose(&block) end |
.KeyPair(subject = nil) ⇒ Stellar::Keypair
Generates Stellar::Keypair from subject, use Stellar::Client.to_keypair as shortcut.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/stellar/dsl.rb', line 52 def KeyPair(subject = nil) case subject when ->(subj) { subj.respond_to?(:to_keypair) } subject.to_keypair when PublicKey KeyPair.from_public_key(subject.value) when SignerKey KeyPair.from_raw_seed(subject.value) when /^G[A-Z0-9]{55}$/ KeyPair.from_address(subject.to_str) when /^S[A-Z0-9]{55}$/ KeyPair.from_seed(subject.to_str) when /^.{32}$/ KeyPair.from_raw_seed(subject.to_str) when nil KeyPair.random else raise TypeError, "cannot convert #{subject.inspect} to Stellar::KeyPair" end end |
.SignerKey(input = nil) ⇒ Stellar::SignerKey
Provides conversion from different input types into the SignerKey to use in ManageData operation.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/stellar/dsl.rb', line 76 def SignerKey(input = nil) case input when Transaction SignerKey.pre_auth_tx(input.hash) when /^[0-9A-Za-z+\/=]{44}$/ SignerKey.hash_x(Stellar::Convert.from_base64(input)) when /^[0-9a-f]{64}$/ SignerKey.hash_x(Stellar::Convert.from_hex(input)) when /^.{32}$/ SignerKey.hash_x(input) else SignerKey.ed25519(KeyPair(input)) end end |