Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feat/return-wallet-fork
Browse files Browse the repository at this point in the history
  • Loading branch information
Vorobeyko committed Sep 30, 2024
2 parents 116ac36 + 99646d4 commit 697d7b7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 43 deletions.
20 changes: 4 additions & 16 deletions packages/wallets/src/metamask/metamask.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class MetamaskPage implements WalletPage {
await this.loginPage.unlock();
if (await this.header.networkListButton.isVisible()) {
await this.popoverElements.closePopover();
await this.walletOperation.rejectAllTxInQueue(); // reject all tx in queue if exist
await this.walletOperation.cancelAllTxInQueue(); // reject all tx in queue if exist
}
});
}
Expand All @@ -70,7 +70,7 @@ export class MetamaskPage implements WalletPage {
if (!(await this.header.networkListButton.isVisible())) {
await this.onboardingPage.firstTimeSetup();
await this.popoverElements.closePopover();
await this.walletOperation.rejectAllTxInQueue(); // reject all tx in queue if exist
await this.walletOperation.cancelAllTxInQueue(); // reject all tx in queue if exist
await this.settingsPage.setupNetworkChangingSetting(); // need to make it possible to change the wallet network
}
});
Expand Down Expand Up @@ -218,21 +218,9 @@ export class MetamaskPage implements WalletPage {
});
}

async signTx(page: Page) {
await test.step('Sign TX', async () => {
await new WalletOperationPage(page).signTransaction();
});
}

async cancelSignTx(page: Page) {
await test.step('Cancel Sign TX', async () => {
await new WalletOperationPage(page).cancelSignTransaction();
});
}

async rejectTx(page: Page) {
async cancelTx(page: Page) {
await test.step('Reject TX', async () => {
await new WalletOperationPage(page).rejectTransaction();
await new WalletOperationPage(page).cancelTransaction();
});
}

Expand Down
39 changes: 17 additions & 22 deletions packages/wallets/src/metamask/pages/walletOperations.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ export class WalletOperationPage {
page: Page;
nextButton: Locator;
confirmButton: Locator;
rejectButton: Locator;
approvalCancelButton: Locator;
cancelButton: Locator;
addTokenButton: Locator;
editGasFeeButton: Locator;
setHighGasFeeButton: Locator;
scrollRequestSignatureBlockButton: Locator;
rejectAllTxsButton: Locator;
cancelAllTxsButton: Locator;
confirmRejectAllTxsButton: Locator;
recipientButton: Locator;
recipientAddress: Locator;
Expand All @@ -22,17 +22,17 @@ export class WalletOperationPage {
this.page = page;
this.nextButton = this.page.getByTestId('page-container-footer-next');
this.confirmButton = this.page.getByTestId('confirm-footer-button');
this.rejectButton = this.page.getByTestId('page-container-footer-cancel');
this.approvalCancelButton = this.page.getByTestId(
'page-container-footer-cancel',
);
this.cancelButton = this.page.getByTestId('confirm-footer-cancel-button');
this.addTokenButton = this.page.locator('button:has-text("Add token")');
this.editGasFeeButton = this.page.getByTestId('edit-gas-fee-icon');
this.setHighGasFeeButton = this.page.getByTestId('edit-gas-fee-item-high');
this.scrollRequestSignatureBlockButton = this.page.getByTestId(
'signature-request-scroll-button',
);
this.rejectAllTxsButton = this.page.locator(
'div[class="page-container__footer-secondary"]',
);
this.cancelAllTxsButton = this.page.getByTestId('confirm-nav__reject-all');
this.confirmRejectAllTxsButton = this.page.locator(
'button:has-text("Reject all")',
);
Expand All @@ -47,35 +47,30 @@ export class WalletOperationPage {
);
}

async rejectAllTxInQueue() {
async cancelAllTxInQueue() {
//Is there is any tx in queue.
try {
await this.rejectButton.waitFor({
await this.cancelButton.waitFor({
state: 'visible',
timeout: 1000,
});
} catch (er) {
return;
}

if (await this.rejectAllTxsButton.isVisible()) {
await this.rejectAllTxsButton.click();
await this.confirmRejectAllTxsButton.click();
if (await this.cancelAllTxsButton.isVisible()) {
await this.cancelAllTxsButton.click();
} else {
await this.rejectButton.click();
await this.cancelButton.click();
}
}

async rejectTransaction() {
await this.rejectButton.click();
}

async cancelSignTransaction() {
await this.cancelButton.click();
}

async signTransaction() {
await this.confirmButton.click();
async cancelTransaction() {
try {
await this.cancelButton.click();
} catch {
await this.approvalCancelButton.click();
}
}

async confirmTransactionOfTokenApproval() {
Expand Down
6 changes: 1 addition & 5 deletions packages/wallets/src/wallet.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ export interface WalletPage {

confirmTx(page: Page, setAggressiveGas?: boolean): Promise<void>;

signTx(page: Page): Promise<void>;

rejectTx?(page: Page): Promise<void>;

cancelSignTx?(page: Page): Promise<void>;
cancelTx?(page: Page): Promise<void>;

approveTokenTx?(page: Page): Promise<void>;

Expand Down

0 comments on commit 697d7b7

Please sign in to comment.