From d34a27970dd97303d579c05e04abb5f46e29d40c Mon Sep 17 00:00:00 2001 From: ctrlc03 <93448202+ctrlc03@users.noreply.github.com> Date: Tue, 2 Jul 2024 09:15:17 +0100 Subject: [PATCH] chore: remove unnecessary code --- package.json | 1 - pnpm-lock.yaml | 8 -------- src/lib/eas/createAttestation.ts | 7 +------ src/lib/eas/createEAS.ts | 2 -- src/lib/eas/registerSchemas.ts | 7 +------ src/utils/csv.ts | 8 -------- src/utils/formatCurrency.ts | 6 ------ src/utils/typedData.ts | 16 ---------------- src/utils/url.ts | 2 -- 9 files changed, 2 insertions(+), 55 deletions(-) delete mode 100644 src/utils/csv.ts delete mode 100644 src/utils/formatCurrency.ts delete mode 100644 src/utils/typedData.ts delete mode 100644 src/utils/url.ts diff --git a/package.json b/package.json index 9ab2ae31..de8b5d6c 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 76ee0c4e..d7fd1b0c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -110,9 +110,6 @@ dependencies: p-limit: specifier: ^5.0.0 version: 5.0.0 - papaparse: - specifier: ^5.4.1 - version: 5.4.1 react: specifier: 18.2.0 version: 18.2.0 @@ -11315,7 +11312,6 @@ packages: dependencies: is-hex-prefixed: 1.0.0 strip-hex-prefix: 1.0.0 - bundledDependencies: false /event-target-shim@5.0.1: resolution: {integrity: sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==} @@ -16422,10 +16418,6 @@ packages: resolution: {integrity: sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==} dev: false - /papaparse@5.4.1: - resolution: {integrity: sha512-HipMsgJkZu8br23pW15uvo6sib6wne/4woLZPlFf3rpDyMe9ywEXUsuD7+6K9PRkJlVT51j/sCOYDKGGS3ZJrw==} - dev: false - /param-case@3.0.4: resolution: {integrity: sha512-RXlj7zCYokReqWpOPH9oYivUzLYZ5vAPIfEmCTNViosC78F8F0H9y7T7gG2M39ymgutxF5gcFEsyZQSph9Bp3A==} dependencies: diff --git a/src/lib/eas/createAttestation.ts b/src/lib/eas/createAttestation.ts index a60a6925..9507cd23 100644 --- a/src/lib/eas/createAttestation.ts +++ b/src/lib/eas/createAttestation.ts @@ -18,10 +18,8 @@ interface Params { } export async function createAttestation(params: Params, signer: JsonRpcSigner): Promise { - console.log("Getting recipient address"); const recipient = params.recipient ?? (await signer.getAddress()); - console.log("Encoding attestation data"); const data = await encodeData(params, signer); return { @@ -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) { @@ -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); } diff --git a/src/lib/eas/createEAS.ts b/src/lib/eas/createEAS.ts index 047d3d97..b765814d 100644 --- a/src/lib/eas/createEAS.ts +++ b/src/lib/eas/createEAS.ts @@ -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); } diff --git a/src/lib/eas/registerSchemas.ts b/src/lib/eas/registerSchemas.ts index 52c757a6..e7237d07 100644 --- a/src/lib/eas/registerSchemas.ts +++ b/src/lib/eas/registerSchemas.ts @@ -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"; @@ -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 }; @@ -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}`); }); diff --git a/src/utils/csv.ts b/src/utils/csv.ts deleted file mode 100644 index cdf49fde..00000000 --- a/src/utils/csv.ts +++ /dev/null @@ -1,8 +0,0 @@ -import Papa, { type UnparseConfig } from "papaparse"; - -export function parse(file: string): Papa.ParseResult { - return Papa.parse(file, { header: true }); -} -export function format(data: unknown[], config: UnparseConfig): string { - return Papa.unparse(data, config); -} diff --git a/src/utils/formatCurrency.ts b/src/utils/formatCurrency.ts deleted file mode 100644 index 1afd9451..00000000 --- a/src/utils/formatCurrency.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { formatNumber } from "./formatNumber"; -import { suffixNumber } from "./suffixNumber"; - -export function formatCurrency(amount: number, currency: string, short = true): string { - return `${short ? suffixNumber(amount) : formatNumber(amount)} ${currency}`; -} diff --git a/src/utils/typedData.ts b/src/utils/typedData.ts deleted file mode 100644 index 74b0290c..00000000 --- a/src/utils/typedData.ts +++ /dev/null @@ -1,16 +0,0 @@ -export const ballotTypedData = (chainId?: number) => - ({ - primaryType: "Ballot", - domain: { - name: "Sign votes", - version: "1", - chainId, - }, - types: { - Ballot: [ - { name: "total_votes", type: "uint256" }, - { name: "project_count", type: "uint256" }, - { name: "hashed_votes", type: "string" }, - ], - }, - }) as const; diff --git a/src/utils/url.ts b/src/utils/url.ts deleted file mode 100644 index c6d4661d..00000000 --- a/src/utils/url.ts +++ /dev/null @@ -1,2 +0,0 @@ -export const mergeParams = (prev: object, next: object = {}): string => - new URLSearchParams({ ...prev, ...next }).toString();