Skip to content

Commit

Permalink
fix: signClient.connect connection hanged
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaccoSordo committed Dec 20, 2024
1 parent 58d0f1d commit b2a8567
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/beacon-core/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const SDK_VERSION: string = '4.3.1'
export const BEACON_VERSION: string = '3'
export const SDK_VERSION: string = '4.3.2-beta.0'
export const BEACON_VERSION: string = '4'

export const NOTIFICATION_ORACLE_URL: string =
'https://beacon-notification-oracle.dev.gke.papers.tech'
Original file line number Diff line number Diff line change
Expand Up @@ -625,11 +625,16 @@ export class WalletConnectCommunicationClient extends CommunicationClient {
}
}

const { uri, approval } = await signClient.connect(connectParams).catch((error) => {
logger.error(`Init error: ${error.message}`)
localStorage && localStorage.setItem(StorageKey.WC_INIT_ERROR, error.message)
throw new Error(error.message)
})
const { uri, approval }: { uri: string, approval: () => Promise<SessionTypes.Struct> } =
await Promise.race([
signClient.connect(connectParams),
new Promise<any>((_, reject) => setTimeout(() => reject(new Error('The connection timed out.')), 60000))
])
.catch((error) => {
logger.error(`Init error: ${error.message}`)
localStorage && localStorage.setItem(StorageKey.WC_INIT_ERROR, error.message)
throw new Error(error.message)
})

// Extract topic from uri. Format is wc:topic@2...
const topic = getStringBetween(uri, ':', '@')
Expand Down Expand Up @@ -1043,7 +1048,11 @@ export class WalletConnectCommunicationClient extends CommunicationClient {

try {
logger.debug('connect', [pairingTopic])
const { approval } = await signClient.connect(connectParams)
const { approval }: { approval: () => Promise<SessionTypes.Struct> } =
await Promise.race([
signClient.connect(connectParams),
new Promise<any>((_, reject) => setTimeout(() => reject(new Error('The connection timed out.')), 60000))
])
logger.debug('before await approal', [pairingTopic])
const session = await approval()
logger.debug('after await approal, have session', [pairingTopic])
Expand Down

0 comments on commit b2a8567

Please sign in to comment.