diff --git a/src/Vm.sol b/src/Vm.sol index 5a6353295..06fd18ac2 100644 --- a/src/Vm.sol +++ b/src/Vm.sol @@ -1921,6 +1921,59 @@ interface VmSafe { /// Encodes a `string` value to a base64 string. function toBase64(string calldata data) external pure returns (string memory); + + // Generates the hash of the canonical EIP-712 type representation. + // + // Supports 2 different inputs: + // 1. Name of the type (i.e. "Transaction"): + // * requires previous binding generation with `forge bind-json`. + // * bindings will be retrieved from the path configured in `foundry.toml`. + // + // 2. String representation of the type (i.e. "Foo(Bar bar) Bar(uint256 baz)"). + // * Note: the cheatcode will output the canonical type even if the input is malformated + // with the wrong order of elements or with extra whitespaces. + function eip712HashType(string calldata typeNameOrDefinition) external pure returns (bytes32 typeHash); + + // Generates the hash of the canonical EIP-712 type representation. + // Requires previous binding generation with `forge bind-json`. + // + // Params: + // * `bindingsPath`: path where the output of `forge bind-json` is stored. + // * `typeName`: Name of the type (i.e. "Transaction"). + function eip712HashType(string calldata bindingsPath, string calldata typeName) + external + pure + returns (bytes32 typeHash); + + // Generates the struct hash of the canonical EIP-712 type representation and its abi-encoded data. + // + // Supports 2 different inputs: + // 1. Name of the type (i.e. "PermitSingle"): + // * requires previous binding generation with `forge bind-json`. + // * bindings will be retrieved from the path configured in `foundry.toml`. + // + // 2. String representation of the type (i.e. "Foo(Bar bar) Bar(uint256 baz)"). + // * Note: the cheatcode will use the canonical type even if the input is malformated + // with the wrong order of elements or with extra whitespaces. + function eip712HashStruct(string calldata typeNameOrDefinition, bytes calldata abiEncodedData) + external + pure + returns (bytes32 typeHash); + + // Generates the struct hash of the canonical EIP-712 type representation and its abi-encoded data. + // Requires previous binding generation with `forge bind-json`. + // + // Params: + // * `bindingsPath`: path where the output of `forge bind-json` is stored. + // * `typeName`: Name of the type (i.e. "PermitSingle"). + // * `abiEncodedData`: ABI-encoded data for the struct that is being hashed. + function eip712HashStruct(string calldata bindingsPath, string calldata typeName, bytes calldata abiEncodedData) + external + pure + returns (bytes32 typeHash); + + // Generates a ready-to-sign digest of human-readable typed data following the EIP-712 standard. + function eip712HashTypedData(string calldata jsonData) external pure returns (bytes32 digest); } /// The `Vm` interface does allow manipulation of the EVM state. These are all intended to be used diff --git a/test/Vm.t.sol b/test/Vm.t.sol index 9ea5e9add..524f4f358 100644 --- a/test/Vm.t.sol +++ b/test/Vm.t.sol @@ -13,6 +13,6 @@ contract VmTest is Test { } function test_VmSafeInterfaceId() public pure { - assertEq(type(VmSafe).interfaceId, bytes4(0x4d98a4ca), "VmSafe"); + assertEq(type(VmSafe).interfaceId, bytes4(0x1b0ca4fb), "VmSafe"); } }