Skip to content
This repository has been archived by the owner on Aug 30, 2022. It is now read-only.

Feature: AMQP Messages #119

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ actions.add(new Action("eosio.token", "transfer", authorizations, jsonData));

processor.prepare(actions);

PushTransactionResponse pushTransactionResponse = processor.signAndBroadcast();
SendTransactionResponse sendTransactionResponse = processor.signAndBroadcast();
```

## Android Example App
Expand Down
4 changes: 2 additions & 2 deletions eosiojava/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ dependencies {
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:2.26.0'
api 'org.bitcoinj:bitcoinj-core:0.15.2'
api 'org.slf4j:slf4j-jdk14:1.7.25'
implementation 'io.reactivex.rxjava2:rxjava:2.2.19'
}

def libraryGroupId = 'one.block'
def libraryArtifactId = 'eosiojava'
def libraryVersion = '0.1.2'
def libraryVersion = '0.2.0-amqp9'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what version do we actually want to bump this to?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Undetermined at this point. Currently the next release is targeted toward eosio-2.1 features and amqp support is not scheduled to be part of that release. If there is a need for it @brandonfancher should be consulted to put it into the release plan.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is needed to support our AMQP provider/plug-in, and we plan to use that on services in the near future so would like to merge this in @brandonfancher @opi-smccoole

task sourcesJar(type: Jar, dependsOn: classes){
classifier = 'sources'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@

import java.util.List;
import one.block.eosiojava.interfaces.IRPCProvider;
import one.block.eosiojava.interfaces.IAMQPProvider;
import one.block.eosiojava.interfaces.ISignatureProvider;
import one.block.eosiojava.models.AbiEosSerializationObject;
import one.block.eosiojava.models.EOSIOName;
import one.block.eosiojava.models.rpcProvider.request.GetBlockRequest;
import one.block.eosiojava.models.rpcProvider.request.GetRequiredKeysRequest;
import one.block.eosiojava.models.rpcProvider.request.PushTransactionRequest;
import one.block.eosiojava.models.rpcProvider.response.GetInfoResponse;
import one.block.eosiojava.models.signatureProvider.EosioTransactionSignatureRequest;
import one.block.eosiojava.session.TransactionProcessor;
import one.block.eosiojava.interfaces.IABIProvider;
import one.block.eosiojava.interfaces.ISerializationProvider;
import one.block.eosiojava.models.signatureProvider.EosioTransactionSignatureResponse;
import one.block.eosiojava.models.rpcProvider.response.GetRequiredKeysResponse;
import one.block.eosiojava.models.rpcProvider.request.SendTransactionRequest;

public class ErrorConstants {
private ErrorConstants(){
Expand Down Expand Up @@ -266,9 +267,14 @@ private ErrorConstants(){
public static final String TRANSACTION_PROCESSOR_GET_SIGN_DESERIALIZE_TRANS_ERROR = "Error happened on calling deserializeTransaction to refresh transaction object with new values";

/**
* Error message get thrown if {@link IRPCProvider#pushTransaction(PushTransactionRequest)} returns error.
* Error message get thrown if {@link IRPCProvider#sendTransaction(SendTransactionRequest)} returns error.
*/
public static final String TRANSACTION_PROCESSOR_RPC_PUSH_TRANSACTION = "Error happened on calling pushTransaction RPC call";
public static final String TRANSACTION_PROCESSOR_RPC_SEND_TRANSACTION = "Error happened on calling sendTransaction RPC call";

/**
* Error message get thrown if {@link IAMQPProvider#send(byte[])} returns error.
*/
public static final String TRANSACTION_PROCESSOR_AMQP_SEND_TRANSACTION = "Error happened on calling send AMQP call";

/**
* Error message get thrown if {@link TransactionProcessor#serialize()}
Expand All @@ -281,9 +287,9 @@ private ErrorConstants(){
public static final String TRANSACTION_PROCESSOR_SIGN_CREATE_SIGN_REQUEST_ERROR = "Error happened on creating signature request for Signature Provider to sign!";

/**
* Error message get thrown if error happens during pushing transaction to backend
* Error message get thrown if error happens during sending transaction to backend
*/
public static final String TRANSACTION_PROCESSOR_BROADCAST_TRANS_ERROR = "Error happened on pushing transaction to chain!";
public static final String TRANSACTION_PROCESSOR_BROADCAST_TRANS_ERROR = "Error happened on sending transaction to chain!";

/**
* Error message get thrown if required keys from {@link GetRequiredKeysResponse} is not subset of keys from {@link ISignatureProvider#getAvailableKeys()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@

/**
* Error class is used when there is an exception while attempting to use the RPC call,
* pushTransaction().
* sendTransaction().
*/
public class PushTransactionRpcError extends RpcProviderError {
public class SendTransactionRpcError extends RpcProviderError {

public PushTransactionRpcError() {
public SendTransactionRpcError() {
}

public PushTransactionRpcError(@NotNull String message) {
public SendTransactionRpcError(@NotNull String message) {
super(message);
}

public PushTransactionRpcError(@NotNull String message,
public SendTransactionRpcError(@NotNull String message,
@NotNull Exception exception) {
super(message, exception);
}

public PushTransactionRpcError(@NotNull Exception exception) {
public SendTransactionRpcError(@NotNull Exception exception) {
super(exception);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package one.block.eosiojava.error.serializationProvider;

import org.jetbrains.annotations.NotNull;

/**
* Error class is used when there is an exception while attempting to call deserializeTransaction()
* of Serialization Provider
*/
public class DeserializePackedTransactionError extends SerializationProviderError {

public DeserializePackedTransactionError() {
}

public DeserializePackedTransactionError(@NotNull String message) {
super(message);
}

public DeserializePackedTransactionError(@NotNull String message,
@NotNull Exception exception) {
super(message, exception);
}

public DeserializePackedTransactionError(@NotNull Exception exception) {
super(exception);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package one.block.eosiojava.error.serializationProvider;

import org.jetbrains.annotations.NotNull;

/**
* Error class is used when there is an exception while attempting to call serializeTransaction() of
* Serialization Provider
*/
public class SerializePackedTransactionError extends SerializationProviderError {

public SerializePackedTransactionError() {
}

public SerializePackedTransactionError(@NotNull String message) {
super(message);
}

public SerializePackedTransactionError(@NotNull String message,
@NotNull Exception exception) {
super(message, exception);
}

public SerializePackedTransactionError(@NotNull Exception exception) {
super(exception);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package one.block.eosiojava.error.session;

import org.jetbrains.annotations.NotNull;

/**
* Error class is used when there is an exception while attempting to call sendTransaction() of TransactionProcessor
*/
public class TransactionSendAmqpTransactionError extends TransactionProcessorError {

public TransactionSendAmqpTransactionError() {
}

public TransactionSendAmqpTransactionError(@NotNull String message) {
super(message);
}

public TransactionSendAmqpTransactionError(@NotNull String message,
@NotNull Exception exception) {
super(message, exception);
}

public TransactionSendAmqpTransactionError(@NotNull Exception exception) {
super(exception);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package one.block.eosiojava.error.session;

import org.jetbrains.annotations.NotNull;

/**
* Error class is used when there is an exception while attempting to call sendTransaction() of TransactionProcessor
*/
public class TransactionSendRpcTransactionError extends TransactionProcessorError {

public TransactionSendRpcTransactionError() {
}

public TransactionSendRpcTransactionError(@NotNull String message) {
super(message);
}

public TransactionSendRpcTransactionError(@NotNull String message,
@NotNull Exception exception) {
super(message, exception);
}

public TransactionSendRpcTransactionError(@NotNull Exception exception) {
super(exception);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package one.block.eosiojava.interfaces;

import io.reactivex.Completable;
import org.jetbrains.annotations.NotNull;

/**
* The interface of AMQP provider.
*/
public interface IAMQPProvider {

/**
* Sends an AMQP message to configured queue
*
* @param message the message to send to AMQP
* @return the response from the queue that message was received
*/
@NotNull
Completable send(byte[] message);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
import one.block.eosiojava.error.rpcProvider.GetInfoRpcError;
import one.block.eosiojava.error.rpcProvider.GetRawAbiRpcError;
import one.block.eosiojava.error.rpcProvider.GetRequiredKeysRpcError;
import one.block.eosiojava.error.rpcProvider.PushTransactionRpcError;
import one.block.eosiojava.error.rpcProvider.SendTransactionRpcError;
import one.block.eosiojava.models.rpcProvider.request.GetBlockRequest;
import one.block.eosiojava.models.rpcProvider.request.GetRawAbiRequest;
import one.block.eosiojava.models.rpcProvider.request.GetRequiredKeysRequest;
import one.block.eosiojava.models.rpcProvider.request.PushTransactionRequest;
import one.block.eosiojava.models.rpcProvider.request.SendTransactionRequest;
import one.block.eosiojava.models.rpcProvider.response.GetBlockResponse;
import one.block.eosiojava.models.rpcProvider.response.GetInfoResponse;
import one.block.eosiojava.models.rpcProvider.response.GetRawAbiResponse;
import one.block.eosiojava.models.rpcProvider.response.GetRequiredKeysResponse;
import one.block.eosiojava.models.rpcProvider.response.PushTransactionResponse;
import one.block.eosiojava.models.rpcProvider.response.SendTransactionResponse;
import org.jetbrains.annotations.NotNull;

/**
Expand Down Expand Up @@ -67,11 +67,11 @@ public interface IRPCProvider {
/**
* This method expects a transaction in JSON format and will attempt to apply it to the blockchain.
*
* @param pushTransactionRequest the transaction to push with signatures.
* @return the push transaction response
* @throws PushTransactionRpcError thrown if there are any exceptions/backend error during the
* pushTransaction() process.
* @param sendTransactionRequest the transaction to send with signatures.
* @return the send transaction response
* @throws SendTransactionRpcError thrown if there are any exceptions/backend error during the
* sendTransaction() process.
*/
@NotNull
PushTransactionResponse pushTransaction(PushTransactionRequest pushTransactionRequest) throws PushTransactionRpcError;
SendTransactionResponse sendTransaction(SendTransactionRequest sendTransactionRequest) throws SendTransactionRpcError;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import one.block.eosiojava.error.serializationProvider.DeserializeAbiError;
import one.block.eosiojava.error.serializationProvider.DeserializeError;
import one.block.eosiojava.error.serializationProvider.DeserializePackedTransactionError;
import one.block.eosiojava.error.serializationProvider.DeserializeTransactionError;
import one.block.eosiojava.error.serializationProvider.SerializeAbiError;
import one.block.eosiojava.error.serializationProvider.SerializeError;
import one.block.eosiojava.error.serializationProvider.SerializePackedTransactionError;
import one.block.eosiojava.error.serializationProvider.SerializeTransactionError;
import one.block.eosiojava.models.AbiEosSerializationObject;

Expand Down Expand Up @@ -76,4 +78,24 @@ public interface ISerializationProvider {
* conversion process.
*/
String serializeAbi(String json) throws SerializeAbiError;

/**
* Convenience method to transform a packed transaction (v0) hex string to a JSON string.
*
* @param hex - Hex string representing the packed transaction (v0) to deserialize.
* @return - Deserialized JSON string representing the transaction hex.
* @throws DeserializePackedTransactionError - A deserialization error is thrown if there are any exceptions during the
* * conversion process.
*/
String deserializePackedTransaction(String hex) throws DeserializePackedTransactionError;

/**
* Convenience method to transform a serialized transaction (v0) JSON string to a hex string.
*
* @param json - JSON string representing the serialized transaction (v0) to serialize.
* @return - Serialized hex string representing the transaction JSON.
* @throws SerializePackedTransactionError - A serialization error is thrown if there are any exceptions during the
* * conversion process.
*/
String serializePackedTransaction(String json) throws SerializePackedTransactionError;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package one.block.eosiojava.models.amqpProvider;

import one.block.eosiojava.models.rpcProvider.response.SendTransactionResponse;

public class AMQPMessageFailedResponse extends SendTransactionResponse {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package one.block.eosiojava.models.amqpProvider;

import one.block.eosiojava.models.rpcProvider.response.SendTransactionResponse;

public class AMQPMessageSuccessResponse extends SendTransactionResponse {
}
Loading