foundry-rs / foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
https://getfoundry.sh
Apache License 2.0
8.31k stars 1.75k forks source link

`cast call` appends newline to output (breaks piping to cast --to-ascii) #8652

Closed fauxbytes closed 3 months ago

fauxbytes commented 3 months ago

Component

Cast

Have you ensured that all of these are up to date?

What version of Foundry are you on?

forge 0.2.0 (a0a0020 2024-08-12T00:25:05.209264900Z)

What command(s) is the bug in?

cast call

Operating System

Windows

Describe the bug

$ cast --version
cast 0.2.0 (a0a0020 2024-08-12T00:24:56.205249700Z)

# pipe output into cast for conversion. 👎🏼
$ cast call 0xdAC17F958D2ee523a2206206994597C13D831ec7 "symbol()" --rpc-url https://eth.llamarpc.com | cast --to-ascii
Error:
Invalid character '\n' at position 192

# Remove newlines before piping into --to-ascii. 👍🏼
$ cast call 0xdAC17F958D2ee523a2206206994597C13D831ec7 "symbol()" --rpc-url https://eth.llamarpc.com | tr -d '\n' | cast --to-ascii
 USDT
leovct commented 3 months ago

I'd like to work on this issue :)

Also worth nothing that the following also works:

$ cast to-ascii $(cast call 0xdAC17F958D2ee523a2206206994597C13D831ec7 "symbol()" --rpc-url https://eth.llamarpc.com)
 USDT
onlydustapp[bot] commented 3 months ago

Hey @leovct! Thanks for showing interest. We've created an application for you to contribute to Foundry. Go check it out on OnlyDust!

SebastianLF commented 3 months ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I'm a JS web2 dev transitionning to web3

How I plan on tackling this issue

I will modify symbol() function to remove newline characters before returning the output.