diff --git a/hardhat.config.ts b/hardhat.config.ts index 396c8ecd..0c25c684 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -29,6 +29,24 @@ task("accounts", "Prints the list of accounts", async (taskArgs, hre) => { } }); +task("blockTimestamp", "Prints the block timestamp", async (taskArgs, hre) => { + const currentBlock = await hre.ethers.provider.getBlockNumber(); + if (!currentBlock) { + console.error("Failed to get the current block number."); + return; + } + let block = await hre.ethers.provider.getBlock(currentBlock); + while (!block) { + await new Promise((resolve) => setTimeout(resolve, 200)); + block = await hre.ethers.provider.getBlock(currentBlock); + } + + const blockTimestamp = block.timestamp; + console.log(blockTimestamp); + const date = new Date(blockTimestamp * 1000); // Date requires ms, whereas block.timestamp is in s + console.log(date); +}); + // You need to export an object to set up your config // Go to https://hardhat.org/config/ to learn more diff --git a/helpers/DeployHelper.ts b/helpers/DeployHelper.ts index 8931eb81..84486be0 100644 --- a/helpers/DeployHelper.ts +++ b/helpers/DeployHelper.ts @@ -5,16 +5,16 @@ import { deployPoseidons } from "./PoseidonDeployHelper"; import { GenesisUtilsWrapper, PrimitiveTypeUtilsWrapper } from "../typechain-types"; import { SmtLibModule, - VCPaymentModule, + VCPaymentProxyModule, StateProxyModule, IdentityTreeStoreProxyModule, UniversalVerifierProxyModule, - LinkedMultiQueryValidatorModule, - EthIdentityValidatorModule, - AuthV2ValidatorModule, - CredentialAtomicQueryV3ValidatorModule, - CredentialAtomicQueryMTPV2ValidatorModule, - CredentialAtomicQuerySigV2ValidatorModule, + LinkedMultiQueryValidatorProxyModule, + EthIdentityValidatorProxyModule, + AuthV2ValidatorProxyModule, + CredentialAtomicQueryV3ValidatorProxyModule, + CredentialAtomicQueryMTPV2ValidatorProxyModule, + CredentialAtomicQuerySigV2ValidatorProxyModule, } from "../ignition"; import { chainIdInfoMap, contractsInfo } from "./constants"; import { @@ -694,22 +694,22 @@ export class DeployHelper { if (deployStrategy === "create2") { switch (validatorType) { case "mtpV2": - validatorModule = CredentialAtomicQueryMTPV2ValidatorModule; + validatorModule = CredentialAtomicQueryMTPV2ValidatorProxyModule; break; case "sigV2": - validatorModule = CredentialAtomicQuerySigV2ValidatorModule; + validatorModule = CredentialAtomicQuerySigV2ValidatorProxyModule; break; case "v3": - validatorModule = CredentialAtomicQueryV3ValidatorModule; + validatorModule = CredentialAtomicQueryV3ValidatorProxyModule; break; case "authV2": - validatorModule = AuthV2ValidatorModule; + validatorModule = AuthV2ValidatorProxyModule; break; case "lmq": - validatorModule = LinkedMultiQueryValidatorModule; + validatorModule = LinkedMultiQueryValidatorProxyModule; break; case "ethIdentity": - validatorModule = EthIdentityValidatorModule; + validatorModule = EthIdentityValidatorProxyModule; break; } @@ -1157,7 +1157,7 @@ export class DeployHelper { // Deploying VCPayment contract to predictable address but with dummy implementation vcPayment = ( - await ignition.deploy(VCPaymentModule, { + await ignition.deploy(VCPaymentProxyModule, { strategy: deployStrategy, }) ).vcPayment; diff --git a/helpers/helperUtils.ts b/helpers/helperUtils.ts index ef1ab62f..8e1583ad 100644 --- a/helpers/helperUtils.ts +++ b/helpers/helperUtils.ts @@ -244,6 +244,20 @@ export async function getStateContractAddress(chainId?: number): Promise return stateContractAddress; } +export async function getBlockTimestamp(provider: JsonRpcProvider): Promise { + const currentBlock = await provider.getBlockNumber(); + if (!currentBlock) { + throw new Error("Failed to get the current block number."); + } + let block = await provider.getBlock(currentBlock); + while (!block) { + await new Promise((resolve) => setTimeout(resolve, 200)); + block = await provider.getBlock(currentBlock); + } + const date = new Date(block.timestamp * 1000); // Date requires ms, whereas block.timestamp is in s + return date; +} + async function getParamsPath(): Promise { const chainId = await getChainId(); const paramsPath = path.join(__dirname, `../ignition/modules/params/chain-${chainId}.json`); diff --git a/scripts/maintenance/multi-chain/checkBlockTimestamp.ts b/scripts/maintenance/multi-chain/checkBlockTimestamp.ts new file mode 100644 index 00000000..80c4ef32 --- /dev/null +++ b/scripts/maintenance/multi-chain/checkBlockTimestamp.ts @@ -0,0 +1,35 @@ +import { + getBlockTimestamp, + getChainId, + getProviders, + getStateContractAddress, + isContract, + Logger, +} from "../../../helpers/helperUtils"; +import { contractsInfo, DEFAULT_MNEMONIC, networks } from "../../../helpers/constants"; +import { ethers } from "hardhat"; + +const mnemonicWallet = ethers.Wallet.fromPhrase(DEFAULT_MNEMONIC); + +async function main() { + const providers = getProviders(); + + for (const provider of providers) { + const jsonRpcProvider = new ethers.JsonRpcProvider(provider.rpcUrl); + + try { + const blockTimestamp = await getBlockTimestamp(jsonRpcProvider); + Logger.success(`${provider.network}: blockTimeStamp ${blockTimestamp.toISOString()}`); + } catch (error) { + Logger.error(`${provider.network}: Failed to get block timestamp - ${error.message}`); + continue; + } + } +} + +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error); + process.exit(1); + });