Sha256: 7b97b34d4f9aa0bf867b3dddc73d4e2e7a0f46928b148d1c61e38938b855d0ab
Contents?: true
Size: 918 Bytes
Versions: 3
Compression:
Stored size: 918 Bytes
Contents
module Stellar class Asset def self.native new(:asset_type_native) end def self.alphanum4(code, issuer) raise ArgumentError, "Bad :issuer" unless issuer.is_a?(KeyPair) code = normalize_code(code) an = AlphaNum4.new({asset_code:code, issuer:issuer.account_id}) new(:asset_type_credit_alphanum4, an) end def to_s if switch == AssetType.asset_type_native "native" else issuer_address = Stellar::Util::StrKey.check_encode(:account_id,alpha_num.issuer) "#{alpha_num.asset_code}/#{issuer_address}" end end def inspect label = switch.to_s "#<Stellar::Asset #{to_s}>" end def code self.alpha_num!.asset_code end def self.normalize_code(code) raise ArgumentError, "Invalid asset code: #{code}, must be <= 4 bytes" if code.length > 4 code.ljust(4, "\x00") end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
stellar-base-0.1.2 | lib/stellar/asset.rb |
stellar-base-0.1.1 | lib/stellar/asset.rb |
stellar-base-0.1.0 | lib/stellar/asset.rb |