Skip to content

Commit

Permalink
fix(sdk): AttestV2 doesn't support customABI
Browse files Browse the repository at this point in the history
  • Loading branch information
alainncls committed Dec 10, 2024
1 parent 6a6a9aa commit 802b438
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 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",
Expand Down
16 changes: 13 additions & 3 deletions sdk/src/dataMapper/PortalDataMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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) {
Expand All @@ -109,6 +109,7 @@ export default class PortalDataMapper extends BaseDataMapper<Portal, Portal_filt
validationPayloads,
],
value,
customAbi,
);
}

Expand All @@ -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);
}

Expand Down Expand Up @@ -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,
Expand All @@ -352,6 +361,7 @@ export default class PortalDataMapper extends BaseDataMapper<Portal, Portal_filt
handleError(ActionType.Simulation, err);
}
}

private async simulatePortalContract(
portalAddress: Address,
functionName: string,
Expand Down

0 comments on commit 802b438

Please sign in to comment.