Feat/verifier update scripts (#157)

This commit is contained in:
nicoshark
2025-02-19 13:51:20 +09:00
committed by GitHub
parent e13c64ba10
commit 94de78d1d4
8 changed files with 144 additions and 225 deletions

Binary file not shown.

View File

@@ -0,0 +1,32 @@
import { getContractInstance } from "./getContracts";
import { waitForTransactionReceipt } from "viem/actions";
export class HubContract {
protected hub: any;
protected client: any;
constructor(
chain: any,
privateKey: `0x${string}`,
rpcUrl: string
) {
const { contract, publicClient } = getContractInstance("hub", chain, privateKey, rpcUrl);
this.hub = contract;
this.client = publicClient;
}
public async sigTypeToRegisterCircuitVerifiers(
id: number
) {
const address = await this.hub.read.sigTypeToRegisterCircuitVerifiers([id]);
return address;
}
public async sigTypeToDscCircuitVerifiers(
id: number
) {
const address = await this.hub.read.sigTypeToDscCircuitVerifiers([id]);
return address
}
}

View File

@@ -1,6 +1,7 @@
import Elysia, { t } from 'elysia';
import { ProofVerifier } from '../../contracts/application/proofVerifier';
import { RegistryContract } from '../../contracts/application/registryContract';
import { HubContract } from '../application/hubContract';
import { getChain } from '../../contracts/application/chains';
import { getDscCommitmentEvents } from '../application/getEvents';
import { MerkleTreeService } from '../application/tree-reader/leanImtService';
@@ -47,7 +48,8 @@ export const ContractsController = new Elysia()
description: 'Retrieve the identity commitment root in registry contract',
},
},
).post(
)
.post(
'update-csca-root',
async ({ body, set }) => {
try {
@@ -317,6 +319,68 @@ export const ContractsController = new Elysia()
},
},
)
.get(
'sig-to-register',
async ({ query }) => {
const id = Number(query.id);
const hubContract = new HubContract(
getChain(process.env.NETWORK as string),
process.env.PRIVATE_KEY as `0x${string}`,
process.env.RPC_URL as string
);
const address = await hubContract.sigTypeToRegisterCircuitVerifiers(id);
return { status: 'success', data: address };
},
{
query: t.Object({ id: t.String() }),
response: {
200: t.Object({
status: t.String(),
data: t.String(),
}),
500: t.Object({
status: t.String(),
message: t.String(),
}),
},
detail: {
tags: ['Hub'],
summary: 'Get Register Circuit Verifier Address via Query',
description: 'Retrieve the Register Circuit Verifier address by passing id as a query parameter.',
},
}
)
.get(
'sig-to-dsc',
async ({ query }) => {
const id = Number(query.id);
const hubContract = new HubContract(
getChain(process.env.NETWORK as string),
process.env.PRIVATE_KEY as `0x${string}`,
process.env.RPC_URL as string
);
const address = await hubContract.sigTypeToDscCircuitVerifiers(id);
return { status: 'success', data: address };
},
{
query: t.Object({ id: t.String() }),
response: {
200: t.Object({
status: t.String(),
data: t.String(),
}),
500: t.Object({
status: t.String(),
message: t.String(),
}),
},
detail: {
tags: ['Hub'],
summary: 'Get DSC Circuit Verifier Address via Query',
description: 'Retrieve the DSC Circuit Verifier address by passing id as a query parameter.',
},
}
)
.post(
'verify-vc-and-disclose-proof',
async (request) => {