diff --git a/contracts/package/attestation/EASverify.sol b/contracts/package/attestation/EASverify.sol index c8d818e..9e2d8fa 100644 --- a/contracts/package/attestation/EASverify.sol +++ b/contracts/package/attestation/EASverify.sol @@ -34,18 +34,17 @@ contract EASverify is AsnDecode, Pok, IdAttest { ); struct AttestationCoreData { + bytes32 schema; // The UID of the associated EAS schema address recipient; // The recipient of the attestation. - uint64 time; // The time when the attestation expires (Unix timestamp). + uint64 time; // The time when the attestation is valid from (Unix timestamp). uint64 expirationTime; // The time when the attestation expires (Unix timestamp). bool revocable; // Whether the attestation is revocable. bytes32 refUID; // The UID of the related attestation. - bytes data; // Custom attestation data. - uint256 value; // An explicit ETH amount to send to the resolver. This is important to prevent accidental user errors. - bytes32 schema; + bytes data; // The actual Schema data (eg eventId: 12345, ticketId: 6 etc) } struct EasTicketData { - string conferenceId; + string eventId; string ticketIdString; uint8 ticketClass; bytes commitment; @@ -129,6 +128,21 @@ contract EASverify is AsnDecode, Pok, IdAttest { } } + function decodeAttestationData( + AttestationCoreData memory easAttestation + ) public pure returns ( + string memory eventId, + string memory ticketId, + uint8 ticketClass, + bytes memory commitment + ) + { + (eventId, ticketId, ticketClass, commitment) = abi.decode( + easAttestation.data, + (string, string, uint8, bytes) + ); + } + function decodeEasTicketData( bytes memory attestation, uint256 hashIndex, @@ -184,7 +198,7 @@ contract EASverify is AsnDecode, Pok, IdAttest { activeByTimestamp = validateTicketTimestamps(payloadObjectData); - (ticket.conferenceId, ticket.ticketIdString, ticket.ticketClass, ticket.commitment) = abi.decode( + (ticket.eventId, ticket.ticketIdString, ticket.ticketClass, ticket.commitment) = abi.decode( payloadObjectData.data, (string, string, uint8, bytes) ); diff --git a/test/EAS.test.ts b/test/EAS.test.ts index 0a5cf34..38efc99 100644 --- a/test/EAS.test.ts +++ b/test/EAS.test.ts @@ -34,7 +34,7 @@ const EAS_CONFIG = { const EAS_TICKET_SCHEMA = { fields: [ - { name: "devconId", type: "string" }, + { name: "eventId", type: "string" }, { name: "ticketIdString", type: "string" }, { name: "ticketClass", type: "uint8" }, { name: "commitment", type: "bytes", isCommitment: true }, @@ -75,7 +75,7 @@ let attestationManager = new EasTicketAttestation( const pubKeyConfig = { "6": issuerPrivKey }; const ticketRequestData = { - devconId: "6", + eventId: "6", ticketIdString: "12345", ticketClass: 2, commitment: email, @@ -186,8 +186,8 @@ describe("EAS verify", function () { // default responce data expect(attestResponce.ticketIssuer).to.equal(issuerWalletTestnet.address); - expect(attestResponce.ticket.conferenceId).to.equal( - ticketRequestData.devconId + expect(attestResponce.ticket.eventId).to.equal( + ticketRequestData.eventId ); expect(attestResponce.ticket.ticketIdString).to.equal( ticketRequestData.ticketIdString