prettymuchbryce/abidecoder

error parsing logs

Opened this issue · 1 comments

I am trying to decrypt a logs from a transaction
val d = Decoder() d.addAbi("[ { \"constant\": false, \"inputs\": [ { \"name\": \"dataType\", \"type\": \"string\" }, { \"name\": \"timesPerDay\", \"type\": \"uint256\" }, { \"name\": \"reward\", \"type\": \"uint256\" }, { \"name\": \"timeInSeconds\", \"type\": \"uint256\" } ], \"name\": \"saveOrUpdateDataType\", \"outputs\": [], \"payable\": false, \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [ { \"name\": \"timestamp\", \"type\": \"uint256\" } ], \"name\": \"getHour\", \"outputs\": [ { \"name\": \"\", \"type\": \"uint8\" } ], \"payable\": false, \"stateMutability\": \"pure\", \"type\": \"function\" }, { \"constant\": false, \"inputs\": [], \"name\": \"kill\", \"outputs\": [], \"payable\": false, \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [ { \"name\": \"timestamp\", \"type\": \"uint256\" } ], \"name\": \"getWeekday\", \"outputs\": [ { \"name\": \"\", \"type\": \"uint8\" } ], \"payable\": false, \"stateMutability\": \"pure\", \"type\": \"function\" }, { \"constant\": false, \"inputs\": [], \"name\": \"refill\", \"outputs\": [], \"payable\": true, \"stateMutability\": \"payable\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [ { \"name\": \"year\", \"type\": \"uint16\" }, { \"name\": \"month\", \"type\": \"uint8\" }, { \"name\": \"day\", \"type\": \"uint8\" }, { \"name\": \"hour\", \"type\": \"uint8\" }, { \"name\": \"minute\", \"type\": \"uint8\" } ], \"name\": \"toTimestamp\", \"outputs\": [ { \"name\": \"timestamp\", \"type\": \"uint256\" } ], \"payable\": false, \"stateMutability\": \"pure\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [ { \"name\": \"timestamp\", \"type\": \"uint256\" } ], \"name\": \"getDay\", \"outputs\": [ { \"name\": \"\", \"type\": \"uint8\" } ], \"payable\": false, \"stateMutability\": \"pure\", \"type\": \"function\" }, { \"constant\": false, \"inputs\": [ { \"name\": \"dataType\", \"type\": \"string\" } ], \"name\": \"setState\", \"outputs\": [], \"payable\": false, \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [], \"name\": \"getContractBalance\", \"outputs\": [ { \"name\": \"\", \"type\": \"uint256\" } ], \"payable\": false, \"stateMutability\": \"view\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [ { \"name\": \"year\", \"type\": \"uint16\" }, { \"name\": \"month\", \"type\": \"uint8\" }, { \"name\": \"day\", \"type\": \"uint8\" }, { \"name\": \"hour\", \"type\": \"uint8\" } ], \"name\": \"toTimestamp\", \"outputs\": [ { \"name\": \"timestamp\", \"type\": \"uint256\" } ], \"payable\": false, \"stateMutability\": \"pure\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [ { \"name\": \"timestamp\", \"type\": \"uint256\" } ], \"name\": \"getSecond\", \"outputs\": [ { \"name\": \"\", \"type\": \"uint8\" } ], \"payable\": false, \"stateMutability\": \"pure\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [ { \"name\": \"year\", \"type\": \"uint16\" }, { \"name\": \"month\", \"type\": \"uint8\" }, { \"name\": \"day\", \"type\": \"uint8\" } ], \"name\": \"toTimestamp\", \"outputs\": [ { \"name\": \"timestamp\", \"type\": \"uint256\" } ], \"payable\": false, \"stateMutability\": \"pure\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [ { \"name\": \"year\", \"type\": \"uint16\" }, { \"name\": \"month\", \"type\": \"uint8\" }, { \"name\": \"day\", \"type\": \"uint8\" }, { \"name\": \"hour\", \"type\": \"uint8\" }, { \"name\": \"minute\", \"type\": \"uint8\" }, { \"name\": \"second\", \"type\": \"uint8\" } ], \"name\": \"toTimestamp\", \"outputs\": [ { \"name\": \"timestamp\", \"type\": \"uint256\" } ], \"payable\": false, \"stateMutability\": \"pure\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [ { \"name\": \"timestamp\", \"type\": \"uint256\" } ], \"name\": \"getYear\", \"outputs\": [ { \"name\": \"\", \"type\": \"uint16\" } ], \"payable\": false, \"stateMutability\": \"pure\", \"type\": \"function\" }, { \"constant\": false, \"inputs\": [ { \"name\": \"dataType\", \"type\": \"string\" }, { \"name\": \"hash1\", \"type\": \"bytes32\" }, { \"name\": \"hash2\", \"type\": \"bytes14\" } ], \"name\": \"saveHash\", \"outputs\": [], \"payable\": false, \"stateMutability\": \"nonpayable\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [ { \"name\": \"timestamp\", \"type\": \"uint256\" } ], \"name\": \"getMonth\", \"outputs\": [ { \"name\": \"\", \"type\": \"uint8\" } ], \"payable\": false, \"stateMutability\": \"pure\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [ { \"name\": \"year\", \"type\": \"uint16\" } ], \"name\": \"isLeapYear\", \"outputs\": [ { \"name\": \"\", \"type\": \"bool\" } ], \"payable\": false, \"stateMutability\": \"pure\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [ { \"name\": \"year\", \"type\": \"uint256\" } ], \"name\": \"leapYearsBefore\", \"outputs\": [ { \"name\": \"\", \"type\": \"uint256\" } ], \"payable\": false, \"stateMutability\": \"pure\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [ { \"name\": \"month\", \"type\": \"uint8\" }, { \"name\": \"year\", \"type\": \"uint16\" } ], \"name\": \"getDaysInMonth\", \"outputs\": [ { \"name\": \"\", \"type\": \"uint8\" } ], \"payable\": false, \"stateMutability\": \"pure\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [ { \"name\": \"dataType\", \"type\": \"string\" } ], \"name\": \"getDataType\", \"outputs\": [ { \"name\": \"name\", \"type\": \"string\" }, { \"name\": \"reward\", \"type\": \"uint256\" }, { \"name\": \"times\", \"type\": \"uint256\" }, { \"name\": \"timeInSecond\", \"type\": \"uint256\" }, { \"name\": \"state\", \"type\": \"bool\" } ], \"payable\": false, \"stateMutability\": \"view\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [ { \"name\": \"dataType\", \"type\": \"string\" } ], \"name\": \"getInformationData\", \"outputs\": [ { \"name\": \"name\", \"type\": \"string\" }, { \"name\": \"hash1\", \"type\": \"bytes32\" }, { \"name\": \"hash2\", \"type\": \"bytes14\" }, { \"name\": \"times\", \"type\": \"uint256\" }, { \"name\": \"time\", \"type\": \"uint256\" } ], \"payable\": false, \"stateMutability\": \"view\", \"type\": \"function\" }, { \"constant\": true, \"inputs\": [ { \"name\": \"timestamp\", \"type\": \"uint256\" } ], \"name\": \"getMinute\", \"outputs\": [ { \"name\": \"\", \"type\": \"uint8\" } ], \"payable\": false, \"stateMutability\": \"pure\", \"type\": \"function\" }, { \"inputs\": [], \"payable\": true, \"stateMutability\": \"payable\", \"type\": \"constructor\" }, { \"anonymous\": false, \"inputs\": [ { \"indexed\": false, \"name\": \"_from\", \"type\": \"address\" }, { \"indexed\": false, \"name\": \"reward\", \"type\": \"uint256\" }, { \"indexed\": false, \"name\": \"dataType\", \"type\": \"string\" }, { \"indexed\": false, \"name\": \"hash1\", \"type\": \"bytes32\" }, { \"indexed\": false, \"name\": \"hash2\", \"type\": \"bytes14\" } ], \"name\": \"Data\", \"type\": \"event\" } ]") val result = d.decodeLogs("0x000000000000000000000000008d4eafd3c7590f253096179253c1723c0a0a6f000000000000000000000000000000000000000000000000000000003b9aca0000000000000000000000000000000000000000000000000000000000000000a066697273742068617368000000000000000000000000000000000000000000007365636f6e64206861736800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000055761746572000000000000000000000000000000000000000000000000000000")

