Skip to content

Commit 26142e4

Browse files
Merge branch 'main' into newsoloversion
2 parents 803ebce + 05bba7e commit 26142e4

File tree

14 files changed

+756
-72
lines changed

14 files changed

+756
-72
lines changed

.github/workflows/main.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
3+
4+
# This workflow uses actions that are not certified by GitHub.
5+
# They are provided by a third-party and are governed by
6+
# separate terms of service, privacy policy, and support
7+
# documentation.
8+
9+
name: Deploy SBOM to Dependencytrack
10+
11+
on:
12+
workflow_dispatch:
13+
push:
14+
branches: [ "main" ]
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout Repo
22+
uses: actions/checkout@v4
23+
24+
- name: Set up JDK 21
25+
uses: actions/setup-java@v4
26+
with:
27+
java-version: '21'
28+
distribution: 'temurin'
29+
cache: maven
30+
31+
- name: Build with Maven
32+
run: ./mvnw org.cyclonedx:cyclonedx-maven-plugin:makeAggregateBom
33+
34+
- name: deploy SBOM to Dependencytrack
35+
uses: DependencyTrack/gh-upload-sbom@v3
36+
with:
37+
serverHostname: 'api.dependencytrack.open-elements.cloud'
38+
apiKey: ${{ secrets.DEPENDENCYTRACK_API_KEY }}
39+
projectName: 'hiero-enterprise-java'
40+
projectVersion: 'main'
41+
bomFilename: "target/bom.xml"
42+
autoCreate: true
43+

.github/workflows/scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
persist-credentials: false
3838

3939
- name: "Run analysis"
40-
uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186 # v2.4.1
40+
uses: ossf/scorecard-action@05b42c624433fc40578a4040d5cf5e36ddca8cde # v2.4.2
4141
with:
4242
results_file: results.sarif
4343
results_format: sarif

hiero-enterprise-base/pom.xml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.open-elements.hiero</groupId>
99
<artifactId>hiero-enterprise</artifactId>
10-
<version>0.19.0-SNAPSHOT</version>
10+
<version>0.20.0-SNAPSHOT</version>
1111
<relativePath>../pom.xml</relativePath>
1212
</parent>
1313

