Commit 87cbd1ab authored by eddie's avatar eddie Committed by GitHub

fix: use ConfirmSwapModal in expert mode (#6673)

Fixes the swap flow for users who are still in expert mode  and need permit2 approvals for a token

### test plan

added e2e test for full permit2 flow with expert mode enabled. 

failing test without the change:
<img width="1394" alt="Screenshot 2023-05-31 at 2 24 12 PM" src="https://github.com/Uniswap/interface/assets/66155195/6a39e039-31b5-4bce-91d2-5e3ebc777378">


passing test with change in the CI of this PR
parent 1090e97b
...@@ -81,6 +81,34 @@ describe('Permit2', () => { ...@@ -81,6 +81,34 @@ describe('Permit2', () => {
}) })
}) })
it('swaps after completing full permit2 approval process in expert mode', () => {
// Sets up a swap between INPUT_TOKEN and OUTPUT_TOKEN.
cy.visit(`/swap/?inputCurrency=${INPUT_TOKEN.address}&outputCurrency=${OUTPUT_TOKEN.address}&ape=true`, {
ethereum: 'hardhat',
})
cy.get('#swap-currency-input .token-amount-input').type(TEST_BALANCE_INCREMENT.toString())
cy.hardhat().then(({ provider }) => {
cy.spy(provider, 'send').as('permitApprovalSpy')
})
initiateSwap()
cy.contains('Enable spending limits for DAI on Uniswap').should('exist')
cy.contains('Approved').should('exist')
cy.contains('Allow DAI to be used for swapping').should('exist')
cy.contains('Confirm Swap').should('exist')
cy.then(() => {
const approvalTime = Date.now()
cy.contains('Swapped').should('exist')
expectTokenAllowanceForPermit2ToBeMax()
expectPermit2AllowanceForUniversalRouterToBeMax(approvalTime)
cy.get('@permitApprovalSpy').should('have.been.calledWith', 'eth_signTypedData_v4')
})
})
it('swaps after handling user rejection of both approval and signature', () => { it('swaps after handling user rejection of both approval and signature', () => {
const USER_REJECTION = { code: 4001 } const USER_REJECTION = { code: 4001 }
cy.hardhat().then((hardhat) => { cy.hardhat().then((hardhat) => {
......
...@@ -699,9 +699,6 @@ export function Swap({ ...@@ -699,9 +699,6 @@ export function Swap({
> >
<ButtonError <ButtonError
onClick={() => { onClick={() => {
if (isExpertMode) {
handleSwap()
} else {
setSwapState({ setSwapState({
tradeToConfirm: trade, tradeToConfirm: trade,
attemptingTxn: false, attemptingTxn: false,
...@@ -709,7 +706,6 @@ export function Swap({ ...@@ -709,7 +706,6 @@ export function Swap({
showConfirm: true, showConfirm: true,
txHash: undefined, txHash: undefined,
}) })
}
}} }}
id="swap-button" id="swap-button"
data-testid="swap-button" data-testid="swap-button"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment