etherlite 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/etherlite/account.rb +4 -4
- data/lib/etherlite/address.rb +2 -6
- data/lib/etherlite/api/address.rb +8 -4
- data/lib/etherlite/api/node.rb +2 -1
- data/lib/etherlite/client.rb +2 -2
- data/lib/etherlite/commands/abi/load_contract.rb +1 -1
- data/lib/etherlite/commands/contract/event_base/decode_log_inputs.rb +2 -2
- data/lib/etherlite/commands/utils/validate_address.rb +1 -1
- data/lib/etherlite/contract/base.rb +1 -1
- data/lib/etherlite/utils.rb +2 -2
- data/lib/etherlite/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b367f296ffd50994239be945e0e546b3e7dbdb0
|
4
|
+
data.tar.gz: f6b56c996e394c582dc2262f0b7a14f7034b28b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b8ddbb397d7c8c988a9619f9919bacbd5688a83cf691b1563a454a9a1c20ed7059df406e25d2bf17c4045ca43c868b9f7a081355b53997cc6b63b7ae0bf0c82
|
7
|
+
data.tar.gz: 7a2c9922d666eaaed434f184f9122193535d52f4c22098f780098c5b8ebdb2bbfe175d788830c338b19029e2071bc78d18ccec9020937b0b9672b380481d9090
|
data/.gitignore
CHANGED
data/lib/etherlite/account.rb
CHANGED
@@ -17,11 +17,11 @@ module Etherlite
|
|
17
17
|
@passphrase = nil
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
20
|
+
def transfer_to(_target, _options = {})
|
21
21
|
params = {
|
22
|
-
from:
|
22
|
+
from: json_encoded_address,
|
23
23
|
to: Utils.encode_address_param(_target),
|
24
|
-
value: Utils.encode_quantity_param(_options
|
24
|
+
value: Utils.encode_quantity_param(_options.fetch(:amount, 0))
|
25
25
|
}
|
26
26
|
|
27
27
|
send_transaction params, _options
|
@@ -32,7 +32,7 @@ module Etherlite
|
|
32
32
|
options = _params.last.is_a?(Hash) ? _params.pop : {}
|
33
33
|
|
34
34
|
params = {
|
35
|
-
from:
|
35
|
+
from: json_encoded_address,
|
36
36
|
to: Utils.encode_address_param(_target),
|
37
37
|
data: _function.encode(_params)
|
38
38
|
}
|
data/lib/etherlite/address.rb
CHANGED
@@ -2,20 +2,16 @@ module Etherlite
|
|
2
2
|
class Address
|
3
3
|
include Etherlite::Api::Address
|
4
4
|
|
5
|
-
attr_reader :connection, :
|
5
|
+
attr_reader :connection, :normalized_address
|
6
6
|
|
7
7
|
def initialize(_connection, _normalized_address)
|
8
8
|
@connection = _connection
|
9
|
-
@
|
9
|
+
@normalized_address = _normalized_address
|
10
10
|
end
|
11
11
|
|
12
12
|
def to_s
|
13
13
|
# TODO: format address using case-chechsum
|
14
14
|
address
|
15
15
|
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
attr_reader :normalized_address
|
20
16
|
end
|
21
17
|
end
|
@@ -1,21 +1,25 @@
|
|
1
1
|
module Etherlite
|
2
2
|
module Api
|
3
3
|
module Address
|
4
|
-
extend Forwardable
|
5
|
-
|
6
4
|
def address
|
7
|
-
normalized_address
|
5
|
+
'0x' + normalized_address
|
8
6
|
end
|
9
7
|
|
10
8
|
def get_balance(block: :latest)
|
11
9
|
Etherlite::Utils.hex_to_uint(
|
12
10
|
connection.ipc_call(
|
13
11
|
:eth_getBalance,
|
14
|
-
|
12
|
+
json_encoded_address,
|
15
13
|
Etherlite::Utils.encode_block_param(block)
|
16
14
|
)
|
17
15
|
)
|
18
16
|
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def json_encoded_address
|
21
|
+
'0x' + normalized_address
|
22
|
+
end
|
19
23
|
end
|
20
24
|
end
|
21
25
|
end
|
data/lib/etherlite/api/node.rb
CHANGED
@@ -2,6 +2,7 @@ module Etherlite
|
|
2
2
|
module Api
|
3
3
|
module Node
|
4
4
|
extend Forwardable
|
5
|
+
include Address
|
5
6
|
|
6
7
|
def get_block_number
|
7
8
|
Etherlite::Utils.hex_to_uint connection.ipc_call(:eth_blockNumber)
|
@@ -30,7 +31,7 @@ module Etherlite
|
|
30
31
|
@first_account ||= accounts.first
|
31
32
|
end
|
32
33
|
|
33
|
-
def_delegators :first_account, :unlock, :lock, :
|
34
|
+
def_delegators :first_account, :unlock, :lock, :normalized_address, :transfer_to, :call
|
34
35
|
end
|
35
36
|
end
|
36
37
|
end
|
data/lib/etherlite/client.rb
CHANGED
@@ -8,11 +8,11 @@ class Etherlite::Contract::EventBase
|
|
8
8
|
@inputs.each { |i| (i.indexed? ? indexed : non_indexed) << i }
|
9
9
|
|
10
10
|
@json['data'][2..-1].scan(/.{64}/).each_with_index do |data, i|
|
11
|
-
attributes[non_indexed[i].
|
11
|
+
attributes[non_indexed[i].original_name] = non_indexed[i].type.decode(@connection, data)
|
12
12
|
end
|
13
13
|
|
14
14
|
@json['topics'][1..-1].each_with_index do |topic, i|
|
15
|
-
attributes[indexed[i].
|
15
|
+
attributes[indexed[i].original_name] = indexed[i].type.decode(@connection, topic[2..-1])
|
16
16
|
end
|
17
17
|
|
18
18
|
attributes
|
@@ -30,7 +30,7 @@ module Etherlite::Contract
|
|
30
30
|
|
31
31
|
def get_logs(events: nil, from_block: :earliest, to_block: :latest)
|
32
32
|
params = {
|
33
|
-
address:
|
33
|
+
address: json_encoded_address,
|
34
34
|
fromBlock: Etherlite::Utils.encode_block_param(from_block),
|
35
35
|
toBlock: Etherlite::Utils.encode_block_param(to_block)
|
36
36
|
}
|
data/lib/etherlite/utils.rb
CHANGED
@@ -38,8 +38,8 @@ module Etherlite
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def normalize_address_param(_value)
|
41
|
-
if _value.respond_to? :
|
42
|
-
_value.
|
41
|
+
if _value.respond_to? :normalized_address
|
42
|
+
_value.normalized_address
|
43
43
|
else
|
44
44
|
_value = _value.to_s
|
45
45
|
raise ArgumentError, 'invalid address' unless valid_address? _value
|
data/lib/etherlite/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: etherlite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ignacio Baixas
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: digest-sha3
|