Skip to content
Open
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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should ContractLog align more closely with the existing ContractResult DTO? Both model Mirror Node contract endpoints, and ContractResult keeps EVM/Mirror metadata fields like contractId, blockHash, blockNumber, and transactionIndex nullable/boxed while using the Mirror field name timestamp. Matching that shape here would make the contract DTOs more consistent and avoid requiring fields that Mirror responses may omit or return as null.

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");
}
}
Copy link
Copy Markdown
Contributor

@alejandroGM0 alejandroGM0 Apr 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should probably be part of ContractRepository rather than a separate ContractLogRepository. Existing repository APIs appear to group Mirror Node reads around the parent domain object, for example TopicRepository owns both topic lookup and topic messages. Since these logs are contract-scoped and queried by ContractId, exposing them alongside the other contract reads would make the API more consistent.

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));
}
}
Loading