Module: Mobius::Client

Defined in:
lib/mobius/client.rb,
lib/mobius/client/version.rb

Defined Under Namespace

Modules: Auth, Blockchain Classes: App, Error, FriendBot

Constant Summary collapse

VERSION =
"0.7.0".freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.asset_codeObject



69
70
71
# File 'lib/mobius/client.rb', line 69

def asset_code
  @asset_code ||= "MOBI"
end

.asset_issuerObject



76
77
78
79
80
# File 'lib/mobius/client.rb', line 76

def asset_issuer
  return @asset_issuer if @asset_issuer
  return "GA6HCMBLTZS5VYYBCATRBRZ3BZJMAFUDKYYF6AH6MVCMGWMRDNSWJPIH" if network == :public
  "GDRWBLJURXUKM4RWDZDTPJNX6XBYFO3PSE4H4GPUL6H6RCUQVKTSD4AT"
end

.challenge_expires_inObject



85
86
87
# File 'lib/mobius/client.rb', line 85

def challenge_expires_in
  @challenge_expires_in ||= 60 * 60 * 24
end

.horizon_clientObject



62
63
64
# File 'lib/mobius/client.rb', line 62

def horizon_client
  @horizon_client ||= network == :test ? Stellar::Client.default_testnet : Stellar::Client.default
end

.mobius_hostObject

Mobius API host



44
45
46
# File 'lib/mobius/client.rb', line 44

def mobius_host
  @mobius_host ||= "https://mobius.network"
end

.strict_intervalObject



97
98
99
# File 'lib/mobius/client.rb', line 97

def strict_interval
  @strict_interval ||= 10
end

Class Method Details

.networkObject

Stellar network to use (:test || :public). See notes on thread-safety in ruby-stellar-base. Safe to set on startup.



55
56
57
# File 'lib/mobius/client.rb', line 55

def network
  @network ||= :test
end

.network=(value) ⇒ Object



48
49
50
51
# File 'lib/mobius/client.rb', line 48

def network=(value)
  @network = value
  Stellar.default_network = stellar_network
end

.on_networkObject

Runs block on selected Stellar network



102
103
104
105
106
# File 'lib/mobius/client.rb', line 102

def on_network
  Stellar.on_network(stellar_network) do
    yield if block_given?
  end
end

.stellar_assetObject

Stellar::Asset instance of asset used for payments



90
91
92
# File 'lib/mobius/client.rb', line 90

def stellar_asset
  @stellar_asset ||= Stellar::Asset.alphanum4(asset_code, Stellar::KeyPair.from_address(asset_issuer))
end

.to_keypair(subject) ⇒ Object

Converts given argument to Stellar::KeyPair



109
110
111
# File 'lib/mobius/client.rb', line 109

def to_keypair(subject)
  Mobius::Client::Blockchain::KeyPairFactory.produce(subject)
end