From fac046bba3e59163bfca25611cbd6dae7e285299 Mon Sep 17 00:00:00 2001 From: v1rtl Date: Mon, 2 Dec 2024 20:21:13 +0200 Subject: [PATCH] wip --- deploy/.utils/nonceManager.ts | 6 ------ deploy/00_legacy_registry.ts | 34 ++++++++++++++++++---------------- deploy/00_register_legacy.ts | 8 +++++--- deploy/00_update_contracts.ts | 5 ++++- 4 files changed, 27 insertions(+), 26 deletions(-) diff --git a/deploy/.utils/nonceManager.ts b/deploy/.utils/nonceManager.ts index d2868743f..db6930d6a 100644 --- a/deploy/.utils/nonceManager.ts +++ b/deploy/.utils/nonceManager.ts @@ -1,9 +1,3 @@ -import type { ethers as EthersT } from 'ethers' - -type Ethers = typeof EthersT & { - provider: EthersT.providers.JsonRpcProvider -} - export const nonceManager = ( ethers: Ethers, diff --git a/deploy/00_legacy_registry.ts b/deploy/00_legacy_registry.ts index de9aa2eb2..20c273b75 100644 --- a/deploy/00_legacy_registry.ts +++ b/deploy/00_legacy_registry.ts @@ -1,29 +1,32 @@ /* eslint-disable import/no-extraneous-dependencies, import/extensions */ -import { ethers } from 'hardhat' import { DeployFunction } from 'hardhat-deploy/types' import { HardhatRuntimeEnvironment } from 'hardhat/types' +import { labelhash, namehash } from 'viem' -import { namehash, labelhash } from 'viem' +import { getContract, getNamedClients } from './utils/viem-hardhat' const ZERO_HASH = '0x0000000000000000000000000000000000000000000000000000000000000000' const names = ['legacy'] const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { - const { getNamedAccounts } = hre - const { owner } = await getNamedAccounts() + const { owner } = await getNamedClients(hre)() - const registry = await ethers.getContract('LegacyENSRegistry', owner) + const registry = (await getContract(hre)('LegacyENSRegistry', owner))! - const tldTx = await registry.setSubnodeOwner(ZERO_HASH, labelhash('test'), owner) - console.log(`Creating .test TLD (tx: ${tldTx.hash})...`) - await tldTx.wait() + const tldTx = await registry.write.setSubnodeOwner( + [ZERO_HASH, labelhash('test'), owner.address], + { chain: owner.public.chain, account: owner.account }, + ) + console.log(`Creating .test TLD (tx: ${tldTx})...`) await Promise.all( names.map(async (name) => { - const nameTx = await registry.setSubnodeOwner(namehash('test'), labelhash(name), owner) - console.log(`Creating ${name}.test (tx: ${nameTx.hash})...`) - await nameTx.wait() + const nameTx = await registry.write.setSubnodeOwner( + [namehash('test'), labelhash(name), owner.address], + { chain: owner.public.chain, account: owner.account }, + ) + console.log(`Creating ${name}.test (tx: ${nameTx})...`) }), ) @@ -34,13 +37,12 @@ func.id = 'legacy-registry-names' func.tags = ['legacy-registry-names'] func.dependencies = ['ENSRegistry'] func.skip = async function (hre: HardhatRuntimeEnvironment) { - const { getNamedAccounts } = hre - const { owner } = await getNamedAccounts() + const { owner } = await getNamedClients(hre)() - const registry = await ethers.getContract('LegacyENSRegistry') + const registry = (await getContract(hre)('LegacyENSRegistry', owner))! - const ownerOfTestTld = await registry.owner(namehash('test')) - if (ownerOfTestTld !== owner) { + const ownerOfTestTld = await registry.read.owner([namehash('test')]) + if (ownerOfTestTld !== owner.address) { return false } return true diff --git a/deploy/00_register_legacy.ts b/deploy/00_register_legacy.ts index c5d868e74..4269d819c 100644 --- a/deploy/00_register_legacy.ts +++ b/deploy/00_register_legacy.ts @@ -7,6 +7,8 @@ import { HardhatRuntimeEnvironment } from 'hardhat/types' import pako from 'pako' import { labelhash, namehash, stringToBytes } from 'viem' +import { getContract } from './utils/viem-hardhat' + const dummyABI = [ { type: 'event', @@ -369,9 +371,9 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const { getNamedAccounts, network } = hre const allNamedAccts = await getNamedAccounts() - const registry = await ethers.getContract('ENSRegistry') - const controller = await ethers.getContract('LegacyETHRegistrarController') - const publicResolver = await ethers.getContract('LegacyPublicResolver') + const registry = await getContract(hre)('ENSRegistry') + const controller = (await getContract(hre)('LegacyETHRegistrarController'))! + const publicResolver = await getContract(hre)('LegacyPublicResolver') const makeData = ({ namedOwner, diff --git a/deploy/00_update_contracts.ts b/deploy/00_update_contracts.ts index 68ea23e6e..5f8154050 100644 --- a/deploy/00_update_contracts.ts +++ b/deploy/00_update_contracts.ts @@ -9,7 +9,10 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const dummyOracale = (await getContract(hre)('DummyOracle', deployer))! - const txHash = await dummyOracale.write['set(int256)'](['156058000000'], {}) + const txHash = await dummyOracale.write['set(int256)'](['156058000000'], { + account: deployer.account, + chain: deployer.public.chain, + }) console.log(`Setting dummy oracle to 156058000000 (tx: ${txHash})...`) return true