From 4172dd0299c82ebdc76cf9a830f37b2db0e6cc3b Mon Sep 17 00:00:00 2001 From: lbeder Date: Sat, 12 Aug 2023 23:26:15 +0300 Subject: [PATCH] Patch and parse all events in a unified way --- dist/eas.d.ts | 4 +- dist/eas.js | 25 ++++++---- dist/eas.js.map | 2 +- dist/utils.d.ts | 6 +-- dist/utils.js | 96 +++++++++++++++--------------------- dist/utils.js.map | 2 +- package.json | 2 +- src/eas.ts | 35 +++++++------- src/utils.ts | 121 +++++++++++++++++++--------------------------- test/test/eas.ts | 14 +++--- 10 files changed, 137 insertions(+), 170 deletions(-) diff --git a/dist/eas.d.ts b/dist/eas.d.ts index eef4722..8064f7f 100644 --- a/dist/eas.d.ts +++ b/dist/eas.d.ts @@ -1,9 +1,9 @@ +import { EAS as EASContract } from '@ethereum-attestation-service/eas-contracts'; +import { Overrides } from 'ethers'; import { EIP712Proxy } from './eip712-proxy'; import { Delegated, Offchain } from './offchain'; import { AttestationRequest, DelegatedAttestationRequest, DelegatedProxyAttestationRequest, DelegatedProxyRevocationRequest, DelegatedRevocationRequest, MultiAttestationRequest, MultiDelegatedAttestationRequest, MultiDelegatedProxyAttestationRequest, MultiDelegatedProxyRevocationRequest, MultiDelegatedRevocationRequest, MultiRevocationRequest, RevocationRequest } from './request'; import { Base, SignerOrProvider, Transaction } from './transaction'; -import { EAS as EASContract } from '@ethereum-attestation-service/eas-contracts'; -import { Overrides } from 'ethers'; export { Overrides } from 'ethers'; export * from './request'; export interface Attestation { diff --git a/dist/eas.js b/dist/eas.js index 63fd8e8..e0fe06a 100644 --- a/dist/eas.js +++ b/dist/eas.js @@ -2,12 +2,12 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.EAS = void 0; const tslib_1 = require("tslib"); +const eas_contracts_1 = require("@ethereum-attestation-service/eas-contracts"); +const version_1 = require("./legacy/version"); const offchain_1 = require("./offchain"); const request_1 = require("./request"); const transaction_1 = require("./transaction"); const utils_1 = require("./utils"); -const eas_contracts_1 = require("@ethereum-attestation-service/eas-contracts"); -const version_1 = require("./legacy/version"); tslib_1.__exportStar(require("./request"), exports); class EAS extends transaction_1.Base { proxy; @@ -76,7 +76,8 @@ class EAS extends transaction_1.Base { // Attests to a specific schema async attest({ schema, data: { recipient, data, expirationTime = request_1.NO_EXPIRATION, revocable = true, refUID = utils_1.ZERO_BYTES32, value = 0n } }, overrides) { const tx = await this.contract.attest({ schema, data: { recipient, expirationTime, revocable, refUID, data, value } }, { value, ...overrides }); - return new transaction_1.Transaction(tx, async (receipt) => (await (0, utils_1.getUIDsFromAttestEvents)(receipt.logs))[0]); + // eslint-disable-next-line require-await + return new transaction_1.Transaction(tx, async (receipt) => (0, utils_1.getUIDsFromAttestReceipt)(receipt)[0]); } // Attests to a specific schema via an EIP712 delegation request async attestByDelegation({ schema, data: { recipient, data, expirationTime = request_1.NO_EXPIRATION, revocable = true, refUID = utils_1.ZERO_BYTES32, value = 0n }, attester, signature }, overrides) { @@ -93,7 +94,8 @@ class EAS extends transaction_1.Base { signature, attester }, { value, ...overrides }); - return new transaction_1.Transaction(tx, async (receipt) => (await (0, utils_1.getUIDsFromAttestEvents)(receipt.logs))[0]); + // eslint-disable-next-line require-await + return new transaction_1.Transaction(tx, async (receipt) => (0, utils_1.getUIDsFromAttestReceipt)(receipt)[0]); } // Multi-attests to multiple schemas async multiAttest(requests, overrides) { @@ -117,7 +119,7 @@ class EAS extends transaction_1.Base { ...overrides }); // eslint-disable-next-line require-await - return new transaction_1.Transaction(tx, async (receipt) => (0, utils_1.getUIDsFromAttestEvents)(receipt.logs)); + return new transaction_1.Transaction(tx, async (receipt) => (0, utils_1.getUIDsFromAttestReceipt)(receipt)); } // Multi-attests to multiple schemas via an EIP712 delegation requests async multiAttestByDelegation(requests, overrides) { @@ -143,7 +145,7 @@ class EAS extends transaction_1.Base { ...overrides }); // eslint-disable-next-line require-await - return new transaction_1.Transaction(tx, async (receipt) => (0, utils_1.getUIDsFromAttestEvents)(receipt.logs)); + return new transaction_1.Transaction(tx, async (receipt) => (0, utils_1.getUIDsFromAttestReceipt)(receipt)); } // Revokes an existing attestation async revoke({ schema, data: { uid, value = 0n } }, overrides) { @@ -234,24 +236,27 @@ class EAS extends transaction_1.Base { // Timestamps the specified bytes32 data async timestamp(data, overrides) { const tx = await this.contract.timestamp(data, overrides ?? {}); - return new transaction_1.Transaction(tx, async (receipt) => (await (0, utils_1.getTimestampFromTimestampEvents)(receipt.logs))[0]); + // eslint-disable-next-line require-await + return new transaction_1.Transaction(tx, async (receipt) => (0, utils_1.getTimestampFromTimestampReceipt)(receipt)[0]); } // Timestamps the specified multiple bytes32 data async multiTimestamp(data, overrides) { const tx = await this.contract.multiTimestamp(data, overrides ?? {}); // eslint-disable-next-line require-await - return new transaction_1.Transaction(tx, async (receipt) => (0, utils_1.getTimestampFromTimestampEvents)(receipt.logs)); + return new transaction_1.Transaction(tx, async (receipt) => (0, utils_1.getTimestampFromTimestampReceipt)(receipt)); } // Revokes the specified offchain attestation UID async revokeOffchain(uid, overrides) { const tx = await this.contract.revokeOffchain(uid, overrides ?? {}); - return new transaction_1.Transaction(tx, async (receipt) => (await (0, utils_1.getTimestampFromOffchainRevocationEvents)(receipt.logs))[0]); + return new transaction_1.Transaction(tx, + // eslint-disable-next-line require-await + async (receipt) => (0, utils_1.getTimestampFromOffchainRevocationReceipt)(receipt)[0]); } // Revokes the specified multiple offchain attestation UIDs async multiRevokeOffchain(uids, overrides) { const tx = await this.contract.multiRevokeOffchain(uids, overrides ?? {}); // eslint-disable-next-line require-await - return new transaction_1.Transaction(tx, async (receipt) => (0, utils_1.getTimestampFromOffchainRevocationEvents)(receipt.logs)); + return new transaction_1.Transaction(tx, async (receipt) => (0, utils_1.getTimestampFromOffchainRevocationReceipt)(receipt)); } // Returns the domain separator used in the encoding of the signatures for attest, and revoke getDomainSeparator() { diff --git a/dist/eas.js.map b/dist/eas.js.map index 59a4532..6363061 100644 --- a/dist/eas.js.map +++ b/dist/eas.js.map @@ -1 +1 @@ -{"version":3,"file":"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- a/dist/utils.d.ts +++ b/dist/utils.d.ts @@ -5,12 +5,12 @@ export declare const ZERO_BYTES32 = "0x00000000000000000000000000000000000000000 export declare const getSchemaUID: (schema: string, resolverAddress: string, revocable: boolean) => string; export declare const getUID: (schema: string, recipient: string, attester: string, time: bigint, expirationTime: bigint, revocable: boolean, refUID: string, data: string, bump: number) => string; export declare const getOffchainUID: (version: number, schema: string, recipient: string, time: bigint, expirationTime: bigint, revocable: boolean, refUID: string, data: string) => string; +export declare const getUIDsFromAttestReceipt: (receipt: TransactionReceipt) => string[]; +export declare const getTimestampFromTimestampReceipt: (receipt: TransactionReceipt) => bigint[]; +export declare const getTimestampFromOffchainRevocationReceipt: (receipt: TransactionReceipt) => bigint[]; export declare const getUIDsFromMultiAttestTx: (res: Promise | TransactionResponse) => Promise; export declare const getUIDFromAttestTx: (res: Promise | TransactionResponse) => Promise; export declare const getUIDFromMultiDelegatedProxyAttestTx: (res: Promise | TransactionResponse) => Promise; export declare const getUIDFromMultiDelegatedProxyAttestReceipt: (res: Promise | TransactionReceipt) => Promise; export declare const getUIDFromDelegatedProxyAttestTx: (res: Promise | TransactionResponse) => Promise; export declare const getUIDFromDelegatedProxyAttestReceipt: (res: Promise | TransactionReceipt) => Promise; -export declare const getUIDsFromAttestEvents: (logs?: ReadonlyArray) => string[]; -export declare const getTimestampFromTimestampEvents: (logs?: ReadonlyArray) => bigint[]; -export declare const getTimestampFromOffchainRevocationEvents: (logs?: ReadonlyArray) => bigint[]; diff --git a/dist/utils.js b/dist/utils.js index ff39dbe..1b662b0 100644 --- a/dist/utils.js +++ b/dist/utils.js @@ -1,11 +1,17 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.getTimestampFromOffchainRevocationEvents = exports.getTimestampFromTimestampEvents = exports.getUIDsFromAttestEvents = exports.getUIDFromDelegatedProxyAttestReceipt = exports.getUIDFromDelegatedProxyAttestTx = exports.getUIDFromMultiDelegatedProxyAttestReceipt = exports.getUIDFromMultiDelegatedProxyAttestTx = exports.getUIDFromAttestTx = exports.getUIDsFromMultiAttestTx = exports.getOffchainUID = exports.getUID = exports.getSchemaUID = exports.ZERO_BYTES32 = exports.ZERO_BYTES = exports.ZERO_ADDRESS = void 0; +exports.getUIDFromDelegatedProxyAttestReceipt = exports.getUIDFromDelegatedProxyAttestTx = exports.getUIDFromMultiDelegatedProxyAttestReceipt = exports.getUIDFromMultiDelegatedProxyAttestTx = exports.getUIDFromAttestTx = exports.getUIDsFromMultiAttestTx = exports.getTimestampFromOffchainRevocationReceipt = exports.getTimestampFromTimestampReceipt = exports.getUIDsFromAttestReceipt = exports.getOffchainUID = exports.getUID = exports.getSchemaUID = exports.ZERO_BYTES32 = exports.ZERO_BYTES = exports.ZERO_ADDRESS = void 0; const eas_contracts_1 = require("@ethereum-attestation-service/eas-contracts"); const ethers_1 = require("ethers"); exports.ZERO_ADDRESS = ethers_1.ZeroAddress; exports.ZERO_BYTES = '0x'; exports.ZERO_BYTES32 = '0x0000000000000000000000000000000000000000000000000000000000000000'; +var Event; +(function (Event) { + Event["Attested"] = "Attested"; + Event["Timestamped"] = "Timestamped"; + Event["RevokedOffchain"] = "RevokedOffchain"; +})(Event || (Event = {})); const getSchemaUID = (schema, resolverAddress, revocable) => (0, ethers_1.solidityPackedKeccak256)(['string', 'address', 'bool'], [schema, resolverAddress, revocable]); exports.getSchemaUID = getSchemaUID; const getUID = (schema, recipient, attester, time, expirationTime, revocable, refUID, data, bump) => (0, ethers_1.solidityPackedKeccak256)(['bytes', 'address', 'address', 'uint64', 'uint64', 'bool', 'bytes32', 'bytes', 'uint32'], [(0, ethers_1.hexlify)((0, ethers_1.toUtf8Bytes)(schema)), recipient, attester, time, expirationTime, revocable, refUID, data, bump]); @@ -32,13 +38,43 @@ const getOffchainUID = (version, schema, recipient, time, expirationTime, revoca } }; exports.getOffchainUID = getOffchainUID; +const getDataFromReceipt = (receipt, event, attribute) => { + const eas = new ethers_1.Interface(eas_contracts_1.EAS__factory.abi); + const logs = []; + for (const log of receipt.logs || []) { + logs.push({ + ...log, + log: event, + fragment: { + name: event + }, + args: eas.decodeEventLog(event, log.data, log.topics) + }); + } + if (!logs) { + return []; + } + const filteredLogs = logs.filter((l) => l.fragment?.name === event); + if (filteredLogs.length === 0) { + throw new Error(`Unable to process ${event} events`); + } + return filteredLogs.map( + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (log) => eas.decodeEventLog(event, log.data, log.topics)[attribute]); +}; +const getUIDsFromAttestReceipt = (receipt) => getDataFromReceipt(receipt, Event.Attested, 'uid'); +exports.getUIDsFromAttestReceipt = getUIDsFromAttestReceipt; +const getTimestampFromTimestampReceipt = (receipt) => getDataFromReceipt(receipt, Event.Timestamped, 'timestamp').map((s) => BigInt(s)); +exports.getTimestampFromTimestampReceipt = getTimestampFromTimestampReceipt; +const getTimestampFromOffchainRevocationReceipt = (receipt) => getDataFromReceipt(receipt, Event.RevokedOffchain, 'timestamp').map((s) => BigInt(s)); +exports.getTimestampFromOffchainRevocationReceipt = getTimestampFromOffchainRevocationReceipt; const getUIDsFromMultiAttestTx = async (res) => { const tx = await res; const receipt = await tx.wait(); if (!receipt) { throw new Error(`Unable to confirm: ${tx}`); } - return (0, exports.getUIDsFromAttestEvents)(receipt.logs); + return (0, exports.getUIDsFromAttestReceipt)(receipt); }; exports.getUIDsFromMultiAttestTx = getUIDsFromMultiAttestTx; const getUIDFromAttestTx = async (res) => { @@ -59,19 +95,7 @@ const getUIDFromMultiDelegatedProxyAttestReceipt = async (res) => { if (!receipt) { throw new Error(`Unable to confirm: ${res}`); } - // eslint-disable-next-line camelcase - const eas = new ethers_1.Interface(eas_contracts_1.EAS__factory.abi); - const logs = []; - for (const log of receipt.logs || []) { - logs.push({ - log: 'Attested', - fragment: { - name: 'Attested' - }, - args: eas.decodeEventLog('Attested', log.data, log.topics) - }); - } - return (0, exports.getUIDsFromAttestEvents)(logs); + return (0, exports.getUIDsFromAttestReceipt)(receipt); }; exports.getUIDFromMultiDelegatedProxyAttestReceipt = getUIDFromMultiDelegatedProxyAttestReceipt; const getUIDFromDelegatedProxyAttestTx = async (res) => { @@ -82,46 +106,4 @@ const getUIDFromDelegatedProxyAttestReceipt = async (res) => { return (await (0, exports.getUIDFromMultiDelegatedProxyAttestReceipt)(res))[0]; }; exports.getUIDFromDelegatedProxyAttestReceipt = getUIDFromDelegatedProxyAttestReceipt; -// eslint-disable-next-line @typescript-eslint/no-explicit-any -const getUIDsFromAttestEvents = (logs) => { - if (!logs) { - return []; - } - const attestedLogs = logs.filter((l) => l.fragment?.name === 'Attested'); - if (attestedLogs.length === 0) { - throw new Error('Unable to process attestation events'); - } - // eslint-disable-next-line camelcase - const eas = new ethers_1.Interface(eas_contracts_1.EAS__factory.abi); - return attestedLogs.map((log) => log.args.uid ?? eas.decodeEventLog('Attested', log.data, log.topics).uid); -}; -exports.getUIDsFromAttestEvents = getUIDsFromAttestEvents; -// eslint-disable-next-line @typescript-eslint/no-explicit-any -const getTimestampFromTimestampEvents = (logs) => { - if (!logs) { - return []; - } - const timestampedEvents = logs.filter((l) => l.fragment?.name === 'Timestamped'); - if (timestampedEvents.length === 0) { - throw new Error('Unable to process attestation events'); - } - // eslint-disable-next-line camelcase - const eas = new ethers_1.Interface(eas_contracts_1.EAS__factory.abi); - return timestampedEvents.map((log) => log.args.uid ?? eas.decodeEventLog('Timestamped', log.data, log.topics).timestamp); -}; -exports.getTimestampFromTimestampEvents = getTimestampFromTimestampEvents; -// eslint-disable-next-line @typescript-eslint/no-explicit-any -const getTimestampFromOffchainRevocationEvents = (logs) => { - if (!logs) { - return []; - } - const revocationEvents = logs.filter((l) => l.fragment?.name === 'RevokedOffchain'); - if (revocationEvents.length === 0) { - throw new Error('Unable to process offchain revocation events'); - } - // eslint-disable-next-line camelcase - const eas = new ethers_1.Interface(eas_contracts_1.EAS__factory.abi); - return revocationEvents.map((log) => log.args.uid ?? eas.decodeEventLog('RevokedOffchain', log.data, log.topics).timestamp); -}; -exports.getTimestampFromOffchainRevocationEvents = getTimestampFromOffchainRevocationEvents; //# sourceMappingURL=utils.js.map \ No newline at end of file diff --git a/dist/utils.js.map b/dist/utils.js.map index a079ff9..0d98169 100644 --- a/dist/utils.js.map +++ b/dist/utils.js.map @@ -1 +1 @@ -{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAAA,+EAA2E;AAC3E,mCAQgB;AAEH,QAAA,YAAY,GAAG,oBAAW,CAAC;AAC3B,QAAA,UAAU,GAAG,IAAI,CAAC;AAClB,QAAA,YAAY,GAAG,oEAAoE,CAAC;AAE1F,MAAM,YAAY,GAAG,CAAC,MAAc,EAAE,eAAuB,EAAE,SAAkB,EAAE,EAAE,CAC1F,IAAA,gCAAuB,EAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC,CAAC;AADlF,QAAA,YAAY,gBACsE;AAExF,MAAM,MAAM,GAAG,CACpB,MAAc,EACd,SAAiB,EACjB,QAAgB,EAChB,IAAY,EACZ,cAAsB,EACtB,SAAkB,EAClB,MAAc,EACd,IAAY,EACZ,IAAY,EACZ,EAAE,CACF,IAAA,gCAAuB,EACrB,CAAC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAC,EACzF,CAAC,IAAA,gBAAO,EAAC,IAAA,oBAAW,EAAC,MAAM,CAAC,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CACzG,CAAC;AAdS,QAAA,MAAM,UAcf;AAEG,MAAM,cAAc,GAAG,CAC5B,OAAe,EACf,MAAc,EACd,SAAiB,EACjB,IAAY,EACZ,cAAsB,EACtB,SAAkB,EAClB,MAAc,EACd,IAAY,EACZ,EAAE;IACF,QAAQ,OA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CAAC,CAAC;KAC9C;IAED,OAAO,IAAA,gCAAwB,EAAC,OAAO,CAAC,CAAC;AAC3C,CAAC,CAAC;AATW,QAAA,0CAA0C,8CASrD;AAEK,MAAM,gCAAgC,GAAG,KAAK,EACnD,GAAuD,EACtC,EAAE;IACnB,OAAO,CAAC,MAAM,IAAA,6CAAqC,EAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/D,CAAC,CAAC;AAJW,QAAA,gCAAgC,oCAI3C;AAEK,MAAM,qCAAqC,GAAG,KAAK,EACxD,GAAqD,EACpC,EAAE;IACnB,OAAO,CAAC,MAAM,IAAA,kDAA0C,EAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACpE,CAAC,CAAC;AAJW,QAAA,qCAAqC,yCAIhD"} \ No newline at end of file diff --git a/package.json b/package.json index d6a7652..ae0b2aa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ethereum-attestation-service/eas-sdk", - "version": "1.1.0-beta.0", + "version": "1.1.0-beta.1", "description": "Ethereum Attestation Service - TypeScript/JavaScript SDK", "repository": "git@github.com:ethereum-attestation-service/eas-sdk.git", "author": "Leonid Beder ", diff --git a/src/eas.ts b/src/eas.ts index ebee30c..2c2251b 100644 --- a/src/eas.ts +++ b/src/eas.ts @@ -1,4 +1,7 @@ +import { EAS__factory, EAS as EASContract } from '@ethereum-attestation-service/eas-contracts'; +import { Overrides, TransactionReceipt } from 'ethers'; import { EIP712Proxy } from './eip712-proxy'; +import { legacyVersion } from './legacy/version'; import { Delegated, Offchain, OFFCHAIN_ATTESTATION_VERSION } from './offchain'; import { AttestationRequest, @@ -17,14 +20,11 @@ import { } from './request'; import { Base, SignerOrProvider, Transaction } from './transaction'; import { - getTimestampFromOffchainRevocationEvents, - getTimestampFromTimestampEvents, - getUIDsFromAttestEvents, + getTimestampFromOffchainRevocationReceipt, + getTimestampFromTimestampReceipt, + getUIDsFromAttestReceipt, ZERO_BYTES32 } from './utils'; -import { EAS__factory, EAS as EASContract } from '@ethereum-attestation-service/eas-contracts'; -import { legacyVersion } from './legacy/version'; -import { Overrides, TransactionReceipt } from 'ethers'; export { Overrides } from 'ethers'; export * from './request'; @@ -143,7 +143,8 @@ export class EAS extends Base { { value, ...overrides } ); - return new Transaction(tx, async (receipt: TransactionReceipt) => (await getUIDsFromAttestEvents(receipt.logs))[0]); + // eslint-disable-next-line require-await + return new Transaction(tx, async (receipt: TransactionReceipt) => getUIDsFromAttestReceipt(receipt)[0]); } // Attests to a specific schema via an EIP712 delegation request @@ -173,7 +174,8 @@ export class EAS extends Base { { value, ...overrides } ); - return new Transaction(tx, async (receipt: TransactionReceipt) => (await getUIDsFromAttestEvents(receipt.logs))[0]); + // eslint-disable-next-line require-await + return new Transaction(tx, async (receipt: TransactionReceipt) => getUIDsFromAttestReceipt(receipt)[0]); } // Multi-attests to multiple schemas @@ -201,7 +203,7 @@ export class EAS extends Base { }); // eslint-disable-next-line require-await - return new Transaction(tx, async (receipt: TransactionReceipt) => getUIDsFromAttestEvents(receipt.logs)); + return new Transaction(tx, async (receipt: TransactionReceipt) => getUIDsFromAttestReceipt(receipt)); } // Multi-attests to multiple schemas via an EIP712 delegation requests @@ -234,7 +236,7 @@ export class EAS extends Base { }); // eslint-disable-next-line require-await - return new Transaction(tx, async (receipt: TransactionReceipt) => getUIDsFromAttestEvents(receipt.logs)); + return new Transaction(tx, async (receipt: TransactionReceipt) => getUIDsFromAttestReceipt(receipt)); } // Revokes an existing attestation @@ -371,10 +373,8 @@ export class EAS extends Base { public async timestamp(data: string, overrides?: Overrides): Promise> { const tx = await this.contract.timestamp(data, overrides ?? {}); - return new Transaction( - tx, - async (receipt: TransactionReceipt) => (await getTimestampFromTimestampEvents(receipt.logs))[0] - ); + // eslint-disable-next-line require-await + return new Transaction(tx, async (receipt: TransactionReceipt) => getTimestampFromTimestampReceipt(receipt)[0]); } // Timestamps the specified multiple bytes32 data @@ -382,7 +382,7 @@ export class EAS extends Base { const tx = await this.contract.multiTimestamp(data, overrides ?? {}); // eslint-disable-next-line require-await - return new Transaction(tx, async (receipt: TransactionReceipt) => getTimestampFromTimestampEvents(receipt.logs)); + return new Transaction(tx, async (receipt: TransactionReceipt) => getTimestampFromTimestampReceipt(receipt)); } // Revokes the specified offchain attestation UID @@ -391,7 +391,8 @@ export class EAS extends Base { return new Transaction( tx, - async (receipt: TransactionReceipt) => (await getTimestampFromOffchainRevocationEvents(receipt.logs))[0] + // eslint-disable-next-line require-await + async (receipt: TransactionReceipt) => getTimestampFromOffchainRevocationReceipt(receipt)[0] ); } @@ -401,7 +402,7 @@ export class EAS extends Base { // eslint-disable-next-line require-await return new Transaction(tx, async (receipt: TransactionReceipt) => - getTimestampFromOffchainRevocationEvents(receipt.logs) + getTimestampFromOffchainRevocationReceipt(receipt) ); } diff --git a/src/utils.ts b/src/utils.ts index a1cc956..aad1ac5 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,18 +1,24 @@ import { EAS__factory } from '@ethereum-attestation-service/eas-contracts'; import { hexlify, + Interface, + solidityPackedKeccak256, toUtf8Bytes, TransactionReceipt, - ZeroAddress, TransactionResponse, - Interface, - solidityPackedKeccak256 + ZeroAddress } from 'ethers'; export const ZERO_ADDRESS = ZeroAddress; export const ZERO_BYTES = '0x'; export const ZERO_BYTES32 = '0x0000000000000000000000000000000000000000000000000000000000000000'; +enum Event { + Attested = 'Attested', + Timestamped = 'Timestamped', + RevokedOffchain = 'RevokedOffchain' +} + export const getSchemaUID = (schema: string, resolverAddress: string, revocable: boolean) => solidityPackedKeccak256(['string', 'address', 'bool'], [schema, resolverAddress, revocable]); @@ -71,6 +77,45 @@ export const getOffchainUID = ( } }; +const getDataFromReceipt = (receipt: TransactionReceipt, event: Event, attribute: string): string[] => { + const eas = new Interface(EAS__factory.abi); + const logs = []; + + for (const log of receipt.logs || []) { + logs.push({ + ...log, + log: event, + fragment: { + name: event + }, + args: eas.decodeEventLog(event, log.data, log.topics) + }); + } + + if (!logs) { + return []; + } + + const filteredLogs = logs.filter((l) => l.fragment?.name === event); + if (filteredLogs.length === 0) { + throw new Error(`Unable to process ${event} events`); + } + + return filteredLogs.map( + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (log: any) => eas.decodeEventLog(event, log.data, log.topics)[attribute] + ); +}; + +export const getUIDsFromAttestReceipt = (receipt: TransactionReceipt): string[] => + getDataFromReceipt(receipt, Event.Attested, 'uid'); + +export const getTimestampFromTimestampReceipt = (receipt: TransactionReceipt): bigint[] => + getDataFromReceipt(receipt, Event.Timestamped, 'timestamp').map((s) => BigInt(s)); + +export const getTimestampFromOffchainRevocationReceipt = (receipt: TransactionReceipt): bigint[] => + getDataFromReceipt(receipt, Event.RevokedOffchain, 'timestamp').map((s) => BigInt(s)); + export const getUIDsFromMultiAttestTx = async ( res: Promise | TransactionResponse ): Promise => { @@ -80,7 +125,7 @@ export const getUIDsFromMultiAttestTx = async ( throw new Error(`Unable to confirm: ${tx}`); } - return getUIDsFromAttestEvents(receipt.logs); + return getUIDsFromAttestReceipt(receipt); }; export const getUIDFromAttestTx = async (res: Promise | TransactionResponse): Promise => { @@ -107,21 +152,7 @@ export const getUIDFromMultiDelegatedProxyAttestReceipt = async ( throw new Error(`Unable to confirm: ${res}`); } - // eslint-disable-next-line camelcase - const eas = new Interface(EAS__factory.abi); - const logs = []; - - for (const log of receipt.logs || []) { - logs.push({ - log: 'Attested', - fragment: { - name: 'Attested' - }, - args: eas.decodeEventLog('Attested', log.data, log.topics) - }); - } - - return getUIDsFromAttestEvents(logs); + return getUIDsFromAttestReceipt(receipt); }; export const getUIDFromDelegatedProxyAttestTx = async ( @@ -135,55 +166,3 @@ export const getUIDFromDelegatedProxyAttestReceipt = async ( ): Promise => { return (await getUIDFromMultiDelegatedProxyAttestReceipt(res))[0]; }; - -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export const getUIDsFromAttestEvents = (logs?: ReadonlyArray): string[] => { - if (!logs) { - return []; - } - - const attestedLogs = logs.filter((l) => l.fragment?.name === 'Attested'); - if (attestedLogs.length === 0) { - throw new Error('Unable to process attestation events'); - } - - // eslint-disable-next-line camelcase - const eas = new Interface(EAS__factory.abi); - return attestedLogs.map((log) => log.args.uid ?? eas.decodeEventLog('Attested', log.data, log.topics).uid); -}; - -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export const getTimestampFromTimestampEvents = (logs?: ReadonlyArray): bigint[] => { - if (!logs) { - return []; - } - - const timestampedEvents = logs.filter((l) => l.fragment?.name === 'Timestamped'); - if (timestampedEvents.length === 0) { - throw new Error('Unable to process attestation events'); - } - - // eslint-disable-next-line camelcase - const eas = new Interface(EAS__factory.abi); - return timestampedEvents.map( - (log) => log.args.uid ?? eas.decodeEventLog('Timestamped', log.data, log.topics).timestamp - ); -}; - -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export const getTimestampFromOffchainRevocationEvents = (logs?: ReadonlyArray): bigint[] => { - if (!logs) { - return []; - } - - const revocationEvents = logs.filter((l) => l.fragment?.name === 'RevokedOffchain'); - if (revocationEvents.length === 0) { - throw new Error('Unable to process offchain revocation events'); - } - - // eslint-disable-next-line camelcase - const eas = new Interface(EAS__factory.abi); - return revocationEvents.map( - (log) => log.args.uid ?? eas.decodeEventLog('RevokedOffchain', log.data, log.topics).timestamp - ); -}; diff --git a/test/test/eas.ts b/test/test/eas.ts index fb4fda5..88385a3 100644 --- a/test/test/eas.ts +++ b/test/test/eas.ts @@ -1,3 +1,10 @@ +import { + EAS as EASContract, + EIP712Proxy as EIP712ProxyContract, + SchemaRegistry as SchemaRegistryContract +} from '@ethereum-attestation-service/eas-contracts'; +import { encodeBytes32String, Signer } from 'ethers'; +import { ethers } from 'hardhat'; import { EAS, NO_EXPIRATION } from '../../src/eas'; import { EIP712Proxy } from '../../src/eip712-proxy'; import { Offchain } from '../../src/offchain'; @@ -15,13 +22,6 @@ import { } from './helpers/eas'; import { duration, latest } from './helpers/time'; import { createWallet } from './helpers/wallet'; -import { - EAS as EASContract, - EIP712Proxy as EIP712ProxyContract, - SchemaRegistry as SchemaRegistryContract -} from '@ethereum-attestation-service/eas-contracts'; -import { ethers } from 'hardhat'; -import { Signer, encodeBytes32String } from 'ethers'; const { expect } = chai;