Skip to content

Commit e4b1c07

Browse files
committed
Upgrade hardhat-viem to support viem@2
1 parent 6bee060 commit e4b1c07

File tree

5 files changed

+19
-10
lines changed

5 files changed

+19
-10
lines changed

.changeset/proud-peas-sort.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@nomicfoundation/hardhat-viem": major
3+
---
4+
5+
Upgraded hardhat-viem to support viem@2

packages/hardhat-viem/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@
6666
"sinon": "^9.0.0",
6767
"ts-node": "^10.8.0",
6868
"typescript": "~5.0.0",
69-
"viem": "^1.15.1"
69+
"viem": "^2.7.6"
7070
},
7171
"peerDependencies": {
7272
"hardhat": "workspace:^2.17.0",
7373
"typescript": "~5.0.0",
74-
"viem": "^1.15.1"
74+
"viem": "^2.7.6"
7575
},
7676
"dependencies": {
7777
"abitype": "^0.9.8",

packages/hardhat-viem/src/internal/contracts.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,10 @@ async function innerGetContractAt(
225225
const viem = await import("viem");
226226
const contract = viem.getContract({
227227
address,
228-
publicClient,
229-
walletClient,
228+
client: {
229+
public: publicClient,
230+
wallet: walletClient,
231+
},
230232
abi: contractAbi,
231233
});
232234

packages/hardhat-viem/src/types.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@ export type GetContractReturnType<
4242
TAbi extends viemT.Abi | readonly unknown[] = viemT.Abi
4343
> = viemT.GetContractReturnType<
4444
TAbi,
45-
PublicClient,
46-
WalletClient,
45+
{
46+
public: PublicClient;
47+
wallet: WalletClient;
48+
},
4749
viemT.Address
4850
>;
4951

packages/hardhat-viem/test/integration.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ describe("Integration tests", function () {
6464
const fromAddress = fromWalletClient.account.address;
6565
const toAddress = toWalletClient.account.address;
6666

67-
const fromBalanceBefore: bigint = await publicClient.getBalance({
67+
const fromBalanceBefore = await publicClient.getBalance({
6868
address: fromAddress,
6969
});
70-
const toBalanceBefore: bigint = await publicClient.getBalance({
70+
const toBalanceBefore = await publicClient.getBalance({
7171
address: toAddress,
7272
});
7373

@@ -79,10 +79,10 @@ describe("Integration tests", function () {
7979
const receipt = await publicClient.waitForTransactionReceipt({ hash });
8080
const transactionFee = receipt.gasUsed * receipt.effectiveGasPrice;
8181

82-
const fromBalanceAfter: bigint = await publicClient.getBalance({
82+
const fromBalanceAfter = await publicClient.getBalance({
8383
address: fromAddress,
8484
});
85-
const toBalanceAfter: bigint = await publicClient.getBalance({
85+
const toBalanceAfter = await publicClient.getBalance({
8686
address: toAddress,
8787
});
8888

0 commit comments

Comments
 (0)