tezos_client 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: daccce9860609c6800e9f8a5f3052268fa2262e07622f052a32ae3b6b34062e2
|
4
|
+
data.tar.gz: c4ad471f67a8779a69990024c676cbdbcdb708457fc4f62ef0a35ab6dfcf4e2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 850f1591ded42c96efcf75b5080c7939f5a3e1c7e652026c8fb415d4db7ea9229ab1eabf5eaea0f385dac87aa0e3cbb6adcce739049d6901abe3c70506eaa97a
|
7
|
+
data.tar.gz: 9d4cc40e68a7c66e892c9310a92956648d0547cd4ec88c36d7902aa9ab3c846c46dbb6c53b93468421fedd386658b17bcde6adb0d110b600598860e30c9cb8c7
|
data/Gemfile.lock
CHANGED
data/lib/tezos_client/crypto.rb
CHANGED
@@ -95,23 +95,22 @@ class TezosClient
|
|
95
95
|
signing_key = signing_key(secret_key)
|
96
96
|
verify_key = signing_key.verify_key
|
97
97
|
hex_pubkey = verify_key.to_s.to_hex
|
98
|
-
|
99
98
|
encode_tz(:edpk, hex_pubkey)
|
100
99
|
end
|
101
100
|
|
102
101
|
def public_key_to_address(public_key)
|
103
|
-
|
102
|
+
hex_public_key = decode_tz(public_key) do |type, _key|
|
104
103
|
raise "invalid public key: #{public_key} " unless type == :edpk
|
105
104
|
end
|
106
105
|
|
107
|
-
hash = RbNaCl::Hash::Blake2b.digest(
|
106
|
+
hash = RbNaCl::Hash::Blake2b.digest(hex_public_key.to_bin, digest_size: 20)
|
108
107
|
hex_hash = hash.to_hex
|
109
108
|
|
110
109
|
encode_tz(:tz1, hex_hash)
|
111
110
|
end
|
112
111
|
|
113
|
-
def generate_key(mnemonic: nil, wallet_seed: nil, path: nil)
|
114
|
-
signing_key = generate_signing_key(mnemonic: mnemonic, wallet_seed: wallet_seed, path: path).to_bytes.to_hex
|
112
|
+
def generate_key(mnemonic: nil, password: nil, wallet_seed: nil, path: nil)
|
113
|
+
signing_key = generate_signing_key(mnemonic: mnemonic, password: password, wallet_seed: wallet_seed, path: path).to_bytes.to_hex
|
115
114
|
|
116
115
|
secret_key = encode_tz(:edsk2, signing_key)
|
117
116
|
public_key = secret_key_to_public_key(secret_key)
|
@@ -179,14 +178,18 @@ class TezosClient
|
|
179
178
|
end
|
180
179
|
|
181
180
|
private
|
182
|
-
def generate_signing_key(mnemonic: nil, wallet_seed: nil, path: nil)
|
181
|
+
def generate_signing_key(mnemonic: nil, password: nil, wallet_seed: nil, path: nil)
|
183
182
|
if mnemonic
|
184
|
-
|
183
|
+
# ensure mnemonic validity
|
184
|
+
BipMnemonic.to_entropy(mnemonic: mnemonic)
|
185
|
+
wallet_seed = BipMnemonic.to_seed(mnemonic: mnemonic, password: password)
|
185
186
|
end
|
186
187
|
if path && wallet_seed
|
187
188
|
master = MoneyTree::Master.new seed_hex: wallet_seed
|
188
189
|
node = master.node_for_path path
|
189
190
|
node.private_key
|
191
|
+
elsif wallet_seed
|
192
|
+
RbNaCl::SigningKey.new(wallet_seed.to_bin[0...32])
|
190
193
|
else
|
191
194
|
RbNaCl::SigningKey.generate
|
192
195
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class TezosClient
|
2
|
+
class ActivateAccountOperation < Operation
|
3
|
+
|
4
|
+
def initialize_operation_args
|
5
|
+
@operation_args = default_args.merge(
|
6
|
+
**@init_args,
|
7
|
+
operation_kind: operation_kind,
|
8
|
+
branch: branch)
|
9
|
+
end
|
10
|
+
|
11
|
+
def operation_kind
|
12
|
+
:activate_account
|
13
|
+
end
|
14
|
+
|
15
|
+
def ensure_applied!(rpc_response)
|
16
|
+
balance_updates = rpc_response[:metadata][:balance_updates]
|
17
|
+
raise "Operation failed\n #{rpc_response.pretty_inspect}" if balance_updates.nil?
|
18
|
+
if block_given?
|
19
|
+
yield rpc_response[:metadata]
|
20
|
+
else
|
21
|
+
rpc_response[:metadata]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def default_args
|
28
|
+
{
|
29
|
+
gas_limit: 0.1,
|
30
|
+
storage_limit: 0.006,
|
31
|
+
fee: 0.05
|
32
|
+
}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -53,6 +53,15 @@ class TezosClient
|
|
53
53
|
operation
|
54
54
|
end
|
55
55
|
|
56
|
+
|
57
|
+
def activate_account_operation(args)
|
58
|
+
{
|
59
|
+
kind: "activate_account",
|
60
|
+
pkh: args.fetch(:pkh),
|
61
|
+
secret: args.fetch(:secret)
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
56
65
|
def operation(args)
|
57
66
|
operation_kind = args.fetch(:operation_kind) { raise ArgumentError, ":operation_kind argument missing" }
|
58
67
|
send("#{operation_kind}_operation", args)
|
data/lib/tezos_client/version.rb
CHANGED
data/lib/tezos_client.rb
CHANGED
@@ -16,6 +16,7 @@ require "tezos_client/operation"
|
|
16
16
|
require "tezos_client/operations/origination_operation"
|
17
17
|
require "tezos_client/operations/transaction_operation"
|
18
18
|
require "tezos_client/operations/transactions_operation"
|
19
|
+
require "tezos_client/operations/activate_account_operation"
|
19
20
|
|
20
21
|
require "tezos_client/client_interface"
|
21
22
|
require "tezos_client/rpc_interface"
|
@@ -105,6 +106,16 @@ class TezosClient
|
|
105
106
|
).test_and_broadcast
|
106
107
|
end
|
107
108
|
|
109
|
+
def activate_account(pkh:, secret:, **args)
|
110
|
+
ActivateAccountOperation.new(
|
111
|
+
liquidity_interface: liquidity_interface,
|
112
|
+
rpc_interface: rpc_interface,
|
113
|
+
pkh: pkh,
|
114
|
+
secret: secret,
|
115
|
+
**args
|
116
|
+
).test_and_broadcast
|
117
|
+
end
|
118
|
+
|
108
119
|
def transfer_to_many(from:, amounts:, secret_key:, **args)
|
109
120
|
TransactionsOperation.new(
|
110
121
|
liquidity_interface: liquidity_interface,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tezos_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pierre Michard
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -227,6 +227,7 @@ files:
|
|
227
227
|
- lib/tezos_client/liquidity_interface.rb
|
228
228
|
- lib/tezos_client/logger.rb
|
229
229
|
- lib/tezos_client/operation.rb
|
230
|
+
- lib/tezos_client/operations/activate_account_operation.rb
|
230
231
|
- lib/tezos_client/operations/origination_operation.rb
|
231
232
|
- lib/tezos_client/operations/transaction_operation.rb
|
232
233
|
- lib/tezos_client/operations/transactions_operation.rb
|