Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update structure to match hash #8

Merged
merged 1 commit into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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