Skip to content

Commit

Permalink
Merge 0d3c697 into 904c21a
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesSmartCell authored Jul 2, 2023
2 parents 904c21a + 0d3c697 commit 019ba85
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
26 changes: 20 additions & 6 deletions contracts/package/attestation/EASverify.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
);
Expand Down
8 changes: 4 additions & 4 deletions test/EAS.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -75,7 +75,7 @@ let attestationManager = new EasTicketAttestation(
const pubKeyConfig = { "6": issuerPrivKey };

const ticketRequestData = {
devconId: "6",
eventId: "6",
ticketIdString: "12345",
ticketClass: 2,
commitment: email,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 019ba85

Please sign in to comment.