Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade the viem toolbox and project creation to viem@2 #4876

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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": major
---

Upgraded hardhat-viem to support viem@2
6 changes: 6 additions & 0 deletions .changeset/silver-waves-cough.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@nomicfoundation/hardhat-toolbox-viem": major
"hardhat": patch
---

Upgraded hardhat-toolbox-viem and project creation to support viem@2
6 changes: 3 additions & 3 deletions packages/hardhat-core/src/internal/cli/project-creation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const ETHERS_PROJECT_DEPENDENCIES: Dependencies = {
};

const VIEM_PROJECT_DEPENDENCIES: Dependencies = {
"@nomicfoundation/hardhat-toolbox-viem": "^2.0.0",
"@nomicfoundation/hardhat-toolbox-viem": "^3.0.0",
};

const PEER_DEPENDENCIES: Dependencies = {
Expand All @@ -68,8 +68,8 @@ const ETHERS_PEER_DEPENDENCIES: Dependencies = {
};

const VIEM_PEER_DEPENDENCIES: Dependencies = {
"@nomicfoundation/hardhat-viem": "^1.0.0",
viem: "^1.15.1",
"@nomicfoundation/hardhat-viem": "^2.0.0",
viem: "^2.7.6",
};

const TYPESCRIPT_DEPENDENCIES: Dependencies = {};
Expand Down
8 changes: 4 additions & 4 deletions packages/hardhat-toolbox-viem/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@nomicfoundation/eslint-plugin-slow-imports": "workspace:^",
"@nomicfoundation/hardhat-network-helpers": "workspace:^1.0.0",
"@nomicfoundation/hardhat-verify": "workspace:^2.0.0",
"@nomicfoundation/hardhat-viem": "workspace:^1.0.0",
"@nomicfoundation/hardhat-viem": "workspace:^2.0.0",
"@types/chai": "^4.2.0",
"@types/chai-as-promised": "^7.1.6",
"@types/mocha": ">=9.1.0",
Expand All @@ -68,12 +68,12 @@
"solidity-coverage": "^0.8.1",
"ts-node": "^10.8.0",
"typescript": "~5.0.4",
"viem": "^1.15.1"
"viem": "^2.7.6"
},
"peerDependencies": {
"@nomicfoundation/hardhat-network-helpers": "^1.0.0",
"@nomicfoundation/hardhat-verify": "^2.0.0",
"@nomicfoundation/hardhat-viem": "^1.0.0",
"@nomicfoundation/hardhat-viem": "^2.0.0",
"@types/chai": "^4.2.0",
"@types/chai-as-promised": "^7.1.6",
"@types/mocha": ">=9.1.0",
Expand All @@ -84,7 +84,7 @@
"solidity-coverage": "^0.8.1",
"ts-node": ">=8.0.0",
"typescript": "~5.0.4",
"viem": "^1.15.1"
"viem": "^2.7.6"
},
"bugs": {
"url": "https://github.com/nomicfoundation/hardhat/issues"
Expand Down
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.

Loading