Skip to content

Commit 127c476

Browse files
gregfromstljnsdls
andauthored
Fix getAddresses call for accounts converted to viem (#2666)
Co-authored-by: Jonas Daniels <jonas.daniels@outlook.com>
1 parent b3fca95 commit 127c476

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

.changeset/blue-kangaroos-cheat.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
fix getAddresses for accounts converted to viem

packages/thirdweb/src/adapters/viem.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { zeroAddress } from "viem";
77
import { typedData } from "~test/typed-data.js";
88
import { ANVIL_PKEY_A } from "~test/test-wallets.js";
99
import { ANVIL_CHAIN } from "../../test/src/chains.js";
10+
import { mainnet } from "../chains/chain-definitions/ethereum.js";
1011

1112
const account = privateKeyAccount({
1213
privateKey: ANVIL_PKEY_A,
@@ -62,4 +63,16 @@ describe("walletClient.toViem", () => {
6263
expect(txHash).toBeDefined();
6364
expect(txHash.slice(0, 2)).toBe("0x");
6465
});
66+
67+
test("should get address on live chain", async () => {
68+
walletClient = viemAdapter.walletClient.toViem({
69+
client: TEST_CLIENT,
70+
account,
71+
chain: mainnet,
72+
});
73+
74+
const address = await walletClient.getAddresses();
75+
expect(address[0]).toBeDefined();
76+
expect(address[0]).toBe(account.address);
77+
});
6578
});

packages/thirdweb/src/adapters/viem.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ function toViemWalletClient(options: ToViemWalletClientOptions) {
225225
const data = JSON.parse(request.params[1]);
226226
return account.signTypedData(data);
227227
}
228+
if (request.method === "eth_accounts") {
229+
return [account.address];
230+
}
228231
return rpcClient(request);
229232
},
230233
});

0 commit comments

Comments
 (0)