From df622d89ec661c53fa46811be2d96fed2ad083d2 Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 28 Aug 2024 18:11:48 +0330 Subject: [PATCH 01/12] remove unused import --- src/constants.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/constants.ts b/src/constants.ts index 664cf61..e72a342 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,5 +1,4 @@ import { assertNotNull } from "@subsquid/evm-processor"; -import { map } from "zod"; const SQUID_NETWORK = process.env.SQUID_NETWORK || "eth-sepolia"; From 4babaa5ffee6b59039c3f2fd6228a781a2023360 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 2 Sep 2024 10:42:14 +0330 Subject: [PATCH 02/12] add NO_AFFILIATION_SCHEMA constant --- src/constants.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/constants.ts b/src/constants.ts index e72a342..a5c8071 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -38,3 +38,5 @@ export const DESCRIPTION_SUMMARY_LENGTH = Number( ); export const AGORA_API_KEY = process.env.AGORA_API_KEY; + +export const NO_AFFILIATION_SCHEMA = process.env.NO_AFFILIATION_SCHEMA; From c6c936402ecb1030a9b4815f3f7fa291690e01bf Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 2 Sep 2024 10:42:27 +0330 Subject: [PATCH 03/12] add ZERO_UID --- src/constants.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/constants.ts b/src/constants.ts index a5c8071..1e21d17 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -40,3 +40,6 @@ export const DESCRIPTION_SUMMARY_LENGTH = Number( export const AGORA_API_KEY = process.env.AGORA_API_KEY; export const NO_AFFILIATION_SCHEMA = process.env.NO_AFFILIATION_SCHEMA; + +export const ZERO_UID = + "0x0000000000000000000000000000000000000000000000000000000000000000"; From c9a6002862421c62d4dad552528f5a600948100d Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 2 Sep 2024 10:50:55 +0330 Subject: [PATCH 04/12] add No Affiliation org migration --- .../1735226891776-AddNo Affiliation.js | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 db/migrations/1735226891776-AddNo Affiliation.js diff --git a/db/migrations/1735226891776-AddNo Affiliation.js b/db/migrations/1735226891776-AddNo Affiliation.js new file mode 100644 index 0000000..5f60c97 --- /dev/null +++ b/db/migrations/1735226891776-AddNo Affiliation.js @@ -0,0 +1,28 @@ +module.exports = class AddNoAffiliation1735226891776 { + name = "AddNoAffiliation1735226891776"; + + async up(db) { + const SQUID_NETWORK = process.env.SQUID_NETWORK || "eth-sepolia"; + if (SQUID_NETWORK !== "eth-sepolia") return; + // add organisation with name "No Affiliation" and schema id "0xb5b2e19821d6124101d31c7d5422a79402a0923a1ffaacbe3d8380688a18b7d1" + await db.query( + `INSERT INTO "organisation" ("id", "name", "issuer", "color", "start_block") + VALUES ( + '0xb5b2e19821d6124101d31c7d5422a79402a0923a1ffaacbe3d8380688a18b7d1', + 'No Affiliation', + '0x8f48094a12c8f99d616ae8f3305d5ec73cbaa6b6', + '#0049b7', + 6614922 + )` + ); + } + + async down(db) { + const SQUID_NETWORK = process.env.SQUID_NETWORK || "eth-sepolia"; + if (SQUID_NETWORK !== "eth-sepolia") return; + // remove organisation with name "No Affiliation" and schema id "0xb5b2e19821d6124101d31c7d5422a79402a0923a1ffaacbe3d8380688a18b7d1" + await db.query( + `DELETE FROM "organisation" WHERE "id" = '0xb5b2e19821d6124101d31c7d5422a79402a0923a1ffaacbe3d8380688a18b7d1'` + ); + } +}; From 7cb71e5b0fffd3d1a38952ab3ff382bd2ccb2451 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 2 Sep 2024 10:51:45 +0330 Subject: [PATCH 05/12] add getOrCreateAttestorOrganisation --- .../projectVerificationAttestation.ts | 19 ++--- src/controllers/utils/modelHelper.ts | 73 +++++++++++++++++++ 2 files changed, 83 insertions(+), 9 deletions(-) diff --git a/src/controllers/projectVerificationAttestation.ts b/src/controllers/projectVerificationAttestation.ts index 631a56a..29f44c0 100644 --- a/src/controllers/projectVerificationAttestation.ts +++ b/src/controllers/projectVerificationAttestation.ts @@ -7,6 +7,8 @@ import { } from "./utils/easHelper"; import { AttestorOrganisation, ProjectAttestation } from "../model"; import { + getAttestor, + getOrCreateAttestorOrganisation, getProject, updateProjectAttestationCounts, } from "./utils/modelHelper"; @@ -30,15 +32,14 @@ export const handleProjectAttestation = async ( schemaUid ); - const attestorOrganisation = await ctx.store.get(AttestorOrganisation, { - where: { - id: refUID.toLowerCase(), - }, - relations: { - organisation: true, - attestor: true, - }, - }); + const attestor = await getAttestor(ctx, issuer); + + const attestorOrganisation = await getOrCreateAttestorOrganisation( + ctx, + attestor, + refUID, + new Date(log.block.timestamp) + ); if (!attestorOrganisation) { ctx.log.debug( diff --git a/src/controllers/utils/modelHelper.ts b/src/controllers/utils/modelHelper.ts index ce26bd0..8bd19ee 100644 --- a/src/controllers/utils/modelHelper.ts +++ b/src/controllers/utils/modelHelper.ts @@ -2,12 +2,14 @@ import { DataHandlerContext } from "@subsquid/evm-processor"; import { Store } from "@subsquid/typeorm-store"; import { Attestor, + AttestorOrganisation, Organisation, OrganisationProject, Project, } from "../../model"; import { getEntityMangerByContext } from "./databaseHelper"; import { ProjectStats } from "./types"; +import { NO_AFFILIATION_SCHEMA, ZERO_UID } from "../../constants"; export const upsertOrganisatoinProject = async ( ctx: DataHandlerContext, @@ -182,3 +184,74 @@ export const getProjectStats = async ( return ProjectStats.parse(result[0]); }; + +export const getOrCreateAttestorOrganisation = async ( + ctx: DataHandlerContext, + attestor: Attestor, + refUID?: string, + attestTimestamp?: Date +): Promise => { + // Check if refUID is valid and not a placeholder for an empty reference + if (refUID && refUID !== ZERO_UID) { + try { + // Attempt to find existing AttestorOrganisation + const attestorOrganisation = await ctx.store.get(AttestorOrganisation, { + where: { id: refUID.toLowerCase() }, + relations: { organisation: true, attestor: true }, + }); + + if (attestorOrganisation) { + ctx.log.debug( + `Found existing attestorOrganisation: ${attestorOrganisation}` + ); + return attestorOrganisation; + } + } catch (error) { + ctx.log.error(`Error retrieving attestorOrganisation: ${error}`); + return undefined; + } + } + + // Attempt to retrieve default organisation + let organisation; + try { + if (!NO_AFFILIATION_SCHEMA) { + ctx.log.error("NO_AFFILIATION_SCHEMA not set"); + return undefined; + } + organisation = await ctx.store.get(Organisation, NO_AFFILIATION_SCHEMA); + } catch (error) { + ctx.log.error(`Error retrieving No Affiliation organisation: ${error}`); + return undefined; + } + + if (!organisation) { + ctx.log.error("No Affiliation organisation not found"); + return undefined; + } + + // Ensure timestamp is set + const timestamp = attestTimestamp || new Date(); + + // Generate unique key + const key = `NO_AFFILIATION${attestor.id}`; + + const newAttestorOrganisation = new AttestorOrganisation({ + id: key, + attestor, + organisation, + attestTimestamp: timestamp, + }); + + try { + await ctx.store.upsert(newAttestorOrganisation); + ctx.log.debug( + `Created new attestorOrganisation: ${newAttestorOrganisation}` + ); + } catch (error) { + ctx.log.error(`Error upserting attestorOrganisation: ${error}`); + return undefined; + } + + return newAttestorOrganisation; +}; From 6d6f53bb7e344fc419546366ef0cfff2c3444a98 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 2 Sep 2024 11:44:00 +0330 Subject: [PATCH 06/12] use zero address for No Affiliation org --- db/migrations/1735226891776-AddNo Affiliation.js | 13 ++++--------- src/constants.ts | 2 -- src/controllers/utils/modelHelper.ts | 8 ++------ 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/db/migrations/1735226891776-AddNo Affiliation.js b/db/migrations/1735226891776-AddNo Affiliation.js index 5f60c97..dfe9217 100644 --- a/db/migrations/1735226891776-AddNo Affiliation.js +++ b/db/migrations/1735226891776-AddNo Affiliation.js @@ -2,27 +2,22 @@ module.exports = class AddNoAffiliation1735226891776 { name = "AddNoAffiliation1735226891776"; async up(db) { - const SQUID_NETWORK = process.env.SQUID_NETWORK || "eth-sepolia"; - if (SQUID_NETWORK !== "eth-sepolia") return; - // add organisation with name "No Affiliation" and schema id "0xb5b2e19821d6124101d31c7d5422a79402a0923a1ffaacbe3d8380688a18b7d1" + // add organisation with name "No Affiliation" await db.query( `INSERT INTO "organisation" ("id", "name", "issuer", "color", "start_block") VALUES ( - '0xb5b2e19821d6124101d31c7d5422a79402a0923a1ffaacbe3d8380688a18b7d1', + '0x0000000000000000000000000000000000000000000000000000000000000000', 'No Affiliation', '0x8f48094a12c8f99d616ae8f3305d5ec73cbaa6b6', '#0049b7', - 6614922 )` ); } async down(db) { - const SQUID_NETWORK = process.env.SQUID_NETWORK || "eth-sepolia"; - if (SQUID_NETWORK !== "eth-sepolia") return; - // remove organisation with name "No Affiliation" and schema id "0xb5b2e19821d6124101d31c7d5422a79402a0923a1ffaacbe3d8380688a18b7d1" + // remove organisation with name "No Affiliation" await db.query( - `DELETE FROM "organisation" WHERE "id" = '0xb5b2e19821d6124101d31c7d5422a79402a0923a1ffaacbe3d8380688a18b7d1'` + `DELETE FROM "organisation" WHERE "id" = '0x0000000000000000000000000000000000000000000000000000000000000000'` ); } }; diff --git a/src/constants.ts b/src/constants.ts index 1e21d17..f5c2420 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -39,7 +39,5 @@ export const DESCRIPTION_SUMMARY_LENGTH = Number( export const AGORA_API_KEY = process.env.AGORA_API_KEY; -export const NO_AFFILIATION_SCHEMA = process.env.NO_AFFILIATION_SCHEMA; - export const ZERO_UID = "0x0000000000000000000000000000000000000000000000000000000000000000"; diff --git a/src/controllers/utils/modelHelper.ts b/src/controllers/utils/modelHelper.ts index 8bd19ee..715d243 100644 --- a/src/controllers/utils/modelHelper.ts +++ b/src/controllers/utils/modelHelper.ts @@ -9,7 +9,7 @@ import { } from "../../model"; import { getEntityMangerByContext } from "./databaseHelper"; import { ProjectStats } from "./types"; -import { NO_AFFILIATION_SCHEMA, ZERO_UID } from "../../constants"; +import { ZERO_UID } from "../../constants"; export const upsertOrganisatoinProject = async ( ctx: DataHandlerContext, @@ -215,11 +215,7 @@ export const getOrCreateAttestorOrganisation = async ( // Attempt to retrieve default organisation let organisation; try { - if (!NO_AFFILIATION_SCHEMA) { - ctx.log.error("NO_AFFILIATION_SCHEMA not set"); - return undefined; - } - organisation = await ctx.store.get(Organisation, NO_AFFILIATION_SCHEMA); + organisation = await ctx.store.get(Organisation, ZERO_UID); } catch (error) { ctx.log.error(`Error retrieving No Affiliation organisation: ${error}`); return undefined; From 28f678bebc6466029820d0e5168153affd89b812 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 2 Sep 2024 12:19:33 +0330 Subject: [PATCH 07/12] change issuer address to zero --- .../1735226891776-AddNo Affiliation.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/db/migrations/1735226891776-AddNo Affiliation.js b/db/migrations/1735226891776-AddNo Affiliation.js index dfe9217..e281558 100644 --- a/db/migrations/1735226891776-AddNo Affiliation.js +++ b/db/migrations/1735226891776-AddNo Affiliation.js @@ -2,20 +2,21 @@ module.exports = class AddNoAffiliation1735226891776 { name = "AddNoAffiliation1735226891776"; async up(db) { - // add organisation with name "No Affiliation" + // Add organisation with name "No Affiliation" await db.query( `INSERT INTO "organisation" ("id", "name", "issuer", "color", "start_block") - VALUES ( - '0x0000000000000000000000000000000000000000000000000000000000000000', - 'No Affiliation', - '0x8f48094a12c8f99d616ae8f3305d5ec73cbaa6b6', - '#0049b7', - )` + VALUES ( + '0x0000000000000000000000000000000000000000000000000000000000000000', + 'No Affiliation', + '0x0000000000000000000000000000000000000000', + '#0049b7', + null + )` ); } async down(db) { - // remove organisation with name "No Affiliation" + // Remove organisation with name "No Affiliation" await db.query( `DELETE FROM "organisation" WHERE "id" = '0x0000000000000000000000000000000000000000000000000000000000000000'` ); From cb5de6ceed6093f8a9dc83ba5da248adf50edfe9 Mon Sep 17 00:00:00 2001 From: Amin Latifi Date: Mon, 2 Sep 2024 12:30:37 +0330 Subject: [PATCH 08/12] Used predefined constants --- db/migrations/1735226891776-AddNo Affiliation.js | 10 +++++++--- src/constants.ts | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/db/migrations/1735226891776-AddNo Affiliation.js b/db/migrations/1735226891776-AddNo Affiliation.js index e281558..6fba130 100644 --- a/db/migrations/1735226891776-AddNo Affiliation.js +++ b/db/migrations/1735226891776-AddNo Affiliation.js @@ -1,3 +1,7 @@ +import { ZeroAddress } from "ethers"; +import {ZERO_BYTES32} from '@ethereum-attestation-service/eas-sdk' + +const ZERO_UID = ZERO_BYTES32; module.exports = class AddNoAffiliation1735226891776 { name = "AddNoAffiliation1735226891776"; @@ -6,9 +10,9 @@ module.exports = class AddNoAffiliation1735226891776 { await db.query( `INSERT INTO "organisation" ("id", "name", "issuer", "color", "start_block") VALUES ( - '0x0000000000000000000000000000000000000000000000000000000000000000', + '${ZERO_UID}', 'No Affiliation', - '0x0000000000000000000000000000000000000000', + '${ZeroAddress}', '#0049b7', null )` @@ -18,7 +22,7 @@ module.exports = class AddNoAffiliation1735226891776 { async down(db) { // Remove organisation with name "No Affiliation" await db.query( - `DELETE FROM "organisation" WHERE "id" = '0x0000000000000000000000000000000000000000000000000000000000000000'` + `DELETE FROM "organisation" WHERE "id" = '${ZERO_UID}'` ); } }; diff --git a/src/constants.ts b/src/constants.ts index f5c2420..b01a53c 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,3 +1,4 @@ +import { ZERO_BYTES32 } from "@ethereum-attestation-service/eas-sdk"; import { assertNotNull } from "@subsquid/evm-processor"; const SQUID_NETWORK = process.env.SQUID_NETWORK || "eth-sepolia"; @@ -39,5 +40,4 @@ export const DESCRIPTION_SUMMARY_LENGTH = Number( export const AGORA_API_KEY = process.env.AGORA_API_KEY; -export const ZERO_UID = - "0x0000000000000000000000000000000000000000000000000000000000000000"; +export const ZERO_UID = ZERO_BYTES32; From 0f2e37125419427e262da42875183387fb498e8c Mon Sep 17 00:00:00 2001 From: Amin Latifi Date: Mon, 2 Sep 2024 12:36:29 +0330 Subject: [PATCH 09/12] Fixed the import, --- db/migrations/1735226891776-AddNo Affiliation.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/db/migrations/1735226891776-AddNo Affiliation.js b/db/migrations/1735226891776-AddNo Affiliation.js index 6fba130..2df9803 100644 --- a/db/migrations/1735226891776-AddNo Affiliation.js +++ b/db/migrations/1735226891776-AddNo Affiliation.js @@ -1,7 +1,7 @@ -import { ZeroAddress } from "ethers"; -import {ZERO_BYTES32} from '@ethereum-attestation-service/eas-sdk' +const ethers = require("ethers"); +const easSdk = require("@ethereum-attestation-service/eas-sdk"); -const ZERO_UID = ZERO_BYTES32; +const ZERO_UID = easSdk.ZERO_BYTES32; module.exports = class AddNoAffiliation1735226891776 { name = "AddNoAffiliation1735226891776"; @@ -12,7 +12,7 @@ module.exports = class AddNoAffiliation1735226891776 { VALUES ( '${ZERO_UID}', 'No Affiliation', - '${ZeroAddress}', + '${ethers.ZeroAddress}', '#0049b7', null )` From a6838950ad10ddc99b9231b22b41eff3618d745a Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 2 Sep 2024 13:05:57 +0330 Subject: [PATCH 10/12] remove try catch --- src/controllers/utils/modelHelper.ts | 46 +++++++++------------------- 1 file changed, 14 insertions(+), 32 deletions(-) diff --git a/src/controllers/utils/modelHelper.ts b/src/controllers/utils/modelHelper.ts index 715d243..768b33d 100644 --- a/src/controllers/utils/modelHelper.ts +++ b/src/controllers/utils/modelHelper.ts @@ -193,33 +193,22 @@ export const getOrCreateAttestorOrganisation = async ( ): Promise => { // Check if refUID is valid and not a placeholder for an empty reference if (refUID && refUID !== ZERO_UID) { - try { - // Attempt to find existing AttestorOrganisation - const attestorOrganisation = await ctx.store.get(AttestorOrganisation, { - where: { id: refUID.toLowerCase() }, - relations: { organisation: true, attestor: true }, - }); - - if (attestorOrganisation) { - ctx.log.debug( - `Found existing attestorOrganisation: ${attestorOrganisation}` - ); - return attestorOrganisation; - } - } catch (error) { - ctx.log.error(`Error retrieving attestorOrganisation: ${error}`); - return undefined; + // Attempt to find existing AttestorOrganisation + const attestorOrganisation = await ctx.store.get(AttestorOrganisation, { + where: { id: refUID.toLowerCase() }, + relations: { organisation: true, attestor: true }, + }); + + if (attestorOrganisation) { + ctx.log.debug( + `Found existing attestorOrganisation: ${attestorOrganisation}` + ); + return attestorOrganisation; } } // Attempt to retrieve default organisation - let organisation; - try { - organisation = await ctx.store.get(Organisation, ZERO_UID); - } catch (error) { - ctx.log.error(`Error retrieving No Affiliation organisation: ${error}`); - return undefined; - } + let organisation = await ctx.store.get(Organisation, ZERO_UID); if (!organisation) { ctx.log.error("No Affiliation organisation not found"); @@ -239,15 +228,8 @@ export const getOrCreateAttestorOrganisation = async ( attestTimestamp: timestamp, }); - try { - await ctx.store.upsert(newAttestorOrganisation); - ctx.log.debug( - `Created new attestorOrganisation: ${newAttestorOrganisation}` - ); - } catch (error) { - ctx.log.error(`Error upserting attestorOrganisation: ${error}`); - return undefined; - } + await ctx.store.upsert(newAttestorOrganisation); + ctx.log.debug(`Created new attestorOrganisation: ${newAttestorOrganisation}`); return newAttestorOrganisation; }; From a64d441662550605a64e08f463b985a4e3b96fc3 Mon Sep 17 00:00:00 2001 From: Amin Latifi Date: Mon, 2 Sep 2024 13:28:55 +0330 Subject: [PATCH 11/12] Updated tests --- src/controllers/utils/types.test.ts | 2 +- src/test/store.test.ts | 27 +++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/controllers/utils/types.test.ts b/src/controllers/utils/types.test.ts index 24b8c28..f54a267 100644 --- a/src/controllers/utils/types.test.ts +++ b/src/controllers/utils/types.test.ts @@ -1,6 +1,6 @@ import { orgCountTuplesTypes } from "./types"; -describe.only("parse database query", () => { +describe("parse database query", () => { it("should parse project stats query", () => { const raw = `{"(0x2e22df9a11e06c306ed8f64ca45ceae02efcf8a443371395a78371bc4fb6f722,1)","(0xf63f2a7159ee674aa6fce42196a8bb0605eafcf20c19e91a7eafba8d39fa0404,1)"}`; diff --git a/src/test/store.test.ts b/src/test/store.test.ts index 4d4ac09..194363f 100644 --- a/src/test/store.test.ts +++ b/src/test/store.test.ts @@ -1,13 +1,17 @@ import { describe, expect, test, afterAll } from "@jest/globals"; -import { closeConnection, getTestCtx } from "./utils"; +import { closeConnection, getTestCtx, getTestEntityManager } from "./utils"; import { Organisation } from "../model"; describe("simple storage", () => { + beforeAll(async () => { + const em = await getTestEntityManager(); + await em.getRepository(Organisation).delete({}); + }); afterAll(async () => { await closeConnection(); }); - test("sample authorized attest", async () => { + test("should save sample authorized attest", async () => { const ctx = await getTestCtx(); const organization = new Organisation({ id: "schemaUid", @@ -24,4 +28,23 @@ describe("simple storage", () => { expect(fetchOrganization).toBeDefined(); expect(fetchOrganization?.name).toBe("name"); }); + + test("should not fail on upserting the same entity", async () => { + const ctx = await getTestCtx(); + const organization = new Organisation({ + id: "schemaUid", + name: "name", + issuer: "issuer", + }); + + await ctx.store.upsert(organization); + await ctx.store.upsert(organization); + + const fetchOrganization = await ctx.store.findOneBy(Organisation, { + name: "name", + }); + + expect(fetchOrganization).toBeDefined(); + expect(fetchOrganization?.name).toBe("name"); + }); }); From 34db5ba2017f1bddf44f124c334f799cb684daac Mon Sep 17 00:00:00 2001 From: Amin Latifi Date: Tue, 3 Sep 2024 19:21:41 +0330 Subject: [PATCH 12/12] Fixed saved user id capitalization --- src/controllers/projectVerificationAttestation.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/controllers/projectVerificationAttestation.ts b/src/controllers/projectVerificationAttestation.ts index 29f44c0..dfe5c9f 100644 --- a/src/controllers/projectVerificationAttestation.ts +++ b/src/controllers/projectVerificationAttestation.ts @@ -5,7 +5,7 @@ import { getAttestationData, removeDuplicateProjectAttestations, } from "./utils/easHelper"; -import { AttestorOrganisation, ProjectAttestation } from "../model"; +import { ProjectAttestation } from "../model"; import { getAttestor, getOrCreateAttestorOrganisation, @@ -18,12 +18,10 @@ export const handleProjectAttestation = async ( ctx: DataHandlerContext, log: Log ): Promise => { - const { - uid, - schema: schemaUid, - attestor: issuer, - recipient, - } = EASContract.events.Attested.decode(log); + const attestedEvent = EASContract.events.Attested.decode(log); + + const { uid, schema: schemaUid, recipient } = attestedEvent; + const issuer = attestedEvent.attestor.toLowerCase(); const { decodedData, refUID } = await getAttestationData( ctx,