Skip to content

Commit dcd652b

Browse files
authored
Merge branch 'OpenElements:main' into master
2 parents 529b374 + de3a6f7 commit dcd652b

File tree

45 files changed

+1776
-111
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1776
-111
lines changed

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
version: 2
3+
updates:
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
...

.github/workflows/codeql.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL Advanced"
13+
14+
on:
15+
push:
16+
branches: [ "main" ]
17+
pull_request:
18+
branches: [ "main" ]
19+
schedule:
20+
- cron: '38 17 * * 1'
21+
22+
jobs:
23+
analyze:
24+
name: Analyze (${{ matrix.language }})
25+
# Runner size impacts CodeQL analysis time. To learn more, please see:
26+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
27+
# - https://gh.io/supported-runners-and-hardware-resources
28+
# - https://gh.io/using-larger-runners (GitHub.com only)
29+
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
30+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
31+
permissions:
32+
# required for all workflows
33+
security-events: write
34+
35+
# required to fetch internal or private CodeQL packs
36+
packages: read
37+
38+
# only required for workflows in private repositories
39+
actions: read
40+
contents: read
41+
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
include:
46+
- language: java-kotlin
47+
build-mode: none # This mode only analyzes Java. Set this to 'autobuild' or 'manual' to analyze Kotlin too.
48+
# CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
49+
# Use `c-cpp` to analyze code written in C, C++ or both
50+
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
51+
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
52+
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
53+
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
54+
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
55+
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
56+
steps:
57+
- name: Checkout repository
58+
uses: actions/checkout@v4
59+
60+
# Initializes the CodeQL tools for scanning.
61+
- name: Initialize CodeQL
62+
uses: github/codeql-action/init@v3
63+
with:
64+
languages: ${{ matrix.language }}
65+
build-mode: ${{ matrix.build-mode }}
66+
# If you wish to specify custom queries, you can do so here or in a config file.
67+
# By default, queries listed here will override any specified in a config file.
68+
# Prefix the list here with "+" to use these queries and those in the config file.
69+
70+
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
71+
# queries: security-extended,security-and-quality
72+
73+
# If the analyze step fails for one of the languages you are analyzing with
74+
# "We were unable to automatically build your code", modify the matrix above
75+
# to set the build mode to "manual" for that language. Then modify this step
76+
# to build your code.
77+
# ℹ️ Command-line programs to run using the OS shell.
78+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
79+
- if: matrix.build-mode == 'manual'
80+
shell: bash
81+
run: |
82+
echo 'If you are using a "manual" build mode for one or more of the' \
83+
'languages you are analyzing, replace this with the commands to build' \
84+
'your code, for example:'
85+
echo ' make bootstrap'
86+
echo ' make release'
87+
exit 1
88+
89+
- name: Perform CodeQL Analysis
90+
uses: github/codeql-action/analyze@v3
91+
with:
92+
category: "/language:${{matrix.language}}"

.github/workflows/maven.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
uses: actions/checkout@v4
2525

2626
- name: Set up JDK 21
27-
uses: actions/setup-java@v3
27+
uses: actions/setup-java@v4
2828
with:
2929
java-version: '21'
3030
distribution: 'temurin'

