-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: luisccastillo <[email protected]> Co-authored-by: abbes benayache <[email protected]> Co-authored-by: Le-Caignec <[email protected]> Co-authored-by: Robin Le Caignec <[email protected]> Co-authored-by: ErwanDecoster <[email protected]> Co-authored-by: Erwan Decoster <[email protected]> Co-authored-by: pjt <[email protected]>
- Loading branch information
1 parent
ed87607
commit 1da6401
Showing
25 changed files
with
368 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
packages/protected-data-delivery-dapp/deployment/src/utils/getEventFromLogs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
export const getEventFromLogs = ({ contract, eventName, logs }) => { | ||
const filter = contract.getEvent(eventName); | ||
if (!filter) { | ||
throw new Error(`Event filter not found for ${eventName}`); | ||
} | ||
|
||
const eventTopic = filter.fragment.topicHash; | ||
// Find the event in the logs based on the topic | ||
const eventFound = logs.find((log) => log.topics[0] === eventTopic); | ||
if (!eventFound) { | ||
throw new Error(`Event ${eventName} not found in logs`); | ||
} | ||
|
||
// Check if the event is already decoded | ||
if (eventFound.args) { | ||
return eventFound; | ||
} | ||
|
||
// If not decoded, decode the event | ||
try { | ||
return { | ||
...eventFound, | ||
args: contract.interface.decodeEventLog( | ||
filter.fragment, | ||
eventFound.data, | ||
eventFound.topics | ||
), | ||
}; | ||
} catch (error) { | ||
throw new Error(`Failed to decode event ${eventName}: ${error.message}`); | ||
} | ||
}; |
8 changes: 0 additions & 8 deletions
8
packages/protected-data-delivery-dapp/deployment/src/utils/transactionEvent.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.