Skip to content

Commit

Permalink
fixing cloneable contract
Browse files Browse the repository at this point in the history
Signed-off-by: Chengxuan Xing <[email protected]>
  • Loading branch information
Chengxuan committed Sep 26, 2024
1 parent 20d302d commit c629bd7
Show file tree
Hide file tree
Showing 12 changed files with 121 additions and 120 deletions.
1 change: 0 additions & 1 deletion solidity/contracts/factory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ contract ZetoTokenFactory is Ownable {
);
// the depositVerifier and withdrawVerifier are optional
// for the non-fungible token implementations
// TODO batchVerifier to be implemented for non-fungible token
implementations[name] = implementation;
}

Expand Down
6 changes: 3 additions & 3 deletions solidity/ignition/modules/zeto_anon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ const VerifierModule = buildModule('Groth16Verifier_Anon', (m) => {
});

const BatchVerifierModule = buildModule('Groth16Verifier_AnonBatch', (m) => {
const batchVerifier = m.contract('Groth16Verifier_AnonBatch', []);
return { batchVerifier };
const verifier = m.contract('Groth16Verifier_AnonBatch', []);
return { verifier };
});

export default buildModule('Zeto_Anon', (m) => {
const { verifier } = m.useModule(VerifierModule);
const { batchVerifier } = m.useModule(BatchVerifierModule);
const { verifier: batchVerifier } = m.useModule(BatchVerifierModule);
const { verifier: depositVerifier } = m.useModule(DepositVerifierModule);
const { verifier: withdrawVerifier } = m.useModule(WithdrawVerifierModule);

Expand Down
6 changes: 3 additions & 3 deletions solidity/ignition/modules/zeto_anon_enc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ const VerifierModule = buildModule('Groth16Verifier_AnonEnc', (m) => {
});

const BatchVerifierModule = buildModule('Groth16Verifier_AnonEncBatch', (m) => {
const batchVerifier = m.contract('Groth16Verifier_AnonEncBatch', []);
return { batchVerifier };
const verifier = m.contract('Groth16Verifier_AnonEncBatch', []);
return { verifier };
});

export default buildModule('Zeto_AnonEnc', (m) => {
const { verifier } = m.useModule(VerifierModule);
const { batchVerifier } = m.useModule(BatchVerifierModule);
const { verifier: batchVerifier } = m.useModule(BatchVerifierModule);
const { verifier: depositVerifier } = m.useModule(DepositVerifierModule);
const { verifier: withdrawVerifier } = m.useModule(WithdrawVerifierModule);
return { depositVerifier, withdrawVerifier, verifier, batchVerifier };
Expand Down
9 changes: 3 additions & 6 deletions solidity/ignition/modules/zeto_anon_enc_nullifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,15 @@ const VerifierModule = buildModule('Groth16Verifier_AnonEncNullifier', (m) => {
const BatchVerifierModule = buildModule(
'Groth16Verifier_AnonEncNullifierBatch',
(m) => {
const batchVerifier = m.contract(
'Groth16Verifier_AnonEncNullifierBatch',
[]
);
return { batchVerifier };
const verifier = m.contract('Groth16Verifier_AnonEncNullifierBatch', []);
return { verifier };
}
);

export default buildModule('Zeto_AnonEncNullifier', (m) => {
const { smtLib, poseidon3 } = m.useModule(SmtLibModule);
const { verifier } = m.useModule(VerifierModule);
const { batchVerifier } = m.useModule(BatchVerifierModule);
const { verifier: batchVerifier } = m.useModule(BatchVerifierModule);
const { verifier: depositVerifier } = m.useModule(DepositVerifierModule);
const { verifier: withdrawVerifier } = m.useModule(
WithdrawNullifierVerifierModule
Expand Down
9 changes: 3 additions & 6 deletions solidity/ignition/modules/zeto_anon_enc_nullifier_kyc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,15 @@ const VerifierModule = buildModule(
const BatchVerifierModule = buildModule(
'Groth16Verifier_AnonEncNullifierKycBatch',
(m) => {
const batchVerifier = m.contract(
'Groth16Verifier_AnonEncNullifierKycBatch',
[]
);
return { batchVerifier };
const verifier = m.contract('Groth16Verifier_AnonEncNullifierKycBatch', []);
return { verifier };
}
);

export default buildModule('Zeto_AnonEncNullifierKyc', (m) => {
const { smtLib, poseidon2, poseidon3 } = m.useModule(SmtLibModule);
const { verifier } = m.useModule(VerifierModule);
const { batchVerifier } = m.useModule(BatchVerifierModule);
const { verifier: batchVerifier } = m.useModule(BatchVerifierModule);
const { verifier: depositVerifier } = m.useModule(DepositVerifierModule);
const { verifier: withdrawVerifier } = m.useModule(
WithdrawNullifierVerifierModule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ const VerifierModule = buildModule(
const BatchVerifierModule = buildModule(
'Groth16Verifier_AnonEncNullifierNonRepudiationBatch',
(m) => {
const batchVerifier = m.contract(
const verifier = m.contract(
'Groth16Verifier_AnonEncNullifierNonRepudiationBatch',
[]
);
return { batchVerifier };
return { verifier };
}
);

export default buildModule('Zeto_AnonEncNullifierNonRepudiation', (m) => {
const { smtLib, poseidon3 } = m.useModule(SmtLibModule);
const { verifier } = m.useModule(VerifierModule);
const { batchVerifier } = m.useModule(BatchVerifierModule);
const { verifier: batchVerifier } = m.useModule(BatchVerifierModule);
const { verifier: depositVerifier } = m.useModule(DepositVerifierModule);
const { verifier: withdrawVerifier } = m.useModule(
WithdrawNullifierVerifierModule
Expand Down
6 changes: 3 additions & 3 deletions solidity/ignition/modules/zeto_anon_nullifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ const VerifierModule = buildModule('Groth16Verifier_AnonNullifier', (m) => {
const BatchVerifierModule = buildModule(
'Groth16Verifier_AnonNullifierBatch',
(m) => {
const batchVerifier = m.contract('Groth16Verifier_AnonNullifierBatch', []);
return { batchVerifier };
const verifier = m.contract('Groth16Verifier_AnonNullifierBatch', []);
return { verifier };
}
);

export default buildModule('Zeto_AnonNullifier', (m) => {
const { smtLib, poseidon3 } = m.useModule(SmtLibModule);
const { verifier } = m.useModule(VerifierModule);
const { batchVerifier } = m.useModule(BatchVerifierModule);
const { verifier: batchVerifier } = m.useModule(BatchVerifierModule);
const { verifier: depositVerifier } = m.useModule(DepositVerifierModule);
const { verifier: withdrawVerifier } = m.useModule(
WithdrawNullifierVerifierModule
Expand Down
9 changes: 3 additions & 6 deletions solidity/ignition/modules/zeto_anon_nullifier_kyc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,15 @@ const VerifierModule = buildModule('Groth16Verifier_AnonNullifierKyc', (m) => {
const BatchVerifierModule = buildModule(
'Groth16Verifier_AnonNullifierKycBatch',
(m) => {
const batchVerifier = m.contract(
'Groth16Verifier_AnonNullifierKycBatch',
[]
);
return { batchVerifier };
const verifier = m.contract('Groth16Verifier_AnonNullifierKycBatch', []);
return { verifier };
}
);

export default buildModule('Zeto_AnonNullifierKyc', (m) => {
const { smtLib, poseidon2, poseidon3 } = m.useModule(SmtLibModule);
const { verifier } = m.useModule(VerifierModule);
const { batchVerifier } = m.useModule(BatchVerifierModule);
const { verifier: batchVerifier } = m.useModule(BatchVerifierModule);
const { verifier: depositVerifier } = m.useModule(DepositVerifierModule);
const { verifier: withdrawVerifier } = m.useModule(
WithdrawNullifierVerifierModule
Expand Down
16 changes: 9 additions & 7 deletions solidity/scripts/deploy_cloneable.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import { ethers, ignition } from "hardhat";
import { ethers, ignition } from 'hardhat';
import erc20Module from '../ignition/modules/erc20';
import { getLinkedContractFactory, deploy } from "./lib/common";
import { getLinkedContractFactory, deploy } from './lib/common';

export async function deployFungible(tokenName: string) {
const { erc20 } = await ignition.deploy(erc20Module);
const verifiersDeployer = require(`./tokens/${tokenName}`);
const { deployer, args, libraries } = await verifiersDeployer.deployDependencies();
const { deployer, args, libraries } =
await verifiersDeployer.deployDependencies();

let zetoFactory;
if (libraries) {
zetoFactory = await getLinkedContractFactory(tokenName, libraries);
} else {
zetoFactory = await ethers.getContractFactory(tokenName)
zetoFactory = await ethers.getContractFactory(tokenName);
}

const zetoImpl: any = await zetoFactory.deploy();
await zetoImpl.waitForDeployment();
// console.log(args);
await zetoImpl.connect(deployer).initialize(...args);

const tx3 = await zetoImpl.connect(deployer).setERC20(erc20.target);
Expand All @@ -36,7 +38,7 @@ export async function deployNonFungible(tokenName: string) {
if (libraries) {
zetoFactory = await getLinkedContractFactory(tokenName, libraries);
} else {
zetoFactory = await ethers.getContractFactory(tokenName)
zetoFactory = await ethers.getContractFactory(tokenName);
}
const zetoImpl: any = await zetoFactory.deploy();
await zetoImpl.waitForDeployment();
Expand All @@ -54,7 +56,7 @@ deploy(deployFungible, deployNonFungible)
}
process.exit(0);
})
.catch(error => {
.catch((error) => {
console.error(error);
process.exit(1);
});
});
Loading

0 comments on commit c629bd7

Please sign in to comment.