Skip to content

Commit

Permalink
fix: Fix trust wallet will get an incorrect account when multiple acc…
Browse files Browse the repository at this point in the history
…ounts were associated with the same dapp (#246)
  • Loading branch information
wenty22 authored Dec 26, 2024
1 parent 82e5744 commit 82c5d18
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changeset/short-planes-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@node-real/walletkit': patch
---

Fix trust wallet will get an incorrect account when multiple accounts were associated with the same
dapp
2 changes: 2 additions & 0 deletions packages/walletkit/__dev__/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ function ConnectButton() {
const { publicKey, disconnect: solanaDisconnect } = useSolanaWallet();
const { address: tronAddress, disconnect: tronDisconnect } = useTronWallet();

console.log(address, '====');

return (
<>
<button
Expand Down
6 changes: 5 additions & 1 deletion packages/walletkit/src/evm/wallets/injected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,11 @@ export function injected(parameters: InjectedParameters = {}) {
async getAccounts() {
const provider = await this.getProvider();
if (!provider) throw new ProviderNotFoundError();
const accounts = await provider.request({ method: 'eth_accounts' });

const accounts = await provider.request({
method: this.id === 'trust' ? 'eth_requestAccounts' : 'eth_accounts',
});

return accounts.map((x) => getAddress(x));
},
async getChainId() {
Expand Down

0 comments on commit 82c5d18

Please sign in to comment.