-
Notifications
You must be signed in to change notification settings - Fork 17
feat: Add ContractLog data model and repository interface #75
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| package org.hiero.base.data; | ||
|
|
||
| import com.hedera.hashgraph.sdk.ContractId; | ||
| import java.time.Instant; | ||
| import java.util.List; | ||
| import java.util.Objects; | ||
| import org.jspecify.annotations.NonNull; | ||
| import org.jspecify.annotations.Nullable; | ||
|
|
||
| /** Represents a smart contract log/event emitted during a contract execution. */ | ||
| public record ContractLog( | ||
| @Nullable String address, | ||
| @Nullable String bloom, | ||
| @NonNull ContractId contractId, | ||
| @Nullable ContractId rootContractId, | ||
| @NonNull Instant consensusTimestamp, | ||
| @NonNull String data, | ||
| int index, | ||
| @NonNull List<String> topics, | ||
| @NonNull String blockHash, | ||
| long blockNumber, | ||
| @NonNull String transactionHash, | ||
| int transactionIndex) { | ||
|
|
||
| public ContractLog { | ||
| Objects.requireNonNull(contractId, "contractId must not be null"); | ||
| Objects.requireNonNull(consensusTimestamp, "consensusTimestamp must not be null"); | ||
| Objects.requireNonNull(data, "data must not be null"); | ||
| Objects.requireNonNull(topics, "topics must not be null"); | ||
| topics = List.copyOf(topics); | ||
| Objects.requireNonNull(blockHash, "blockHash must not be null"); | ||
| Objects.requireNonNull(transactionHash, "transactionHash must not be null"); | ||
| } | ||
| } |
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should probably be part of |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package org.hiero.base.mirrornode; | ||
|
|
||
| import com.hedera.hashgraph.sdk.ContractId; | ||
| import java.util.Objects; | ||
| import org.hiero.base.HieroException; | ||
| import org.hiero.base.data.ContractLog; | ||
| import org.hiero.base.data.Page; | ||
| import org.jspecify.annotations.NonNull; | ||
|
|
||
| /** | ||
| * Repository for querying smart contract logs (events) from a Hiero network. This provides an | ||
| * easy-to-use API for observing events emitted by deployed smart contracts via the Hiero Mirror | ||
| * Node. | ||
| */ | ||
| public interface ContractLogRepository { | ||
|
|
||
| @NonNull Page<ContractLog> findByContractId(@NonNull ContractId contractId) throws HieroException; | ||
|
|
||
| @NonNull | ||
| default Page<ContractLog> findByContractId(@NonNull String contractId) throws HieroException { | ||
| Objects.requireNonNull(contractId, "contractId must not be null"); | ||
| return findByContractId(ContractId.fromString(contractId)); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should
ContractLogalign more closely with the existingContractResultDTO? Both model Mirror Node contract endpoints, andContractResultkeeps EVM/Mirror metadata fields likecontractId,blockHash,blockNumber, andtransactionIndexnullable/boxed while using the Mirror field nametimestamp. Matching that shape here would make the contract DTOs more consistent and avoid requiring fields that Mirror responses may omit or return as null.