File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import Foundation
88
99public extension BigUInt {
1010 init ? ( hex: String ) {
11- self . init ( hex. web3. noHexPrefix. lowercased ( ) , radix: 16 )
11+ self . init ( hex. web3. noHexPrefix. web3 . orZero . lowercased ( ) , radix: 16 )
1212 }
1313}
1414
@@ -24,7 +24,7 @@ public extension Web3Extensions where Base == BigUInt {
2424
2525public extension BigInt {
2626 init ? ( hex: String ) {
27- self . init ( hex. web3. noHexPrefix. lowercased ( ) , radix: 16 )
27+ self . init ( hex. web3. noHexPrefix. web3 . orZero . lowercased ( ) , radix: 16 )
2828 }
2929}
3030
@@ -79,6 +79,11 @@ public extension Web3Extensions where Base == String {
7979 return base
8080 }
8181
82+ var orZero : String {
83+ if base. isEmpty { return " 0 " }
84+ return base
85+ }
86+
8287 var stringValue : String {
8388 if let byteArray = try ? HexUtil . byteArray ( fromHex: base. web3. noHexPrefix) , let str = String ( bytes: byteArray, encoding: . utf8) {
8489 return str
You can’t perform that action at this time.
0 commit comments