getSignatures() {
80 | return signatures;
81 | }
82 |
83 | /**
84 | * Gets error.
85 | *
86 | * @return the error
87 | */
88 | @Nullable
89 | public SignatureProviderError getError() {
90 | return error;
91 | }
92 |
93 | /**
94 | * Gets serialized context free data.
95 | *
96 | * @return the serialized context free data
97 | */
98 | @NotNull
99 | public String getSerializedContextFreeData() { return serializedContextFreeData; }
100 | }
101 |
--------------------------------------------------------------------------------
/eosiojava/src/main/java/one/block/eosiojava/models/signatureProvider/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Provides model classes for Signature provider {@link one.block.eosiojava.interfaces.ISignatureProvider}
3 | */
4 |
5 | package one.block.eosiojava.models.signatureProvider;
--------------------------------------------------------------------------------
/eosiojava/src/main/java/one/block/eosiojava/session/TransactionSession.java:
--------------------------------------------------------------------------------
1 | package one.block.eosiojava.session;
2 |
3 | import one.block.eosiojava.error.session.TransactionProcessorConstructorInputError;
4 | import one.block.eosiojava.interfaces.IABIProvider;
5 | import one.block.eosiojava.interfaces.IRPCProvider;
6 | import one.block.eosiojava.interfaces.ISerializationProvider;
7 | import one.block.eosiojava.interfaces.ISignatureProvider;
8 | import one.block.eosiojava.models.rpcProvider.Transaction;
9 | import org.jetbrains.annotations.NotNull;
10 |
11 | /**
12 | * Transaction Session class has a factory role for creating {@link TransactionProcessor} object from providers instances
13 | */
14 | public class TransactionSession {
15 |
16 | /**
17 | * Serialization provider to be used as a reference on {@link TransactionProcessor} object
18 | *
19 | * Responsible for serialization/deserialization between JSON and Hex for communicate with EOSIO chain
20 | */
21 | @NotNull
22 | private ISerializationProvider serializationProvider;
23 |
24 | /**
25 | * Rpc provider to be used as a reference on {@link TransactionProcessor} object
26 | *
27 | * Responsible for communicate with EOSIO chain
28 | */
29 | @NotNull
30 | private IRPCProvider rpcProvider;
31 |
32 | /**
33 | * ABI Provider to be used as a reference on {@link TransactionProcessor} object
34 | *
35 | * Responsible for managing ABIs for serialization/deserialization
36 | */
37 | @NotNull
38 | private IABIProvider abiProvider;
39 |
40 | /**
41 | * Signature provider to be used as a reference on {@link TransactionProcessor} object
42 | *
43 | * Responsible for managing keys, create signature to make transaction to EOSIO chain
44 | */
45 | @NotNull
46 | private ISignatureProvider signatureProvider;
47 |
48 | /**
49 | * Initialize TransactionSession object which acts like a factory to create {@link TransactionProcessor} object from providers instances.
50 | *
51 | * @param serializationProvider serialization provider.
52 | * @param rpcProvider Rpc provider.
53 | * @param abiProvider ABI provider.
54 | * @param signatureProvider signature provider.
55 | */
56 | public TransactionSession(
57 | @NotNull ISerializationProvider serializationProvider,
58 | @NotNull IRPCProvider rpcProvider, @NotNull IABIProvider abiProvider,
59 | @NotNull ISignatureProvider signatureProvider) {
60 | this.serializationProvider = serializationProvider;
61 | this.rpcProvider = rpcProvider;
62 | this.abiProvider = abiProvider;
63 | this.signatureProvider = signatureProvider;
64 | }
65 |
66 | /**
67 | * Create and return a new instance of TransactionProcessor
68 | *
69 | * @return new instance of TransactionProcessor
70 | */
71 | public TransactionProcessor getTransactionProcessor() {
72 | return new TransactionProcessor(this.serializationProvider, this.rpcProvider,
73 | this.abiProvider, this.signatureProvider);
74 | }
75 |
76 | /**
77 | * Create and return a new instance of TransactionProcessor with preset transaction
78 | *
79 | * @param transaction - preset transaction
80 | * @return new instance of TransactionProcessor
81 | * @throws TransactionProcessorConstructorInputError thrown if initializing {@link TransactionProcessor} get error.
82 | */
83 | public TransactionProcessor getTransactionProcessor(Transaction transaction) throws TransactionProcessorConstructorInputError {
84 | return new TransactionProcessor(this.serializationProvider, this.rpcProvider,
85 | this.abiProvider, this.signatureProvider, transaction);
86 | }
87 |
88 | //region getters
89 |
90 | /**
91 | * Get serialization provider to be used as a reference on {@link TransactionProcessor} object
92 | *
93 | * Responsible for serialization/deserialization between JSON and Hex for communicate with EOSIO chain
94 | * @return the serialization provider
95 | */
96 | @NotNull
97 | public ISerializationProvider getSerializationProvider() {
98 | return serializationProvider;
99 | }
100 |
101 | /**
102 | * Get rpc provider to be used as a reference on {@link TransactionProcessor} object
103 | *
104 | * Responsible for communicate with EOSIO chain
105 | * @return the rpc provider.
106 | */
107 | @NotNull
108 | public IRPCProvider getRpcProvider() {
109 | return rpcProvider;
110 | }
111 |
112 | /**
113 | * Get ABI Provider to be used as a reference on {@link TransactionProcessor} object
114 | *
115 | * Responsible for managing ABIs for serialization/deserialization
116 | * @return the rpc provider.
117 | */
118 | @NotNull
119 | public IABIProvider getAbiProvider() {
120 | return abiProvider;
121 | }
122 |
123 | /**
124 | * Get signature provider to be used as a reference on {@link TransactionProcessor} object
125 | *
126 | * Responsible for managing keys, create signature to make transaction to EOSIO chain
127 | * @return the signature provider.
128 | */
129 | @NotNull
130 | public ISignatureProvider getSignatureProvider() {
131 | return signatureProvider;
132 | }
133 | //endregion
134 | }
135 |
--------------------------------------------------------------------------------
/eosiojava/src/main/java/one/block/eosiojava/session/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Provides the core classes to handle transaction manipulation.
3 | */
4 |
5 | package one.block.eosiojava.session;
--------------------------------------------------------------------------------
/eosiojava/src/main/java/one/block/eosiojava/utilities/ByteFormatter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017-2019 block.one all rights reserved.
3 | */
4 |
5 | package one.block.eosiojava.utilities;
6 |
7 | import com.google.common.base.CharMatcher;
8 | import com.google.common.base.Strings;
9 | import org.bitcoinj.core.Sha256Hash;
10 | import org.bouncycastle.util.encoders.Base64;
11 | import org.bouncycastle.util.encoders.Hex;
12 | import org.jetbrains.annotations.NotNull;
13 |
14 | /**
15 | * This class provides methods for transforming and formatting byte data to and from different
16 | * formats in use on the blockchain.
17 | */
18 | public class ByteFormatter {
19 |
20 | private static final int BASE64_PADDING = 4;
21 | private static final char BASE64_PADDING_CHAR = '=';
22 |
23 | @NotNull
24 | private byte[] context;
25 |
26 | public ByteFormatter(@NotNull byte[] context) {
27 | this.context = context;
28 | }
29 |
30 | /**
31 | * Create and initialize a ByteFormatter from a Base64 encoded string. The Base64 string
32 | * will have its padding checked and adjusted if necessary.
33 | *
34 | * @param base64String - Base64 encoded string.
35 | * @return - Initialized ByteFormatter
36 | */
37 | public static ByteFormatter createFromBase64(@NotNull String base64String) {
38 | // Base64 encoded strings must be an even multiple of 4 if they are handled with padding.
39 | // The strings that we get back from the blockchain in the JSON do not follow this
40 | // strictly so we have to adjust the string if necessary before decoding. The padding
41 | // character is '='. So we remove all existing padding characters and then pad the
42 | // string to the nearest multiple of 4.
43 | String trimmed = CharMatcher.is(BASE64_PADDING_CHAR).removeFrom(base64String);
44 | String padded = Strings.padEnd(trimmed,
45 | (trimmed.length() + BASE64_PADDING - 1) / BASE64_PADDING * BASE64_PADDING,
46 | BASE64_PADDING_CHAR);
47 | return new ByteFormatter(Base64.decode(padded));
48 | }
49 |
50 | /**
51 | * Create and initialize a ByteFormatter from a hex encoded string.
52 | *
53 | * @param hexString - Hex encoded string.
54 | * @return - Initialized ByteFormatter
55 | */
56 | public static ByteFormatter createFromHex(@NotNull String hexString) {
57 | byte[] data = Hex.decode(hexString);
58 | return new ByteFormatter(data);
59 | }
60 |
61 | /**
62 | * Convert the current ByteFormatter contents to a Hex encoded string and return it.
63 | * @return - Hex encoded string representation of the current formatter context.
64 | */
65 | public String toHex() {
66 | return Hex.toHexString(this.context);
67 | }
68 |
69 | /**
70 | * Calculate the sha256 hash of the current ByteFormatter context and return it as a new
71 | * ByteFormatter.
72 | *
73 | * @return - New ByteFormatter containing the sha256 hash of the current one.
74 | */
75 | public ByteFormatter sha256() {
76 | return new ByteFormatter(Sha256Hash.hash(this.context));
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/eosiojava/src/main/java/one/block/eosiojava/utilities/DateFormatter.java:
--------------------------------------------------------------------------------
1 | package one.block.eosiojava.utilities;
2 |
3 | import java.text.ParseException;
4 | import java.text.SimpleDateFormat;
5 | import java.util.Calendar;
6 | import java.util.Date;
7 | import java.util.TimeZone;
8 |
9 | /**
10 | * This class provides utility methods to handle the formatting of dates and times to supported patterns.
11 | */
12 | public class DateFormatter {
13 |
14 | /**
15 | * Blockchain pattern for SimpleDateFormat
16 | */
17 | public static final String BACKEND_DATE_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSS";
18 |
19 | /**
20 | * Blockchain pattern for SimpleDateFormat. It includes timezone.
21 | */
22 | public static final String BACKEND_DATE_PATTERN_WITH_TIMEZONE = "yyyy-MM-dd'T'HH:mm:ss.SSS zzz";
23 |
24 | /**
25 | * Blockchain timezone/time standard for SimpleDateFormat
26 | */
27 | public static final String BACKEND_DATE_TIME_ZONE = "UTC";
28 |
29 | private DateFormatter() {}
30 |
31 | /**
32 | * Converting backend time to millisecond.
33 | *
34 | * Backend time pattern "yyyy-MM-dd'T'HH:mm:ss.sss" in GMT.
35 | * @param backendTime input backend time.
36 | * @return Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by parsed input backend time.
37 | * @throws ParseException thrown if the input does not match with any supported datetime pattern.
38 | */
39 | public static long convertBackendTimeToMilli(String backendTime) throws ParseException {
40 | String[] datePatterns = new String[]{
41 | BACKEND_DATE_PATTERN, BACKEND_DATE_PATTERN_WITH_TIMEZONE
42 | };
43 |
44 | for (String datePattern : datePatterns) {
45 | try {
46 | SimpleDateFormat sdf = new SimpleDateFormat(datePattern);
47 | sdf.setTimeZone(TimeZone.getTimeZone(BACKEND_DATE_TIME_ZONE));
48 | Date parsedDate = sdf.parse(backendTime);
49 | return parsedDate.getTime();
50 | } catch (ParseException ex) {
51 | // Keep going even if exception is thrown for trying different date pattern
52 | } catch (IllegalArgumentException ex) {
53 | // Keep going even if exception is thrown for trying different date pattern
54 | }
55 | }
56 |
57 | throw new ParseException("Unable to parse input backend time with supported date patterns!", 0);
58 | }
59 |
60 | /**
61 | * Convert milliseconds to time string format used on blockchain.
62 | *
63 | * Backend time pattern "yyyy-MM-dd'T'HH:mm:ss.sss" in GMT
64 | * @param timeInMilliSeconds input number of milliseconds
65 | * @return String format of input number of milliseconds
66 | */
67 | public static String convertMilliSecondToBackendTimeString(long timeInMilliSeconds) {
68 | SimpleDateFormat sdf = new SimpleDateFormat(BACKEND_DATE_PATTERN);
69 | sdf.setTimeZone(TimeZone.getTimeZone(BACKEND_DATE_TIME_ZONE));
70 |
71 | Calendar calendar = Calendar.getInstance();
72 | calendar.setTimeInMillis(timeInMilliSeconds);
73 |
74 | return sdf.format(calendar.getTime());
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/eosiojava/src/main/java/one/block/eosiojava/utilities/Utils.java:
--------------------------------------------------------------------------------
1 | package one.block.eosiojava.utilities;
2 |
3 | import com.google.gson.Gson;
4 | import com.google.gson.GsonBuilder;
5 | import java.io.ByteArrayInputStream;
6 | import java.io.ByteArrayOutputStream;
7 | import java.io.IOException;
8 | import java.io.ObjectInputStream;
9 | import java.io.ObjectOutputStream;
10 | import java.io.Serializable;
11 |
12 | /**
13 | * This class provides generic utility methods
14 | */
15 | public class Utils {
16 |
17 | private Utils() {}
18 |
19 | /**
20 | * Clone an object
21 | *
22 | * @param object input object
23 | * @param - Class of the object
24 | * @return the cloned object.
25 | * @throws IOException Any exception thrown by the underlying OutputStream.
26 | * @throws ClassNotFoundException Class of a serialized object cannot be found.
27 | */
28 | public static T clone(T object) throws IOException, ClassNotFoundException {
29 | ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
30 | ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
31 | objectOutputStream.writeObject(object); // Could clone only the Transaction (i.e. this.transaction)
32 | ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
33 | ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream);
34 | return (T) objectInputStream.readObject();
35 | }
36 |
37 | /**
38 | * Getting a GSON object with a date time pattern
39 | * @param datePattern - input date time pattern
40 | * @return Configured GSON object with input.
41 | */
42 | public static Gson getGson(String datePattern) {
43 | return new GsonBuilder()
44 | .setDateFormat(datePattern)
45 | .disableHtmlEscaping()
46 | .create();
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/eosiojava/src/main/java/one/block/eosiojava/utilities/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Provides the utility classes to support handling key conversion, byte handling, datetime handling and pem processing.
3 | */
4 |
5 | package one.block.eosiojava.utilities;
--------------------------------------------------------------------------------
/eosiojava/src/test/java/one/block/eosiojava/DateFormatterTest.java:
--------------------------------------------------------------------------------
1 | package one.block.eosiojava;
2 |
3 | import java.text.ParseException;
4 | import one.block.eosiojava.utilities.DateFormatter;
5 | import org.junit.Assert;
6 | import org.junit.Test;
7 |
8 | public class DateFormatterTest {
9 |
10 | @Test
11 | public void testConvertBackendTimeToMilli() throws ParseException {
12 | this.convertStrDateToMilliAndVerify("2019-09-11T19:38:05.000");
13 | this.convertStrDateToMilliAndVerify("2019-01-01T19:38:05.000");
14 | this.convertStrDateToMilliAndVerify("2019-09-11T00:38:05.000");
15 | this.convertStrDateToMilliAndVerify("2019-09-11T00:00:00.000");
16 | this.convertStrDateToMilliAndVerify("2019-01-01T00:00:00.000");
17 | this.convertStrDateToMilliAndVerify("1900-01-01T00:00:00.000");
18 | }
19 |
20 | @Test
21 | public void testIncreaseTime() throws ParseException {
22 | this.increaseTimeByMilliSecondToStrDateAndVerify("2019-09-11T19:38:05.000", 300 * 1000,
23 | "2019-09-11T19:43:05.000");
24 | this.increaseTimeByMilliSecondToStrDateAndVerify("2019-01-01T19:38:05.000", 180 * 1000,
25 | "2019-01-01T19:41:05.000");
26 | this.increaseTimeByMilliSecondToStrDateAndVerify("2019-09-11T00:38:05.000", 600 * 1000,
27 | "2019-09-11T00:48:05.000");
28 | this.increaseTimeByMilliSecondToStrDateAndVerify("2019-09-11T00:00:00.000", 300 * 1000,
29 | "2019-09-11T00:05:00.000");
30 | this.increaseTimeByMilliSecondToStrDateAndVerify("2019-01-01T00:00:00.000", 300 * 1000,
31 | "2019-01-01T00:05:00.000");
32 | this.increaseTimeByMilliSecondToStrDateAndVerify("1900-01-01T00:00:00.000", 300 * 1000,
33 | "1900-01-01T00:05:00.000");
34 | }
35 |
36 | private void convertStrDateToMilliAndVerify(String strDate) throws ParseException {
37 | long milliSeconds = DateFormatter.convertBackendTimeToMilli(strDate);
38 | String convertedStrDate = DateFormatter.convertMilliSecondToBackendTimeString(milliSeconds);
39 | Assert.assertEquals(strDate, convertedStrDate);
40 | }
41 |
42 | private void increaseTimeByMilliSecondToStrDateAndVerify(String strDate,
43 | long appendMilliSeconds, String strDateAfterAppended)
44 | throws ParseException {
45 | long milliSeconds = DateFormatter.convertBackendTimeToMilli(strDate);
46 | milliSeconds += appendMilliSeconds;
47 | String convertedStrDate = DateFormatter.convertMilliSecondToBackendTimeString(milliSeconds);
48 | Assert.assertEquals(strDateAfterAppended, convertedStrDate);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/eosiojava/src/test/java/one/block/eosiojava/EosioErrorTest.java:
--------------------------------------------------------------------------------
1 |
2 |
3 | package one.block.eosiojava;
4 |
5 | import one.block.eosiojava.error.EosioError;
6 | import one.block.eosiojava.error.serializationProvider.SerializationProviderError;
7 | import org.junit.Test;
8 |
9 | import java.io.IOException;
10 |
11 | import static org.junit.Assert.*;
12 |
13 | public class EosioErrorTest {
14 |
15 | @Test
16 | public void errroMessage() {
17 | EosioError err = new EosioError("Parsing Error!");
18 | String description = err.getLocalizedMessage();
19 | assertEquals("Parsing Error!", description);
20 |
21 | Exception origError = new IOException("File Not Found");
22 | EosioError err2 = new EosioError(
23 | "Could not find resource.",
24 | origError);
25 | assertEquals("Could not find resource.", err2.getLocalizedMessage());
26 |
27 | assertEquals("File Not Found", err2.getCause().getMessage());
28 | }
29 |
30 | @Test
31 | public void asJsonString() {
32 | String jsonResult = "{\n" +
33 | " \"errorType\": \"EosioError\",\n" +
34 | " \"errorInfo\": {\n" +
35 | " \"errorCode\": \"SerializationProviderError\",\n" +
36 | " \"reason\": \"Serialization Provider Failure\"\n" +
37 | " }\n" +
38 | "}";
39 | SerializationProviderError err2 = new SerializationProviderError("Serialization Provider Failure");
40 | String errJsonString = err2.asJsonString();
41 | assertEquals(jsonResult, errJsonString);
42 | }
43 |
44 | }
--------------------------------------------------------------------------------
/eosiojava/src/test/java/one/block/eosiojava/models/ActionTest.java:
--------------------------------------------------------------------------------
1 | package one.block.eosiojava.models;
2 |
3 | import java.util.ArrayList;
4 | import one.block.eosiojava.models.rpcProvider.Action;
5 | import one.block.eosiojava.models.rpcProvider.Authorization;
6 | import org.junit.Test;
7 | import static junit.framework.TestCase.*;
8 |
9 | public class ActionTest {
10 | Action action;
11 |
12 | public void setup() {
13 | action = new Action("Account", "Name", new ArrayList(), "{\"data\": \"test\"}");
14 | }
15 |
16 | public void setup(boolean isContextFree) {
17 | action = new Action("Account", "Name", new ArrayList(), "{\"data\": \"test\"}", isContextFree);
18 | }
19 |
20 | @Test
21 | public void testCreateActionWithDefaultConstructor() {
22 | this.setup();
23 | assertFalse(action.getIsContextFree());
24 | }
25 |
26 | @Test
27 | public void testCreateActionWithOverloadedConstructor() {
28 | this.setup(false);
29 | assertFalse(action.getIsContextFree());
30 | }
31 |
32 | @Test
33 | public void testCreateContextFreeActionWithOverloadedConstructor() {
34 | this.setup(true);
35 | assertTrue(action.getIsContextFree());
36 | }
37 |
38 | @Test
39 | public void testSetIsContextFree() {
40 | this.setup();
41 | action.setIsContextFree(true);
42 |
43 | assertTrue(action.getIsContextFree());
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/eosiojava/src/test/java/one/block/eosiojava/models/EosioTransactionSignatureRequestTest.java:
--------------------------------------------------------------------------------
1 | package one.block.eosiojava.models;
2 |
3 | import java.util.ArrayList;
4 | import one.block.eosiojava.models.signatureProvider.BinaryAbi;
5 | import one.block.eosiojava.models.signatureProvider.EosioTransactionSignatureRequest;
6 | import org.bouncycastle.util.encoders.Hex;
7 | import org.junit.Test;
8 | import static junit.framework.TestCase.*;
9 |
10 | public class EosioTransactionSignatureRequestTest {
11 | EosioTransactionSignatureRequest request;
12 |
13 | public void setup() {
14 | this.setup(null);
15 | }
16 |
17 | public void setup(String contextFreeData) {
18 | if (contextFreeData == null) {
19 | request = new EosioTransactionSignatureRequest("", new ArrayList(), "", new ArrayList(), false);
20 | } else {
21 | request = new EosioTransactionSignatureRequest("", new ArrayList(), "", new ArrayList(), false, contextFreeData);
22 | }
23 | }
24 |
25 | @Test
26 | public void testCreateWithoutContextFreeDataSetsTo32Zeros() {
27 | this.setup();
28 |
29 | assertEquals(request.getSerializedContextFreeData(), Hex.toHexString(new byte[32]));
30 | }
31 |
32 | @Test
33 | public void testCreateWithContextFreeDataSetsParameter() {
34 | String serializedContextFreeData = "6595140530fcbd94469196e5e6d73af65693910df8fcf5d3088c3616bff5ee9f";
35 | this.setup(serializedContextFreeData);
36 |
37 | assertEquals(request.getSerializedContextFreeData(), serializedContextFreeData);
38 | }
39 |
40 | @Test
41 | public void testSetSerializedContextFreeDataWithEmptyStringSetsTo32Zeros() {
42 | String serializedContextFreeData = Hex.toHexString(new byte[32]);
43 | this.setup();
44 |
45 | request.setSerializedContextFreeData("");
46 |
47 | assertEquals(request.getSerializedContextFreeData(), serializedContextFreeData);
48 | }
49 |
50 | @Test
51 | public void testSetSerializedContextFreeDataWithDataReturnsData() {
52 | String serializedContextFreeData = "6595140530fcbd94469196e5e6d73af65693910df8fcf5d3088c3616bff5ee9f";
53 | this.setup();
54 |
55 | request.setSerializedContextFreeData(serializedContextFreeData);
56 |
57 | assertEquals(request.getSerializedContextFreeData(), serializedContextFreeData);
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/eosiojava/src/test/java/one/block/eosiojava/session/TransactionSessionTest.java:
--------------------------------------------------------------------------------
1 | package one.block.eosiojava.session;
2 |
3 | import static org.junit.Assert.assertNotNull;
4 | import static org.mockito.Mockito.mock;
5 |
6 | import one.block.eosiojava.interfaces.IABIProvider;
7 | import one.block.eosiojava.interfaces.IRPCProvider;
8 | import one.block.eosiojava.interfaces.ISerializationProvider;
9 | import one.block.eosiojava.interfaces.ISignatureProvider;
10 | import org.junit.Before;
11 | import org.junit.Test;
12 |
13 | public class TransactionSessionTest {
14 |
15 | private TransactionSession session;
16 |
17 | @Before
18 | public void setUpTransactionSession() {
19 | this.session = new TransactionSession(
20 | mock(ISerializationProvider.class),
21 | mock(IRPCProvider.class),
22 | mock(IABIProvider.class),
23 | mock(ISignatureProvider.class));
24 | }
25 |
26 | @Test
27 | public void getTransactionProcessor() {
28 | TransactionProcessor processor = this.session.getTransactionProcessor();
29 | assertNotNull(processor);
30 | }
31 |
32 | @Test
33 | public void getSerializationProvider() {
34 | assertNotNull(this.session.getSerializationProvider());
35 | }
36 |
37 | @Test
38 | public void getRpcProvider() {
39 | assertNotNull(this.session.getRpcProvider());
40 | }
41 |
42 | @Test
43 | public void getAbiProvider() {
44 | assertNotNull(this.session.getAbiProvider());
45 | }
46 |
47 | @Test
48 | public void getSignatureProvider() {
49 | assertNotNull(this.session.getSignatureProvider());
50 | }
51 | }
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EOSIO/eosio-java/dd0dbd2e6e15a5ac799de40c633126b90e82116e/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Mar 08 19:34:29 CST 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-bin.zip
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/img/Android_Robot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EOSIO/eosio-java/dd0dbd2e6e15a5ac799de40c633126b90e82116e/img/Android_Robot.png
--------------------------------------------------------------------------------
/img/java-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EOSIO/eosio-java/dd0dbd2e6e15a5ac799de40c633126b90e82116e/img/java-logo.png
--------------------------------------------------------------------------------
/scripts/deploy-artifactory.sh:
--------------------------------------------------------------------------------
1 | DEST_REPO=$1 && \
2 | echo "publishing to $DEST_REPO on Artifactory" && \
3 | ./gradlew clean artifactoryPublish -Partifactory_repo=$DEST_REPO
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':eosiojava'
2 |
--------------------------------------------------------------------------------