.github/workflows/scorecard.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# This workflow uses actions that are not certified by GitHub. They are provided
2+
# by a third-party and are governed by separate terms of service, privacy
3+
# policy, and support documentation.
4+
5+
name: Scorecard supply-chain security
6+
on:
7+
# For Branch-Protection check. Only the default branch is supported. See
8+
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
9+
branch_protection_rule:
10+
# To guarantee Maintained check is occasionally updated. See
11+
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
12+
schedule:
13+
- cron: '40 19 * * 1'
14+
push:
15+
branches: [ "main" ]
16+
17+
# Declare default permissions as read only.
18+
permissions: read-all
19+
20+
jobs:
21+
analysis:
22+
name: Scorecard analysis
23+
runs-on: ubuntu-latest
24+
permissions:
25+
# Needed to upload the results to code-scanning dashboard.
26+
security-events: write
27+
# Needed to publish results and get a badge (see publish_results below).
28+
id-token: write
29+
# Uncomment the permissions below if installing in a private repository.
30+
# contents: read
31+
# actions: read
32+
33+
steps:
34+
- name: "Checkout code"
35+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
36+
with:
37+
persist-credentials: false
38+
39+
- name: "Run analysis"
40+
uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # v2.3.1
41+
with:
42+
results_file: results.sarif
43+
results_format: sarif
44+
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
45+
# - you want to enable the Branch-Protection check on a *public* repository, or
46+
# - you are installing Scorecard on a *private* repository
47+
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action?tab=readme-ov-file#authentication-with-fine-grained-pat-optional.
48+
# repo_token: ${{ secrets.SCORECARD_TOKEN }}
49+
50+
# Public repositories:
51+
# - Publish results to OpenSSF REST API for easy access by consumers
52+
# - Allows the repository to include the Scorecard badge.
53+
# - See https://github.com/ossf/scorecard-action#publishing-results.
54+
# For private repositories:
55+
# - `publish_results` will always be set to `false`, regardless
56+
# of the value entered here.
57+
publish_results: true
58+
59+
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
60+
# format to the repository Actions tab.
61+
- name: "Upload artifact"
62+
uses: actions/upload-artifact@97a0fba1372883ab732affbe8f94b823f91727db # v3.pre.node20
63+
with:
64+
name: SARIF file
65+
path: results.sarif
66+
retention-days: 5
67+
68+
# Upload the results to GitHub's code scanning dashboard (optional).
69+
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
70+
- name: "Upload to code-scanning"
71+
uses: github/codeql-action/upload-sarif@v3
72+
with:
73+
sarif_file: results.sarif

hedera-base/pom.xml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.open-elements.hedera</groupId>
99
<artifactId>hedera-enterprise</artifactId>
10-
<version>0.10.0-SNAPSHOT</version>
10+
<version>0.11.0-SNAPSHOT</version>
1111
<relativePath>../pom.xml</relativePath>
1212
</parent>
1313

@@ -22,6 +22,12 @@
2222
<dependency>
2323
<groupId>com.hedera.hashgraph</groupId>
2424
<artifactId>sdk</artifactId>
25+
</dependency>
26+
<dependency>
27+
<groupId>io.github.cdimascio</groupId>
28+
<artifactId>dotenv-java</artifactId>
29+
<version>2.3.2</version>
30+
<scope>test</scope>
2531
</dependency>
2632
<dependency>
2733
<groupId>org.slf4j</groupId>
@@ -47,11 +53,6 @@
4753
<artifactId>grpc-inprocess</artifactId>
4854
<scope>test</scope>
4955
</dependency>
50-
<dependency>
51-
<groupId>io.github.cdimascio</groupId>
52-
<artifactId>dotenv-java</artifactId>
53-
<scope>test</scope>
54-
</dependency>
5556
<dependency>
5657
<groupId>org.slf4j</groupId>
5758
<artifactId>slf4j-simple</artifactId>
@@ -75,4 +76,4 @@
7576
</plugins>
7677
</build>
7778

