class Mobius::Cli::Create
Constants
- TEMPLATE
Public Instance Methods
account()
click to toggle source
# File lib/mobius/cli/create.rb, line 26 def account keypair = create_account say " * Public Key: #{keypair.address}" say " * Private Key: #{keypair.seed}" say " * XLM balance: #{Mobius::Client::Blockchain::Account.new(keypair).balance(:native)}" say "Done!" rescue StandardError => e say "[ERROR] #{e.message}", :red end
add_cosigner(keypair, app_keypair)
click to toggle source
# File lib/mobius/cli/create.rb, line 78 def add_cosigner(keypair, app_keypair) say "Adding cosigner..." Mobius::Client::Blockchain::AddCosigner.call(keypair, app_keypair) end
create_account()
click to toggle source
# File lib/mobius/cli/create.rb, line 71 def create_account say "Calling Stellar FriendBot..." Stellar::KeyPair.random.tap do |keypair| Mobius::Client::Blockchain::FriendBot.call(keypair) end end
create_dapp_account(amount = 1000)
click to toggle source
# File lib/mobius/cli/create.rb, line 64 def create_dapp_account(amount = 1000) say "Calling Mobius FriendBot..." Stellar::KeyPair.random.tap do |keypair| Mobius::Client::FriendBot.call(keypair.seed, amount) end end
dapp_account()
click to toggle source
rubocop:disable Metrics/AbcSize, Metrics/MethodLength
# File lib/mobius/cli/create.rb, line 8 def dapp_account keypair = create_dapp_account say " * Public Key: #{keypair.address}" say " * Private Key: #{keypair.seed}" say " * MOBI balance: #{Mobius::Client::Blockchain::Account.new(keypair).balance}" if options["application"] app_keypair = Mobius::Client.to_keypair(options["application"]) add_cosigner(keypair, app_keypair) end say "Done!" rescue StandardError => e say "[ERROR] #{e.message}", :red end
dev_wallet()
click to toggle source
# File lib/mobius/cli/create.rb, line 39 def dev_wallet app_keypair = create_dapp_account(0) normal_keypair = create_dapp_account(1000) add_cosigner(normal_keypair, app_keypair) zero_balance_keypair = create_dapp_account(0) unauthorized_keypair = create_account vars = { app: app_keypair, normal: normal_keypair, zero_balance: zero_balance_keypair, unauthorized: unauthorized_keypair } t = File.read(TEMPLATE) r = ERB.new(t).result(OpenStruct.new(vars).instance_eval { binding }) File.open("dev-wallet.html", "w+") { |f| f.puts r } say "dev-wallet.html created. Copy it to your public web server directory and do not forget to change the URL!" rescue StandardError => e say "[ERROR] #{e.message}", :red end