but i have this mistake:
FATAL EXCEPTION: main
Process: health.bowhead.com.bowheadhealth, PID: 30509
java.lang.ExceptionInInitializerError
at org.ethereum.crypto.HashUtil.sha3(HashUtil.java:83)
at org.ethereum.solidity.Abi$Entry.fingerprintSignature(Abi.java:164)
at org.ethereum.solidity.Abi$Entry.encodeSignature(Abi.java:168)
at org.ethereum.solidity.Abi$Function.encodeSignature(Abi.java:265)
at health.bowhead.com.bowheadhealth.utils.Decoder.addAbi(Decoder.kt:45)
at health.bowhead.com.bowheadhealth.ContractsTest.onCreate(ContractsTest.kt:52)
at android.app.Activity.performCreate(Activity.java:6955)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2927)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
Caused by: java.lang.RuntimeException: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.io.Reader.read(char[])' on a null object reference
at org.ethereum.config.SystemProperties.(SystemProperties.java:227)
at org.ethereum.config.SystemProperties.(SystemProperties.java:172)
at org.ethereum.config.SystemProperties.(SystemProperties.java:160)
at org.ethereum.config.SystemProperties.getSpringDefault(SystemProperties.java:104)
at org.ethereum.config.SystemProperties.getDefault(SystemProperties.java:99)
at org.ethereum.crypto.HashUtil.(HashUtil.java:55)
at org.ethereum.crypto.HashUtil.sha3(HashUtil.java:83) 
at org.ethereum.solidity.Abi$Entry.fingerprintSignature(Abi.java:164) 
at org.ethereum.solidity.Abi$Entry.encodeSignature(Abi.java:168) 
at org.ethereum.solidity.Abi$Function.encodeSignature(Abi.java:265) 
at health.bowhead.com.bowheadhealth.utils.Decoder.addAbi(Decoder.kt:45) 
at health.bowhead.com.bowheadhealth.ContractsTest.onCreate(ContractsTest.kt:52) 
at android.app.Activity.performCreate(Activity.java:6955) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2927) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045) 
at android.app.ActivityThread.-wrap14(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6776) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410) 
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.io.Reader.read(char[])' on a null object reference
at java.util.Properties$LineReader.readLine(Properties.java:435)
at java.util.Properties.load0(Properties.java:354)
at java.util.Properties.load(Properties.java:342)
at org.ethereum.config.SystemProperties.(SystemProperties.java:216)
at org.ethereum.config.SystemProperties.(SystemProperties.java:172) 
at org.ethereum.config.SystemProperties.(SystemProperties.java:160) 
at org.ethereum.config.SystemProperties.getSpringDefault(SystemProperties.java:104) 
at org.ethereum.config.SystemProperties.getDefault(SystemProperties.java:99) 
at org.ethereum.crypto.HashUtil.(HashUtil.java:55) 
at org.ethereum.crypto.HashUtil.sha3(HashUtil.java:83) 
at org.ethereum.solidity.Abi$Entry.fingerprintSignature(Abi.java:164) 
at org.ethereum.solidity.Abi$Entry.encodeSignature(Abi.java:168) 
at org.ethereum.solidity.Abi$Function.encodeSignature(Abi.java:265) 
at health.bowhead.com.bowheadhealth.utils.Decoder.addAbi(Decoder.kt:45) 
at health.bowhead.com.bowheadhealth.ContractsTest.onCreate(ContractsTest.kt:52) 
at android.app.Activity.performCreate(Activity.java:6955) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2927) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045) 
at android.app.ActivityThread.-wrap14(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6776) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410) 

i even tried with your abi of the test but have the same mistake