Skip to content

Commit

Permalink
fix terminate method
Browse files Browse the repository at this point in the history
  • Loading branch information
Funkatronics committed Nov 14, 2024
1 parent 0ebe3e7 commit b10c9a5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
7 changes: 3 additions & 4 deletions js/packages/mobile-wallet-adapter-protocol/src/transact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,14 +455,13 @@ export async function transactRemote<TReturn>(
try {
resolve(await callback(new Proxy(wallet as RemoteMobileWallet, {
get<TMethodName extends keyof RemoteMobileWallet>(target: RemoteMobileWallet, p: TMethodName) {
if (p === 'terminateSession' && target[p] == null) {
target['terminateSession'] = async function () {
if (p == 'terminateSession') {
return async function () {
disposeSocket();
socket.close();
return;
};
}
return target[p];
} else return target[p];
},
})))
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion js/packages/wallet-standard-mobile/src/getIsSupported.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ export function getIsRemoteAssociationSupported() {
typeof window !== 'undefined' &&
window.isSecureContext &&
typeof document !== 'undefined' &&
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
);
}
4 changes: 1 addition & 3 deletions js/packages/wallet-standard-mobile/src/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -746,9 +746,7 @@ export class RemoteSolanaMobileWalletAdapterWallet implements SolanaMobileWallet
}

#disconnect: StandardDisconnectMethod = async () => {
// TODO: figure out why this call throws "TypeError: _a.terminateSession is not a function"
// even though the session termination is actually executed (websocket closes).
try { this.#wallet?.terminateSession(); } catch (e) {}
this.#wallet?.terminateSession();
this.#authorizationResultCache.clear(); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
this.#connecting = false;
this.#connectionGeneration++;
Expand Down

0 comments on commit b10c9a5

Please sign in to comment.