Module: TezosClient::RpcInterface::Contracts

Included in:
TezosClient::RpcInterface
Defined in:
lib/tezos_client/rpc_interface/contracts.rb

Instance Method Summary collapse

Instance Method Details

#balance(contract_id) ⇒ Object



17
18
19
20
# File 'lib/tezos_client/rpc_interface/contracts.rb', line 17

def balance(contract_id)
  res = get("#{contract_link(contract_id)}/balance")
  res.to_i.from_satoshi
end

#big_map_value(big_map_id:, key:, key_type:) ⇒ Object



35
36
37
38
39
# File 'lib/tezos_client/rpc_interface/contracts.rb', line 35

def big_map_value(big_map_id:, key:, key_type:)
  expr_key = encode_script_expr(data: key, type: key_type)

  get "/chains/main/blocks/head/context/big_maps/#{big_map_id}/#{expr_key}"
end

#contract_counter(contract_id) ⇒ Object



22
23
24
25
# File 'lib/tezos_client/rpc_interface/contracts.rb', line 22

def contract_counter(contract_id)
  res = get("#{contract_link(contract_id)}/counter")
  res.to_i
end

#contract_detail(contract_id) ⇒ Object



13
14
15
# File 'lib/tezos_client/rpc_interface/contracts.rb', line 13

def contract_detail(contract_id)
  get contract_link(contract_id)
end


9
10
11
# File 'lib/tezos_client/rpc_interface/contracts.rb', line 9

def contract_link(contract_id)
  "/chains/main/blocks/head/context/contracts/#{contract_id}"
end

#contract_manager_key(contract_id) ⇒ Object



27
28
29
# File 'lib/tezos_client/rpc_interface/contracts.rb', line 27

def contract_manager_key(contract_id)
  get "#{contract_link(contract_id)}/manager_key"
end

#contract_storage(contract_id) ⇒ Object



31
32
33
# File 'lib/tezos_client/rpc_interface/contracts.rb', line 31

def contract_storage(contract_id)
  get "#{contract_link(contract_id)}/storage"
end

#list_big_map_by_contract(contract_address:) ⇒ Object



41
42
43
44
45
46
47
48
49
50
# File 'lib/tezos_client/rpc_interface/contracts.rb', line 41

def list_big_map_by_contract(contract_address:)
  contract_storage = contract_storage(contract_address)
  contract = contract_detail(contract_address)
  storage_type = contract[:script][:code].find { |elem| elem[:prim] == "storage" }[:args].first

  TezosClient::Tools::FindBigMapsInStorage.run!(
    storage: contract_storage,
    storage_type: storage_type
  )
end