Skip to content

Commit

Permalink
Use web3j AbiDefinition, jackson
Browse files Browse the repository at this point in the history
  • Loading branch information
prettymuchbryce committed Jan 25, 2018
1 parent 9903c5a commit 787b923
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ mainClassName = 'abidecoder.DecoderKt'
defaultTasks 'run'

repositories {
jcenter()
mavenCentral()
}

dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile ('org.web3j:core:3.2.0')
compile 'org.web3j:core:3.2.0'
compile "com.fasterxml.jackson.module:jackson-module-kotlin:2.9.0"
testCompile 'junit:junit:4.11'
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
}
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ include 'api'
include 'services:webservice'
*/

rootProject.name = 'riff-kotlin'
rootProject.name = 'abidecoder'
35 changes: 29 additions & 6 deletions src/com/prettymuchbryce/abidecoder/decoder.kt
Original file line number Diff line number Diff line change
@@ -1,19 +1,42 @@
package abidecoder

import org.web3j.protocol.Web3j;
import org.web3j.protocol.http.HttpService;
import org.web3j.protocol.Web3j
import org.web3j.protocol.core.methods.response.AbiDefinition
import org.web3j.protocol.http.HttpService
import com.fasterxml.jackson.module.kotlin.*

fun main(args: Array<String>) {
var web3: Web3j = Web3j.build(HttpService());
var web3: Web3j = Web3j.build(HttpService())
println("Hello, world!")
println(web3)

val json = """
[{"inputs": [{"type": "address", "name": ""}], "constant": true, "name": "isInstantiation", "payable": false, "outputs": [{"type": "bool", "name": ""}], "type": "function"}, {"inputs": [{"type": "address[]", "name": "_owners"}, {"type": "uint256", "name": "_required"}, {"type": "uint256", "name": "_dailyLimit"}], "constant": false, "name": "create", "payable": false, "outputs": [{"type": "address", "name": "wallet"}], "type": "function"}, {"inputs": [{"type": "address", "name": ""}, {"type": "uint256", "name": ""}], "constant": true, "name": "instantiations", "payable": false, "outputs": [{"type": "address", "name": ""}], "type": "function"}, {"inputs": [{"type": "address", "name": "creator"}], "constant": true, "name": "getInstantiationCount", "payable": false, "outputs": [{"type": "uint256", "name": ""}], "type": "function"}, {"inputs": [{"indexed": false, "type": "address", "name": "sender"}, {"indexed": false, "type": "address", "name": "instantiation"}], "type": "event", "name": "ContractInstantiation", "anonymous": false}]
"""

val mapper = jacksonObjectMapper()

var contracts: List<AbiDefinition> = mapper.readValue<List<AbiDefinition>>(json)
println(contracts[0].getName())
}

class Decoder constructor() {
fun getABIs() { }
fun addABI() { }
fun getMethodIDs() { }
private val _savedAbis = mutableListOf<AbiDefinition>()
private val _methodIDs: HashMap<String, AbiDefinition> = HashMap()

fun getAbis(): List<AbiDefinition> {
}

fun addAbi (abis: List<AbiDefinition>) {

}

fun getMethodIDs(): Map<String, AbiDefinition> {
return _methodIDs
}

fun decodeMethod() { }
fun decodeLogs() { }
fun removeABI() { }
}

0 comments on commit 787b923

Please sign in to comment.