Skip to content

Commit

Permalink
Merge pull request #195 from privacy-scaling-explorations/chore/cleanup
Browse files Browse the repository at this point in the history
chore: remove unnecessary code
  • Loading branch information
ctrlc03 authored Jul 5, 2024
2 parents 3b9cf8c + d34a279 commit b747b50
Show file tree
Hide file tree
Showing 9 changed files with 2 additions and 55 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"node-fetch-cache": "^4.1.0",
"nuqs": "^1.17.1",
"p-limit": "^5.0.0",
"papaparse": "^5.4.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-hook-form": "^7.49.3",
Expand Down
8 changes: 0 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions src/lib/eas/createAttestation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ interface Params {
}

export async function createAttestation(params: Params, signer: JsonRpcSigner): Promise<AttestationRequest> {
console.log("Getting recipient address");
const recipient = params.recipient ?? (await signer.getAddress());

console.log("Encoding attestation data");
const data = await encodeData(params, signer);

return {
Expand All @@ -38,15 +36,13 @@ export async function createAttestation(params: Params, signer: JsonRpcSigner):

async function encodeData({ values, schemaUID }: Params, signer: JsonRpcSigner) {
const schemaRegistry = new SchemaRegistry(config.eas.contracts.schemaRegistry);
console.log("Connecting signer to SchemaRegistry...");

schemaRegistry.connect(signer as unknown as TransactionSigner);

console.log("Getting schema record...");
const schemaRecord = await schemaRegistry.getSchema({ uid: schemaUID });

const schemaEncoder = new SchemaEncoder(schemaRecord.schema);

console.log("Creating data to encode from schema record...");
const dataToEncode = schemaRecord.schema.split(",").map((param) => {
const [type, name] = param.trim().split(" ");
if (name && type) {
Expand All @@ -56,6 +52,5 @@ async function encodeData({ values, schemaUID }: Params, signer: JsonRpcSigner)
throw new Error(`Attestation data: ${name} not found in ${JSON.stringify(values)}`);
});

console.log("Encoding data with schema...");
return schemaEncoder.encodeData(dataToEncode);
}
2 changes: 0 additions & 2 deletions src/lib/eas/createEAS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { type JsonRpcSigner } from "ethers";
import * as config from "~/config";

export function createEAS(signer: JsonRpcSigner): EAS {
console.log("Creating EAS instance");
const eas = new EAS(config.eas.contracts.eas);
console.log("Connecting signer to EAS");
return eas.connect(signer as unknown as TransactionSigner);
}
7 changes: 1 addition & 6 deletions src/lib/eas/registerSchemas.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-console */
import { SchemaRegistry, ZERO_ADDRESS, getSchemaUID } from "@ethereum-attestation-service/eas-sdk";
import "dotenv/config";
import { ethers, formatEther } from "ethers";
import { ethers } from "ethers";

import { eas, config } from "~/config";

Expand Down Expand Up @@ -35,17 +35,13 @@ const schemaRegistry = new SchemaRegistry(eas.contracts.schemaRegistry);
schemaRegistry.connect(wallet as unknown as TransactionSigner);

export async function registerSchemas(): Promise<{ name: string; uid: string }[]> {
console.log("Balance: ", await provider.getBalance(wallet).then(formatEther));
return Promise.all(
schemas.map(async ({ name, schema }) => {
console.log(`Registering schema: ${name}`);

const exists = await schemaRegistry
.getSchema({
uid: getSchemaUID(schema, ZERO_ADDRESS, true),
})
.catch(console.error);
console.log("exists", exists);

if (exists) {
return { name, ...exists };
Expand All @@ -54,7 +50,6 @@ export async function registerSchemas(): Promise<{ name: string; uid: string }[]
return schemaRegistry.register({ schema, revocable: true }).then(async (tx) => ({ name, uid: await tx.wait() }));
}),
).then((registered) => {
console.log(`Schemas registered!`);
registered.forEach((schema) => {
console.log(` ${schema.name}: ${schema.uid}`);
});
Expand Down
8 changes: 0 additions & 8 deletions src/utils/csv.ts

This file was deleted.

6 changes: 0 additions & 6 deletions src/utils/formatCurrency.ts

This file was deleted.

16 changes: 0 additions & 16 deletions src/utils/typedData.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/utils/url.ts

This file was deleted.

0 comments on commit b747b50

Please sign in to comment.