-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Bug]: Missing "Unlimited" as value for the DAI permit #28964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hey @bschorchit : the simulation displayed above are not returned by decoding api but they are implemented by us in UI. Decoding api for request above is returning Reason could be that request body does not comply to 712 format. |
Ah, the correct payload would be:
I should've clarified that I was simply pasting the |
Hey @imblue-dabadee , @bschorchit : I used the sample request above and it is giving me this error: |
Additionally displaying |
For DAI we need to fix our default implementation to display Note: our default implementation for permit is displayed when decoding api result is not available. |
<!-- 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.
<!-- 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.
Describe the bug
For DAI permit, we're currently displaying no value for DAI permits.
Expected behavior
For DAI permit, we should display
Unlimited
as the value within estimated changes.Screenshots/Recordings
Steps to reproduce
Payload:
API response:
Error messages or log output
No response
Detection stage
During release testing
Version
12.9.0
Build type
None
Browser
Brave
Operating system
MacOS
Hardware wallet
No response
Additional context
No response
Severity
No response
The text was updated successfully, but these errors were encountered: