feat(forge): implement vm.signTypedData cheatcode#10330
feat(forge): implement vm.signTypedData cheatcode#10330Haxry wants to merge 21 commits intofoundry-rs:masterfrom
Conversation
|
@Haxry pls don't introduce ethers dep bit use alloy. Also pls add a test for the new cheatcodes and make sure priv key is redacted in traces, you can add here foundry/crates/evm/traces/src/decoder/mod.rs Line 460 in 709f266 Thanks |
|
@grandizzy |
yep, lgtm! I run |
|
Hey |
Awesome, thanks. Mind that the PR wasn't merged yet so you'll need to build locally and test, was wondering if you could provide a sample for input / output to include as a test. |
|
@Haxry i finally took over cause we want to integrate this feature asap, as 2 other PRs that implement eip712-related cheatcodes will be merged soon. Regardless of that, thanks for your contribution! fyi, i've named the cheatcode that produces the digest the @aviggiano please lmk if this is what u needed |
| Some(decoded.iter().map(format_token).collect()) | ||
| } | ||
| "signDelegation" | "signAndAttachDelegation" => { | ||
| "signDelegation" | "signAndAttachDelegation" | "signTypedData" => { |
There was a problem hiding this comment.
@grandizzy i noticed that signDelegation and signAndAttachDelegation are under the Scripting group, however signTypedData is under Crypto.
does it matter? should we change its group perhaps?
|
@0xrusowsky thanks I still don't see how I can sign without a private key, though My goal is to use EIP-712 with ledger. How would I accomplish this with the current cheatcode? |
my bad, i should have read more carefully the previous convos that u had... now i see that u want to get rid of the FFI dependency |
|
@aviggiano if the cheatcode were to simply perfom the ffi call to cast under the hood, and adopt this API: /// Signs human-readable typed data `jsonData` using a hardware wallet.
///
/// This cheatcode performs a foreign function call to `cast` to abstract away complexity of
/// manually building the calldata. Because of that, it requires the FFI cheatcode to be enabled.
///
/// # Params:
///
/// * jsonData: the typed data must follow the EIP-712 standard.
/// * walletType: the hardware wallet type, either "ledger" or "trezor".
/// * walletArgs: the wallet derivation path or the mnemonic index.
function signTypedData(string calldata jsonData, string calldata walletType, string calldata walletArgs)
external pure returns (uint8 v, bytes32 r,bytes32 s);would it solve your issues? note that u'd still have to enable the FFI flag |
|
I think this solves my problem, thanks |
|
@aviggiano unfortunately, the ledger support will have to wait a little bit more. after discussing it with @zerosnacks and @grandizzy, we've agreed that my proposal is not optimal due to the inherent risks of executing FFI calls on the terminal (even if it's a call to Instead, we will think how to come around the limitation that forces cheatcodes to be synchronous. However, this requires some design and exploration work. |
|
Ah damn so the async part is the source of complexity here. I was also building something on top of @aviggiano 's lib and the Any intution on how likely it would be to make async cheatcodes a reality? |
|
going to close this one in favor of fix of #10986 |
Motivation
Solution
closes #10281
PR Checklist