Skip to content

Commit

Permalink
Upgrade hardhat-viem to support viem@2
Browse files Browse the repository at this point in the history
  • Loading branch information
schaable committed Feb 15, 2024
1 parent 5f0e42d commit bc34536
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/proud-peas-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/hardhat-viem": patch
---

Upgraded hardhat-viem to support viem@2
4 changes: 2 additions & 2 deletions packages/hardhat-viem/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@
"sinon": "^9.0.0",
"ts-node": "^10.8.0",
"typescript": "~5.0.0",
"viem": "^1.15.1"
"viem": "^2.7.6"
},
"peerDependencies": {
"hardhat": "^2.17.0",
"typescript": "~5.0.0",
"viem": "^1.15.1"
"viem": "^2.7.6"
},
"dependencies": {
"abitype": "^0.9.8",
Expand Down
6 changes: 4 additions & 2 deletions packages/hardhat-viem/src/internal/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,10 @@ async function innerGetContractAt(
const viem = await import("viem");
const contract = viem.getContract({
address,
publicClient,
walletClient,
client: {
public: publicClient,
wallet: walletClient,
},
abi: contractAbi,
});

Expand Down
6 changes: 4 additions & 2 deletions packages/hardhat-viem/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ export type GetContractReturnType<
TAbi extends viemT.Abi | readonly unknown[] = viemT.Abi
> = viemT.GetContractReturnType<
TAbi,
PublicClient,
WalletClient,
{
public: PublicClient;
wallet: WalletClient;
},
viemT.Address
>;

Expand Down
8 changes: 4 additions & 4 deletions packages/hardhat-viem/test/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ describe("Integration tests", function () {
const fromAddress = fromWalletClient.account.address;
const toAddress = toWalletClient.account.address;

const fromBalanceBefore: bigint = await publicClient.getBalance({
const fromBalanceBefore = await publicClient.getBalance({
address: fromAddress,
});
const toBalanceBefore: bigint = await publicClient.getBalance({
const toBalanceBefore = await publicClient.getBalance({
address: toAddress,
});

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

const fromBalanceAfter: bigint = await publicClient.getBalance({
const fromBalanceAfter = await publicClient.getBalance({
address: fromAddress,
});
const toBalanceAfter: bigint = await publicClient.getBalance({
const toBalanceAfter = await publicClient.getBalance({
address: toAddress,
});

Expand Down
45 changes: 41 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bc34536

Please sign in to comment.