Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Commit

Permalink
feat: add open popup method
Browse files Browse the repository at this point in the history
  • Loading branch information
xstelea committed Aug 10, 2023
1 parent c8bd2c8 commit 48ab81c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<button id="login-btn">Login</button>
<button id="account-address-btn">Get account addresses</button>
<button id="persona-data-btn">Get persona data</button>
<button id="open-popup-btn">Open popup</button>
<div id="results"></div>
</body>
</html>
4 changes: 4 additions & 0 deletions examples/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ const sdk = WalletSdk({
networkId: 12,
})

document.getElementById('open-popup-btn')!.onclick = async () => {
sdk.openPopup()
}

const displayResults = (result: Result<any, any>) => {
document.getElementById('results')!.innerHTML = `<pre>${JSON.stringify(
result.isErr() ? result.error : result.value,
Expand Down
7 changes: 7 additions & 0 deletions lib/connector-extension/connector-extension-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,13 @@ export const ConnectorExtensionClient = (
subscription.unsubscribe()
removeEventListener(eventType.incomingMessage, handleIncomingMessage)
},
openPopup: () => {
window.dispatchEvent(
new CustomEvent(eventType.outgoingMessage, {
detail: { discriminator: 'openPopup' },
})
)
},
extensionStatus$: of(true).pipe(
tap(() => {
subjects.outgoingMessageSubject.next({
Expand Down
1 change: 1 addition & 0 deletions lib/create-methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@ export const createMethods = (
request,
sendTransaction,
extensionStatus$: connectorExtensionClient.extensionStatus$,
openPopup: connectorExtensionClient.openPopup,
}
}

0 comments on commit 48ab81c

Please sign in to comment.