scrtlabs / dev-help

This repository is for opening and managing developer issues
3 stars 0 forks source link

Issues with eth_contract macro #52

Open levackt opened 4 years ago

levackt commented 4 years ago

forum post

2 parts to this one

Consider a situation in which I have an Ethereum contract called TwoGather.sol, and discovery compile successfully compiles it into the build folder as build/smart_contracts/TwoGather.json

First question: It seems that I cannot just pass this file to the eth_contract macro, but that I first need to extract only the array that can be found at the abi property, is that correct? I was getting errors passing the file from the build/smart_contracts folder and that seemed to get me further.

Based on the the voting example this seems correct.

97 | #[eth_contract("TwoGather_abi_only.json")] = help: message: called Result::unwrap() on an Err value: TokenParseError { error: "unexpected token" }

We don't see the rest of the contract but the eth_contract declaration seems correct, and the json looks valid in the post.

Will refer to the voting example while I try reproduce the error, perhaps Brendan can share a broken project.

levackt commented 4 years ago

Some updates;

  1. Improvements to the macro:

Allow a way to pull the abi from a locally built contract json. This will facilitate development of custom contracts more easily. Provide better error messages when an abi fails to parse - at least the line/character number where the failure occurred!

  1. Possible bug leading to the error, will request more info about the compiler.

    by removing the length [48] from the bytes then the error went away.

I think this must be an error in your discovery parser, because the solidity contract compiled fine and the bytes[48] is a valid type in solidity.

I would encourage your team to look into/fix that bug. Thx.

levackt commented 4 years ago

There's an open issue in discovery-cli, will keep this open until it's resolved to close the loop.