etherlite 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/lib/etherlite/account/base.rb +4 -0
- data/lib/etherlite/api/address.rb +2 -6
- data/lib/etherlite/api/node.rb +22 -1
- data/lib/etherlite/api/rpc.rb +4 -0
- data/lib/etherlite/commands/abi/load_contract.rb +1 -1
- data/lib/etherlite/transaction.rb +18 -3
- data/lib/etherlite/types/bytes.rb +3 -0
- 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: b26ef9659e1ea23ddedd3959500bcf341cde07b4
|
4
|
+
data.tar.gz: 05edd2b33d17ceb66a7461d8e6d9f9dc06935057
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 962d4b0f389a0824a48de67397cb69f96d8f46da2be0d9a1551f320e2a13d8f1a1b4234594d54347d0b269adbd61ecbb8d2d570c07533987560117a644da2b4c
|
7
|
+
data.tar.gz: 0196cf0b26cd6ad397bee4f1d24b2dab1c512fc7de247fbebc860d2bbb5dfd16df141f04f1b68a9b08a03eb7431eac1d625fd9d7189da1c3e12abe7eac34aa84
|
@@ -33,6 +33,10 @@ module Etherlite::Account
|
|
33
33
|
raise NotSupportedError, 'transactions are not supported by this kind of account'
|
34
34
|
end
|
35
35
|
|
36
|
+
def ==(_other)
|
37
|
+
normalized_address == _other.normalized_address
|
38
|
+
end
|
39
|
+
|
36
40
|
private
|
37
41
|
|
38
42
|
def call_constant(_target, _function, _params, _options)
|
@@ -6,12 +6,8 @@ module Etherlite
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def get_balance(block: :latest)
|
9
|
-
|
10
|
-
|
11
|
-
:eth_getBalance,
|
12
|
-
json_encoded_address,
|
13
|
-
Etherlite::Utils.encode_block_param(block)
|
14
|
-
)
|
9
|
+
connection.eth_get_balance(
|
10
|
+
json_encoded_address, Etherlite::Utils.encode_block_param(block)
|
15
11
|
)
|
16
12
|
end
|
17
13
|
|
data/lib/etherlite/api/node.rb
CHANGED
@@ -12,6 +12,22 @@ module Etherlite
|
|
12
12
|
connection.eth_gas_price
|
13
13
|
end
|
14
14
|
|
15
|
+
def get_transaction(_hash)
|
16
|
+
load_transaction(_hash).refresh
|
17
|
+
end
|
18
|
+
|
19
|
+
def load_transaction(_hash)
|
20
|
+
Transaction.new(connection, _hash)
|
21
|
+
end
|
22
|
+
|
23
|
+
def load_account(from_pk: nil)
|
24
|
+
Etherlite::Account::PrivateKey.new connection, from_pk
|
25
|
+
end
|
26
|
+
|
27
|
+
def load_address(_address)
|
28
|
+
Etherlite::Address.new(connection, Etherlite::Utils.normalize_address_param(_address))
|
29
|
+
end
|
30
|
+
|
15
31
|
def register_account(_passphrase)
|
16
32
|
address = connection.ipc_call(:personal_newAccount, _passphrase)
|
17
33
|
Etherlite::Account::Local.new @connection, Etherlite::Utils.normalize_address(address)
|
@@ -28,7 +44,12 @@ module Etherlite
|
|
28
44
|
end
|
29
45
|
|
30
46
|
def account_from_pk(_pk)
|
31
|
-
Etherlite
|
47
|
+
Etherlite.logger.warn(
|
48
|
+
"use of 'account_from_pk' is deprecated and will be removed in next version, \
|
49
|
+
use 'load_account' instead"
|
50
|
+
)
|
51
|
+
|
52
|
+
load_account(from_pk: _pk)
|
32
53
|
end
|
33
54
|
|
34
55
|
def_delegators :default_account, :unlock, :lock, :normalized_address, :transfer_to, :call
|
data/lib/etherlite/api/rpc.rb
CHANGED
@@ -17,6 +17,10 @@ module Etherlite
|
|
17
17
|
Etherlite::Utils.hex_to_uint ipc_call(:eth_getTransactionCount, _address, _block)
|
18
18
|
end
|
19
19
|
|
20
|
+
def eth_get_balance(_address, _block = 'latest')
|
21
|
+
Etherlite::Utils.hex_to_uint ipc_call(:eth_getBalance, _address, _block)
|
22
|
+
end
|
23
|
+
|
20
24
|
def eth_call(_params, _block = 'latest')
|
21
25
|
ipc_call(:eth_call, _params, _block)
|
22
26
|
end
|
@@ -10,11 +10,25 @@ module Etherlite
|
|
10
10
|
|
11
11
|
def refresh
|
12
12
|
@receipt = @connection.eth_get_transaction_receipt(@tx_hash) || {}
|
13
|
-
|
13
|
+
self
|
14
|
+
end
|
15
|
+
|
16
|
+
def removed?
|
17
|
+
@receipt.nil?
|
18
|
+
end
|
19
|
+
|
20
|
+
def succeeded?
|
21
|
+
!removed? && @receipt['status'] == 1
|
14
22
|
end
|
15
23
|
|
16
24
|
def mined?
|
17
|
-
@receipt.key?
|
25
|
+
!removed? && @receipt.key?('blockNumber')
|
26
|
+
end
|
27
|
+
|
28
|
+
def confirmations
|
29
|
+
return 0 unless mined?
|
30
|
+
|
31
|
+
@connection.eth_block_number - block_number
|
18
32
|
end
|
19
33
|
|
20
34
|
def gas_used
|
@@ -31,7 +45,8 @@ module Etherlite
|
|
31
45
|
|
32
46
|
def wait_for_block(timeout: 120)
|
33
47
|
start = Time.now
|
34
|
-
while !refresh
|
48
|
+
while !refresh.mined?
|
49
|
+
return false if removed?
|
35
50
|
return false if Time.now - start > timeout
|
36
51
|
sleep 1
|
37
52
|
end
|
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.2.
|
4
|
+
version: 0.2.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: 2018-01
|
11
|
+
date: 2018-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: digest-sha3
|