ethereum 0.4.98 → 0.4.99
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ethereum/formatter.rb +14 -2
- data/lib/ethereum/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: b587b530c3f3fdf42f4dd23f2ef32e88744ea366
|
4
|
+
data.tar.gz: de6d9f9995d2029e2a20f36a488c7f62696e4616
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3330163ae56a7d7302a632ab06c240c554c461afa1790633f2f754d208ee62acfedfe90782624d9a0d93d86f157032432ff56a068e888c6aa4b6fb50b5e82c42
|
7
|
+
data.tar.gz: bd1c9cc34da66cecb53fbfeaa88768712f6c2bdf4a1f600f47eb3bf87f9596d59d6b98b9f1662b517d888bea9a651f923f969cd9ca5736b3de81648d75382be1
|
data/lib/ethereum/formatter.rb
CHANGED
@@ -37,42 +37,52 @@ module Ethereum
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def from_bool(boolval)
|
40
|
+
return nil if boolval.nil?
|
40
41
|
boolval ? "1" : "0"
|
41
42
|
end
|
42
43
|
|
43
44
|
def to_bool(hexstring)
|
45
|
+
return nil if hexstring.nil?
|
44
46
|
(hexstring == "0000000000000000000000000000000000000000000000000000000000000001")
|
45
47
|
end
|
46
48
|
|
47
49
|
def to_ascii(hexstring)
|
50
|
+
return nil if hexstring.nil?
|
48
51
|
hexstring.gsub(/^0x/,'').scan(/.{2}/).collect {|x| x.hex}.pack("c*")
|
49
52
|
end
|
50
53
|
|
51
54
|
def to_utf8(hexstring)
|
55
|
+
return nil if hexstring.nil?
|
52
56
|
hexstring.gsub(/^0x/,'').scan(/.{2}/).collect {|x| x.hex}.pack("U*").delete("\u0000")
|
53
57
|
end
|
54
58
|
|
55
59
|
def from_ascii(ascii_string)
|
60
|
+
return nil if ascii_string.nil?
|
56
61
|
ascii_string.unpack('H*')[0]
|
57
62
|
end
|
58
63
|
|
59
64
|
def from_utf8(utf8_string)
|
65
|
+
return nil if utf8_string.nil?
|
60
66
|
utf8_string.force_encoding('UTF-8').split("").collect {|x| x.ord.to_s(16)}.join("")
|
61
67
|
end
|
62
68
|
|
63
69
|
def to_address(hexstring)
|
70
|
+
return "0x0000000000000000000000000000000000000000" if hexstring.nil?
|
64
71
|
"0x" + hexstring[-40..-1]
|
65
72
|
end
|
66
73
|
|
67
|
-
def to_wei(amount, unit)
|
74
|
+
def to_wei(amount, unit = "ether")
|
75
|
+
return nil if amount.nil?
|
68
76
|
BigDecimal.new(UNITS[unit.to_sym] * amount, 16).to_s.to_i rescue nil
|
69
77
|
end
|
70
78
|
|
71
|
-
def from_wei(amount, unit)
|
79
|
+
def from_wei(amount, unit = "ether")
|
80
|
+
return nil if amount.nil?
|
72
81
|
(BigDecimal.new(amount, 16) / BigDecimal.new(UNITS[unit.to_sym], 16)).to_s rescue nil
|
73
82
|
end
|
74
83
|
|
75
84
|
def from_address(address)
|
85
|
+
return "0x0000000000000000000000000000000000000000" if address.nil?
|
76
86
|
address.gsub(/^0x/,'').rjust(64, "0")
|
77
87
|
end
|
78
88
|
|
@@ -89,6 +99,7 @@ module Ethereum
|
|
89
99
|
end
|
90
100
|
|
91
101
|
def to_int(hexstring)
|
102
|
+
return nil if hexstring.nil?
|
92
103
|
(hexstring.gsub(/^0x/,'')[0..1] == "ff") ? (hexstring.hex - (2 ** 256)) : hexstring.hex
|
93
104
|
end
|
94
105
|
|
@@ -150,3 +161,4 @@ module Ethereum
|
|
150
161
|
end
|
151
162
|
|
152
163
|
end
|
164
|
+
|
data/lib/ethereum/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ethereum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.99
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DigixGlobal Pte Ltd (https://dgx.io)
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|