Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2 #6

Open
wants to merge 11 commits into
base: development
Choose a base branch
from
Open
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>blockchains.iaas.uni.stuttgart.de</groupId>
<artifactId>blockchain-access-layer-api</artifactId>
<version>1.0.7</version>
<version>2.0.7</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
Expand Down Expand Up @@ -61,5 +61,10 @@
<version>5.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/********************************************************************************
* Copyright (c) 2023 Institute for the Architecture of Application System -
* University of Stuttgart
* Author: Akshay Patel
*
* This program and the accompanying materials are made available under the
* terms the Apache Software License 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
package blockchains.iaas.uni.stuttgart.de.api.exceptions;

import com.github.arteam.simplejsonrpc.core.annotation.JsonRpcError;

@JsonRpcError(code = ExceptionCode.CancelRejectedError, message = "The specified invocation cannot be cancelled")
public class CancelRejectedError extends BalException {

public CancelRejectedError() {
super();
}

public CancelRejectedError(String message) {
super(message);
}

@Override
public int getCode() {
return ExceptionCode.CancelRejectedError;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class ExceptionCode {
public static final int UnknownError = 0;

/**
* The blockchain instance, smart contract, event or function are not found
* The blockchain instance, smart contract, or invocation, event or function are not found
*/
public static final int NotFound = -32000;
/**
Expand Down Expand Up @@ -73,4 +73,11 @@ public class ExceptionCode {
* This is an asynchronous error.
*/
public static final int Timeout = -32201;

public static final int CancelRejectedError = -32209;

public static final int ReplaceRejectedError = -32210;

public static final int InvalidMessageSignedError = -32211;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/********************************************************************************
* Copyright (c) 2023 Institute for the Architecture of Application System -
* University of Stuttgart
* Author: Akshay Patel
*
* This program and the accompanying materials are made available under the
* terms the Apache Software License 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
package blockchains.iaas.uni.stuttgart.de.api.exceptions;

import com.github.arteam.simplejsonrpc.core.annotation.JsonRpcError;

@JsonRpcError(code = ExceptionCode.InsufficientFunds, message = "Not enough funds to invoke the state-changing\n" +
"smart contract function.")
public class InsufficientFundsException extends BalException {

public InsufficientFundsException() {
super();
}

public InsufficientFundsException(String message) {
super(message);
}

@Override
public int getCode() {
return ExceptionCode.InsufficientFunds;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/********************************************************************************
* Copyright (c) 2023 Institute for the Architecture of Application System -
* University of Stuttgart
* Author: Akshay Patel
*
* This program and the accompanying materials are made available under the
* terms the Apache Software License 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
package blockchains.iaas.uni.stuttgart.de.api.exceptions;

import com.github.arteam.simplejsonrpc.core.annotation.JsonRpcError;

@JsonRpcError(code = ExceptionCode.NotFound, message = "The specified invocation with given correlation id cannot be found")
public class InvocationNotFoundException extends BalException {

public InvocationNotFoundException() {
super();
}

public InvocationNotFoundException(String message) {
super(message);
}

@Override
public int getCode() {
return ExceptionCode.NotFound;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/********************************************************************************
* Copyright (c) 2023 Institute for the Architecture of Application System -
* University of Stuttgart
* Author: Akshay Patel
*
* This program and the accompanying materials are made available under the
* terms the Apache Software License 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
package blockchains.iaas.uni.stuttgart.de.api.exceptions;

import com.github.arteam.simplejsonrpc.core.annotation.JsonRpcError;

@JsonRpcError(code = ExceptionCode.ReplaceRejectedError, message = "The specified invocation cannot be replaced")
public class ReplaceRejectedError extends BalException {

public ReplaceRejectedError() {
super();
}

public ReplaceRejectedError(String message) {
super(message);
}

@Override
public int getCode() {
return ExceptionCode.ReplaceRejectedError;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/********************************************************************************
* Copyright (c) 2018-2022 Institute for the Architecture of Application System -
* Copyright (c) 2018-2023 Institute for the Architecture of Application System -
* University of Stuttgart
* Author: Ghareeb Falazi
* Co-author: Akshay Patel
*
* This program and the accompanying materials are made available under the
* terms the Apache Software License 2.0
Expand All @@ -17,6 +18,7 @@
import blockchains.iaas.uni.stuttgart.de.api.exceptions.NotSupportedException;
import blockchains.iaas.uni.stuttgart.de.api.model.*;
import io.reactivex.Observable;
import org.apache.commons.lang3.tuple.ImmutablePair;

import java.math.BigDecimal;
import java.util.List;
Expand Down Expand Up @@ -84,10 +86,17 @@ public interface BlockchainAdapter {
CompletableFuture<Transaction> invokeSmartContract(
String smartContractPath,
String functionIdentifier,
List<String> typeArguments,
List<Parameter> inputs,
List<Parameter> outputs,
double requiredConfidence,
long timeoutMillis
long timeoutMillis,
String signature,
String signer,
List<String> signers,
List<ImmutablePair<String, String>> signatures,
long minimumNumberOfSignatures

) throws BalException;

/**
Expand Down Expand Up @@ -115,12 +124,60 @@ Observable<Occurrence> subscribeToEvent(String smartContractAddress, String even
* @param timeFrame The timeFrame in which to consider event occurrences.
* @return A completable future containing a list of matching occurrences.
*/
CompletableFuture<QueryResult> queryEvents(String smartContractAddress, String eventIdentifier, List<Parameter> outputParameters,
String filter, TimeFrame timeFrame) throws BalException;
CompletableFuture<QueryResult> queryEvents(String smartContractAddress, String eventIdentifier,
List<String> typeArguments, List<Parameter> outputParameters, String filter,
TimeFrame timeFrame)
throws BalException;

/**
* Tests the connection settings with the underlying blockchain
*
* @return true if the connection is successful, an error message otherwise.
*/
String testConnection();


CompletableFuture<Transaction> tryReplaceInvocation(String correlationId, String smartContractPath,
String functionIdentifier,
List<String> typeArguments,
List<Parameter> inputs,
List<Parameter> outputs,
double requiredConfidence,
String signature,
String signer,
List<String> signers,
long minimumNumberOfSignatures);

boolean tryCancelInvocation(String correlationId);

/*
* This method should be implemented by the plugin to indicate whether the plugin is capable of handling subscription
* and the callbacks both.
* */
boolean canHandleDelegatedSubscription();

/*
* This method is an alternative to initial gateway implementation where the gateway acts as a centralized entity
* and handles subscriptions and callbacks. Using this method, a plugin can must invoke callbacks on its own rather
* than gateway managing the callbacks.
* */
boolean delegatedSubscribe(String functionIdentifier,
String eventIdentifier,
List<Parameter> outputParameters,
double degreeOfConfidence,
String filter,
String callbackUrl,
String correlationId);

/*
* This method is an alternative to initial gateway implementation where the gateway acts as a centralized entity
* and handles subscriptions, callbacks and cancelling subscriptions.
* */
boolean delegatedUnsubscribe(String smartContractPath,
String functionIdentifier,
String eventIdentifier,
List<String> typeArguments,
List<Parameter> parameters,
String correlationId);

}