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

56 expiry time issue for certification #63

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
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: 12 additions & 6 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const {
ETHERSCAN_API_KEY,
SEPOLIA_URL,
POLYGON_AMOY_URL,
ARBITRUM_SEPOLIA_URL,
ETHEREUM_SEPOLIA_URL
} = process.env;

export const config = {
Expand Down Expand Up @@ -46,12 +48,16 @@ export const config = {
accounts: PRIVATE_KEY ? [`0x${PRIVATE_KEY}`] : [],
gasPrice: 22000000000,
},

// arbitrumSepolia: {
// url: ARBITRUM_SEPOLIA_URL || "",
// accounts: PRIVATE_KEY ? [`0x${PRIVATE_KEY}`] : [],
// gasPrice: 22000000000,
// },
"arbitrum-sepolia": {
url: ARBITRUM_SEPOLIA_URL || "",
accounts: PRIVATE_KEY ? [`0x${PRIVATE_KEY}`] : [],
gasPrice: 22000000000,
},
"ethereum-sepolia": {
url: ETHEREUM_SEPOLIA_URL || "",
accounts: PRIVATE_KEY ? [`0x${PRIVATE_KEY}`] : [],
gasPrice: 22000000000,
},
},
solidity: {
compilers: [
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@
"dependencies": {
"@rainprotocol/rain-protocol": "git://github.com/rainprotocol/rain-protocol.git#33275a8c9ef751c3d1187dc9a66b37d77aca6848",
"solc": "=0.8.17"
},
"scripts": {
"certify-arb-sepolia": "npx hardhat run scripts/certify.ts --network arbitrum-sepolia"
}
}
71 changes: 71 additions & 0 deletions scripts/certify.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { artifacts, ethers } from "hardhat";
import * as dotenv from "dotenv";
import { getEventArgs } from "../test/util";
import { Contract } from "ethers";
import type { OffchainAssetReceiptVault } from "../typechain-types";

dotenv.config();

async function main() {
const { PRIVATE_KEY, CONTRACT_FACTORY_ADDRESS } = process.env;

if ( !PRIVATE_KEY || !CONTRACT_FACTORY_ADDRESS) {
throw new Error("Please set PRIVATE_KEY and CONTRACT_FACTORY_ADDRESS in your .env file");
}

// const provider = new ethers.providers.JsonRpcProvider(ETHEREUM_SEPOLIA_URL);
const wallet = new ethers.Wallet(PRIVATE_KEY, ethers.provider);

const contractFactoryAbi = ( await artifacts.readArtifact("OffchainAssetReceiptVaultFactory") ).abi;

const contractFactory = new ethers.Contract(CONTRACT_FACTORY_ADDRESS, contractFactoryAbi, wallet);

const constructionConfig = {
admin: wallet.address,
vaultConfig: {
asset: ethers.constants.AddressZero,
name: `OffchainAssetVaul-${ new Date().getTime() }`,
symbol: "OAV"
}
};

let tx = await contractFactory.connect(wallet).createChildTyped(
constructionConfig
);

const { child } = await getEventArgs(
tx,
"NewChild",
contractFactory
);

let contract = new Contract(
child,
( await artifacts.readArtifact("OffchainAssetReceiptVault") ).abi
) as OffchainAssetReceiptVault;

try {
const blockNum = await ethers.provider.getBlockNumber();
const block = await ethers.provider.getBlock(blockNum);
const _certifiedUntil = block.timestamp + 100;

// Grant role and wait for the transaction to be mined
const grantRoleTx = await contract.connect(wallet).grantRole(await contract.connect(wallet).CERTIFIER(), wallet.address);
await grantRoleTx.wait();

// Call certify function
const certifyTx = await contract.connect(wallet).certify(_certifiedUntil, blockNum, false, []);
console.log("Transaction sent:", certifyTx.hash);

// Wait for the transaction to be mined
const receipt = await certifyTx.wait();
console.log("Transaction mined:", receipt);
} catch (error) {
console.error("Error occurred:", error);
}
}

main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
Loading