diff --git a/src/metamask/pages/sign-in-request.ts b/src/metamask/pages/sign-in-request.ts index e369355..0468683 100644 --- a/src/metamask/pages/sign-in-request.ts +++ b/src/metamask/pages/sign-in-request.ts @@ -1,3 +1,4 @@ +import { HTMLElement } from '../../controls/html-element'; import { IConfirmation } from '../../interface/wallet/confirmation'; import { ConfirmTransaction } from './confirm-transaction'; @@ -10,11 +11,32 @@ import { ConfirmTransaction } from './confirm-transaction'; * @implements {IConfirmation} */ export class SignInRequest extends ConfirmTransaction implements IConfirmation { + protected nextButton: () => HTMLElement = () => new HTMLElement('[data-testid="confirm-footer-button"]'); + protected cancelButton: () => HTMLElement = () => new HTMLElement('[data-testid="confirm-footer-cancel-button"]'); + private scrollButton: () => HTMLElement = () => new HTMLElement('[aria-label="Scroll down"]', 8000); /** * Creates an instance of SignInRequest. * @memberof SignInRequest */ constructor() { - super(new RegExp(/#confirm-transaction\/.*\/signature-request/), 'MetaMask'); + super(new RegExp(/#confirm-transaction/), 'MetaMask'); + } + /** + * + * + * @template TPage + * @param {new () => TPage} [page] + * @return {*} {Promise} + * @memberof SignInRequest + */ + async accept(page?: new () => TPage): Promise { + if (await this.scrollButton().isDisplayed()) { + await this.scrollButton().clickAndWait(); + } + if (page) { + return await this.nextButton().clickAndSwitchToMainWindow(page); + } else { + return await this.nextButton().click(); + } } } diff --git a/src/metamask/pages/sign-message.ts b/src/metamask/pages/sign-message.ts index 6e8d6c7..1841dfb 100644 --- a/src/metamask/pages/sign-message.ts +++ b/src/metamask/pages/sign-message.ts @@ -12,6 +12,7 @@ import { ConfirmTransaction } from './confirm-transaction'; */ export class SignMessage extends ConfirmTransaction implements IConfirmation { protected nextButton: () => HTMLElement = () => new HTMLElement('[data-testid="confirm-footer-button"]'); + protected cancelButton: () => HTMLElement = () => new HTMLElement('[data-testid="confirm-footer-cancel-button"]'); private scrollButton: () => HTMLElement = () => new HTMLElement('[aria-label="Scroll down"]', 8000); /** * Creates an instance of SignMessage. diff --git a/src/metamask/pages/signature-request.ts b/src/metamask/pages/signature-request.ts index 7c9c7d2..3fe41a7 100644 --- a/src/metamask/pages/signature-request.ts +++ b/src/metamask/pages/signature-request.ts @@ -12,6 +12,7 @@ import { ConfirmTransaction } from './confirm-transaction'; */ export class SignatureRequest extends ConfirmTransaction implements IConfirmation { protected nextButton: () => HTMLElement = () => new HTMLElement('[data-testid="confirm-footer-button"]'); + protected cancelButton: () => HTMLElement = () => new HTMLElement('[data-testid="confirm-footer-cancel-button"]'); private scrollButton: () => HTMLElement = () => new HTMLElement('[aria-label="Scroll down"]', 8000); /** * Creates an instance of SignatureRequest.