Skip to content

Commit

Permalink
Add data classes to basic Solidity types. Upgrade dependencies. (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmrsabino authored and rmeissner committed Apr 12, 2018
1 parent a6600ef commit efd7df4
Show file tree
Hide file tree
Showing 9 changed files with 323 additions and 214 deletions.
24 changes: 10 additions & 14 deletions bivrost-abi-parser/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,6 @@ apply plugin: 'maven'

sourceCompatibility = 1.8

task runSolidityTypeGenerator(type: JavaExec) {
def srcDirs = sourceSets.main.kotlin.getSrcDirs()
if (srcDirs.isEmpty()) {
logger.error("Couldn't find kotlin main source sets")
return
}

def path = "${sourceSets.main.kotlin.getSrcDirs().getAt(0)}"
main = 'pm.gnosis.SolidityTypeGenerator'
classpath = sourceSets.main.runtimeClasspath
args (path, project.group)
}

dependencies {

implementation project(':bivrost-utils')
Expand Down Expand Up @@ -45,4 +32,13 @@ uploadArchives {
repository(url: uri('../repo'))
}
}
}
}

task sourcesJar(type: Jar, dependsOn:classes) {
from sourceSets.main.allSource
classifier = 'sources'
}

artifacts {
archives sourcesJar
}
11 changes: 10 additions & 1 deletion bivrost-gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,13 @@ uploadArchives {
repository(url: uri('../repo'))
}
}
}
}

task sourcesJar(type: Jar, dependsOn:classes) {
from sourceSets.main.allSource
classifier = 'sources'
}

artifacts {
archives sourcesJar
}
12 changes: 11 additions & 1 deletion bivrost-solidity-types-generator/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ dependencies {
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}

compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
}

task sourcesJar(type: Jar, dependsOn:classes) {
from sourceSets.main.allSource
classifier = 'sources'
}

artifacts {
archives sourcesJar
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ private fun generateUInts(): List<TypeSpec> = (8..256 step 8).map { generateUInt
private fun generateUInt(className: String, nBits: Int): TypeSpec {
val decoderTypeName = ParameterizedTypeName.get(SolidityBase.UIntBase.Decoder::class.asClassName(), ClassName("", className))
return TypeSpec.classBuilder(className)
.addModifiers(KModifier.DATA)
.superclass(SolidityBase.UIntBase::class)
.addSuperclassConstructorParameter("%1L, %2L", "value", nBits)
.companionObject(GeneratorUtils.generateDecoderCompanion(
Expand All @@ -96,6 +97,7 @@ private fun generateAddress(): TypeSpec {
val name = "Address"
val decoderTypeName = ParameterizedTypeName.get(SolidityBase.UIntBase.Decoder::class.asClassName(), ClassName("", name))
return TypeSpec.classBuilder(name)
.addModifiers(KModifier.DATA)
.superclass(SolidityBase.UIntBase::class)
.addSuperclassConstructorParameter("%1L, %2L", "value", "160")
.companionObject(GeneratorUtils.generateDecoderCompanion(
Expand All @@ -113,6 +115,7 @@ private fun generateBool(): TypeSpec {
val name = "Bool"
val decoderTypeName = ClassName.bestGuess("Decoder")
return TypeSpec.classBuilder(name)
.addModifiers(KModifier.DATA)
.superclass(SolidityBase.UIntBase::class)
.addSuperclassConstructorParameter("if (%1L) %2T.ONE else %2T.ZERO, %3L", "value", BigInteger::class, "8")
.primaryConstructor(FunSpec.constructorBuilder().addParameter(
Expand All @@ -137,6 +140,7 @@ private fun generateInts() = (8..256 step 8).map { generateInt("Int$it", it) }.t
private fun generateInt(className: String, nBits: Int): TypeSpec {
val decoderTypeName = ParameterizedTypeName.get(SolidityBase.IntBase.Decoder::class.asClassName(), ClassName("", className))
return TypeSpec.classBuilder(className)
.addModifiers(KModifier.DATA)
.superclass(SolidityBase.IntBase::class)
.addSuperclassConstructorParameter("%1L, %2L", "value", nBits)
.companionObject(GeneratorUtils.generateDecoderCompanion(
Expand Down Expand Up @@ -212,6 +216,7 @@ private fun generateString(): TypeSpec {
val superClass = ClassName.bestGuess("Bytes")
val decoderTypeName = ClassName.bestGuess("Decoder")
return TypeSpec.classBuilder(name)
.addModifiers(KModifier.DATA)
.superclass(superClass)
.addSuperclassConstructorParameter("%1L.toByteArray()", "value")
.primaryConstructor(FunSpec.constructorBuilder().addParameter(
Expand Down
24 changes: 10 additions & 14 deletions bivrost-solidity-types/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,6 @@ apply plugin: 'maven'

sourceCompatibility = 1.8

task runSolidityTypeGenerator(type: JavaExec) {
def srcDirs = sourceSets.main.kotlin.getSrcDirs()
if (srcDirs.isEmpty()) {
logger.error("Couldn't find kotlin main source sets")
return
}

def path = "${sourceSets.main.kotlin.getSrcDirs().getAt(0)}"
main = 'pm.gnosis.SolidityTypeGenerator'
classpath = sourceSets.main.runtimeClasspath
args (path, project.group)
}

dependencies {
implementation deps.kotlin.stdLibJre8

Expand All @@ -36,4 +23,13 @@ uploadArchives {
repository(url: uri('../repo'))
}
}
}
}

task sourcesJar(type: Jar, dependsOn:classes) {
from sourceSets.main.allSource
classifier = 'sources'
}

artifacts {
archives sourcesJar
}
Loading

0 comments on commit efd7df4

Please sign in to comment.