Skip to content

Commit

Permalink
patch
Browse files Browse the repository at this point in the history
  • Loading branch information
glitch-txs committed Jul 29, 2024
2 parents 650d706 + 441667e commit 515f064
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
7 changes: 5 additions & 2 deletions packages/appkit-universal/appKitClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class WalletConnectModal extends Web3ModalScaffold {
private universalProvider: Awaited<ReturnType<(typeof UniversalProvider)['init']>>
private requestedScope: string
private requestedNamespaces: Exclude<ConnectParams['optionalNamespaces'], undefined>
private _onSyncAccount: WalletConnectModal['syncAccount'] | undefined

public constructor(options: Web3ModalClientOptions) {
const { universalProvider, namespaces, ...w3mOptions } = options
Expand Down Expand Up @@ -104,8 +105,10 @@ export class WalletConnectModal extends Web3ModalScaffold {
])
this.syncAccount()
this.syncNetwork()
universalProvider.client.on('session_update', this.syncAccount.bind(this))
universalProvider.client.on('session_delete', this.syncAccount.bind(this))

this._onSyncAccount = this.syncAccount.bind(this)
universalProvider.client.on('session_update', this._onSyncAccount)
universalProvider.client.on('session_delete', this._onSyncAccount)
}

async disconnect() {
Expand Down
2 changes: 1 addition & 1 deletion packages/appkit-universal/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@walletconnect/solana-adapter-ui",
"version": "0.0.3",
"version": "0.0.4",
"license": "Apache-2.0",
"type": "module",
"main": "./dist/appKitClient.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/walletconnect-solana/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@walletconnect/solana-adapter",
"version": "0.0.3",
"version": "0.0.4",
"license": "Apache-2.0",
"type": "module",
"sideEffects": false,
Expand Down
8 changes: 6 additions & 2 deletions packages/walletconnect-solana/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export class WalletConnectWalletAdapter extends BaseSignerWalletAdapter {
private _readyState: WalletReadyState =
typeof window === 'undefined' ? WalletReadyState.Unsupported : WalletReadyState.Loadable

private _onDisconnect: WalletConnectWalletAdapter['disconnect'] | undefined

constructor(config: WalletConnectWalletAdapterConfig) {
super()

Expand All @@ -52,6 +54,8 @@ export class WalletConnectWalletAdapter extends BaseSignerWalletAdapter {
: WalletConnectChainID.Devnet,
options: this._config.options,
})

this._onDisconnect = this.disconnect.bind(this)
}

get publicKey() {
Expand All @@ -76,7 +80,7 @@ export class WalletConnectWalletAdapter extends BaseSignerWalletAdapter {
const { publicKey } = await this._wallet.connect()
this._publicKey = publicKey
this.emit('connect', publicKey)
this._wallet.client.on('session_delete', this.disconnect.bind(this))
this._wallet.client.on('session_delete', this._onDisconnect)
} catch (error: unknown) {
if ((error as Error).constructor.name === 'QRCodeModalError') throw new WalletWindowClosedError()
throw error
Expand All @@ -88,7 +92,7 @@ export class WalletConnectWalletAdapter extends BaseSignerWalletAdapter {
async disconnect(): Promise<void> {
const wallet = this._wallet
if (wallet) {
wallet.client.off('session_delete', this.disconnect)
wallet.client.off('session_delete', this._onDisconnect)
this._publicKey = null

try {
Expand Down

0 comments on commit 515f064

Please sign in to comment.