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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 84008eb04c7583cf3af957baeae6e90c0f2562f5
4
- data.tar.gz: 95ffa5112b13ec411aca38426ded830aa011b48c
3
+ metadata.gz: b587b530c3f3fdf42f4dd23f2ef32e88744ea366
4
+ data.tar.gz: de6d9f9995d2029e2a20f36a488c7f62696e4616
5
5
  SHA512:
6
- metadata.gz: 888094de234a1c170a178f4df60245d42d0690f157aa6c43028b4cc1abea2fd7679f211629d5be49decc71a5acbd2c2c262a171b363e3f3d89e3fb6a60cc85ec
7
- data.tar.gz: 88b31b3785f1e8fff7d2d420196c5cfba1c953b61340870509da4dd92429bdedb3670b2c4c7cec573a746c0f9a3afc60717cb5aa00c19e2224536bafc161dec8
6
+ metadata.gz: 3330163ae56a7d7302a632ab06c240c554c461afa1790633f2f754d208ee62acfedfe90782624d9a0d93d86f157032432ff56a068e888c6aa4b6fb50b5e82c42
7
+ data.tar.gz: bd1c9cc34da66cecb53fbfeaa88768712f6c2bdf4a1f600f47eb3bf87f9596d59d6b98b9f1662b517d888bea9a651f923f969cd9ca5736b3de81648d75382be1
@@ -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
+
@@ -1,3 +1,3 @@
1
1
  module Ethereum
2
- VERSION = "0.4.98"
2
+ VERSION = "0.4.99"
3
3
  end
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.98
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-01 00:00:00.000000000 Z
11
+ date: 2016-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler