Class: Mobius::Cli::Create

Inherits:
Base
  • Object
show all
Defined in:
lib/mobius/cli/create.rb

Constant Summary collapse

TEMPLATE =
File.join(File.dirname(__FILE__), "../../../template/dev-wallet.html.erb").freeze

Instance Method Summary collapse

Instance Method Details

#accountObject



26
27
28
29
30
31
32
33
34
35
# File 'lib/mobius/cli/create.rb', line 26

def 
  keypair = 

  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

#dapp_accountObject

rubocop:disable Metrics/AbcSize, Metrics/MethodLength



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/mobius/cli/create.rb', line 8

def 
  keypair = 

  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_walletObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/mobius/cli/create.rb', line 39

def dev_wallet
  app_keypair = (0)
  normal_keypair = (1000)
  add_cosigner(normal_keypair, app_keypair)
  zero_balance_keypair = (0)
  unauthorized_keypair = 

  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