@@ -68,16 +68,4 @@
6868
<scope>test</scope>
6969
</dependency>
7070
</dependencies>
71-
72-
<build>
73-
<plugins>
74-
<plugin>
75-
<groupId>org.jreleaser</groupId>
76-
<artifactId>jreleaser-maven-plugin</artifactId>
77-
<configuration>
78-
<skip>true</skip>
79-
</configuration>
80-
</plugin>
81-
</plugins>
82-
</build>
8371
</project>
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
package com.openelements.hiero.base.config.implementation;
2+
3+
import com.hedera.hashgraph.sdk.AccountId;
4+
import com.hedera.hashgraph.sdk.PrivateKey;
5+
import com.hedera.hashgraph.sdk.PublicKey;
6+
import com.openelements.hiero.base.config.ConsensusNode;
7+
import com.openelements.hiero.base.config.HieroConfig;
8+
import com.openelements.hiero.base.data.Account;
9+
import java.util.Optional;
10+
import java.util.Set;
11+
import org.jspecify.annotations.NonNull;
12+
13+
public class EnvBasedHieroConfig implements HieroConfig {
14+
15+
private final AccountId operatorAccountId;
16+
private final PublicKey operatorPublicKey;
17+
private final PrivateKey operatorPrivateKey;
18+
private final String mirrorNodeAddress;
19+
20+
private final String consensusNodeIp;
21+
private final String consensusNodePort;
22+
private final String consensusNodeAccount;
23+
24+
private final String relayUrl;
25+
26+
private final Long chainId;
27+
28+
public EnvBasedHieroConfig() {
29+
operatorAccountId = getEnv("HEDERA_OPERATOR_ACCOUNT_ID")
30+
.map(AccountId::fromString)
31+
.orElseThrow(() -> new IllegalStateException("HEDERA_OPERATOR_ACCOUNT_ID is not set"));
32+
operatorPublicKey = getEnv("HEDERA_OPERATOR_PUBLIC_KEY")
33+
.map(PublicKey::fromString)
34+
.orElseThrow(() -> new IllegalStateException("HEDERA_OPERATOR_PUBLIC_KEY is not set"));
35+
operatorPrivateKey = getEnv("HEDERA_OPERATOR_PRIVATE_KEY")
36+
.map(PrivateKey::fromString)
37+
.orElseThrow(() -> new IllegalStateException("HEDERA_OPERATOR_PRIVATE_KEY is not set"));
38+
mirrorNodeAddress = getEnv("HEDERA_MIRROR_NODE_ADDRESS")
39+
.orElse(null);
40+
consensusNodeIp = getEnv("HEDERA_CONSENSUS_NODE_IP")
41+
.orElseThrow(() -> new IllegalStateException("HEDERA_CONSENSUS_NODE_IP is not set"));
42+
consensusNodePort = getEnv("HEDERA_CONSENSUS_NODE_PORT")
43+
.orElseThrow(() -> new IllegalStateException("HEDERA_CONSENSUS_NODE_PORT is not set"));
44+
consensusNodeAccount = getEnv("HEDERA_CONSENSUS_NODE_ACCOUNT")
45+
.orElseThrow(() -> new IllegalStateException("HEDERA_CONSENSUS_NODE_ACCOUNT is not set"));
46+
relayUrl = getEnv("HEDERA_RELAY_URL").orElse(null);
47+
chainId = getEnv("HEDERA_CHAIN_ID")
48+
.map(Long::valueOf)
49+
.orElse(null);
50+
}
51+
52+
private Optional<String> getEnv(String key) {
53+
return Optional.ofNullable(System.getenv(key));
54+
}
55+
56+
@Override
57+
public @NonNull Account getOperatorAccount() {
58+
return new Account(operatorAccountId, operatorPublicKey, operatorPrivateKey);
59+
}
60+
61+
@Override
62+
public @NonNull Optional<String> getNetworkName() {
63+
return Optional.empty();
64+
}
65+
66+
@Override
67+
public @NonNull Set<String> getMirrorNodeAddresses() {
68+
if (mirrorNodeAddress == null) {
69+
return Set.of();
70+
}
71+
return Set.of(mirrorNodeAddress);
72+
}
73+
74+
@Override
75+
public @NonNull Set<ConsensusNode> getConsensusNodes() {
76+
ConsensusNode node = new ConsensusNode(
77+
consensusNodeIp,
78+
consensusNodePort,
79+
consensusNodeAccount
80+
);
81+
return Set.of(node);
82+
}
83+
84+
@Override
85+
public @NonNull Optional<Long> chainId() {
86+
return Optional.ofNullable(chainId);
87+
}
88+
89+
@Override
90+
public @NonNull Optional<String> relayUrl() {
91+
return Optional.ofNullable(relayUrl);
92+
}
93+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package com.openelements.hiero.base.config.implementation;
2+
3+
import com.openelements.hiero.base.config.ConsensusNode;
4+
import com.openelements.hiero.base.config.HieroConfig;
5+
import com.openelements.hiero.base.config.NetworkSettings;
6+
import com.openelements.hiero.base.data.Account;
7+
import java.util.Objects;
8+
import java.util.Optional;
9+
import java.util.Set;
10+
import org.jspecify.annotations.NonNull;
11+
12+
public class NetworkSettingsBasedHieroConfig implements HieroConfig {
13+
14+
private final Account operatorAccount;
15+
16+
private final NetworkSettings networkSetting;
17+
18+
public NetworkSettingsBasedHieroConfig(@NonNull final Account operatorAccount, @NonNull final String networkName) {
19+
this.operatorAccount = Objects.requireNonNull(operatorAccount, "operatorAccount must not be null");
20+
Objects.requireNonNull(networkName, "networkName must not be null");
21+
this.networkSetting = NetworkSettings.forIdentifier(networkName)
22+
.orElseThrow(() -> new IllegalStateException("Network settings for '" + networkName + "' not found"));
23+
}
24+
25+
@Override
26+
public @NonNull Account getOperatorAccount() {
27+
return operatorAccount;
28+
}
29+
30+
@Override
31+
public @NonNull Optional<String> getNetworkName() {
32+
return networkSetting.getNetworkName();
33+
}
34+
35+
@Override
36+
public @NonNull Set<String> getMirrorNodeAddresses() {
37+
return networkSetting.getMirrorNodeAddresses();
38+
}
39+
40+
@Override
41+
public @NonNull Set<ConsensusNode> getConsensusNodes() {
42+
return networkSetting.getConsensusNodes();
43+
}
44+
45+
@Override
46+
public @NonNull Optional<Long> chainId() {
47+
return networkSetting.chainId();
48+
}
49+
50+
@Override
51+
public @NonNull Optional<String> relayUrl() {
52+
return networkSetting.relayUrl();
53+
}
54+
}

0 commit comments

Comments
 (0)