Skip to content

Commit

Permalink
Merge pull request #26 from Hanssen0/main
Browse files Browse the repository at this point in the history
feat(common): support local config for `runPopup`
  • Loading branch information
yuche authored Jun 24, 2024
2 parents e1d004e + 4c2a6a9 commit 7dd4ba5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/wise-boxes-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@joyid/common": minor
---

feat(common): support local config for `runPopup`
7 changes: 4 additions & 3 deletions packages/common/src/sdk/popup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable prefer-const */
import type {
AuthResponseData,
DappConfig,
DappRequestType,
SignCkbTxResponseData,
SignCotaNFTResponseData,
Expand Down Expand Up @@ -51,7 +52,7 @@ export const openPopup = (url: string = ''): Window | null => {
)
}

interface PopupRerurnType {
export interface PopupRerurnType {
[DappRequestType.Auth]: AuthResponseData
[DappRequestType.SignMessage]: SignMessageResponseData
[DappRequestType.SignEvm]: SignEvmTxResponseData
Expand All @@ -72,7 +73,7 @@ interface PopupRerurnType {
}

export const runPopup = async <T extends DappRequestType>(
config: PopupConfigOptions<T>
config: PopupConfigOptions<T> & Partial<DappConfig>
): Promise<PopupRerurnType[T]> =>
new Promise<PopupRerurnType[T]>((resolve, reject) => {
if (isStandaloneBrowser()) {
Expand Down Expand Up @@ -100,7 +101,7 @@ export const runPopup = async <T extends DappRequestType>(
)

popupEventListener = (e: MessageEvent) => {
const { joyidAppURL } = getConfig()
const joyidAppURL = config.joyidAppURL ?? getConfig().joyidAppURL
if (joyidAppURL == null) {
throw new Error('joyidAppURL is not set in the config')
}
Expand Down

0 comments on commit 7dd4ba5

Please sign in to comment.