module TezosClient::RpcInterface::Helper

Public Instance Methods

activate_account_operation(args) click to toggle source
# File lib/tezos_client/rpc_interface/helper.rb, line 42
def activate_account_operation(args)
  {
    kind: "activate_account",
    pkh: args.fetch(:pkh),
    secret: args.fetch(:secret)
  }
end
counter(args) click to toggle source
# File lib/tezos_client/rpc_interface/helper.rb, line 62
def counter(args)
  args.fetch(:counter) do
    contract_counter(args.fetch(:from)) + 1
  end
end
forge_operation(operation:, **options) click to toggle source
# File lib/tezos_client/rpc_interface/helper.rb, line 78
def forge_operation(operation:, **options)
  forge_operations(operations: [operation], **options)
end
origination_operation(args) click to toggle source
# File lib/tezos_client/rpc_interface/helper.rb, line 26
def origination_operation(args)
  operation = {
    kind: "origination",
    balance: args.fetch(:amount, 0).to_satoshi.to_s,
    source: args.fetch(:from),
    gas_limit: args.fetch(:gas_limit, 0.1).to_satoshi.to_s,
    storage_limit: args.fetch(:storage_limit, 0.06).to_satoshi.to_s,
    counter: counter(args).to_s,
    fee: args.fetch(:fee, 0.05).to_satoshi.to_s,
  }

  operation[:script] = args[:script] if args[:script]
  operation
end
preapply_operation(operation:, **options) click to toggle source
# File lib/tezos_client/rpc_interface/helper.rb, line 68
def preapply_operation(operation:, **options)
  res = preapply_operations(operations: [operation], **options)
  res[0]
end
reveal_operation(args) click to toggle source
# File lib/tezos_client/rpc_interface/helper.rb, line 50
def reveal_operation(args)
  {
    kind: "reveal",
    source: args.fetch(:from),
    fee: args.fetch(:fee, 0.05).to_satoshi.to_s,
    counter: counter(args).to_s,
    gas_limit: args.fetch(:gas_limit, 0.1).to_satoshi.to_s,
    storage_limit: args.fetch(:storage_limit, 0).to_satoshi.to_s,
    public_key: args.fetch(:public_key)
  }
end
run_operation(operation:, **options) click to toggle source
# File lib/tezos_client/rpc_interface/helper.rb, line 73
def run_operation(operation:, **options)
  res = run_operations(operations: [operation], **options)
  res[0]
end
transaction_operation(args) click to toggle source
# File lib/tezos_client/rpc_interface/helper.rb, line 8
def transaction_operation(args)
  operation = {
    kind: "transaction",
    amount: args.fetch(:amount).to_satoshi.to_s,
    source: args.fetch(:from),
    destination: args.fetch(:to),
    gas_limit: args.fetch(:gas_limit, 0.1).to_satoshi.to_s,
    storage_limit: args.fetch(:storage_limit, 0.006).to_satoshi.to_s,
    counter: counter(args).to_s,
    fee: args.fetch(:fee, 0.05).to_satoshi.to_s
  }

  if args[:parameters]
    operation[:parameters] = args[:parameters]
  end
  operation
end