tezos_client 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/tezos_client/operation.rb +31 -12
- data/lib/tezos_client/rpc_interface/context.rb +2 -1
- data/lib/tezos_client/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a192811cdc281656ad008df4408d830283c77f7ccf66150c0282005a68505f7c
|
4
|
+
data.tar.gz: d1c9561af9631e8db8c54b867983efc0e0c54c0628a8f88354fc0a0d55e861dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 334a46f80c4e6873dbd587413589d343eaba149881f6b99dcc44c658f5c904fded810ed938748aa3085bcd70db198f74564ae1e2e5a2099a6d55b40e2c425569
|
7
|
+
data.tar.gz: bc6a850b461d0608f82d1929745a5c34493f4c34365e4018e3bcc1ee6f3ab7e8b26613d540e05556932166a7e6af3c4fea3db60e663898bef25518ba6593810d
|
data/Gemfile.lock
CHANGED
@@ -7,8 +7,6 @@ class TezosClient
|
|
7
7
|
|
8
8
|
attr_accessor :liquidity_interface,
|
9
9
|
:rpc_interface,
|
10
|
-
:base_58_signature,
|
11
|
-
:signed_hex,
|
12
10
|
:from,
|
13
11
|
:operation_args,
|
14
12
|
:rpc_args
|
@@ -19,9 +17,9 @@ class TezosClient
|
|
19
17
|
@from = args.fetch(:from) { raise ArgumentError, "Argument :from missing" }
|
20
18
|
@secret_key = args.fetch(:secret_key)
|
21
19
|
@init_args = args
|
22
|
-
@signed = false
|
23
20
|
@operation_args = {}
|
24
21
|
initialize_operation_args
|
22
|
+
@signed_operation_args_h = nil
|
25
23
|
@rpc_args = rpc_interface.operation(@operation_args)
|
26
24
|
end
|
27
25
|
|
@@ -37,12 +35,16 @@ class TezosClient
|
|
37
35
|
rpc_interface.head_hash
|
38
36
|
end
|
39
37
|
|
38
|
+
def remote_counter
|
39
|
+
@remote_counter ||= rpc_interface.contract_counter(from) + 1
|
40
|
+
end
|
41
|
+
|
40
42
|
def counter
|
41
|
-
@init_args.fetch(:counter) {
|
43
|
+
@counter ||= @init_args.fetch(:counter) { remote_counter }
|
42
44
|
end
|
43
45
|
|
44
46
|
def protocol
|
45
|
-
rpc_interface.
|
47
|
+
rpc_interface.protocol
|
46
48
|
end
|
47
49
|
|
48
50
|
def simulate_and_update_limits
|
@@ -61,27 +63,47 @@ class TezosClient
|
|
61
63
|
secret_key: @secret_key,
|
62
64
|
operation_hex: to_hex
|
63
65
|
) do |base_58_signature, signed_hex, _op_id|
|
66
|
+
@signed_operation_args_h = operation_args.hash
|
64
67
|
@base_58_signature = base_58_signature
|
65
68
|
@signed_hex = signed_hex
|
66
69
|
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def signed?
|
73
|
+
@signed_operation_args_h == operation_args.hash
|
74
|
+
end
|
75
|
+
|
76
|
+
def base_58_signature
|
77
|
+
sign unless signed?
|
78
|
+
@base_58_signature
|
79
|
+
end
|
67
80
|
|
68
|
-
|
81
|
+
def signed_hex
|
82
|
+
sign unless signed?
|
83
|
+
@signed_hex
|
69
84
|
end
|
70
85
|
|
71
86
|
def test_and_broadcast
|
87
|
+
# https://gitlab.com/tezos/tezos/issues/376
|
88
|
+
operation_args.merge!(counter: remote_counter)
|
89
|
+
|
72
90
|
# simulate operations and adjust gas limits
|
73
91
|
simulate_and_update_limits
|
74
|
-
sign
|
75
92
|
operation_result = preapply
|
93
|
+
|
94
|
+
# https://gitlab.com/tezos/tezos/issues/376
|
95
|
+
operation_args.merge!(counter: counter)
|
96
|
+
|
76
97
|
op_id = broadcast
|
77
98
|
{
|
78
99
|
operation_id: op_id,
|
79
|
-
operation_result: operation_result
|
100
|
+
operation_result: operation_result,
|
101
|
+
counter: counter
|
80
102
|
}
|
81
103
|
end
|
82
104
|
|
83
105
|
def run
|
84
|
-
rpc_response = rpc_interface.run_operation(**operation_args, signature:
|
106
|
+
rpc_response = rpc_interface.run_operation(**operation_args, signature: base_58_signature)
|
85
107
|
|
86
108
|
operation_result = ensure_applied!(rpc_response)
|
87
109
|
|
@@ -97,8 +119,6 @@ class TezosClient
|
|
97
119
|
end
|
98
120
|
|
99
121
|
def preapply
|
100
|
-
raise "can not preapply unsigned operations" unless @signed
|
101
|
-
|
102
122
|
res = rpc_interface.preapply_operation(
|
103
123
|
**operation_args,
|
104
124
|
signature: base_58_signature,
|
@@ -108,7 +128,6 @@ class TezosClient
|
|
108
128
|
end
|
109
129
|
|
110
130
|
def broadcast
|
111
|
-
raise "can not preapply unsigned operations" unless @signed
|
112
131
|
rpc_interface.broadcast_operation(signed_hex)
|
113
132
|
end
|
114
133
|
|
data/lib/tezos_client/version.rb
CHANGED