Class: Tezos::Client
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#contract_call(contract_address, parameter, burn_cap) ⇒ Object
-
#contract_call_cmd(contract_address, parameter, burn_cap) ⇒ Object
-
#get_receipt(operation_hash) ⇒ Object
-
#get_storage(contract_address) ⇒ Object
-
#get_storage_cmd(contract_address) ⇒ Object
-
#initialize(tezos_client_path, user_address) ⇒ Client
constructor
A new instance of Client.
-
#originate(contract_name, contract_code, initial_storage, burn_cap) ⇒ Object
-
#originate_cmd(contract_name, contract_code, initial_storage, burn_cap) ⇒ Object
#system_line, #system_lines, #system_operation_hash
Constructor Details
#initialize(tezos_client_path, user_address) ⇒ Client
Returns a new instance of Client.
10
11
12
13
|
# File 'lib/tezos/client.rb', line 10
def initialize(tezos_client_path, user_address)
@tezos_client_path = tezos_client_path
@user_address = user_address
end
|
Instance Attribute Details
#tezos_client_path ⇒ Object
Returns the value of attribute tezos_client_path.
8
9
10
|
# File 'lib/tezos/client.rb', line 8
def tezos_client_path
@tezos_client_path
end
|
#user_address ⇒ Object
Returns the value of attribute user_address.
8
9
10
|
# File 'lib/tezos/client.rb', line 8
def user_address
@user_address
end
|
Instance Method Details
#contract_call(contract_address, parameter, burn_cap) ⇒ Object
57
58
59
60
61
62
|
# File 'lib/tezos/client.rb', line 57
def contract_call(contract_address, parameter, burn_cap)
if operation_hash = self.system_operation_hash(self.contract_call_cmd(contract_address, parameter, burn_cap))
{ 'operation_hash' => operation_hash,
'receipt' => self.get_receipt(operation_hash) }
end
end
|
#contract_call_cmd(contract_address, parameter, burn_cap) ⇒ Object
47
48
49
50
51
52
53
54
55
|
# File 'lib/tezos/client.rb', line 47
def contract_call_cmd(contract_address, parameter, burn_cap)
"#{self.tezos_client_path} --wait none transfer 0 from #{self.user_address} " +
[ "to #{contract_address}",
if parameter.nil? then "" else "--arg #{parameter.inspect}" end,
"--burn-cap #{burn_cap}"
].map do |line|
" #{line} \\"
end.join("\n")
end
|
#get_receipt(operation_hash) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/tezos/client.rb', line 15
def get_receipt(operation_hash)
result = nil
while result.nil?
begin
result = if result_lines = self.system_lines("#{@tezos_client_path} get receipt for #{operation_hash}")
unless result_lines.any?{|line| line.match /Couldn't find operation/}
result_lines
end
end
rescue SystemError
end
end
result
end
|
#get_storage(contract_address) ⇒ Object
68
69
70
|
# File 'lib/tezos/client.rb', line 68
def get_storage(contract_address)
self.system_lines(self.get_storage_cmd(contract_address))
end
|
#get_storage_cmd(contract_address) ⇒ Object
64
65
66
|
# File 'lib/tezos/client.rb', line 64
def get_storage_cmd(contract_address)
"#{self.tezos_client_path} get contract storage for #{contract_address}"
end
|
#originate(contract_name, contract_code, initial_storage, burn_cap) ⇒ Object
41
42
43
44
45
|
# File 'lib/tezos/client.rb', line 41
def originate(contract_name, contract_code, initial_storage, burn_cap)
if operation_hash = self.system_operation_hash(self.originate_cmd(contract_name, contract_code, initial_storage, burn_cap))
self.get_receipt(operation_hash).find_originated_contract
end
end
|
#originate_cmd(contract_name, contract_code, initial_storage, burn_cap) ⇒ Object
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/tezos/client.rb', line 30
def originate_cmd(contract_name, contract_code, initial_storage, burn_cap)
"#{self.tezos_client_path} --wait none originate contract #{contract_name}" +
[ "transferring 0 from #{self.user_address} running",
contract_code.inspect,
if initial_storage.nil? then "" else "--init #{initial_storage.inspect}" end,
"--burn-cap #{burn_cap}"
].map do |line|
" #{line} \\"
end.join("\n") + "\n --force"
end
|