Closed tbocek closed 6 years ago
@zilm13 Makes sense to check the other DTOs as well. I have updated my pull request accordingly
@tbocek i think we should return 0 for null same way you do for empty array
@zilm13 I think this does not work. Web3J expects for an address 20 bytes, and when I returned 0x0 for every empty byte array, Web3J threw an IndexOutOfBoundsException. If the address is not valid, then Web3J is fine with that. However, I tested with "0x0" and not "0".
Ah, got it. I think it does not matter, but probably its better to return 0.
@tbocek I've just realized - we are not adding 0x
normally in helper, but it's hex data
@zilm13 What do you mean, every toJsonHex* adds a 0x in TypeConverter?
Ahhh i'm blind sorry. Everything is ok, will merge shortly.
The problem with "to":"0x" and "value":"0x" is that the remix IDE cannot convert those numbers and addresses and throws the following exception: "Error: new BigNumber() not a base 16 number". For the gettransactionreceipt, the JSON looks as follows:
{"jsonrpc":"2.0","id":63,"result":{"hash":"0x4f2a5...","nonce":"0x00", "blockHash":"0x57698...","blockNumber":"0x2","transactionIndex":"0x0", "from":"0x5c5a...","to":"0x","gas":"0x012118","gasPrice":"0x0ba43b7400", "value":"0x","input":"0x608060405260..."}}
This fix checks if the byte array or the resulting string is empty and if it is the case it returns 0x0 for the value or null for the address. This fixes the issue with the remix IDE
According to https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethgettransactionreceipt, value must be a BigNumber, and "0x" seems not to be a valid BigNumber