Skip to content

Commit

Permalink
fix: Fix an issue where solana is disconnected when trust evm wallet …
Browse files Browse the repository at this point in the history
…is disconnected
  • Loading branch information
wenty22 committed Nov 21, 2024
1 parent 808aab9 commit 615241f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/happy-jobs-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@node-real/walletkit': patch
---

Fix an issue where solana is disconnected when trust evm wallet is disconnected
33 changes: 19 additions & 14 deletions packages/walletkit/src/evm/wallets/injected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export type InjectedParameters = {
// Regex of wallets/providers that can accurately simulate contract calls & display contract revert reasons.
const supportsSimulationIdRegex = /(rabby|trustwallet)/;

const notRevokePermissionWallets = ['trust'];

const targetMap = {
coinbaseWallet: {
id: 'coinbaseWallet',
Expand Down Expand Up @@ -264,20 +266,23 @@ export function injected(parameters: InjectedParameters = {}) {
try {
// Adding timeout as not all wallets support this method and can hang
// https://github.com/wevm/wagmi/issues/4064
await withTimeout(
() =>
// TODO: Remove explicit type for viem@3
provider.request<{
Method: 'wallet_revokePermissions';
Parameters: [permissions: { eth_accounts: Record<string, any> }];
ReturnType: null;
}>({
// `'wallet_revokePermissions'` added in `[email protected]`
method: 'wallet_revokePermissions',
params: [{ eth_accounts: {} }],
}),
{ timeout: 100 },
);

if (!notRevokePermissionWallets.includes(this.id)) {
await withTimeout(
() =>
// TODO: Remove explicit type for viem@3
provider.request<{
Method: 'wallet_revokePermissions';
Parameters: [permissions: { eth_accounts: Record<string, any> }];
ReturnType: null;
}>({
// `'wallet_revokePermissions'` added in `[email protected]`
method: 'wallet_revokePermissions',
params: [{ eth_accounts: {} }],
}),
{ timeout: 100 },
);
}
} catch {}

// Add shim signalling connector is disconnected
Expand Down

0 comments on commit 615241f

Please sign in to comment.