-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a342b85
commit 68aa72b
Showing
16 changed files
with
384 additions
and
131 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
test/e2e/tests/confirmations/transactions/revoke-allowance-redesign.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/* eslint-disable @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */ | ||
import { MockttpServer } from 'mockttp'; | ||
import { WINDOW_TITLES } from '../../../helpers'; | ||
import { Driver } from '../../../webdriver/driver'; | ||
import { scrollAndConfirmAndAssertConfirm } from '../helpers'; | ||
import { mocked4BytesApprove } from './erc20-approve-redesign.spec'; | ||
import { | ||
assertChangedSpendingCap, | ||
editSpendingCap, | ||
} from './increase-token-allowance-redesign.spec'; | ||
import { openDAppWithContract, TestSuiteArguments } from './shared'; | ||
|
||
const { | ||
defaultGanacheOptions, | ||
defaultGanacheOptionsForType2Transactions, | ||
withFixtures, | ||
} = require('../../../helpers'); | ||
const FixtureBuilder = require('../../../fixture-builder'); | ||
const { SMART_CONTRACTS } = require('../../../seeder/smart-contracts'); | ||
|
||
describe('Confirmation Redesign ERC20 Revoke Allowance', function () { | ||
const smartContract = SMART_CONTRACTS.HST; | ||
|
||
describe('Submit an revoke transaction @no-mmi', function () { | ||
it('Sends a type 0 transaction (Legacy)', async function () { | ||
await withFixtures( | ||
{ | ||
dapp: true, | ||
fixtures: new FixtureBuilder() | ||
.withPermissionControllerConnectedToTestDapp() | ||
.withPreferencesController({ | ||
preferences: { | ||
redesignedConfirmationsEnabled: true, | ||
isRedesignedConfirmationsDeveloperEnabled: true, | ||
}, | ||
}) | ||
.build(), | ||
ganacheOptions: defaultGanacheOptions, | ||
smartContract, | ||
testSpecificMock: mocks, | ||
title: this.test?.fullTitle(), | ||
}, | ||
async ({ driver, contractRegistry }: TestSuiteArguments) => { | ||
await openDAppWithContract(driver, contractRegistry, smartContract); | ||
|
||
await createERC20ApproveTransaction(driver); | ||
|
||
const NEW_SPENDING_CAP = '0'; | ||
await editSpendingCap(driver, NEW_SPENDING_CAP); | ||
|
||
await driver.waitForSelector({ | ||
css: 'h2', | ||
text: 'Remove permission', | ||
}); | ||
|
||
await scrollAndConfirmAndAssertConfirm(driver); | ||
|
||
await assertChangedSpendingCap(driver, NEW_SPENDING_CAP); | ||
}, | ||
); | ||
}); | ||
|
||
it('Sends a type 2 transaction (EIP1559)', async function () { | ||
await withFixtures( | ||
{ | ||
dapp: true, | ||
fixtures: new FixtureBuilder() | ||
.withPermissionControllerConnectedToTestDapp() | ||
.withPreferencesController({ | ||
preferences: { | ||
redesignedConfirmationsEnabled: true, | ||
isRedesignedConfirmationsDeveloperEnabled: true, | ||
}, | ||
}) | ||
.build(), | ||
ganacheOptions: defaultGanacheOptionsForType2Transactions, | ||
smartContract, | ||
testSpecificMock: mocks, | ||
title: this.test?.fullTitle(), | ||
}, | ||
async ({ driver, contractRegistry }: TestSuiteArguments) => { | ||
await openDAppWithContract(driver, contractRegistry, smartContract); | ||
|
||
await createERC20ApproveTransaction(driver); | ||
|
||
const NEW_SPENDING_CAP = '0'; | ||
await editSpendingCap(driver, NEW_SPENDING_CAP); | ||
|
||
await driver.waitForSelector({ | ||
css: 'h2', | ||
text: 'Remove permission', | ||
}); | ||
|
||
await scrollAndConfirmAndAssertConfirm(driver); | ||
|
||
await assertChangedSpendingCap(driver, NEW_SPENDING_CAP); | ||
}, | ||
); | ||
}); | ||
}); | ||
}); | ||
|
||
async function mocks(server: MockttpServer) { | ||
return [await mocked4BytesApprove(server)]; | ||
} | ||
|
||
async function createERC20ApproveTransaction(driver: Driver) { | ||
await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp); | ||
await driver.clickElement('#approveTokens'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
ui/pages/confirmations/components/confirm/info/approve/hooks/use-custom-spending-cap.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { useState } from 'react'; | ||
|
||
export const useCustomSpendingCap = () => { | ||
const [customSpendingCap, setCustomSpendingCap] = useState(''); | ||
|
||
return { customSpendingCap, setCustomSpendingCap }; | ||
}; |
11 changes: 11 additions & 0 deletions
11
ui/pages/confirmations/components/confirm/info/approve/revoke-details/revoke-details.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react'; | ||
import { ConfirmInfoSection } from '../../../../../../../components/app/confirm/info/row/section'; | ||
import { OriginRow } from '../../shared/transaction-details/transaction-details'; | ||
|
||
export const RevokeDetails = () => { | ||
return ( | ||
<ConfirmInfoSection> | ||
<OriginRow /> | ||
</ConfirmInfoSection> | ||
); | ||
}; |
Oops, something went wrong.