Sha256: d3058f1c90b19497011f389d813c560cd90b6a5742bcc9490d165c5d7eb6b971

Contents?: true

Size: 950 Bytes

Versions: 5

Compression:

Stored size: 950 Bytes

Contents

require "stellar/convert"
require "stellar/dsl"

module Stellar
  class LedgerKey
    class << self
      include Stellar::DSL

      def switch_for_arm(name)
        (@switch_by_arm ||= switches.invert).fetch(name)
      end

      def from(account_id:, **options)
        field, value = options.first
        case field
        when nil
          account(account_id: KeyPair(account_id).account_id)
        when :balance_id
          claimable_balance(balance_id: ClaimableBalanceID.v0(Stellar::Convert.from_hex(value.to_s)))
        when :offer_id
          offer(seller_id: account_id, offer_id: Integer(value))
        when :data_name
          data(account_id: account_id, data_name: value.to_s)
        when :asset
          trust_line(account_id: account_id, asset: Asset(value))
        else
          raise ArgumentError, "unknown option #{field} (not in :asset, :offer_id, :data_name, :balance_id)"
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
stellar-base-0.29.0 lib/stellar/ledger_key.rb
stellar-base-0.28.0 lib/stellar/ledger_key.rb
stellar-base-0.27.0 lib/stellar/ledger_key.rb
stellar-base-0.26.0 lib/stellar/ledger_key.rb
stellar-base-0.25.0 lib/stellar/ledger_key.rb