fix(permit2): Update example witnessTypeString contents #1092
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Remove some incorrect stray text in the
witnessTypeStringexample at https://docs.uniswap.org/contracts/permit2/reference/signature-transfer#batch-permitwitnesstransferfrom , and fix some nearby references to EIP-712.Type(s) of changes
Motivation for PR
Fix incorrect example.
How Has This Been Tested?
n/a
Follow-up PR
Given the emphasis on proper ordering of struct types with the injection of a not-obviously-relevant TokenPermissions, it would be nice for the example entry-point type to actually reference some other structs. For example:
```solidity struct ExampleTrade { address exampleTokenAddress; uint256 exampleMinimumAmountOut; + TradeCondition condition; } +struct TradeCondition { + string language; + string expression; +} ``` Following EIP-712, the typehash for the data would be defined by: ```solidity -bytes32 _EXAMPLE_TRADE_TYPEHASH = keccak256('ExampleTrade(address exampleTokenAddress,uint256 exampleMinimumAmountOut)'); +bytes32 _EXAMPLE_TRADE_TYPEHASH = keccak256('ExampleTrade(address exampleTokenAddress,uint256 exampleMinimumAmountOut,TradeCondition condition)TradeCondition(string language,string expression)'); ``` The `witness` that should be passed along with the permit message should be: ```solidity bytes32 witness = keccak256( - abi.encode(_EXAMPLE_TRADE_TYPEHASH, exampleTrade.exampleTokenAddress, exampleTrade.exampleMinimumAmountOut)); + abi.encode(_EXAMPLE_TRADE_TYPEHASH, exampleTrade.exampleTokenAddress, exampleTrade.exampleMinimumAmountOut, (exampleTrade.condition.language, exampleTrade.condition.expression))); ``` And the `witnessTypeString` to be passed in should be: ```solidity -string constant witnessTypeString = "ExampleTrade(address exampleTokenAddress,uint256 exampleMinimumAmountOut)TokenPermissions(address token,uint256 amount)" +string constant witnessTypeString = "ExampleTrade(address exampleTokenAddress,uint256 exampleMinimumAmountOut,TradeCondition condition)TokenPermissions(address token,uint256 amount)TradeCondition(string language,string expression)"