Skip to content
Open
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
18 changes: 18 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
28 changes: 14 additions & 14 deletions helpers/DeployHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down
14 changes: 14 additions & 0 deletions helpers/helperUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,20 @@ export async function getStateContractAddress(chainId?: number): Promise<string>
return stateContractAddress;
}

export async function getBlockTimestamp(provider: JsonRpcProvider): Promise<Date> {
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<string> {
const chainId = await getChainId();
const paramsPath = path.join(__dirname, `../ignition/modules/params/chain-${chainId}.json`);
Expand Down
35 changes: 35 additions & 0 deletions scripts/maintenance/multi-chain/checkBlockTimestamp.ts
Original file line number Diff line number Diff line change
@@ -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);
});
Loading