hiero-ledger / hiero-ledger/hiero-enterprise-java
Issue 7 — SmartContractClient.subscribeEvent(...): ContractId / EvmAddress / String overloads
- Dominant language
- Java
- Stars
- 6
- Forks
- 21
- Avg merge
- 10h 27m
- Merged PRs (30d)
- 37
Description
### Context
Per the design doc, SmartContractClient gets three subscribeEvent overloads, each returning a ContractSubscription (#4) and all ultimately resolving to an EVM address before delegating into ContractListener (#6):
```java
ContractSubscription subscribeEvent(ContractId contractId, String eventName, List eventParams);
ContractSubscription subscribeEvent(EvmAddress evmAddress, String eventName, List eventParams);
ContractSubscription subscribeEvent(String contractAddress, String eventName, List eventParams);
```
These live on SmartContractClient in the base module — the same client that already provides createAccount, createTopic, and the existing contract deploy/call methods — so no separate Spring or Microprofile wiring is required; both modules pick this up automatically through the client they already inject.
### Scope
* ContractId overload: resolve to an EVM contract address using the SDK's MirrorNodeContractQuery, then delegate to the String overload.
```txt
ContractId → MirrorNodeContractQuery → EVM contract address → subscribeEvent(String, ...)
```
* EvmAddress overload: convert via evmAddress.toString(), then delegate to the String overload.
```txt
EvmAddress → toString() → EVM contract address → subscribeEvent(String, ...)
```
* String overload: the core implementation — accepts an EVM-format address directly and performs the actual subscription via ContractListener (#6), returning the ContractSubscription it produces.
* Validate the raw String overload's input format (EVM 0x… address) and fail fast with a clear error on malformed input, consistent with existing SmartContractClient validation conventions.
* Determine and document which LedgerId is used for the Web3j provider lookup — presumably taken from HieroContext/the client's configured network, same as other SmartContractClient operations.
### Acceptance Criteria
[x] All three overloads implemented; ContractId and EvmAddress overloads verified to resolve to the same subscription as calling the String overload directly with the equivalent address.
[x] MirrorNodeContractQuery resolution failure (unknown/invalid contract) surfaces a clear exception rather than an obscure NPE further down the chain.
[x] Unit tests for each overload's resolution path (can mock the String overload to isolate resolution logic from live subscription behavior).
]x] Integration test exercising at least the ContractId overload end-to-end against testnet, including calling close()/unsubscribe() on the returned ContractSubscription.
Contributor guide
Assessment
This issue has not been assessed yet.