Kr1ptal / ethers-kt

Async, high-performance Kotlin library for interacting with EVM-based blockchains. Targeting JVM and Android platforms.
https://www.kriptal.io/
Apache License 2.0
22 stars 8 forks source link

Setting foundryRoot in ethers-abigen-plugin is not respected #166

Closed phoefflingdvc closed 1 day ago

phoefflingdvc commented 4 days ago

Module

Other

What version of ethers-kt are you using?

1.2.0

What version of Java you are working on?

21.0.4 (Eclipse Adoptium 21.0.4+7-LTS)

Are you developing an Android app? If yes, please provide the OS version.

No response

📝 Description

Hi,

we are using foundry for solidity development. In order to keep our src/main folder clean and make development easier, we moved the foundry project from src/main/solidity to solidity.

Configuration:

ethersAbigen {
    foundrySource("com.example.abi") {
        foundryRoot = "solidity"
    }
}

The result is: Failed to load foundry config: Could not find file src/main/solidity/foundry.toml

I think this is a lazy evaluation issue and could be fixed by switching to from String to Property<String>. The RegularFile should be a RegularFileProperty and everything becomes lazy.

Example:

tasks.register("lazyRoot") {
    val foundryRoot: Property<String> = objects.property(String::class.java).convention("src/main/solidity")
    val foundryConfigFile: RegularFileProperty = objects.fileProperty().convention(foundryRoot.map { layout.projectDirectory.dir(it).file("foundry.toml") })

    foundryRoot.set("somewhere")

    doLast {
        println("foundryRoot: ${foundryRoot.get()}")
        println("foundryConfigFile: ${foundryConfigFile.get()}")
    }
}

Thanks for the project, blockchain on the JVM needs some love ...

📑 Stack trace

No response

💻 Code to reproduce the bug

build.gradle.kts

plugins {
    kotlin("jvm") version "2.0.10"
    id("io.kriptal.ethers.abigen-plugin") version "1.2.0"
}

ethersAbigen {
    foundrySource("com.example.abi") {
        foundryRoot = "solidity"
    }
}

repositories {
    mavenCentral()
}
ArtificialPB commented 4 days ago

Thanks for reporting this issue - was able to replicate it locally and prepared a fix.

Can you try the changes in the PR to make sure it now works for you? Instructions for locally testing the plugin are documented in ethers-abigen-plugin/README.md. Happy to help you with setting it up if you encounter any issues!

ArtificialPB commented 1 day ago

@phoefflingdvc released v1..2.1 which addresses this issue.

LMK if you find any other issues

phoefflingdvc commented 23 hours ago

Thanks for the quick fix. I found some more issues regarding the general design of this plugin, but this is a new feature request and needs some discussions upfront.

ArtificialPB commented 19 hours ago

@phoefflingdvc you can open an issue and we can discuss it here, or we can talk directly on our Discord channel: https://discord.com/invite/rx35NzQGSb