Skip to content

Commit

Permalink
fix cancel action
Browse files Browse the repository at this point in the history
  • Loading branch information
andreigiura committed Mar 28, 2024
1 parent ee65744 commit 2b1ac28
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-web-wallet-cross-window-provider",
"version": "0.0.28-alpha.9",
"version": "0.0.28-alpha.10",
"description": "Signing provider for dApps: Cross Window",
"main": "out/index.js",
"types": "out/index.d.js",
Expand Down
7 changes: 7 additions & 0 deletions src/CrossWindowProvider/CrossWindowProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,13 @@ export class CrossWindowProvider {
}

cancelAction() {
const isWalletOpened = this.windowManager?.isWalletOpened(
CrossWindowProviderRequestEnums.cancelAction
);
if (!isWalletOpened) {
return;
}

return this.windowManager?.postMessage({
type: CrossWindowProviderRequestEnums.cancelAction,
payload: undefined
Expand Down
10 changes: 7 additions & 3 deletions src/WindowManager/WindowManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,15 @@ export class WindowManager {
return this.initialized;
}

async handshake(type: CrossWindowProviderRequestEnums): Promise<boolean> {
const isOpened =
public isWalletOpened(type?: CrossWindowProviderRequestEnums) {
return (
type === CrossWindowProviderRequestEnums.cancelAction &&
Boolean(this.walletWindow);
Boolean(this.walletWindow)
);
}

async handshake(type: CrossWindowProviderRequestEnums): Promise<boolean> {
const isOpened = this.isWalletOpened(type);
if (isOpened) {
return true;
}
Expand Down

0 comments on commit 2b1ac28

Please sign in to comment.