78-
</project>
79+
</project>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.openelements.hedera.base;
2+
3+
import com.hedera.hashgraph.sdk.AccountId;
4+
import com.openelements.hedera.base.mirrornode.AccountInfo;
5+
import org.jspecify.annotations.NonNull;
6+
7+
import java.util.Objects;
8+
import java.util.Optional;
9+
10+
/**
11+
* Interface for interacting with a Hedera network. This interface provides methods for searching for Accounts.
12+
*/
13+
public interface AccountRepository {
14+
/**
15+
* Return the AccountInfo of a given accountId.
16+
*
17+
* @param accountId id of the account
18+
* @return {@link Optional} containing the found AccountInfo or null
19+
* @throws HederaException if the search fails
20+
*/
21+
Optional<AccountInfo> findById(@NonNull AccountId accountId) throws HederaException;
22+
23+
/**
24+
* Return the AccountInfo of a given accountId.
25+
*
26+
* @param accountId id of the account
27+
* @return {@link Optional} containing the found AccountInfo or null
28+
* @throws HederaException if the search fails
29+
*/
30+
default Optional<AccountInfo> findById(@NonNull String accountId) throws HederaException {
31+
Objects.requireNonNull(accountId, "accountId must not be null");
32+
return findById(AccountId.fromString(accountId));
33+
}
34+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.openelements.hedera.base;
2+
3+
import java.util.Objects;
4+
import java.util.Optional;
5+
6+
import org.jspecify.annotations.NonNull;
7+
8+
import com.hedera.hashgraph.sdk.AccountId;
9+
import com.openelements.hedera.base.mirrornode.Page;
10+
import com.openelements.hedera.base.mirrornode.TransactionInfo;
11+
12+
/**
13+
* Interface for interacting with transactions on a Hedera network.
14+
* This interface provides methods for querying transactions.
15+
*/
16+
public interface TransactionRepository {
17+
/**
18+
* Find all transactions associated with a specific account.
19+
*
20+
* @param accountId id of the account
21+
* @return page of transactions
22+
* @throws HederaException if the search fails
23+
*/
24+
@NonNull
25+
Page<TransactionInfo> findByAccount(@NonNull AccountId accountId) throws HederaException;
26+
27+
/**
28+
* Find all transactions associated with a specific account.
29+
*
30+
* @param accountId id of the account as a string
31+
* @return page of transactions
32+
* @throws HederaException if the search fails
33+
*/
34+
@NonNull
35+
default Page<TransactionInfo> findByAccount(@NonNull String accountId) throws HederaException {
36+
Objects.requireNonNull(accountId, "accountId must not be null");
37+
return findByAccount(AccountId.fromString(accountId));
38+
}
39+
40+
/**
41+
* Find a specific transaction by its ID.
42+
*
43+
* @param transactionId the transaction ID
44+
* @return Optional containing the transaction if found
45+
* @throws HederaException if the search fails
46+
*/
47+
@NonNull
48+
Optional<TransactionInfo> findById(@NonNull String transactionId) throws HederaException;
49+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.openelements.hedera.base.implementation;
2+
3+
import com.hedera.hashgraph.sdk.AccountId;
4+
import com.openelements.hedera.base.AccountRepository;
5+
import com.openelements.hedera.base.HederaException;
6+
import com.openelements.hedera.base.mirrornode.AccountInfo;
7+
import com.openelements.hedera.base.mirrornode.MirrorNodeClient;
8+
import org.jspecify.annotations.NonNull;
9+
10+
import java.util.Objects;
11+
import java.util.Optional;
12+
13+
public class AccountRepositoryImpl implements AccountRepository {
14+
private final MirrorNodeClient mirrorNodeClient;
15+
16+
public AccountRepositoryImpl(@NonNull final MirrorNodeClient mirrorNodeClient) {
17+
this.mirrorNodeClient = Objects.requireNonNull(mirrorNodeClient, "mirrorNodeClient must not be null");
18+
}
19+
20+
@Override
21+
public Optional<AccountInfo> findById(@NonNull AccountId accountId) throws HederaException {
22+
return mirrorNodeClient.queryAccount(accountId);
23+
}
24+
}

hedera-base/src/main/java/com/openelements/hedera/base/implementation/FileClientImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
public class FileClientImpl implements FileClient {
2525

26-
private final static Logger log = LoggerFactory.getLogger(FileClientImpl.class);
26+
private static final Logger log = LoggerFactory.getLogger(FileClientImpl.class);
2727

2828
private final ProtocolLayerClient protocolLayerClient;
2929

hedera-base/src/main/java/com/openelements/hedera/base/implementation/HederaNetwork.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ public String getName() {
4848
public String getMirrornodeEndpoint() {
4949
return mirrornodeEndpoint;
5050
}
51-
}
51+
}

0 commit comments

Comments
 (0)