Geth version: 1.8.15
OS & Version: Windows/Linux/OSX (all)
Commit hash : n/a
When you pipe stuff from solc to abigen (example below) you should be able to
pipe more than 1 contract with a number of calls to the pair of commands. The --type
flag should allow you to keep the code in a single package and not have Go compilation
errors.
The --type flag is ignored when you use a pipe. This is different than with a file.
mkdir -p ./gocode
cd contracts
solc --allow-paths . \
--combined-json abi,bin,devdoc,userdoc,metadata \
Contract1.sol | \
abigen --abi - --pkg AbiCode -type Contract1 --out ../gocode/Contract1.go
solc --allow-paths . \
--combined-json abi,bin,devdoc,userdoc,metadata \
Contract2.sol | \
abigen --abi - --pkg AbiCode -type Contract1 --out ../gocode/Contract2.go
cd ../gocode
go build
I will create a PR with a fix - it is a very simple 15 or so lines of code to add to abigen.
After PR https://github.com/ethereum/go-ethereum/pull/17648 it is not possible to use --pkg flag with JSON contract artifacts.
Previously execution of command
cat <contract.json> | abigen --abi - --pkg <packagename> --out <output.go>
lead to execution of the contractsFromStdin() at https://github.com/ethereum/go-ethereum/blob/7e7781ffaa5c5486c5e7b66dea4986e063524f63/cmd/abigen/main.go#L94
And after the PR pkgFlag == "" condition prevents falling into this branch:
https://github.com/ethereum/go-ethereum/blob/7e7781ffaa5c5486c5e7b66dea4986e063524f63/cmd/abigen/main.go#L78
And fails with the parse error.
Was this condition made by intention? What is the reason of adding it?
That seems like it may be an accidental check, since *pkgFlag == "" should exit earlier anyway:
Seems worth a PR to fix it?
Also maybe seems like this issue could be closed.
@Shadowfiend, do you know how to get my PR merged? I am not able to assign reviewers and CI seems to be red for all PRs. I have asked help in discordapp go-ethereum/abigen channel, but have no answer.
Nope, you're in the land of the maintainers :)
Merged the fix with #19207 last month, closing this issue.