diff --git a/.changeset/proud-peas-sort.md b/.changeset/proud-peas-sort.md new file mode 100644 index 00000000000..dabb626d6b1 --- /dev/null +++ b/.changeset/proud-peas-sort.md @@ -0,0 +1,5 @@ +--- +"@nomicfoundation/hardhat-viem": patch +--- + +Upgraded hardhat-viem to support viem@2 diff --git a/packages/hardhat-viem/package.json b/packages/hardhat-viem/package.json index c548701f854..fffa9b08f54 100644 --- a/packages/hardhat-viem/package.json +++ b/packages/hardhat-viem/package.json @@ -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", diff --git a/packages/hardhat-viem/src/internal/contracts.ts b/packages/hardhat-viem/src/internal/contracts.ts index a5c8b1359f6..8d253162e70 100644 --- a/packages/hardhat-viem/src/internal/contracts.ts +++ b/packages/hardhat-viem/src/internal/contracts.ts @@ -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, }); diff --git a/packages/hardhat-viem/src/types.ts b/packages/hardhat-viem/src/types.ts index 39071d2e6c0..42890070d8b 100644 --- a/packages/hardhat-viem/src/types.ts +++ b/packages/hardhat-viem/src/types.ts @@ -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 >; diff --git a/packages/hardhat-viem/test/integration.ts b/packages/hardhat-viem/test/integration.ts index f8ff1454c5b..d62ac2d0306 100644 --- a/packages/hardhat-viem/test/integration.ts +++ b/packages/hardhat-viem/test/integration.ts @@ -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, }); @@ -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, }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 39b9e7d278c..f51d9065fc0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1570,8 +1570,8 @@ importers: specifier: ~5.0.0 version: 5.0.4 viem: - specifier: ^1.15.1 - version: 1.21.4(typescript@5.0.4) + specifier: ^2.7.6 + version: 2.7.9(typescript@5.0.4) packages/hardhat-vyper: dependencies: @@ -3271,7 +3271,7 @@ packages: resolution: {integrity: sha512-N1ZhksgwD3OBlwTv3R6KFEcPojl/W4ElJOeCZdi+vuI5QmTFwLq3OFf2zd2ROpKvxFdgZ6hUpb0dx9bVNEwYCA==} dependencies: '@noble/curves': 1.2.0 - '@noble/hashes': 1.3.2 + '@noble/hashes': 1.3.3 '@scure/base': 1.1.5 dev: true @@ -3291,7 +3291,7 @@ packages: /@scure/bip39@1.2.1: resolution: {integrity: sha512-Z3/Fsz1yr904dduJD0NpiyRHhRYHdcnyh73FZWiV+/qhWi83wNJ3NWolYqCEN+ZWsUz2TWwajJggcRE9r1zUYg==} dependencies: - '@noble/hashes': 1.3.2 + '@noble/hashes': 1.3.3 '@scure/base': 1.1.5 dev: true @@ -4048,6 +4048,20 @@ packages: typescript: 5.0.4 dev: true + /abitype@1.0.0(typescript@5.0.4): + resolution: {integrity: sha512-NMeMah//6bJ56H5XRj8QCV4AwuW6hB6zqz2LnhhLdcWVQOsXki6/Pn3APeqxCma62nXIcmZWdu1DlHWS74umVQ==} + peerDependencies: + typescript: '>=5.0.4' + zod: ^3 >=3.22.0 + peerDependenciesMeta: + typescript: + optional: true + zod: + optional: true + dependencies: + typescript: 5.0.4 + dev: true + /abortcontroller-polyfill@1.7.5: resolution: {integrity: sha512-JMJ5soJWP18htbbxJjG7bG6yuI6pRhgJ0scHHTfkUjf6wjP912xZWvM+A4sJK3gqd9E8fcPbDnOefbA9Th/FIQ==} @@ -10581,6 +10595,29 @@ packages: - zod dev: true + /viem@2.7.9(typescript@5.0.4): + resolution: {integrity: sha512-iDfc8TwaZFp1K95zlsxYh6Cs0OWCt35Tqs8uYgXKSxtz7w075mZ0H5SJ8zSyJGoEaticVDhtdmRRX6TtcW9EeQ==} + peerDependencies: + typescript: '>=5.0.4' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + '@adraffy/ens-normalize': 1.10.0 + '@noble/curves': 1.2.0 + '@noble/hashes': 1.3.2 + '@scure/bip32': 1.3.2 + '@scure/bip39': 1.2.1 + abitype: 1.0.0(typescript@5.0.4) + isows: 1.0.3(ws@8.13.0) + typescript: 5.0.4 + ws: 8.13.0 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + - zod + dev: true + /wcwidth@1.0.1: resolution: {integrity: sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==} dependencies: