Skip to content

Commit

Permalink
fix(sdk): AttestV2 doesn't support customABI
Browse files Browse the repository at this point in the history
alainncls committed Dec 11, 2024
1 parent 6a6a9aa commit 0b83207
Showing 3 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@verax-attestation-registry/verax-sdk",
"version": "2.2.1",
"version": "2.2.2",
"description": "Verax Attestation Registry SDK to interact with the subgraph and the contracts",
"keywords": [
"linea-attestation-registry",
16 changes: 13 additions & 3 deletions sdk/src/dataMapper/PortalDataMapper.ts
Original file line number Diff line number Diff line change
@@ -2,13 +2,12 @@ import { AttestationPayload, Portal } from "../types";
import { ActionType } from "../utils/constants";
import BaseDataMapper from "./BaseDataMapper";
import { abiDefaultPortal } from "../abi/DefaultPortal";
import { Address } from "viem";
import { Abi, Address } from "viem";
import { encode } from "../utils/abiCoder";
import { Portal_filter, Portal_orderBy } from "../../.graphclient";
import { abiPortalRegistry } from "../abi/PortalRegistry";
import { handleError } from "../utils/errorHandler";
import { executeTransaction } from "../utils/transactionSender";
import { Abi } from "viem";

export default class PortalDataMapper extends BaseDataMapper<Portal, Portal_filter, Portal_orderBy> {
typeName = "portal";
@@ -95,6 +94,7 @@ export default class PortalDataMapper extends BaseDataMapper<Portal, Portal_filt
attestationPayload: AttestationPayload,
validationPayloads: string[],
value: bigint = 0n,
customAbi?: Abi,
) {
const matchingSchema = await this.veraxSdk.schema.findOneById(attestationPayload.schemaId);
if (!matchingSchema) {
@@ -109,6 +109,7 @@ export default class PortalDataMapper extends BaseDataMapper<Portal, Portal_filt
validationPayloads,
],
value,
customAbi,
);
}

@@ -118,8 +119,15 @@ export default class PortalDataMapper extends BaseDataMapper<Portal, Portal_filt
validationPayloads: string[],
waitForConfirmation: boolean = false,
value: bigint = 0n,
customAbi?: Abi,
) {
const request = await this.simulateAttestV2(portalAddress, attestationPayload, validationPayloads, value);
const request = await this.simulateAttestV2(
portalAddress,
attestationPayload,
validationPayloads,
value,
customAbi,
);
return executeTransaction(request, this.web3Client, this.walletClient, waitForConfirmation);
}

@@ -327,6 +335,7 @@ export default class PortalDataMapper extends BaseDataMapper<Portal, Portal_filt
async isPortalRegistered(id: Address) {
return this.executePortalRegistryReadMethod("isRegistered", [id]);
}

private async executePortalRegistryReadMethod(functionName: string, args: unknown[]) {
return this.web3Client.readContract({
abi: abiPortalRegistry,
@@ -352,6 +361,7 @@ export default class PortalDataMapper extends BaseDataMapper<Portal, Portal_filt
handleError(ActionType.Simulation, err);
}
}

private async simulatePortalContract(
portalAddress: Address,
functionName: string,
4 changes: 2 additions & 2 deletions sdk/test/integration/Portal.integration.test.ts
Original file line number Diff line number Diff line change
@@ -52,9 +52,9 @@ describe("PortalDataMapper", () => {
expect(result[0].name).toContain(partialName);
expect(result[0].id).toEqual("0x0cb56f201e7afe02e542e2d2d42c34d4ce7203f7");
expect(result[1].name).toContain(partialName);
expect(result[1].id).toEqual("0x2b4af326976c29adb9846209b5f0eab09e1facc2");
expect(result[1].id).toEqual("0x19cd034885c9ab5ed9964f95c0dd690dc2ca6d19");
expect(result[2].name).toContain(partialName);
expect(result[2].id).toEqual("0x79c06b913c42fd960b6917798c39edff292835f1");
expect(result[2].id).toEqual("0x2b4af326976c29adb9846209b5f0eab09e1facc2");
});
});
});

0 comments on commit 0b83207

Please sign in to comment.