Skip to content

Commit

Permalink
feat: update metamask siwe page object
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterYinusa committed Sep 11, 2024
1 parent 5ebcf89 commit 2de683b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/metamask/pages/sign-in-request.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { HTMLElement } from '../../controls/html-element';
import { IConfirmation } from '../../interface/wallet/confirmation';
import { ConfirmTransaction } from './confirm-transaction';

Expand All @@ -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<any>}
* @memberof SignInRequest
*/
async accept<TPage>(page?: new () => TPage): Promise<any> {
if (await this.scrollButton().isDisplayed()) {
await this.scrollButton().clickAndWait();
}
if (page) {
return await this.nextButton().clickAndSwitchToMainWindow<TPage>(page);
} else {
return await this.nextButton().click();
}
}
}
1 change: 1 addition & 0 deletions src/metamask/pages/sign-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/metamask/pages/signature-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 2de683b

Please sign in to comment.