Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Commit

Permalink
Split Aion project into common, FVM and AVM modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavier committed Jun 17, 2019
1 parent dc0c956 commit 40ed96e
Show file tree
Hide file tree
Showing 56 changed files with 280 additions and 146 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Expand Up @@ -21,3 +21,14 @@

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# Maven
pom.xml
maven.gradle

# NodeJS
node_modules
package-lock.json

# Aion
fork.properties
32 changes: 32 additions & 0 deletions avm/build.gradle
@@ -0,0 +1,32 @@
web3j {
excludedContracts = ['Mortal']
}

dependencies {
implementation project(':web3j-aion-common')

implementation "org.web3j:abi:${versions.web3j}"

implementation name: 'org-aion-avm-api'
implementation name: 'org-aion-avm-core'
implementation name: 'org-aion-avm-rt'
implementation name: 'org-aion-avm-tooling'
implementation name: 'org-aion-avm-userlib'

testImplementation project(path: ':web3j-aion-common', configuration: 'testOutput')
integrationTestImplementation project(path: ':web3j-aion-common', configuration: 'integrationTestOutput')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
}
repositories {
mavenCentral()
}
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
Expand Up @@ -64,7 +64,7 @@ public RemoteCall<TransactionReceipt> sayHello() {

public RemoteCall<String> greet(String param0) {
final Function function = new Function(FUNC_GREET,
Arrays.<Type>asList(new org.web3j.abi.datatypes.Utf8String(param0)),
Arrays.<Type>asList(new Utf8String(param0)),
Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {
}));
return executeRemoteCallSingleValueReturn(function, String.class);
Expand All @@ -81,7 +81,7 @@ public RemoteCall<String> getString() {
public RemoteCall<TransactionReceipt> setString(String param0) {
final Function function = new Function(
FUNC_SETSTRING,
Arrays.<Type>asList(new org.web3j.abi.datatypes.Utf8String(param0)),
Arrays.<Type>asList(new Utf8String(param0)),
Collections.<TypeReference<?>>emptyList());
return executeRemoteCallTransaction(function);
}
Expand Down
@@ -1,4 +1,4 @@
package org.web3j.aion.abi
package org.web3j.aion.abi.avm

// FIXME Remove core dependency
import org.aion.avm.userlib.abi.ABIDecoder
Expand Down Expand Up @@ -81,10 +81,22 @@ internal object AbiFunctionDecoder : FunctionReturnDecoder() {
Double::class.java.isAssignableFrom(type) -> decodeOneDouble().toWeb3j()
Utf8String::class.java.isAssignableFrom(type) -> decodeOneString().toWeb3j()
Bool::class.java.isAssignableFrom(type) -> decodeOneBoolean().toWeb3j()
BytesType::class.java.isAssignableFrom(type) -> decodeBytesType(type, decoder)
IntType::class.java.isAssignableFrom(type) -> decodeIntType(type, decoder)
DynamicArray::class.java.isAssignableFrom(type) -> decodeDynamicArray(typeReference, decoder)
StaticArray::class.java.isAssignableFrom(type) -> decodeStaticArray(typeReference, decoder)
BytesType::class.java.isAssignableFrom(type) -> decodeBytesType(
type,
decoder
)
IntType::class.java.isAssignableFrom(type) -> decodeIntType(
type,
decoder
)
DynamicArray::class.java.isAssignableFrom(type) -> decodeDynamicArray(
typeReference,
decoder
)
StaticArray::class.java.isAssignableFrom(type) -> decodeStaticArray(
typeReference,
decoder
)
else -> throw ABIException("Unsupported ABI type")
}
}
Expand Down Expand Up @@ -128,9 +140,18 @@ internal object AbiFunctionDecoder : FunctionReturnDecoder() {

private val Class<Type<*>>.bitSize: kotlin.Int?
get() = when {
INT_REGEX.matches(simpleName) -> bitSize(simpleName, INT_REGEX)
UINT_REGEX.matches(simpleName) -> bitSize(simpleName, UINT_REGEX)
BYTES_REGEX.matches(simpleName) -> bitSize(simpleName, BYTES_REGEX)
INT_REGEX.matches(simpleName) -> bitSize(
simpleName,
INT_REGEX
)
UINT_REGEX.matches(simpleName) -> bitSize(
simpleName,
UINT_REGEX
)
BYTES_REGEX.matches(simpleName) -> bitSize(
simpleName,
BYTES_REGEX
)
else -> throw ABIException("Unknown type ${javaClass.canonicalName}")
}

Expand Down
@@ -1,4 +1,4 @@
package org.web3j.aion.abi
package org.web3j.aion.abi.avm

// FIXME Remove core dependency
import org.aion.avm.core.util.ABIUtil
Expand Down
@@ -1,11 +1,11 @@
package org.web3j.aion.abi.spi
package org.web3j.aion.abi.avm.spi

import org.web3j.abi.FunctionEncoder
import org.web3j.abi.FunctionReturnDecoder
import org.web3j.abi.spi.FunctionDecoderProvider
import org.web3j.abi.spi.FunctionEncoderProvider
import org.web3j.aion.abi.AbiFunctionDecoder
import org.web3j.aion.abi.AbiFunctionEncoder
import org.web3j.aion.abi.avm.AbiFunctionDecoder
import org.web3j.aion.abi.avm.AbiFunctionEncoder

class AbiFunctionEncoderProvider : FunctionEncoderProvider {
override fun get(): FunctionEncoder = AbiFunctionEncoder
Expand Down
@@ -0,0 +1 @@
org.web3j.aion.abi.avm.spi.AbiFunctionDecoderProvider
218 changes: 106 additions & 112 deletions build.gradle
@@ -1,12 +1,17 @@
plugins {
id 'java'
id 'idea'
id 'maven-publish'
id 'org.web3j' version '4.3.0'
id 'org.jetbrains.kotlin.jvm' version '1.3.31'
id 'org.unbroken-dome.test-sets' version '2.1.1'
id 'com.diffplug.gradle.spotless' version '3.23.0'
id 'com.adarshr.test-logger' version '1.6.0'
buildscript {
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'org.web3j:web3j-gradle-plugin:4.3.0'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.31'
classpath 'org.unbroken-dome.gradle-plugins:gradle-testsets-plugin:2.1.1'
classpath 'com.diffplug.spotless:spotless-plugin-gradle:3.23.0'
classpath 'com.adarshr:gradle-test-logger-plugin:1.7.0'
}
}

group = 'org.web3j.aion'
Expand All @@ -28,130 +33,119 @@ ext {
versions = loadPropsFromFile("$rootDir/versions.properties")
}

repositories {
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
mavenContent {
snapshotsOnly()
subprojects {
apply plugin: 'maven'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'org.web3j'
apply plugin: 'maven-publish'
apply plugin: 'org.unbroken-dome.test-sets'
apply plugin: 'com.diffplug.gradle.spotless'
apply plugin: 'com.adarshr.test-logger'

repositories {
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
mavenContent {
snapshotsOnly()
}
}
flatDir {
dirs "$rootProject.projectDir/lib"
}
}
flatDir {
dirs "$projectDir/lib"
}
}

solidity {
executable = "docker run --rm -v $projectDir:/src satran004/aion-fastvm:0.3.1 solc"
version = '0.4.15'
}

web3j {
excludedContracts = ['Mortal']
}

testSets {
integrationTest {
dirName = 'integration-test'
testSets {
integrationTest {
dirName = 'integration-test'
}
}
}

dependencies {
implementation name: 'org-aion-avm-api'
implementation name: 'org-aion-avm-core'
implementation name: 'org-aion-avm-rt'
implementation name: 'org-aion-avm-tooling'
implementation name: 'org-aion-avm-userlib'

implementation name: 'rlp4j', version: '46e0cb3'
implementation name: 'util4j', version: '2c5aa4ad'

implementation "org.web3j:core:${versions.web3j}"
implementation "org.web3j:codegen:${versions.web3j}"
implementation "info.picocli:picocli:${versions.picocli}"

implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
implementation 'org.jetbrains.kotlin:kotlin-reflect'
implementation 'org.jetbrains.kotlin:kotlin-noarg'
implementation 'org.jetbrains.kotlin:kotlin-native-utils'

implementation "io.github.microutils:kotlin-logging:${versions.kLogging}"
implementation "org.bouncycastle:bcpkix-jdk15on:${versions.bouncycastle}"
tasks.withType(Test) {
useJUnitPlatform()
reports.html.enabled = false
reports.junitXml.enabled = false
systemProperties = [
'junit.jupiter.extensions.autodetection.enabled': 'true',
'junit.jupiter.testinstance.lifecycle.default' : 'per_class'
]
}

implementation("com.github.shyiko:ktlint:${versions.ktlint}") {
exclude group: 'org.jetbrains.kotlin'
exclude group: 'org.slf4j'
configurations {
testOutput.extendsFrom (testCompile)
integrationTestOutput.extendsFrom (integrationTestCompile)
}

testImplementation(group: 'org.web3j', name: 'core', version: versions.web3j, classifier: 'tests')
testImplementation "org.junit.jupiter:junit-jupiter-api:${versions.junit5}"
testImplementation "com.willowtreeapps.assertk:assertk-jvm:${versions.assertk}"
testImplementation "junit:junit:${versions.junit4}"
testImplementation("io.mockk:mockk:${versions.mockk}") {
exclude group: 'org.jetbrains.kotlin'
artifacts {
testOutput testJar
integrationTestOutput integrationTestJar
}

testlogger {
showStandardStreams true
}

runtimeOnly "com.github.schnitker.logmanager:logmgr-logback:${versions.logmanager}"
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'

testImplementation(group: 'org.web3j', name: 'core', version: versions.web3j, classifier: 'tests')
testImplementation "org.junit.jupiter:junit-jupiter-api:${versions.junit5}"
testImplementation "com.willowtreeapps.assertk:assertk-jvm:${versions.assertk}"
testImplementation "junit:junit:${versions.junit4}"
testImplementation("io.mockk:mockk:${versions.mockk}") {
exclude group: 'org.jetbrains.kotlin'
}

testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${versions.junit5}"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:${versions.junit5}"
runtimeOnly "com.github.schnitker.logmanager:logmgr-logback:${versions.logmanager}"

integrationTestImplementation "org.testcontainers:testcontainers:${versions.testcontainers}"
integrationTestImplementation "org.testcontainers:junit-jupiter:${versions.testcontainers}"
}
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${versions.junit5}"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:${versions.junit5}"

spotless {
kotlin {
// This path needs to be relative to each project
target fileTree('.') {
include '**/*.kt'
exclude '**/.gradle/**'
}
ktlint(versions.ktlint)
trimTrailingWhitespace()
endWithNewline()
integrationTestImplementation "org.testcontainers:testcontainers:${versions.testcontainers}"
integrationTestImplementation "org.testcontainers:junit-jupiter:${versions.testcontainers}"
}
}

tasks.withType(Test) {
useJUnitPlatform()
reports.html.enabled = false
reports.junitXml.enabled = false
systemProperties = [
'junit.jupiter.extensions.autodetection.enabled': 'true',
'junit.jupiter.testinstance.lifecycle.default' : 'per_class'
]
}

testlogger {
showStandardStreams true
}
sourceCompatibility = JavaVersion.VERSION_1_8

sourceCompatibility = JavaVersion.VERSION_1_8
compileKotlin {
kotlinOptions {
jvmTarget = '1.8'
}
dependsOn 'generateContractWrappers'
}

compileKotlin {
kotlinOptions {
jvmTarget = '1.8'
compileTestKotlin {
kotlinOptions {
jvmTarget = '1.8'
}
dependsOn 'generateTestContractWrappers'
}
dependsOn 'generateContractWrappers'
}

compileTestKotlin {
kotlinOptions {
jvmTarget = '1.8'
compileIntegrationTestKotlin {
kotlinOptions {
jvmTarget = '1.8'
}
dependsOn 'generateIntegrationTestContractWrappers'
}
dependsOn 'generateTestContractWrappers'
}

compileIntegrationTestKotlin {
kotlinOptions {
jvmTarget = '1.8'
sourceSets {
main.kotlin.srcDirs += "${web3j.generatedFilesBaseDir}/main/java"
test.kotlin.srcDirs += "${web3j.generatedFilesBaseDir}/test/java"
integrationTest.kotlin.srcDirs += "${web3j.generatedFilesBaseDir}/integrationTest/java"
}
dependsOn 'generateIntegrationTestContractWrappers'
}

sourceSets {
main.kotlin.srcDirs += "${web3j.generatedFilesBaseDir}/main/java"
test.kotlin.srcDirs += "${web3j.generatedFilesBaseDir}/test/java"
integrationTest.kotlin.srcDirs += "${web3j.generatedFilesBaseDir}/integrationTest/java"
spotless {
kotlin {
// This path needs to be relative to each project
target fileTree('.') {
include '**/*.kt'
exclude '**/.gradle/**'
}
ktlint(versions.ktlint)
trimTrailingWhitespace()
endWithNewline()
}
}
}

0 comments on commit 40ed96e

Please sign in to comment.