Skip to content

Commit

Permalink
fix: pr review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
uF4No committed Nov 11, 2024
1 parent 88343d8 commit 6c2b4e1
Show file tree
Hide file tree
Showing 21 changed files with 2,458 additions and 112 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ jobs:
matrix:
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
env:
WALLET_PRIVATE_KEY: "0x3d3cbc973389cb26f657686445bcc75662b415b656078503592ac8c1abb8810e"

steps:
- name: Checkout Code
Expand Down
20 changes: 9 additions & 11 deletions contracts/deploy/allowListPaymaster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ if (!PRIVATE_KEY)
throw "⛔️ Private key not detected! Add it to the .env file!";

async function main() {
const artifact = "AllowlistPaymaster";
const contract = "AllowlistPaymaster";
const artifact = await hre.ethers.loadArtifact(contract);

console.log(
`Running script to deploy ${artifact} contract on ${hre.network.name}`,
`Running script to deploy ${artifact.contractName} contract on ${hre.network.name}`,
);

// Retrieve signers
const [deployer] = await hre.ethers.getSigners();

// Deploying the paymaster
const paymaster = await deployContract(artifact, []);
const paymaster = await deployContract(artifact.contractName, []);
const paymasterAddress = await paymaster.getAddress();
console.log(`Paymaster address: ${paymasterAddress}`);
console.log(`Contract owner added to allow list: ${deployer.address}`);
Expand All @@ -34,20 +36,16 @@ async function main() {
paymasterAddress,
);
console.log(`Paymaster ETH balance is now ${paymasterBalance.toString()}`);
// only verify on testnet and mainnet
if (hre.network.name.includes("ZKsyncEra")) {
// only verify on testnet and mainnet
// Verify contract programmatically
//
// Contract MUST be fully qualified name (e.g. path/sourceName:contractName)
const contractFullyQualifedName =
"contracts/paymasters/AllowlistPaymaster.sol:AllowlistPaymaster";
const verificationId = await hre.run("verify:verify", {
address: paymasterAddress,
contract: contractFullyQualifedName,
// Contract MUST be fully qualified name (e.g. path/sourceName:contractName)
contract: `${artifact.sourceName}:${artifact.contractName}`,
constructorArguments: [],
});
console.log(
`${contractFullyQualifedName} verified! VerificationId: ${verificationId}`,
`${artifact.contractName} verified! VerificationId: ${verificationId}`,
);
}

Expand Down
27 changes: 15 additions & 12 deletions contracts/deploy/erc20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,43 +18,46 @@ if (!RECIPIENT_ADDRESS)
throw "⛔️ RECIPIENT_ADDRESS not detected! Add it to the RECIPIENT_ADDRESS variable!";

async function main() {
const artifact = "MyERC20";
const contract = "MyERC20";
const artifact = await hre.ethers.loadArtifact(contract);

console.log(
`Running script to deploy ${artifact} contract on ${hre.network.name}`,
);
const name = "MyERC20";
const symbol = "ERC20";
const decimals = 18;
// Deploy the contract
const contract = await deployContract(artifact, [name, symbol, decimals]);
const contractAddress = await contract.getAddress();
const erc20 = await deployContract(artifact.contractName, [
name,
symbol,
decimals,
]);
const contractAddress = await erc20.getAddress();
console.log(`Token contract address: ${contractAddress}`);

// Mint token to the recipient address
const amount = hre.ethers.parseEther("100");
const tx = await contract.mint(RECIPIENT_ADDRESS, amount);
const tx = await erc20.mint(RECIPIENT_ADDRESS, amount);
console.log(
`${amount} tokens minted to ${RECIPIENT_ADDRESS}! TxHash: ${tx.hash}`,
);
await tx.wait();

// Get and log the balance of the recipient
const balance = await contract.balanceOf(RECIPIENT_ADDRESS);
const balance = await erc20.balanceOf(RECIPIENT_ADDRESS);
console.log(`Balance of the recipient: ${balance}`);

// only verify on testnet and mainnet
if (hre.network.name.includes("ZKsyncEra")) {
// only verify on testnet and mainnet
// Verify contract programmatically
//
// Contract MUST be fully qualified name (e.g. path/sourceName:contractName)
const contractFullyQualifedName = "contracts/token/ERC20.sol:MyERC20";
const verificationId = await hre.run("verify:verify", {
address: contractAddress,
contract: contractFullyQualifedName,
// Contract MUST be fully qualified name (e.g. path/sourceName:contractName)
contract: `${artifact.sourceName}:${artifact.contractName}`,
constructorArguments: [name, symbol, decimals],
});
console.log(
`${contractFullyQualifedName} verified! VerificationId: ${verificationId}`,
`${artifact.contractName} verified! VerificationId: ${verificationId}`,
);
}

Expand Down
23 changes: 11 additions & 12 deletions contracts/deploy/erc20fixedPaymaster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,20 @@ if (!TOKEN_ADDRESS)
throw "⛔️ TOKEN_ADDRESS not detected! Add it to the TOKEN_ADDRESS variable!";

async function main() {
const artifact = "ERC20fixedPaymaster";
const contract = "ERC20fixedPaymaster";
const artifact = await hre.ethers.loadArtifact(contract);

console.log(
`Running script to deploy ${artifact} contract on ${hre.network.name}`,
`Running script to deploy ${artifact.contractName} contract on ${hre.network.name}`,
);

// Retrieve signers
const [deployer] = await hre.ethers.getSigners();

// Deploying the paymaster
const paymaster = await deployContract(artifact, [TOKEN_ADDRESS]);
const paymaster = await deployContract(artifact.contractName, [
TOKEN_ADDRESS,
]);
const paymasterAddress = await paymaster.getAddress();
console.log(`Paymaster address: ${paymasterAddress}`);

Expand All @@ -39,21 +43,16 @@ async function main() {
);
console.log(`Paymaster ETH balance is now ${paymasterBalance.toString()}`);

// only verify on testnet and mainnet
if (hre.network.name.includes("ZKsyncEra")) {
// only verify on testnet and mainnet

// Verify contract programmatically
//
// Contract MUST be fully qualified name (e.g. path/sourceName:contractName)
const contractFullyQualifedName =
"contracts/paymasters/ERC20fixedPaymaster.sol:ERC20fixedPaymaster";
const verificationId = await hre.run("verify:verify", {
address: paymasterAddress,
contract: contractFullyQualifedName,
// Contract MUST be fully qualified name (e.g. path/sourceName:contractName)
contract: `${artifact.sourceName}:${artifact.contractName}`,
constructorArguments: [TOKEN_ADDRESS],
});
console.log(
`${contractFullyQualifedName} verified! VerificationId: ${verificationId}`,
`${artifact.contractName} verified! VerificationId: ${verificationId}`,
);
}
console.log(`Done!`);
Expand Down
19 changes: 8 additions & 11 deletions contracts/deploy/erc721.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ if (!RECIPIENT_ADDRESS)
throw "⛔️ RECIPIENT_ADDRESS not detected! Add it to the RECIPIENT_ADDRESS variable!";

async function main() {
const artifact = "MyNFT";
const contract = "MyNFT";
const artifact = await hre.ethers.loadArtifact(contract);
console.log(
`Running script to deploy ${artifact} contract on ${hre.network.name}`,
`Running script to deploy ${artifact.contractName} contract on ${hre.network.name}`,
);
// Deploy the contract
const nftContract = await deployContract(artifact, []);
const nftContract = await deployContract(artifact.contractName, []);
const nftAddress = await nftContract.getAddress();
console.log(`NFT contract address: ${nftAddress}`);

Expand All @@ -36,20 +37,16 @@ async function main() {
const balance = await nftContract.balanceOf(RECIPIENT_ADDRESS);
console.log(`Balance of the recipient: ${balance}`);

// only verify on testnet and mainnet
if (hre.network.name.includes("ZKsyncEra")) {
// only verify on testnet and mainnet

// Verify contract programmatically
//
// Contract MUST be fully qualified name (e.g. path/sourceName:contractName)
const contractFullyQualifedName = "contracts/token/ERC721.sol:MyNFT";
const verificationId = await hre.run("verify:verify", {
address: nftAddress,
contract: contractFullyQualifedName,
// Contract MUST be fully qualified name (e.g. path/sourceName:contractName)
contract: `${artifact.sourceName}:${artifact.contractName}`,
constructorArguments: [],
});
console.log(
`${contractFullyQualifedName} verified! VerificationId: ${verificationId}`,
`${artifact.contractName} verified! VerificationId: ${verificationId}`,
);
}

Expand Down
23 changes: 11 additions & 12 deletions contracts/deploy/erc721gatedPaymaster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@ if (!NFT_COLLECTION_ADDRESS)
throw "⛔️ NFT_COLLECTION_ADDRESS not detected! Add it to the NFT_COLLECTION_ADDRESS variable!";

async function main() {
const artifact = "ERC721gatedPaymaster";
const contract = "ERC721gatedPaymaster";
const artifact = await hre.ethers.loadArtifact(contract);

console.log(
`Running script to deploy ${artifact} contract on ${hre.network.name}`,
`Running script to deploy ${artifact.contractName} contract on ${hre.network.name}`,
);
const [deployer] = await hre.ethers.getSigners();

// Deploying the paymaster
const paymaster = await deployContract(artifact, [NFT_COLLECTION_ADDRESS]);
const paymaster = await deployContract(artifact.contractName, [
NFT_COLLECTION_ADDRESS,
]);
const paymasterAddress = await paymaster.getAddress();
console.log(`Paymaster address: ${paymasterAddress}`);

Expand All @@ -35,21 +39,16 @@ async function main() {
let paymasterBalance = await hre.ethers.provider.getBalance(paymasterAddress);
console.log(`Paymaster ETH balance is now ${paymasterBalance.toString()}`);

// only verify on testnet and mainnet
if (hre.network.name.includes("ZKsyncEra")) {
// only verify on testnet and mainnet

// Verify contract programmatically
//
// Contract MUST be fully qualified name (e.g. path/sourceName:contractName)
const contractFullyQualifedName =
"contracts/paymasters/ERC721gatedPaymaster.sol:ERC721gatedPaymaster";
const verificationId = await hre.run("verify:verify", {
address: paymasterAddress,
contract: contractFullyQualifedName,
// Contract MUST be fully qualified name (e.g. path/sourceName:contractName)
contract: `${artifact.sourceName}:${artifact.contractName}`,
constructorArguments: [NFT_COLLECTION_ADDRESS],
});
console.log(
`${contractFullyQualifedName} verified! VerificationId: ${verificationId}`,
`${artifact.contractName} verified! VerificationId: ${verificationId}`,
);
}

Expand Down
21 changes: 9 additions & 12 deletions contracts/deploy/gaslessPaymaster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ if (!PRIVATE_KEY)
throw "⛔️ Private key not detected! Add it to the .env file!";

async function main() {
const artifact = "GaslessPaymaster";
const contract = "GaslessPaymaster";
const artifact = await hre.ethers.loadArtifact(contract);

console.log(
`Running script to deploy ${artifact} contract on ${hre.network.name}`,
`Running script to deploy ${artifact.contractName} contract on ${hre.network.name}`,
);

// Retrieve signers
const [deployer] = await hre.ethers.getSigners();

// Deploying the paymaster
const paymaster = await deployContract(artifact, []);
const paymaster = await deployContract(artifact.contractName, []);
const paymasterAddress = await paymaster.getAddress();
console.log(`Paymaster address: ${paymasterAddress}`);

Expand All @@ -33,21 +35,16 @@ async function main() {
);
console.log(`Paymaster ETH balance is now ${paymasterBalance.toString()}`);

// only verify on testnet and mainnet
if (hre.network.name.includes("ZKsyncEra")) {
// only verify on testnet and mainnet

// Verify contract programmatically
//
// Contract MUST be fully qualified name (e.g. path/sourceName:contractName)
const contractFullyQualifedName =
"contracts/paymasters/GaslessPaymaster.sol:GaslessPaymaster";
const verificationId = await hre.run("verify:verify", {
address: paymasterAddress,
contract: contractFullyQualifedName,
// Contract MUST be fully qualified name (e.g. path/sourceName:contractName)
contract: `${artifact.sourceName}:${artifact.contractName}`,
constructorArguments: [],
});
console.log(
`${contractFullyQualifedName} verified! VerificationId: ${verificationId}`,
`${artifact.contractName} verified! VerificationId: ${verificationId}`,
);
}

Expand Down
25 changes: 12 additions & 13 deletions contracts/deploy/greeter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,33 @@ if (!PRIVATE_KEY)
throw "⛔️ Private key not detected! Add it to the .env file!";

async function main() {
const artifact = "Greeter";
const contract = "Greeter";
const artifact = await hre.ethers.loadArtifact(contract);
console.log(
`Running script to deploy ${artifact} contract on ${hre.network.name}`,
`Running script to deploy ${artifact.contractName} contract on ${hre.network.name}`,
);
const message = "ZK is the endgame";
// Deploy the contract
const contract = await deployContract(artifact, [message]);
const contractAddress = await contract.getAddress();
const greeter = await deployContract((await artifact).contractName, [
message,
]);
const contractAddress = await greeter.getAddress();
console.log(`Greeter contract address: ${contractAddress}`);

// Get and log the balance of the recipient
const greet = await contract.greet();
const greet = await greeter.greet();
console.log(`Message in contract is: ${greet}`);

// only verify on testnet and mainnet
if (hre.network.name.includes("ZKsyncEra")) {
// only verify on testnet and mainnet
console.log("Verifying contract...");
// Verify contract programmatically
//
// Contract MUST be fully qualified name (e.g. path/sourceName:contractName)
const contractFullyQualifedName = "contracts/utils/Greeter.sol:Greeter";
const verificationId = await hre.run("verify:verify", {
address: contractAddress,
contract: contractFullyQualifedName,
// Contract MUST be fully qualified name (e.g. path/sourceName:contractName)
contract: `${artifact.sourceName}:${artifact.contractName}`,
constructorArguments: [message],
});
console.log(
`${contractFullyQualifedName} verified! VerificationId: ${verificationId}`,
`${artifact.contractName} verified! VerificationId: ${verificationId}`,
);
}

Expand Down
22 changes: 11 additions & 11 deletions contracts/deploy/signatureBasedPaymaster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,20 @@ if (!PRIVATE_KEY)
throw "⛔️ Private key not detected! Add it to the .env file!";

async function main() {
const artifact = "SignatureBasedPaymaster";
const contract = "SignatureBasedPaymaster";
const artifact = await hre.ethers.loadArtifact(contract);

console.log(
`Running script to deploy ${artifact} contract on ${hre.network.name}`,
`Running script to deploy ${artifact.contractName} contract on ${hre.network.name}`,
);

// Retrieve signers
const [deployer] = await hre.ethers.getSigners();

// Deploying the paymaster
const paymaster = await deployContract(artifact, [deployer.address]);
const paymaster = await deployContract(artifact.contractName, [
deployer.address,
]);
const paymasterAddress = await paymaster.getAddress();
console.log(`Paymaster address: ${paymasterAddress}`);
console.log(`Signer of the contract: ${deployer.address}`);
Expand All @@ -35,20 +39,16 @@ async function main() {
);
console.log(`Paymaster ETH balance is now ${paymasterBalance.toString()}`);

// only verify on testnet and mainnet
if (hre.network.name.includes("ZKsyncEra")) {
// only verify on testnet and mainnet
// Verify contract programmatically
//
// Contract MUST be fully qualified name (e.g. path/sourceName:contractName)
const contractFullyQualifedName =
"contracts/paymasters/SignatureBasedPaymaster.sol:SignatureBasedPaymaster";
const verificationId = await hre.run("verify:verify", {
address: paymasterAddress,
contract: contractFullyQualifedName,
// Contract MUST be fully qualified name (e.g. path/sourceName:contractName)
contract: `${artifact.sourceName}:${artifact.contractName}`,
constructorArguments: [deployer.address],
});
console.log(
`${contractFullyQualifedName} verified! VerificationId: ${verificationId}`,
`${artifact.contractName} verified! VerificationId: ${verificationId}`,
);
}

Expand Down
Loading

0 comments on commit 6c2b4e1

Please sign in to comment.