You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: Missing "Unlimited" as value for the DAI permit (#29597)
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->
## **Description**
Introduces a new logical path for displaying "Unlimited" in the permit
simulation, for when the `allowed` property in the signature message is
set and the permit is for the token DAI. This is as is specified in
[ERC-2612](https://eips.ethereum.org/EIPS/eip-2612)'s "Backwards
Compatibility" section:
> There are already a couple of permit functions in token contracts
implemented in contracts in the wild, most notably the one introduced in
the dai.sol.
> Its implementation differs slightly from the presentation here in
that:
> instead of taking a value argument, it takes a bool allowed, setting
approval to 0 or uint(-1).
This PR also fixes a bug that prevents boolean values from being
displayed in the key value display in the message section of signatures.
<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->
[](https://codespaces.new/MetaMask/metamask-extension/pull/29597?quickstart=1)
## **Related issues**
Fixes: #28964
## **Manual testing steps**
1. Open the browser console and execute the following code:
```javascript
async function connectMetaMask() {
try {
const accounts = await window.ethereum.request({
method: 'eth_requestAccounts',
});
console.log('Connected account:', accounts[0]);
return accounts[0];
} catch (error) {
console.error('User rejected the request:', error);
throw error;
}
}
async function signPermit() {
try {
const fromAddress = await connectMetaMask();
const msgParams = {
types: {
EIP712Domain: [
{ name: 'name', type: 'string' },
{ name: 'version', type: 'string' },
{ name: 'chainId', type: 'uint256' },
{ name: 'verifyingContract', type: 'address' },
],
Permit: [
{ name: 'holder', type: 'address' },
{ name: 'spender', type: 'address' },
{ name: 'nonce', type: 'uint256' },
{ name: 'expiry', type: 'uint256' },
{ name: 'allowed', type: 'bool' },
],
},
domain: {
name: 'Dai Stablecoin',
version: '1',
verifyingContract: '0x6B175474E89094C44Da98b954EedeAC495271d0F',
chainId: '0x1',
},
primaryType: 'Permit',
message: {
holder: '0xD2C44F28eC4C7eF686f587FADdb204da3aEFa827',
spender: '0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45',
allowed: true,
nonce: 0,
expiry: 1660916504,
},
};
const signature = await window.ethereum.request({
method: 'eth_signTypedData_v4',
params: [fromAddress, JSON.stringify(msgParams)],
});
console.log('Signature:', signature);
return signature;
} catch (error) {
console.error('Error signing permit:', error);
}
}
signPermit();
```
2. Change `"allowed": true` to `"allowed": false` in the aforementioned
code and execute it to see the revocation screen.
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<!-- [screenshots/recordings] -->
### **After**
<!-- [screenshots/recordings] -->
<img width="472" alt="Screenshot 2025-01-08 at 18 30 35"
src="https://github.com/user-attachments/assets/93e5f295-7b75-4e1d-88c0-aaa1d11ff01d"
/>
<img width="472" alt="Screenshot 2025-01-08 at 18 30 37"
src="https://github.com/user-attachments/assets/59e8b129-df26-4f24-bcd2-a978f974eedd"
/>
<img width="472" alt="Screenshot 2025-01-09 at 10 22 09"
src="https://github.com/user-attachments/assets/10064bde-2e65-43de-b624-1c0a04d6eea4"
/>
<img width="472" alt="Screenshot 2025-01-09 at 10 22 13"
src="https://github.com/user-attachments/assets/22ecff23-71de-4293-9fba-fab74b52a42c"
/>
## **Pre-merge author checklist**
- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
Copy file name to clipboardExpand all lines: ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign-v4-simulation/permit-simulation/permit-simulation.tsx
Copy file name to clipboardExpand all lines: ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign-v4-simulation/value-display/value-display.tsx
0 commit comments