Skip to content

Commit

Permalink
datatypes
Browse files Browse the repository at this point in the history
  • Loading branch information
hendrikebbers committed Jul 1, 2024
1 parent b35bd04 commit 9e8be41
Show file tree
Hide file tree
Showing 18 changed files with 951 additions and 67 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.openelements.spring.hedera.api;

import com.hedera.hashgraph.sdk.ContractId;
import com.openelements.spring.hedera.api.data.ContractVerificationState;

public interface ContractVerificationClient {

ContractVerificationState checkVerification(String contractId, String contractSource, String contractMetadata);

ContractVerificationState checkVerification(ContractId contractId, String contractSource, String contractMetadata);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.openelements.spring.hedera.api;

import com.hedera.hashgraph.sdk.FileId;

public interface FileServiceClient {

FileId createFile(byte[] contents) throws HederaException;

default byte[] readFile(String fileId) throws HederaException {
return readFile(FileId.fromString(fileId));
}

byte[] readFile(FileId fileId) throws HederaException;

default void deleteFile(String fileId) throws HederaException {
deleteFile(FileId.fromString(fileId));
}

void deleteFile(FileId fileId) throws HederaException;
}
27 changes: 2 additions & 25 deletions src/main/java/com/openelements/spring/hedera/api/HederaClient.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.openelements.spring.hedera.api;

import com.hedera.hashgraph.sdk.Client;
import com.hedera.hashgraph.sdk.ContractFunctionResult;
import com.hedera.hashgraph.sdk.ContractId;
import com.hedera.hashgraph.sdk.FileId;
import com.openelements.spring.hedera.api.data.ContractParam;
Expand All @@ -24,31 +25,7 @@
/**
* Interface for interacting with the Hedera network.
*/
public interface HederaClient {

FileId createFile(byte[] contents) throws HederaException;

default byte[] readFile(String fileId) throws HederaException {
return readFile(FileId.fromString(fileId));
}

byte[] readFile(FileId fileId) throws HederaException;

default void deleteFile(String fileId) throws HederaException {
deleteFile(FileId.fromString(fileId));
}

void deleteFile(FileId fileId) throws HederaException;

default ContractId createContract(String fileId, ContractParam<?>... constructorParams) throws HederaException {
return createContract(FileId.fromString(fileId), constructorParams);
}

ContractId createContract(FileId fileId, ContractParam<?>... constructorParams) throws HederaException;

ContractId createContract(byte[] contents, ContractParam<?>... constructorParams) throws HederaException;

ContractId createContract(Path pathToBin, ContractParam<?>... constructorParams) throws HederaException;
public interface HederaClient extends FileServiceClient, SmartContractServiceClient {

AccountBalanceResponse executeAccountBalanceQuery(AccountBalanceRequest request) throws HederaException;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.openelements.spring.hedera.api;

import com.hedera.hashgraph.sdk.ContractFunctionResult;
import com.hedera.hashgraph.sdk.ContractId;
import com.hedera.hashgraph.sdk.FileId;
import com.openelements.spring.hedera.api.data.ContractParam;
import java.nio.file.Path;

public interface SmartContractServiceClient {

default ContractId createContract(String fileId, ContractParam<?>... constructorParams) throws HederaException {
return createContract(FileId.fromString(fileId), constructorParams);
}

ContractId createContract(FileId fileId, ContractParam<?>... constructorParams) throws HederaException;

ContractId createContract(byte[] contents, ContractParam<?>... constructorParams) throws HederaException;

ContractId createContract(Path pathToBin, ContractParam<?>... constructorParams) throws HederaException;

default ContractFunctionResult callContractFunction(String contractId, String functionName, ContractParam<?>... params) throws HederaException {
return callContractFunction(ContractId.fromString(contractId), functionName, params);
}

ContractFunctionResult callContractFunction(ContractId contractId, String functionName, ContractParam<?>... params) throws HederaException;

}
Loading

0 comments on commit 9e8be41

Please sign in to comment.