hiero-ledger / hiero-ledger/hiero-enterprise-java

Issue 5 — ContractListener: per-LedgerId Web3j provider registry

Open
#311 1 comment 0 reactions 2 assignees Claimed by @manishdait View on GitHub
enhancement pending-review smart-contracts
Dominant language
Java
Stars
6
Forks
21
Avg merge
10h 27m
Merged PRs (30d)
37

Description

### Context

Per the design doc, `ContractListener` maintains one Web3j instance per supported `LedgerId`, backed by the `Hashio JSON-RPC` relay endpoints:

| Ledger | Web3j Endpoint |
| --- | --- |
| Mainnet | https://mainnet.hashio.io/api |
| Previewnet | https://previewnet.hashio.io/api |
| Testnet | https://testnet.hashio.io/api |
| Solo | http://localhost:37546 |

```java
private static final Map PROVIDERS = Map.of(
LedgerId.MAINNET, Web3j.build(new HttpService("https://mainnet.hashio.io/api")),
LedgerId.PREVIEWNET, Web3j.build(new HttpService("https://previewnet.hashio.io/api")),
LedgerId.TESTNET, Web3j.build(new HttpService("https://testnet.hashio.io/api"))
);
```
Note: the doc's endpoint table includes Solo, but the sample PROVIDERS map does not — this issue should add the Solo entry to the map (flagged as a gap in the doc).

### Scope
- Implement the `PROVIDERS` registry as specified, adding the missing Solo entry (http://localhost:37546).
- Implement provider resolution: `LedgerId → PROVIDERS.get(ledgerId) → Web3j`.
- If the requested `LedgerId` is not present in PROVIDERS, throw an exception confirm with mentors whether this should be a new dedicated exception type (e.g. `UnsupportedLedgerException`) or an existing project convention (`IllegalArgumentException`, etc.) before implementing.
* Confirm lifecycle: whether Web3j instances are process-wide singletons (as the static final Map implies) and how/if they get shutdown() on application teardown Web3j providers hold open HTTP/WS connections.

### Acceptance Criteria
- [ ] All four ledgers (`Mainnet`, `Previewnet`, `Testnet`, `Solo`) resolve to a working Web3j instance.
- [ ] Unsupported/unknown `LedgerId` throws the agreed exception type with a clear message.
- [ ] Unit tests for resolution logic; no live network calls required for this issue.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.