diff --git a/core/pom.xml b/core/pom.xml index 949f2589..e8dfcffe 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -177,7 +177,7 @@ 2.2 1.15 2.10.0 - 3.9 + 3.8 2.6 1.7.26 2.12.1 diff --git a/core/src/main/java/eu/bittrade/libs/steemj/enums/RequestMethod.java b/core/src/main/java/eu/bittrade/libs/steemj/enums/RequestMethod.java index b85330ac..41bc9152 100644 --- a/core/src/main/java/eu/bittrade/libs/steemj/enums/RequestMethod.java +++ b/core/src/main/java/eu/bittrade/libs/steemj/enums/RequestMethod.java @@ -32,6 +32,8 @@ public enum RequestMethod { GET_TRANSACTION, /** Get the full history of an account. */ GET_ACCOUNT_HISTORY, + /** Receive virtual operations for blocks. */ + ENUM_VIRTUAL_OPS, // block_api /** */ GET_BLOCK, @@ -273,6 +275,6 @@ public enum RequestMethod { GET_ACCOUNT_BANDWIDTH, /** */ GET_REVERSE_RATIO, - + GET_LIQUIDITY_QUEUE } diff --git a/core/src/main/java/eu/bittrade/libs/steemj/plugins/apis/account/history/AccountHistoryApi.java b/core/src/main/java/eu/bittrade/libs/steemj/plugins/apis/account/history/AccountHistoryApi.java index 21a7d1a2..8adac800 100644 --- a/core/src/main/java/eu/bittrade/libs/steemj/plugins/apis/account/history/AccountHistoryApi.java +++ b/core/src/main/java/eu/bittrade/libs/steemj/plugins/apis/account/history/AccountHistoryApi.java @@ -22,11 +22,14 @@ import eu.bittrade.libs.steemj.enums.SteemApiType; import eu.bittrade.libs.steemj.exceptions.SteemCommunicationException; import eu.bittrade.libs.steemj.exceptions.SteemResponseException; +import eu.bittrade.libs.steemj.plugins.apis.account.history.models.EnumVirtualOps; +import eu.bittrade.libs.steemj.plugins.apis.account.history.models.EnumVirtualOpsArgs; import eu.bittrade.libs.steemj.plugins.apis.account.history.models.GetAccountHistoryArgs; import eu.bittrade.libs.steemj.plugins.apis.account.history.models.GetAccountHistoryReturn; import eu.bittrade.libs.steemj.plugins.apis.account.history.models.GetOpsInBlockArgs; import eu.bittrade.libs.steemj.plugins.apis.account.history.models.GetOpsInBlockReturn; import eu.bittrade.libs.steemj.protocol.AnnotatedSignedTransaction; +import eu.bittrade.libs.steemj.protocol.TransactionId; /** * This class implements the "account_history_api". @@ -71,22 +74,26 @@ private AccountHistoryApi() { * */ public static GetOpsInBlockReturn getOpsInBlock(CommunicationHandler communicationHandler, - GetOpsInBlockArgs getOpsInBlockArgs) throws SteemCommunicationException, SteemResponseException { - JsonRPCRequest requestObject = new JsonRPCRequest(SteemApiType.ACCOUNT_HISTORY_API, + GetOpsInBlockArgs getOpsInBlockArgs) throws SteemCommunicationException, SteemResponseException { + JsonRPCRequest requestObject = new JsonRPCRequest(SteemApiType.ACCOUNT_HISTORY_API, RequestMethod.GET_OPS_IN_BLOCK, getOpsInBlockArgs); return communicationHandler.performRequest(requestObject, GetOpsInBlockReturn.class).get(0); } /** - * Find a transaction by its transactionId. + * Returns the details of a transaction based on a + * transactionId. * + * @deprecated According to + * https://developers.steem.io/apidefinitions/#apidefinitions-account-history-api + * this method is deprecated. * @param communicationHandler * A * {@link eu.bittrade.libs.steemj.communication.CommunicationHandler * CommunicationHandler} instance that should be used to send the * request. - * @param transactionId + * @param getTransactionArgs * The transactionId to search for. * @return A sequence of operations included/generated within a particular * block. @@ -105,8 +112,9 @@ public static GetOpsInBlockReturn getOpsInBlock(CommunicationHandler communicati *
  • If the Server returned an error object.
  • * */ + @Deprecated public static AnnotatedSignedTransaction getTransaction(CommunicationHandler communicationHandler, - GetAccountHistoryArgs getTransactionArgs) throws SteemCommunicationException, SteemResponseException { + TransactionId getTransactionArgs) throws SteemCommunicationException, SteemResponseException { JsonRPCRequest requestObject = new JsonRPCRequest(SteemApiType.ACCOUNT_HISTORY_API, RequestMethod.GET_TRANSACTION, getTransactionArgs); @@ -151,4 +159,40 @@ public static GetAccountHistoryReturn getAccountHistory(CommunicationHandler com return communicationHandler.performRequest(requestObject, GetAccountHistoryReturn.class).get(0); } + + /** + * Get all virtual operations in a specified range of blocks.. + * + * @param communicationHandler + * A + * {@link eu.bittrade.libs.steemj.communication.CommunicationHandler + * CommunicationHandler} instance that should be used to send the + * request. + * @param enumVirtualOpsArgs + * The user name of the account. + * @return A list of + * {@link eu.bittrade.libs.steemj.plugins.apis.account.history.models.AppliedOperation + * AppliedOperations}. + * @throws SteemCommunicationException + * + * @throws SteemResponseException + * + */ + public static EnumVirtualOps enumVirtualOps(CommunicationHandler communicationHandler, + EnumVirtualOpsArgs enumVirtualOpsArgs) throws SteemCommunicationException, SteemResponseException { + JsonRPCRequest requestObject = new JsonRPCRequest(SteemApiType.ACCOUNT_HISTORY_API, + RequestMethod.ENUM_VIRTUAL_OPS, enumVirtualOpsArgs); + + return communicationHandler.performRequest(requestObject, EnumVirtualOps.class).get(0); + } } diff --git a/core/src/main/java/eu/bittrade/libs/steemj/plugins/apis/account/history/models/AppliedOperation.java b/core/src/main/java/eu/bittrade/libs/steemj/plugins/apis/account/history/models/AppliedOperation.java index 7b414a3f..217e2d97 100644 --- a/core/src/main/java/eu/bittrade/libs/steemj/plugins/apis/account/history/models/AppliedOperation.java +++ b/core/src/main/java/eu/bittrade/libs/steemj/plugins/apis/account/history/models/AppliedOperation.java @@ -24,8 +24,8 @@ import com.fasterxml.jackson.annotation.JsonProperty; import eu.bittrade.libs.steemj.fc.TimePointSec; +import eu.bittrade.libs.steemj.plugins.apis.account.history.models.deserializer.OperationWrapper; import eu.bittrade.libs.steemj.protocol.TransactionId; -import eu.bittrade.libs.steemj.protocol.operations.Operation; /** * This class is the java implementation of the Steem "api_operation_object" @@ -51,7 +51,7 @@ public class AppliedOperation { @JsonProperty("timestamp") private TimePointSec timestamp; @JsonProperty("op") - private Operation op; + private OperationWrapper operationWrapper; /** * This object is only used to wrap the JSON response in a POJO, so @@ -79,27 +79,27 @@ public UInteger getBlock() { } /** - * Get the index of the transaction inside the block. + * Get the number of transactions inside the block. * - * @return The transaction index in the block. + * @return The number of transactions inside the block. */ public UInteger getTrxInBlock() { return trxInBlock; } /** - * Get the index of the operation inside the transaction. + * Get the number of operations inside the transaction. * - * @return The operation index in the transaction. + * @return The number of operations inside the transaction. */ public UShort getOpInTrx() { return opInTrx; } /** - * Get the index of the virtual operation inside the transaction. + * Get the number of virtual operations inside the transaction. * - * @return The virtual operation index in the transaction. + * @return The number of virtual operations inside the transaction. */ public ULong getVirtualOp() { return virtualOp; @@ -115,12 +115,12 @@ public TimePointSec getTimestamp() { } /** - * Get the whole operation object. + * Get a wrapper object which stores the whole operation object. * * @return The operation object. */ - public Operation getOp() { - return op; + public OperationWrapper getOperationWrapper() { + return operationWrapper; } @Override diff --git a/core/src/main/java/eu/bittrade/libs/steemj/plugins/apis/account/history/models/EnumVirtualOps.java b/core/src/main/java/eu/bittrade/libs/steemj/plugins/apis/account/history/models/EnumVirtualOps.java new file mode 100644 index 00000000..15ab0c08 --- /dev/null +++ b/core/src/main/java/eu/bittrade/libs/steemj/plugins/apis/account/history/models/EnumVirtualOps.java @@ -0,0 +1,56 @@ +/* + * This file is part of SteemJ (formerly known as 'Steem-Java-Api-Wrapper') + * + * SteemJ is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SteemJ is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with SteemJ. If not, see . + */ +package eu.bittrade.libs.steemj.plugins.apis.account.history.models; + +import java.util.List; + +import org.joou.UInteger; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * This class implements the Steem "enum_virtual_ops_return" object. + * + * @author dez1337 + */ +public class EnumVirtualOps { + @JsonProperty("ops") + private List operations; + @JsonProperty("next_block_range_begin") + private UInteger nextBlockRangeBegin; + + /** + * This object is only used to wrap the JSON response in a POJO, so + * therefore this class should not be instantiated. + */ + private EnumVirtualOps() { + } + + /**TODO + * @return the operations + */ + public List getOperations() { + return operations; + } + + /**TODO + * @return the nextBlockRangeBegin + */ + public UInteger getNextBlockRangeBegin() { + return nextBlockRangeBegin; + } +} diff --git a/core/src/main/java/eu/bittrade/libs/steemj/plugins/apis/account/history/models/EnumVirtualOpsArgs.java b/core/src/main/java/eu/bittrade/libs/steemj/plugins/apis/account/history/models/EnumVirtualOpsArgs.java new file mode 100644 index 00000000..efc42856 --- /dev/null +++ b/core/src/main/java/eu/bittrade/libs/steemj/plugins/apis/account/history/models/EnumVirtualOpsArgs.java @@ -0,0 +1,68 @@ +/* + * This file is part of SteemJ (formerly known as 'Steem-Java-Api-Wrapper') + * + * SteemJ is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SteemJ is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with SteemJ. If not, see . + */ +package eu.bittrade.libs.steemj.plugins.apis.account.history.models; + +import org.apache.commons.lang3.Validate; +import org.joou.UInteger; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * This class implements the Steem "enum_virtual_ops_args" object. + * + * @author dez1337 + */ +public class EnumVirtualOpsArgs { + @JsonProperty("block_range_begin") + private UInteger blockRangeBegin; + @JsonProperty("block_range_end") + private UInteger blockRangeEnd; + + public static class Builder { + private UInteger blockRangeBegin; + private UInteger blockRangeEnd; + + public Builder() { + this.blockRangeBegin = UInteger.valueOf(1); + this.blockRangeEnd = UInteger.valueOf(2); + } + + public Builder startAt(UInteger startBlock) { + this.blockRangeBegin = Validate.notNull(startBlock); + return this; + } + + public Builder endAt(UInteger endBlock) { + this.blockRangeEnd = Validate.notNull(endBlock); + return this; + } + + public EnumVirtualOpsArgs build() { + EnumVirtualOpsArgs enumVirtualOpsArgs = new EnumVirtualOpsArgs(); + enumVirtualOpsArgs.blockRangeBegin = this.blockRangeBegin; + enumVirtualOpsArgs.blockRangeEnd = this.blockRangeEnd; + return enumVirtualOpsArgs; + } + } + + @JsonCreator() + private EnumVirtualOpsArgs() { + + } + +} diff --git a/core/src/main/java/eu/bittrade/libs/steemj/plugins/apis/account/history/models/GetAccountHistoryReturn.java b/core/src/main/java/eu/bittrade/libs/steemj/plugins/apis/account/history/models/GetAccountHistoryReturn.java index d520973f..52223b43 100644 --- a/core/src/main/java/eu/bittrade/libs/steemj/plugins/apis/account/history/models/GetAccountHistoryReturn.java +++ b/core/src/main/java/eu/bittrade/libs/steemj/plugins/apis/account/history/models/GetAccountHistoryReturn.java @@ -19,7 +19,6 @@ import java.util.Map; import org.apache.commons.lang3.builder.ToStringBuilder; -import org.joou.UInteger; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; @@ -34,7 +33,7 @@ public class GetAccountHistoryReturn { @JsonProperty("history") @JsonDeserialize(using = AppliedOperationHashMapDeserializer.class) - private Map history; + private Map history; /** * This object is only used to wrap the JSON response in a POJO, so @@ -51,7 +50,7 @@ private GetAccountHistoryReturn() { * * @return A map of operations and their id. */ - public Map getHistory() { + public Map getHistory() { return history; } diff --git a/core/src/main/java/eu/bittrade/libs/steemj/plugins/apis/account/history/models/GetTransactionArgs.java b/core/src/main/java/eu/bittrade/libs/steemj/plugins/apis/account/history/models/GetTransactionArgs.java deleted file mode 100644 index 7d971db8..00000000 --- a/core/src/main/java/eu/bittrade/libs/steemj/plugins/apis/account/history/models/GetTransactionArgs.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * This file is part of SteemJ (formerly known as 'Steem-Java-Api-Wrapper') - * - * SteemJ is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * SteemJ is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with SteemJ. If not, see . - */ -package eu.bittrade.libs.steemj.plugins.apis.account.history.models; - -import java.security.InvalidParameterException; - -import org.apache.commons.lang3.builder.ToStringBuilder; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import eu.bittrade.libs.steemj.communication.CommunicationHandler; -import eu.bittrade.libs.steemj.plugins.apis.account.history.AccountHistoryApi; -import eu.bittrade.libs.steemj.protocol.TransactionId; -import eu.bittrade.libs.steemj.util.SteemJUtils; - -/** - * This class implements the Steem "get_transaction_args" object. - * - * @author dez1337 - */ -public class GetTransactionArgs { - @JsonProperty("id") - private TransactionId id; - - /** - * Create a new {@link GetAccountHistoryArgs} instance to be passed to the - * {@link AccountHistoryApi#getAccountHistory(CommunicationHandler, GetAccountHistoryArgs)} - * method. - * - * @param id - * The {@link TransactionId} to set. - */ - @JsonCreator() - public GetTransactionArgs(@JsonProperty("id") TransactionId id) { - this.setId(id); - } - - /** - * @return The {@link TransactionId} wrapped by this instance. - */ - public TransactionId getId() { - return id; - } - - /** - * Override the current {@link TransactionId} wrapped by this instance. - * Please notice that the id is required. If not provided, the - * method will throw an {@link InvalidParameterException}. - * - * @param id - * The {@link TransactionId} to set. - * @throws InvalidParameterException - * If the id is null. - */ - public void setId(TransactionId id) { - this.id = SteemJUtils.setIfNotNull(id, "The id cannot be null."); - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this); - } -} diff --git a/core/src/main/java/eu/bittrade/libs/steemj/plugins/apis/account/history/models/deserializer/AppliedOperationHashMapDeserializer.java b/core/src/main/java/eu/bittrade/libs/steemj/plugins/apis/account/history/models/deserializer/AppliedOperationHashMapDeserializer.java index bf98868c..200f30f8 100644 --- a/core/src/main/java/eu/bittrade/libs/steemj/plugins/apis/account/history/models/deserializer/AppliedOperationHashMapDeserializer.java +++ b/core/src/main/java/eu/bittrade/libs/steemj/plugins/apis/account/history/models/deserializer/AppliedOperationHashMapDeserializer.java @@ -20,8 +20,6 @@ import java.util.HashMap; import java.util.Map; -import org.joou.UInteger; - import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.ObjectCodec; import com.fasterxml.jackson.core.TreeNode; @@ -40,19 +38,19 @@ * * @author dez1337 */ -public class AppliedOperationHashMapDeserializer extends JsonDeserializer> { +public class AppliedOperationHashMapDeserializer extends JsonDeserializer> { @Override - public Map deserialize(JsonParser jsonParser, - DeserializationContext deserializationContext) throws IOException { + public Map deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) + throws IOException { - HashMap result = new HashMap<>(); + HashMap result = new HashMap<>(); ObjectCodec codec = jsonParser.getCodec(); TreeNode rootNode = codec.readTree(jsonParser); if (rootNode.isArray()) { for (JsonNode node : (ArrayNode) rootNode) { - result.put(UInteger.valueOf(node.get(0).asLong()), + result.put(node.get(0).asLong(), CommunicationHandler.getObjectMapper().treeToValue(node.get(1), AppliedOperation.class)); } diff --git a/core/src/main/java/eu/bittrade/libs/steemj/plugins/apis/account/history/models/deserializer/OperationWrapper.java b/core/src/main/java/eu/bittrade/libs/steemj/plugins/apis/account/history/models/deserializer/OperationWrapper.java new file mode 100644 index 00000000..f9554624 --- /dev/null +++ b/core/src/main/java/eu/bittrade/libs/steemj/plugins/apis/account/history/models/deserializer/OperationWrapper.java @@ -0,0 +1,187 @@ +/* + * This file is part of SteemJ (formerly known as 'Steem-Java-Api-Wrapper') + * + * SteemJ is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * SteemJ is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with SteemJ. If not, see . + */ +package eu.bittrade.libs.steemj.plugins.apis.account.history.models.deserializer; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonSubTypes.Type; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +import eu.bittrade.libs.steemj.protocol.operations.AccountCreateOperation; +import eu.bittrade.libs.steemj.protocol.operations.AccountCreateWithDelegationOperation; +import eu.bittrade.libs.steemj.protocol.operations.AccountUpdateOperation; +import eu.bittrade.libs.steemj.protocol.operations.AccountWitnessProxyOperation; +import eu.bittrade.libs.steemj.protocol.operations.AccountWitnessVoteOperation; +import eu.bittrade.libs.steemj.protocol.operations.CancelTransferFromSavingsOperation; +import eu.bittrade.libs.steemj.protocol.operations.ChallengeAuthorityOperation; +import eu.bittrade.libs.steemj.protocol.operations.ChangeRecoveryAccountOperation; +import eu.bittrade.libs.steemj.protocol.operations.ClaimAccountOperation; +import eu.bittrade.libs.steemj.protocol.operations.ClaimRewardBalanceOperation; +import eu.bittrade.libs.steemj.protocol.operations.CommentOperation; +import eu.bittrade.libs.steemj.protocol.operations.CommentOptionsOperation; +import eu.bittrade.libs.steemj.protocol.operations.ConvertOperation; +import eu.bittrade.libs.steemj.protocol.operations.CreateClaimedAccountOperation; +import eu.bittrade.libs.steemj.protocol.operations.CustomBinaryOperation; +import eu.bittrade.libs.steemj.protocol.operations.CustomJsonOperation; +import eu.bittrade.libs.steemj.protocol.operations.CustomOperation; +import eu.bittrade.libs.steemj.protocol.operations.DeclineVotingRightsOperation; +import eu.bittrade.libs.steemj.protocol.operations.DelegateVestingSharesOperation; +import eu.bittrade.libs.steemj.protocol.operations.DeleteCommentOperation; +import eu.bittrade.libs.steemj.protocol.operations.EscrowApproveOperation; +import eu.bittrade.libs.steemj.protocol.operations.EscrowDisputeOperation; +import eu.bittrade.libs.steemj.protocol.operations.EscrowReleaseOperation; +import eu.bittrade.libs.steemj.protocol.operations.EscrowTransferOperation; +import eu.bittrade.libs.steemj.protocol.operations.FeedPublishOperation; +import eu.bittrade.libs.steemj.protocol.operations.LimitOrderCancelOperation; +import eu.bittrade.libs.steemj.protocol.operations.LimitOrderCreate2Operation; +import eu.bittrade.libs.steemj.protocol.operations.LimitOrderCreateOperation; +import eu.bittrade.libs.steemj.protocol.operations.Operation; +import eu.bittrade.libs.steemj.protocol.operations.Pow2Operation; +import eu.bittrade.libs.steemj.protocol.operations.PowOperation; +import eu.bittrade.libs.steemj.protocol.operations.ProveAuthorityOperation; +import eu.bittrade.libs.steemj.protocol.operations.RecoverAccountOperation; +import eu.bittrade.libs.steemj.protocol.operations.ReportOverProductionOperation; +import eu.bittrade.libs.steemj.protocol.operations.RequestAccountRecoveryOperation; +import eu.bittrade.libs.steemj.protocol.operations.ResetAccountOperation; +import eu.bittrade.libs.steemj.protocol.operations.SetResetAccountOperation; +import eu.bittrade.libs.steemj.protocol.operations.SetWithdrawVestingRouteOperation; +import eu.bittrade.libs.steemj.protocol.operations.TransferFromSavingsOperation; +import eu.bittrade.libs.steemj.protocol.operations.TransferOperation; +import eu.bittrade.libs.steemj.protocol.operations.TransferToSavingsOperation; +import eu.bittrade.libs.steemj.protocol.operations.TransferToVestingOperation; +import eu.bittrade.libs.steemj.protocol.operations.VoteOperation; +import eu.bittrade.libs.steemj.protocol.operations.WithdrawVestingOperation; +import eu.bittrade.libs.steemj.protocol.operations.WitnessSetPropertiesOperation; +import eu.bittrade.libs.steemj.protocol.operations.WitnessUpdateOperation; +import eu.bittrade.libs.steemj.protocol.operations.virtual.AuthorRewardOperation; +import eu.bittrade.libs.steemj.protocol.operations.virtual.CommentBenefactorRewardOperation; +import eu.bittrade.libs.steemj.protocol.operations.virtual.CommentPayoutUpdateOperation; +import eu.bittrade.libs.steemj.protocol.operations.virtual.CommentRewardOperation; +import eu.bittrade.libs.steemj.protocol.operations.virtual.CurationRewardOperation; +import eu.bittrade.libs.steemj.protocol.operations.virtual.FillConvertRequestOperation; +import eu.bittrade.libs.steemj.protocol.operations.virtual.FillOrderOperation; +import eu.bittrade.libs.steemj.protocol.operations.virtual.FillTransferFromSavingsOperation; +import eu.bittrade.libs.steemj.protocol.operations.virtual.FillVestingWithdrawOperation; +import eu.bittrade.libs.steemj.protocol.operations.virtual.HardforkOperation; +import eu.bittrade.libs.steemj.protocol.operations.virtual.InterestOperation; +import eu.bittrade.libs.steemj.protocol.operations.virtual.LiquidityRewardOperation; +import eu.bittrade.libs.steemj.protocol.operations.virtual.ProducerRewardOperation; +import eu.bittrade.libs.steemj.protocol.operations.virtual.ReturnVestingDelegationOperation; +import eu.bittrade.libs.steemj.protocol.operations.virtual.ShutdownWitnessOpeartion; + +/** + * With Steem 0.22.0, the JSON structure for an applied operation changed. It + * now returns an object with a 'type' and a 'value' field as shown below: + * + * "op":{"type":"example_operation","value":{"fieldA": ...}} + * + * As there does not seem to be an out of the box way to solve this properly, + * this wrapper object has been created. It simply wraps the 'type' and 'value' + * field of the response and uses the Jackson 'EXTERNAL_PROPERTY' configuration + * for deserialization. + * + * @author dez1337 + */ +public class OperationWrapper { + @JsonProperty("type") + private String originalSteemOperationName; + @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXTERNAL_PROPERTY, property = "type") + @JsonSubTypes({ @Type(value = VoteOperation.class, name = "vote_operation"), + @Type(value = CommentOperation.class, name = "comment_operation"), + @Type(value = TransferOperation.class, name = "transfer_operation"), + @Type(value = TransferToVestingOperation.class, name = "transfer_to_vesting_operation"), + @Type(value = WithdrawVestingOperation.class, name = "withdraw_vesting_operation"), + @Type(value = LimitOrderCreateOperation.class, name = "limit_order_create_operation"), + @Type(value = LimitOrderCancelOperation.class, name = "limit_order_cancel_operation"), + @Type(value = FeedPublishOperation.class, name = "feed_publish_operation"), + @Type(value = ConvertOperation.class, name = "convert_operation"), + @Type(value = AccountCreateOperation.class, name = "account_create_operation"), + @Type(value = AccountUpdateOperation.class, name = "account_update_operation"), + @Type(value = WitnessUpdateOperation.class, name = "witness_update_operation"), + @Type(value = WitnessSetPropertiesOperation.class, name = "witness_set_properties_operation"), + @Type(value = AccountWitnessVoteOperation.class, name = "account_witness_vote_operation"), + @Type(value = AccountWitnessProxyOperation.class, name = "account_witness_proxy_operation"), + @Type(value = PowOperation.class, name = "pow"), + @Type(value = CustomOperation.class, name = "custom_operation"), + @Type(value = ReportOverProductionOperation.class, name = "report_over_production_operation"), + @Type(value = DeleteCommentOperation.class, name = "delete_comment_operation"), + @Type(value = CustomJsonOperation.class, name = "custom_json_operation"), + @Type(value = CommentOptionsOperation.class, name = "comment_options_operation"), + @Type(value = SetWithdrawVestingRouteOperation.class, name = "set_withdraw_vesting_route_operation"), + @Type(value = LimitOrderCreate2Operation.class, name = "limit_order_create2_operation"), + @Type(value = ChallengeAuthorityOperation.class, name = "challenge_authority_operation"), + @Type(value = ProveAuthorityOperation.class, name = "prove_authority_operation"), + @Type(value = RequestAccountRecoveryOperation.class, name = "request_account_recovery_operation"), + @Type(value = RecoverAccountOperation.class, name = "recover_account_operation"), + @Type(value = ChangeRecoveryAccountOperation.class, name = "change_recovery_account_operation"), + @Type(value = EscrowTransferOperation.class, name = "escrow_transfer_operation"), + @Type(value = EscrowDisputeOperation.class, name = "escrow_dispute_operation"), + @Type(value = EscrowReleaseOperation.class, name = "escrow_release_operation"), + @Type(value = Pow2Operation.class, name = "pow2_operation"), + @Type(value = EscrowApproveOperation.class, name = "escrow_approve_operation"), + @Type(value = TransferToSavingsOperation.class, name = "transfer_to_savings_operation"), + @Type(value = TransferFromSavingsOperation.class, name = "transfer_from_savings_operation"), + @Type(value = CancelTransferFromSavingsOperation.class, name = "cancel_transfer_from_savings_operation"), + @Type(value = CustomBinaryOperation.class, name = "custom_binary_operation"), + @Type(value = DeclineVotingRightsOperation.class, name = "decline_voting_rights_operation"), + @Type(value = ResetAccountOperation.class, name = "reset_account_operation"), + @Type(value = SetResetAccountOperation.class, name = "set_reset_account_operation"), + @Type(value = ClaimRewardBalanceOperation.class, name = "claim_reward_balance_operation"), + @Type(value = DelegateVestingSharesOperation.class, name = "delegate_vesting_shares_operation"), + @Type(value = AccountCreateWithDelegationOperation.class, name = "account_create_with_delegation_operation"), + @Type(value = ClaimAccountOperation.class, name = "claim_account_operation"), + @Type(value = CreateClaimedAccountOperation.class, name = "create_claimed_account_operation"), + // Virtual Operations + @Type(value = AuthorRewardOperation.class, name = "author_reward_operation"), + @Type(value = CommentBenefactorRewardOperation.class, name = "comment_benefactor_reward_operation"), + @Type(value = CommentPayoutUpdateOperation.class, name = "comment_payout_update_operation"), + @Type(value = CommentRewardOperation.class, name = "comment_reward_operation"), + @Type(value = CurationRewardOperation.class, name = "curation_reward_operation"), + @Type(value = FillConvertRequestOperation.class, name = "fill_convert_request_operation"), + @Type(value = FillOrderOperation.class, name = "fill_order_operation"), + @Type(value = FillTransferFromSavingsOperation.class, name = "fill_transfer_from_savings_operation"), + @Type(value = FillVestingWithdrawOperation.class, name = "fill_vesting_withdraw_operation"), + @Type(value = HardforkOperation.class, name = "hardfork_operation"), + @Type(value = InterestOperation.class, name = "interest_operation"), + @Type(value = LiquidityRewardOperation.class, name = "liquidity_reward_operation"), + @Type(value = ReturnVestingDelegationOperation.class, name = "return_vesting_delegation_operation"), + @Type(value = ShutdownWitnessOpeartion.class, name = "shutdown_witness_operation"), + @Type(value = ProducerRewardOperation.class, name = "producer_reward_operation") }) + @JsonProperty("value") + private Operation operation; + + /** + * This object is only used to wrap the JSON response in a POJO, so + * therefore this class should not be instantiated. + */ + private OperationWrapper() { + } + + /** + * @return Get the name of the operation provided by the Steem node. + */ + public String getOriginalSteemOperationName() { + return originalSteemOperationName; + } + + /** + * @return The operation itself. + */ + public Operation getOperation() { + return operation; + } +} diff --git a/core/src/main/java/eu/bittrade/libs/steemj/protocol/Asset.java b/core/src/main/java/eu/bittrade/libs/steemj/protocol/Asset.java index 2a1b330d..df484485 100644 --- a/core/src/main/java/eu/bittrade/libs/steemj/protocol/Asset.java +++ b/core/src/main/java/eu/bittrade/libs/steemj/protocol/Asset.java @@ -18,6 +18,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.math.BigDecimal; import org.apache.commons.lang3.builder.ToStringBuilder; @@ -62,10 +63,13 @@ public Asset(@JsonProperty("amount") long amount, @JsonProperty("precision") byt } /** - * TODO + * Create a new Asset by providing an amount and an + * {@code #assetSymbolType}. * * @param amount + * The amount. * @param assetSymbolType + * The symbol type. */ public Asset(long amount, AssetSymbolType assetSymbolType) { this.amount = amount; @@ -73,7 +77,7 @@ public Asset(long amount, AssetSymbolType assetSymbolType) { } /** - * @return the amount + * @return The amount. */ public long getAmount() { return amount; @@ -81,14 +85,14 @@ public long getAmount() { /** * @param amount - * the amount to set + * The amount to set. */ public void setAmount(long amount) { this.amount = amount; } /** - * @return the assetSymbolType + * @return The symbol of the asset. */ public AssetSymbolType getAssetSymbolType() { return assetSymbolType; @@ -96,12 +100,21 @@ public AssetSymbolType getAssetSymbolType() { /** * @param assetSymbolType - * the assetSymbolType to set + * The symbol of the asset. */ public void setAssetSymbolType(AssetSymbolType assetSymbolType) { this.assetSymbolType = assetSymbolType; } + /** + * Transform this asset into its {@link BigDecimal} representation. + * + * @return The value of this asset in its {@link BigDecimal} representation. + */ + public BigDecimal toReal() { + return BigDecimal.valueOf(this.getAmount(), this.getAssetSymbolType().getDecimalPlaces()); + } + @Override public byte[] toByteArray() throws SteemInvalidTransactionException { try (ByteArrayOutputStream serializedAsset = new ByteArrayOutputStream()) { diff --git a/core/src/main/java/eu/bittrade/libs/steemj/protocol/AssetSymbolType.java b/core/src/main/java/eu/bittrade/libs/steemj/protocol/AssetSymbolType.java index 2dd8bb21..219c0282 100644 --- a/core/src/main/java/eu/bittrade/libs/steemj/protocol/AssetSymbolType.java +++ b/core/src/main/java/eu/bittrade/libs/steemj/protocol/AssetSymbolType.java @@ -18,6 +18,7 @@ import java.security.InvalidParameterException; +import org.apache.commons.lang3.Validate; import org.joou.UInteger; import com.fasterxml.jackson.annotation.JsonCreator; @@ -31,6 +32,37 @@ * @author dez1337 */ public class AssetSymbolType { + // The NAI digits for the three default types: + private static final int STEEM_NAI_SBD = 1; + private static final int STEEM_NAI_STEEM = 2; + private static final int STEEM_NAI_VESTS = 3; + // The precision of the the three default types: + private static final int STEEM_PRECISION_SBD = 3; + private static final int STEEM_PRECISION_STEEM = 3; + private static final int STEEM_PRECISION_VESTS = 6; + + // SMT Configuration + private static final long SMT_MAX_NAI = 99999999; + private static final long SMT_MIN_NON_RESERVED_NAI = 10000000; + private static final byte STEEM_ASSET_SYMBOL_PRECISION_BITS = 4; + private static final byte STEEM_ASSET_CONTROL_BITS = 1; + private static final byte SMT_MIN_NAI = 1; + private static final byte STEEM_NAI_SHIFT = (STEEM_ASSET_SYMBOL_PRECISION_BITS + STEEM_ASSET_CONTROL_BITS); + private static final int STEEM_ASSET_SYMBOL_NAI_LENGTH = 10; + private static final int STEEM_ASSET_SYMBOL_NAI_STRING_LENGTH = (STEEM_ASSET_SYMBOL_NAI_LENGTH + 2); + private static final int STEEM_ASSET_MAX_DECIMALS = 12; + private static final byte SMT_ASSET_NUM_PRECISION_MASK = 0xF; + private static final byte SMT_ASSET_NUM_CONTROL_MASK = 0x10; + private static final byte SMT_ASSET_NUM_VESTING_MASK = 0x20; + + // The asset numbers of the the three default types: + private static final long STEEM_ASSET_NUM_SBD = ((SMT_MAX_NAI + STEEM_NAI_SBD) << STEEM_NAI_SHIFT) + | STEEM_PRECISION_SBD; + private static final long STEEM_ASSET_NUM_STEEM = ((SMT_MAX_NAI + STEEM_NAI_STEEM) << STEEM_NAI_SHIFT) + | STEEM_PRECISION_STEEM; + private static final long STEEM_ASSET_NUM_VESTS = ((SMT_MAX_NAI + STEEM_NAI_VESTS) << STEEM_NAI_SHIFT) + | STEEM_PRECISION_VESTS; + /** * Numerical asset identifiers. * @@ -53,7 +85,7 @@ public class AssetSymbolType { */ public AssetSymbolType(UInteger nai, byte decimalPlaces) { this.decimalPlaces = decimalPlaces; - this.assetNumber = assetNumberFromNai(nai, decimalPlaces); + this.assetNumber = UInteger.valueOf(assetNumberFromNai(nai, decimalPlaces)); } /** @@ -99,19 +131,36 @@ public void setAssetNumber(UInteger assetNumber) { } /** - * TODO + * Parse the asset number from the given nai. * * @param nai + * The nai. * @param decimalPlaces - * @return + * The decimal places. + * @return The asset number. */ - public static UInteger assetNumberFromNai(UInteger nai, byte decimalPlaces) { - return null; + public static long assetNumberFromNai(UInteger nai, byte decimalPlaces) { + long naiCheckDigits = nai.longValue() % 10; + long naiDataDigits = nai.longValue() / 10; + + // TODO: Damm Checksum validation. + + switch ((int) naiDataDigits) { + case STEEM_NAI_SBD: + Validate.isTrue(decimalPlaces == STEEM_PRECISION_SBD); + return STEEM_ASSET_NUM_SBD; + case STEEM_NAI_STEEM: + Validate.isTrue(decimalPlaces == STEEM_PRECISION_STEEM); + return STEEM_ASSET_NUM_STEEM; + case STEEM_NAI_VESTS: + Validate.isTrue(decimalPlaces == STEEM_PRECISION_VESTS); + return STEEM_ASSET_NUM_VESTS; + default: + Validate.isTrue(decimalPlaces <= STEEM_ASSET_MAX_DECIMALS, "Invalid decimal places."); + return (naiDataDigits << STEEM_NAI_SHIFT) | SMT_ASSET_NUM_CONTROL_MASK | decimalPlaces; + } } - // TODO - // from_asset_num - /** * This method is used to transform a naiString into a * nai by removing the prefix of it. In example the diff --git a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/Operation.java b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/Operation.java index 68f7cdb3..d66e0c44 100644 --- a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/Operation.java +++ b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/Operation.java @@ -54,50 +54,51 @@ * @author dez1337 */ @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") -@JsonSubTypes({ @Type(value = VoteOperation.class, name = "vote"), - @Type(value = CommentOperation.class, name = "comment"), - @Type(value = TransferOperation.class, name = "transfer"), - @Type(value = TransferToVestingOperation.class, name = "transfer_to_vesting"), - @Type(value = WithdrawVestingOperation.class, name = "withdraw_vesting"), - @Type(value = LimitOrderCreateOperation.class, name = "limit_order_create"), - @Type(value = LimitOrderCancelOperation.class, name = "limit_order_cancel"), - @Type(value = FeedPublishOperation.class, name = "feed_publish"), - @Type(value = ConvertOperation.class, name = "convert"), - @Type(value = AccountCreateOperation.class, name = "account_create"), - @Type(value = AccountUpdateOperation.class, name = "account_update"), - @Type(value = WitnessUpdateOperation.class, name = "witness_update"), - @Type(value = WitnessSetPropertiesOperation.class, name = "witness_set_properties"), - @Type(value = AccountWitnessVoteOperation.class, name = "account_witness_vote"), - @Type(value = AccountWitnessProxyOperation.class, name = "account_witness_proxy"), - @Type(value = PowOperation.class, name = "pow"), @Type(value = CustomOperation.class, name = "custom"), - @Type(value = ReportOverProductionOperation.class, name = "report_over_production"), - @Type(value = DeleteCommentOperation.class, name = "delete_comment"), - @Type(value = CustomJsonOperation.class, name = "custom_json"), - @Type(value = CommentOptionsOperation.class, name = "comment_options"), - @Type(value = SetWithdrawVestingRouteOperation.class, name = "set_withdraw_vesting_route"), - @Type(value = LimitOrderCreate2Operation.class, name = "limit_order_create2"), - @Type(value = ChallengeAuthorityOperation.class, name = "challenge_authority"), - @Type(value = ProveAuthorityOperation.class, name = "prove_authority"), - @Type(value = RequestAccountRecoveryOperation.class, name = "request_account_recovery"), - @Type(value = RecoverAccountOperation.class, name = "recover_account"), - @Type(value = ChangeRecoveryAccountOperation.class, name = "change_recovery_account"), - @Type(value = EscrowTransferOperation.class, name = "escrow_transfer"), - @Type(value = EscrowDisputeOperation.class, name = "escrow_dispute"), - @Type(value = EscrowReleaseOperation.class, name = "escrow_release"), - @Type(value = Pow2Operation.class, name = "pow2"), - @Type(value = EscrowApproveOperation.class, name = "escrow_approve"), - @Type(value = TransferToSavingsOperation.class, name = "transfer_to_savings"), - @Type(value = TransferFromSavingsOperation.class, name = "transfer_from_savings"), - @Type(value = CancelTransferFromSavingsOperation.class, name = "cancel_transfer_from_savings"), - @Type(value = CustomBinaryOperation.class, name = "custom_binary"), - @Type(value = DeclineVotingRightsOperation.class, name = "decline_voting_rights"), - @Type(value = ResetAccountOperation.class, name = "reset_account"), - @Type(value = SetResetAccountOperation.class, name = "set_reset_account"), - @Type(value = ClaimRewardBalanceOperation.class, name = "claim_reward_balance"), - @Type(value = DelegateVestingSharesOperation.class, name = "delegate_vesting_shares"), - @Type(value = AccountCreateWithDelegationOperation.class, name = "account_create_with_delegation"), - @Type(value = ClaimAccountOperation.class, name = "claim_account"), - @Type(value = CreateClaimedAccountOperation.class, name = "create_claimed_account"), +@JsonSubTypes({ @Type(value = VoteOperation.class, name = "vote_operation"), + @Type(value = CommentOperation.class, name = "comment_operation"), + @Type(value = TransferOperation.class, name = "transfer_operation"), + @Type(value = TransferToVestingOperation.class, name = "transfer_to_vesting_operation"), + @Type(value = WithdrawVestingOperation.class, name = "withdraw_vesting_operation"), + @Type(value = LimitOrderCreateOperation.class, name = "limit_order_create_operation"), + @Type(value = LimitOrderCancelOperation.class, name = "limit_order_cancel_operation"), + @Type(value = FeedPublishOperation.class, name = "feed_publish_operation"), + @Type(value = ConvertOperation.class, name = "convert_operation"), + @Type(value = AccountCreateOperation.class, name = "account_create_operation"), + @Type(value = AccountUpdateOperation.class, name = "account_update_operation"), + @Type(value = WitnessUpdateOperation.class, name = "witness_update_operation"), + @Type(value = WitnessSetPropertiesOperation.class, name = "witness_set_properties_operation"), + @Type(value = AccountWitnessVoteOperation.class, name = "account_witness_vote_operation"), + @Type(value = AccountWitnessProxyOperation.class, name = "account_witness_proxy_operation"), + @Type(value = PowOperation.class, name = "pow"), + @Type(value = CustomOperation.class, name = "custom_operation"), + @Type(value = ReportOverProductionOperation.class, name = "report_over_production_operation"), + @Type(value = DeleteCommentOperation.class, name = "delete_comment_operation"), + @Type(value = CustomJsonOperation.class, name = "custom_json_operation"), + @Type(value = CommentOptionsOperation.class, name = "comment_options_operation"), + @Type(value = SetWithdrawVestingRouteOperation.class, name = "set_withdraw_vesting_route_operation"), + @Type(value = LimitOrderCreate2Operation.class, name = "limit_order_create2_operation"), + @Type(value = ChallengeAuthorityOperation.class, name = "challenge_authority_operation"), + @Type(value = ProveAuthorityOperation.class, name = "prove_authority_operation"), + @Type(value = RequestAccountRecoveryOperation.class, name = "request_account_recovery_operation"), + @Type(value = RecoverAccountOperation.class, name = "recover_account_operation"), + @Type(value = ChangeRecoveryAccountOperation.class, name = "change_recovery_account_operation"), + @Type(value = EscrowTransferOperation.class, name = "escrow_transfer_operation"), + @Type(value = EscrowDisputeOperation.class, name = "escrow_dispute_operation"), + @Type(value = EscrowReleaseOperation.class, name = "escrow_release_operation"), + @Type(value = Pow2Operation.class, name = "pow2_operation"), + @Type(value = EscrowApproveOperation.class, name = "escrow_approve_operation"), + @Type(value = TransferToSavingsOperation.class, name = "transfer_to_savings_operation"), + @Type(value = TransferFromSavingsOperation.class, name = "transfer_from_savings_operation"), + @Type(value = CancelTransferFromSavingsOperation.class, name = "cancel_transfer_from_savings_operation"), + @Type(value = CustomBinaryOperation.class, name = "custom_binary_operation"), + @Type(value = DeclineVotingRightsOperation.class, name = "decline_voting_rights_operation"), + @Type(value = ResetAccountOperation.class, name = "reset_account_operation"), + @Type(value = SetResetAccountOperation.class, name = "set_reset_account_operation"), + @Type(value = ClaimRewardBalanceOperation.class, name = "claim_reward_balance_operation"), + @Type(value = DelegateVestingSharesOperation.class, name = "delegate_vesting_shares_operation"), + @Type(value = AccountCreateWithDelegationOperation.class, name = "account_create_with_delegation_operation"), + @Type(value = ClaimAccountOperation.class, name = "claim_account_operation"), + @Type(value = CreateClaimedAccountOperation.class, name = "create_claimed_account_operation"), // Virtual Operations @Type(value = AuthorRewardOperation.class, name = "author_reward_operation"), @Type(value = CommentBenefactorRewardOperation.class, name = "comment_benefactor_reward_operation"), diff --git a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/AuthorRewardOperation.java b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/AuthorRewardOperation.java index b93ff655..aa9b726d 100644 --- a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/AuthorRewardOperation.java +++ b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/AuthorRewardOperation.java @@ -28,8 +28,9 @@ import eu.bittrade.libs.steemj.enums.ValidationType; import eu.bittrade.libs.steemj.exceptions.SteemInvalidTransactionException; import eu.bittrade.libs.steemj.interfaces.SignatureObject; +import eu.bittrade.libs.steemj.protocol.AccountName; +import eu.bittrade.libs.steemj.protocol.Asset; import eu.bittrade.libs.steemj.protocol.operations.Operation; -import eu.bittrade.libs.steemj.protocol.operations.virtual.value.AuthorRewardOperationValue; /** * This class represents the Steem "author_reward_operation" object. @@ -40,9 +41,16 @@ * @author dez1337 */ public class AuthorRewardOperation extends Operation { - - @JsonProperty("value") - private AuthorRewardOperationValue value; + @JsonProperty("author") + private AccountName author; + @JsonProperty("permlink") + private Permlink permlink; + @JsonProperty("sbd_payout") + private Asset sbdPayout; + @JsonProperty("steem_payout") + private Asset steemPayout; + @JsonProperty("vesting_payout") + private Asset vestingPayout; /** * This operation is a virtual one and can only be created by the blockchain @@ -52,18 +60,52 @@ private AuthorRewardOperation() { super(true); } + /** + * Get the author who received this reward. + * + * @return The author who received the reward. + */ + public AccountName getAuthor() { + return author; + } + + /** + * Get the permanent link of the post for which the author is rewarded. + * + * @return The permanent link of the article. + */ + public Permlink getPermlink() { + return permlink; + } + + /** + * Get the SDB amount the author gets for the article. + * + * @return The amount of SBD. + */ + public Asset getSbdPayout() { + return sbdPayout; + } /** - * Gets all the values + * Get the Steem amount the author gets for the article. * - * @return the value for type author_reward_operation + * @return The amount of Steem. */ - public AuthorRewardOperationValue getValue() { - return value; - } + public Asset getSteemPayout() { + return steemPayout; + } + /** + * Get the Vests amount the author gets for the article. + * + * @return The amount of Vests. + */ + public Asset getVestingPayout() { + return vestingPayout; + } - @Override + @Override public byte[] toByteArray() throws SteemInvalidTransactionException { // The byte representation is not needed for virtual operations as we // can't broadcast them. diff --git a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/CommentBenefactorRewardOperation.java b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/CommentBenefactorRewardOperation.java index c924b0ef..68944905 100644 --- a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/CommentBenefactorRewardOperation.java +++ b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/CommentBenefactorRewardOperation.java @@ -23,12 +23,14 @@ import com.fasterxml.jackson.annotation.JsonProperty; +import eu.bittrade.libs.steemj.base.models.Permlink; import eu.bittrade.libs.steemj.enums.PrivateKeyType; import eu.bittrade.libs.steemj.enums.ValidationType; import eu.bittrade.libs.steemj.exceptions.SteemInvalidTransactionException; import eu.bittrade.libs.steemj.interfaces.SignatureObject; +import eu.bittrade.libs.steemj.protocol.AccountName; +import eu.bittrade.libs.steemj.protocol.Asset; import eu.bittrade.libs.steemj.protocol.operations.Operation; -import eu.bittrade.libs.steemj.protocol.operations.virtual.value.CommentBenefactorRewardOperationValue; /** * This class represents the Steem "comment_benefactor_reward_operation" object. @@ -36,8 +38,19 @@ * @author dez1337 */ public class CommentBenefactorRewardOperation extends Operation { - @JsonProperty("value") - private CommentBenefactorRewardOperationValue value; + @JsonProperty("benefactor") + private AccountName benefactor; + @JsonProperty("author") + private AccountName author; + @JsonProperty("permlink") + private Permlink permlink; + @JsonProperty("sbd_payout") + private Asset sbdPayout; + @JsonProperty("steem_payout") + private Asset steemPayout; + @JsonProperty("vesting_payout") + private Asset vestingPayout; + /** * This operation is a virtual one and can only be created by the blockchain * itself. Due to that, this constructor is private. @@ -47,17 +60,48 @@ private CommentBenefactorRewardOperation() { } /** - * Gets all the values - * - * @return the value for type comment_benefactor_reward_operation + * @return The benefactor which the payout. */ - public CommentBenefactorRewardOperationValue getValue() { - return value; - } + public AccountName getBenefactor() { + return benefactor; + } + /** + * @return The author of the post. + */ + public AccountName getAuthor() { + return author; + } + /** + * @return The link to the post. + */ + public Permlink getPermlink() { + return permlink; + } - @Override + /** + * @return The amount of SBD received by the {@code #benefactor}. + */ + public Asset getSbdPayout() { + return sbdPayout; + } + + /** + * @return The amount of STEEM received by the {@code #benefactor}. + */ + public Asset getSteemPayout() { + return steemPayout; + } + + /** + * @return The amount of VESTS received by the {@code #benefactor}. + */ + public Asset getVestingPayout() { + return vestingPayout; + } + + @Override public byte[] toByteArray() throws SteemInvalidTransactionException { // The byte representation is not needed for virtual operations as we // can't broadcast them. diff --git a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/CommentPayoutUpdateOperation.java b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/CommentPayoutUpdateOperation.java index 737fed34..8fb3bcf8 100644 --- a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/CommentPayoutUpdateOperation.java +++ b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/CommentPayoutUpdateOperation.java @@ -47,14 +47,14 @@ private CommentPayoutUpdateOperation() { } /** - * @return the author + * @return The author of the comment. */ public AccountName getAuthor() { return author; } /** - * @return the permlink + * @return The link to the comment. */ public Permlink getPermlink() { return permlink; diff --git a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/CurationRewardOperation.java b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/CurationRewardOperation.java index fc82f9de..6f2644b1 100644 --- a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/CurationRewardOperation.java +++ b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/CurationRewardOperation.java @@ -23,12 +23,14 @@ import com.fasterxml.jackson.annotation.JsonProperty; +import eu.bittrade.libs.steemj.base.models.Permlink; import eu.bittrade.libs.steemj.enums.PrivateKeyType; import eu.bittrade.libs.steemj.enums.ValidationType; import eu.bittrade.libs.steemj.exceptions.SteemInvalidTransactionException; import eu.bittrade.libs.steemj.interfaces.SignatureObject; +import eu.bittrade.libs.steemj.protocol.AccountName; +import eu.bittrade.libs.steemj.protocol.Asset; import eu.bittrade.libs.steemj.protocol.operations.Operation; -import eu.bittrade.libs.steemj.protocol.operations.virtual.value.CurationRewardValue; /** * This class represents a "curation_reward_operation" object. @@ -39,8 +41,14 @@ * @author dez1337 */ public class CurationRewardOperation extends Operation { - @JsonProperty("value") - private CurationRewardValue curationRewardValue; + @JsonProperty("curator") + private AccountName curator; + @JsonProperty("reward") + private Asset reward; + @JsonProperty("comment_author") + private AccountName commentAuthor; + @JsonProperty("comment_permlink") + private Permlink commentPermlink; /** * This operation is a virtual one and can only be created by the blockchain @@ -51,14 +59,43 @@ private CurationRewardOperation() { } /** - * Gets all the values + * Get the person that receives the reward. * - * @return the value for type curation_reward_operation + * @return The person that receives the reward. */ - public CurationRewardValue getCurationRewardValue() { - return curationRewardValue; - } - + public AccountName getCurator() { + return curator; + } + + /** + * Get the amount and the currency the curator receives. + * + * @return The reward. + */ + public Asset getReward() { + return reward; + } + + /** + * Get the author of the post or comment that this curation reward is for. + * + * @return The author of the post or comment. + */ + public AccountName getCommentAuthor() { + return commentAuthor; + } + + /** + * Get the permanent link of the post or comment that this curation reward + * is for. + * + * @return The permanent link of the post or comment that this curation + * reward is for. + */ + public Permlink getCommentPermlink() { + return commentPermlink; + } + @Override public byte[] toByteArray() throws SteemInvalidTransactionException { // The byte representation is not needed for virtual operations as we diff --git a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/FillConvertRequestOperation.java b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/FillConvertRequestOperation.java index dc997048..04e9f224 100644 --- a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/FillConvertRequestOperation.java +++ b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/FillConvertRequestOperation.java @@ -27,8 +27,9 @@ import eu.bittrade.libs.steemj.enums.ValidationType; import eu.bittrade.libs.steemj.exceptions.SteemInvalidTransactionException; import eu.bittrade.libs.steemj.interfaces.SignatureObject; +import eu.bittrade.libs.steemj.protocol.AccountName; +import eu.bittrade.libs.steemj.protocol.Asset; import eu.bittrade.libs.steemj.protocol.operations.Operation; -import eu.bittrade.libs.steemj.protocol.operations.virtual.value.FillConvertRequestOperationValue; /** * This class represents a Steem "fill_convert_request_operation" object. @@ -39,8 +40,15 @@ * @author dez1337 */ public class FillConvertRequestOperation extends Operation { - @JsonProperty("value") - private FillConvertRequestOperationValue value; + @JsonProperty("owner") + private AccountName owner; + // Original type is uint32_t so we have to use long here. + @JsonProperty("requestid") + private long requestId; + @JsonProperty("amount_in") + private Asset amountIn; + @JsonProperty("amount_out") + private Asset amountOut; /** * This operation is a virtual one and can only be created by the blockchain @@ -51,15 +59,43 @@ private FillConvertRequestOperation() { } /** - * Gets all the values + * Get the owner of this conversion request. * - * @return the value for type fill_convert_request_operation + * @return The owner as an AccountName instance. */ - public FillConvertRequestOperationValue getValue() { - return value; - } + public AccountName getOwner() { + return owner; + } - @Override + /** + * Get the id of this request. + * + * @return The id of this request. + */ + public long getRequestId() { + return requestId; + } + + /** + * Get the amount and the type of the currency that has been converted + * within this operation. + * + * @return The source asset. + */ + public Asset getAmountIn() { + return amountIn; + } + + /** + * Get the amount and the type of the target currency. + * + * @return The target asset. + */ + public Asset getAmountOut() { + return amountOut; + } + + @Override public byte[] toByteArray() throws SteemInvalidTransactionException { // The byte representation is not needed for virtual operations as we // can't broadcast them. diff --git a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/FillOrderOperation.java b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/FillOrderOperation.java index 089381b0..c0d151cd 100644 --- a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/FillOrderOperation.java +++ b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/FillOrderOperation.java @@ -27,8 +27,9 @@ import eu.bittrade.libs.steemj.enums.ValidationType; import eu.bittrade.libs.steemj.exceptions.SteemInvalidTransactionException; import eu.bittrade.libs.steemj.interfaces.SignatureObject; +import eu.bittrade.libs.steemj.protocol.AccountName; +import eu.bittrade.libs.steemj.protocol.Asset; import eu.bittrade.libs.steemj.protocol.operations.Operation; -import eu.bittrade.libs.steemj.protocol.operations.virtual.value.FillOrderOperationValue; /** * This class represents a Steem "fill_order_operation" object. @@ -39,9 +40,20 @@ * @author dez1337 */ public class FillOrderOperation extends Operation { - - @JsonProperty("value") - private FillOrderOperationValue value; + @JsonProperty("current_owner") + private AccountName currentOwner; + @JsonProperty("current_orderid") + // Original type is uint32_t here so we have to use long. + private int currentOrderId; + @JsonProperty("current_pays") + private Asset currentPays; + @JsonProperty("open_owner") + private AccountName openOwner; + @JsonProperty("open_orderid") + // Original type is uint32_t here so we have to use long. + private long openOrderId; + @JsonProperty("open_pays") + private Asset openPays; /** * This operation is a virtual one and can only be created by the blockchain @@ -52,17 +64,48 @@ private FillOrderOperation() { } /** - * Gets all the values - * - * @return the value for type fill_order_operation + * @return The current owner. */ - public FillOrderOperationValue getValue() { - return value; - } + public AccountName getCurrentOwner() { + return currentOwner; + } + + /** + * @return The current order id. + */ + public int getCurrentOrderId() { + return currentOrderId; + } + + /** + * @return The current pays. + */ + public Asset getCurrentPays() { + return currentPays; + } + + /** + * @return The open owner. + */ + public AccountName getOpenOwner() { + return openOwner; + } + /** + * @return The open order id. + */ + public long getOpenOrderId() { + return openOrderId; + } + /** + * @return The open pays. + */ + public Asset getOpenPays() { + return openPays; + } - @Override + @Override public byte[] toByteArray() throws SteemInvalidTransactionException { // The byte representation is not needed for virtual operations as we // can't broadcast them. diff --git a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/FillTransferFromSavingsOperation.java b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/FillTransferFromSavingsOperation.java index b8aec2e7..c775c07f 100644 --- a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/FillTransferFromSavingsOperation.java +++ b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/FillTransferFromSavingsOperation.java @@ -27,18 +27,27 @@ import eu.bittrade.libs.steemj.enums.ValidationType; import eu.bittrade.libs.steemj.exceptions.SteemInvalidTransactionException; import eu.bittrade.libs.steemj.interfaces.SignatureObject; +import eu.bittrade.libs.steemj.protocol.AccountName; +import eu.bittrade.libs.steemj.protocol.Asset; import eu.bittrade.libs.steemj.protocol.operations.Operation; -import eu.bittrade.libs.steemj.protocol.operations.virtual.value.FillTransferFromSavingsOperationValue; /** * This class represents the Steem "fill_transfer_from_savings_operation" * object. * + * This operation occurs if a transfer from the savings wallet has been + * fulfilled. + * * @author dez1337 */ public class FillTransferFromSavingsOperation extends Operation { - @JsonProperty("value") - private FillTransferFromSavingsOperationValue value; + private AccountName from; + private AccountName to; + private Asset amount; + // Original type is uint32_t here so we have to use long. + @JsonProperty("request_id") + private long requestId; + private String memo; /** * This operation is a virtual one and can only be created by the blockchain @@ -49,16 +58,41 @@ private FillTransferFromSavingsOperation() { } /** - * Gets all the values - * - * @return the value for type fill_transfer_from_savings_operation + * @return The account the {@code #amount} is coming from. + */ + public AccountName getFrom() { + return from; + } + + /** + * @return The account which received the {@code #amount}. + */ + public AccountName getTo() { + return to; + } + + /** + * @return The amount that has been transfered. */ - public FillTransferFromSavingsOperationValue getValue() { - return value; - } + public Asset getAmount() { + return amount; + } + /** + * @return The id of the transfer operation. + */ + public long getRequestId() { + return requestId; + } - @Override + /** + * @return The message added to the transfer. + */ + public String getMemo() { + return memo; + } + + @Override public byte[] toByteArray() throws SteemInvalidTransactionException { // The byte representation is not needed for virtual operations as we // can't broadcast them. diff --git a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/FillVestingWithdrawOperation.java b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/FillVestingWithdrawOperation.java index b331d139..cfa611b6 100644 --- a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/FillVestingWithdrawOperation.java +++ b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/FillVestingWithdrawOperation.java @@ -27,8 +27,9 @@ import eu.bittrade.libs.steemj.enums.ValidationType; import eu.bittrade.libs.steemj.exceptions.SteemInvalidTransactionException; import eu.bittrade.libs.steemj.interfaces.SignatureObject; +import eu.bittrade.libs.steemj.protocol.AccountName; +import eu.bittrade.libs.steemj.protocol.Asset; import eu.bittrade.libs.steemj.protocol.operations.Operation; -import eu.bittrade.libs.steemj.protocol.operations.virtual.value.FillVestingWithdrawOperationValue; /** * This class represents the Steem "fill_vesting_withdraw_operation" object. @@ -36,8 +37,12 @@ * @author dez1337 */ public class FillVestingWithdrawOperation extends Operation { - @JsonProperty("value") - private FillVestingWithdrawOperationValue value; + @JsonProperty("from_account") + private AccountName fromAccount; + @JsonProperty("to_account") + private AccountName toAccount; + private Asset withdrawn; + private Asset deposited; /** * This operation is a virtual one and can only be created by the blockchain @@ -48,16 +53,34 @@ private FillVestingWithdrawOperation() { } /** - * Gets all the values - * - * @return the value for type fill_vesting_withdraw_operation + * @return The account which has withdrawn VESTS. */ - public FillVestingWithdrawOperationValue getValue() { - return value; - } + public AccountName getFromAccount() { + return fromAccount; + } + /** + * @return The account which will receive the VESTS. + */ + public AccountName getToAccount() { + return toAccount; + } - @Override + /** + * @return The amount that has been withdrawn. + */ + public Asset getWithdrawn() { + return withdrawn; + } + + /** + * @return The amount that has been deposited. + */ + public Asset getDeposited() { + return deposited; + } + + @Override public byte[] toByteArray() throws SteemInvalidTransactionException { // The byte representation is not needed for virtual operations as we // can't broadcast them. diff --git a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/InterestOperation.java b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/InterestOperation.java index 8f2b59a8..4b5e7231 100644 --- a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/InterestOperation.java +++ b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/InterestOperation.java @@ -27,8 +27,9 @@ import eu.bittrade.libs.steemj.enums.ValidationType; import eu.bittrade.libs.steemj.exceptions.SteemInvalidTransactionException; import eu.bittrade.libs.steemj.interfaces.SignatureObject; +import eu.bittrade.libs.steemj.protocol.AccountName; +import eu.bittrade.libs.steemj.protocol.Asset; import eu.bittrade.libs.steemj.protocol.operations.Operation; -import eu.bittrade.libs.steemj.protocol.operations.virtual.value.InterestOperationValue; /** * This class represents a Steem "interest_operation" object. @@ -36,8 +37,10 @@ * @author dez1337 */ public class InterestOperation extends Operation { - @JsonProperty("value") - private InterestOperationValue value; + @JsonProperty("owner") + private AccountName owner; + @JsonProperty("interest") + private Asset interest; /** * This operation is a virtual one and can only be created by the blockchain @@ -48,16 +51,20 @@ private InterestOperation() { } /** - * Gets all the values - * - * @return the value for type interest_operation + * @return The owner. */ - public InterestOperationValue getValue() { - return value; - } + public AccountName getOwner() { + return owner; + } + /** + * @return The interest. + */ + public Asset getInterest() { + return interest; + } - @Override + @Override public byte[] toByteArray() throws SteemInvalidTransactionException { // The byte representation is not needed for virtual operations as we // can't broadcast them. diff --git a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/LiquidityRewardOperation.java b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/LiquidityRewardOperation.java index 14f36c33..b2e1cc3a 100644 --- a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/LiquidityRewardOperation.java +++ b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/LiquidityRewardOperation.java @@ -47,14 +47,14 @@ private LiquidityRewardOperation() { } /** - * @return the owner + * @return The account which receives the payout. */ public AccountName getOwner() { return owner; } /** - * @return the payout + * @return The amount the owner receives. */ public LegacyAsset getPayout() { return payout; diff --git a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/ProducerRewardOperation.java b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/ProducerRewardOperation.java index 01f827ef..fbf3db8e 100644 --- a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/ProducerRewardOperation.java +++ b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/ProducerRewardOperation.java @@ -28,8 +28,9 @@ import eu.bittrade.libs.steemj.enums.ValidationType; import eu.bittrade.libs.steemj.exceptions.SteemInvalidTransactionException; import eu.bittrade.libs.steemj.interfaces.SignatureObject; +import eu.bittrade.libs.steemj.protocol.AccountName; +import eu.bittrade.libs.steemj.protocol.Asset; import eu.bittrade.libs.steemj.protocol.operations.Operation; -import eu.bittrade.libs.steemj.protocol.operations.virtual.value.ProducerRewardOperationValue; /** * This class represents the Steem "producer_reward_operation" object. @@ -40,8 +41,10 @@ */ @JsonTypeName("producer_reward_operation") public class ProducerRewardOperation extends Operation { - @JsonProperty("value") - private ProducerRewardOperationValue value; + @JsonProperty("producer") + private AccountName producer; + @JsonProperty("vesting_shares") + private Asset vestingShares; /** * This operation is a virtual one and can only be created by the blockchain @@ -52,16 +55,24 @@ private ProducerRewardOperation() { } /** - * Gets all the values + * Get the block producer. * - * @return the value for type producer_reward_operation + * @return The block producer. */ - public ProducerRewardOperationValue getValue() { - return value; - } + public AccountName getProducer() { + return producer; + } + /** + * Get the amount of VESTS the producer got. + * + * @return The vesting shares paid to the producer. + */ + public Asset getVestingShares() { + return vestingShares; + } - @Override + @Override public byte[] toByteArray() throws SteemInvalidTransactionException { // The byte representation is not needed for virtual operations as we // can't broadcast them. diff --git a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/ReturnVestingDelegationOperation.java b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/ReturnVestingDelegationOperation.java index ed90d20a..2c94fa1c 100644 --- a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/ReturnVestingDelegationOperation.java +++ b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/ReturnVestingDelegationOperation.java @@ -27,8 +27,9 @@ import eu.bittrade.libs.steemj.enums.ValidationType; import eu.bittrade.libs.steemj.exceptions.SteemInvalidTransactionException; import eu.bittrade.libs.steemj.interfaces.SignatureObject; +import eu.bittrade.libs.steemj.protocol.AccountName; +import eu.bittrade.libs.steemj.protocol.Asset; import eu.bittrade.libs.steemj.protocol.operations.Operation; -import eu.bittrade.libs.steemj.protocol.operations.virtual.value.ReturnVestingDelegationOperationValue; /** * This class represents the Steem "return_vesting_delegation_operation" object. @@ -36,8 +37,9 @@ * @author dez1337 */ public class ReturnVestingDelegationOperation extends Operation { - @JsonProperty("value") - private ReturnVestingDelegationOperationValue value; + private AccountName account; + @JsonProperty("vesting_shares") + private Asset vestingShares; /** * This operation is a virtual one and can only be created by the blockchain @@ -48,17 +50,20 @@ private ReturnVestingDelegationOperation() { } /** - * Gets all the values - * - * @return the value for type return_vesting_delegation_operation + * @return The account which receives the VESTS. */ - public ReturnVestingDelegationOperationValue getValue() { - return value; - } - + public AccountName getAccount() { + return account; + } + /** + * @return Return the amount of VESTS the account receives. + */ + public Asset getVestingShares() { + return vestingShares; + } - @Override + @Override public byte[] toByteArray() throws SteemInvalidTransactionException { // The byte representation is not needed for virtual operations as we // can't broadcast them. diff --git a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/value/AuthorRewardOperationValue.java b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/value/AuthorRewardOperationValue.java deleted file mode 100644 index f80fcc64..00000000 --- a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/value/AuthorRewardOperationValue.java +++ /dev/null @@ -1,66 +0,0 @@ -package eu.bittrade.libs.steemj.protocol.operations.virtual.value; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import eu.bittrade.libs.steemj.base.models.Permlink; -import eu.bittrade.libs.steemj.protocol.AccountName; -import eu.bittrade.libs.steemj.protocol.Asset; - -public class AuthorRewardOperationValue { - - @JsonProperty("author") - private AccountName author; - @JsonProperty("permlink") - private Permlink permlink; - @JsonProperty("sbd_payout") - private Asset sbdPayout; - @JsonProperty("steem_payout") - private Asset steemPayout; - @JsonProperty("vesting_payout") - private Asset vestingPayout; - - /** - * Get the author who received this reward. - * - * @return The author who received the reward. - */ - public AccountName getAuthor() { - return author; - } - - /** - * Get the permanent link of the post for which the author is rewarded. - * - * @return The permanent link of the article. - */ - public Permlink getPermlink() { - return permlink; - } - - /** - * Get the SDB amount the author gets for the article. - * - * @return The amount of SBD. - */ - public Asset getSbdPayout() { - return sbdPayout; - } - - /** - * Get the Steem amount the author gets for the article. - * - * @return The amount of Steem. - */ - public Asset getSteemPayout() { - return steemPayout; - } - - /** - * Get the Vests amount the author gets for the article. - * - * @return The amount of Vests. - */ - public Asset getVestingPayout() { - return vestingPayout; - } -} diff --git a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/value/CommentBenefactorRewardOperationValue.java b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/value/CommentBenefactorRewardOperationValue.java deleted file mode 100644 index ddce7b1b..00000000 --- a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/value/CommentBenefactorRewardOperationValue.java +++ /dev/null @@ -1,65 +0,0 @@ -package eu.bittrade.libs.steemj.protocol.operations.virtual.value; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import eu.bittrade.libs.steemj.base.models.Permlink; -import eu.bittrade.libs.steemj.protocol.AccountName; -import eu.bittrade.libs.steemj.protocol.Asset; - -public class CommentBenefactorRewardOperationValue { - @JsonProperty("benefactor") - private AccountName benefactor; - @JsonProperty("author") - private AccountName author; - @JsonProperty("permlink") - private Permlink permlink; - @JsonProperty("sbd_payout") - private Asset sbdPayout; - @JsonProperty("steem_payout") - private Asset steemPayout; - @JsonProperty("vesting_payout") - private Asset vestingPayout; - - /** - * @return the benefactor - */ - public AccountName getBenefactor() { - return benefactor; - } - - /** - * @return the author - */ - public AccountName getAuthor() { - return author; - } - - /** - * @return the permlink - */ - public Permlink getPermlink() { - return permlink; - } - - /** - * @return the sbd payout - */ - public Asset getSbdPayout() { - return sbdPayout; - } - - /** - * @return the steem payout - */ - public Asset getSteemPayout() { - return steemPayout; - } - - /** - * @return the vesting payout - */ - public Asset getVestingPayout() { - return vestingPayout; - } - -} diff --git a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/value/CurationRewardValue.java b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/value/CurationRewardValue.java deleted file mode 100644 index 903de3bd..00000000 --- a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/value/CurationRewardValue.java +++ /dev/null @@ -1,59 +0,0 @@ -package eu.bittrade.libs.steemj.protocol.operations.virtual.value; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import eu.bittrade.libs.steemj.base.models.Permlink; -import eu.bittrade.libs.steemj.protocol.AccountName; -import eu.bittrade.libs.steemj.protocol.Asset; - -public class CurationRewardValue { - - @JsonProperty("curator") - private AccountName curator; - @JsonProperty("reward") - private Asset reward; - @JsonProperty("comment_author") - private AccountName commentAuthor; - @JsonProperty("comment_permlink") - private Permlink commentPermlink; - - /** - * Get the person that receives the reward. - * - * @return The person that receives the reward. - */ - public AccountName getCurator() { - return curator; - } - - /** - * Get the amount and the currency the curator receives. - * - * @return The reward. - */ - public Asset getReward() { - return reward; - } - - /** - * Get the author of the post or comment that this curation reward is for. - * - * @return The author of the post or comment. - */ - public AccountName getCommentAuthor() { - return commentAuthor; - } - - /** - * Get the permanent link of the post or comment that this curation reward - * is for. - * - * @return The permanent link of the post or comment that this curation - * reward is for. - */ - public Permlink getCommentPermlink() { - return commentPermlink; - } - - -} diff --git a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/value/FillConvertRequestOperationValue.java b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/value/FillConvertRequestOperationValue.java deleted file mode 100644 index eb4c553f..00000000 --- a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/value/FillConvertRequestOperationValue.java +++ /dev/null @@ -1,55 +0,0 @@ -package eu.bittrade.libs.steemj.protocol.operations.virtual.value; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import eu.bittrade.libs.steemj.protocol.AccountName; -import eu.bittrade.libs.steemj.protocol.Asset; - -public class FillConvertRequestOperationValue { - @JsonProperty("owner") - private AccountName owner; - // Original type is uint32_t so we have to use long here. - @JsonProperty("requestid") - private long requestId; - @JsonProperty("amount_in") - private Asset amountIn; - @JsonProperty("amount_out") - private Asset amountOut; - - /** - * Get the owner of this conversion request. - * - * @return The owner as an AccountName instance. - */ - public AccountName getOwner() { - return owner; - } - - /** - * Get the id of this request. - * - * @return The id of this request. - */ - public long getRequestId() { - return requestId; - } - - /** - * Get the amount and the type of the currency that has been converted - * within this operation. - * - * @return The source asset. - */ - public Asset getAmountIn() { - return amountIn; - } - - /** - * Get the amount and the type of the target currency. - * - * @return The target asset. - */ - public Asset getAmountOut() { - return amountOut; - } -} diff --git a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/value/FillOrderOperationValue.java b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/value/FillOrderOperationValue.java deleted file mode 100644 index 2ef65df4..00000000 --- a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/value/FillOrderOperationValue.java +++ /dev/null @@ -1,66 +0,0 @@ -package eu.bittrade.libs.steemj.protocol.operations.virtual.value; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import eu.bittrade.libs.steemj.protocol.AccountName; -import eu.bittrade.libs.steemj.protocol.Asset; - -public class FillOrderOperationValue { - - @JsonProperty("current_owner") - private AccountName currentOwner; - @JsonProperty("current_orderid") - // Original type is uint32_t here so we have to use long. - private int currentOrderId; - @JsonProperty("current_pays") - private Asset currentPays; - @JsonProperty("open_owner") - private AccountName openOwner; - @JsonProperty("open_orderid") - // Original type is uint32_t here so we have to use long. - private long openOrderId; - @JsonProperty("open_pays") - private Asset openPays; - - /** - * @return The current owner. - */ - public AccountName getCurrentOwner() { - return currentOwner; - } - - /** - * @return The current order id. - */ - public int getCurrentOrderId() { - return currentOrderId; - } - - /** - * @return The current pays. - */ - public Asset getCurrentPays() { - return currentPays; - } - - /** - * @return The open owner. - */ - public AccountName getOpenOwner() { - return openOwner; - } - - /** - * @return The open order id. - */ - public long getOpenOrderId() { - return openOrderId; - } - - /** - * @return The open pays. - */ - public Asset getOpenPays() { - return openPays; - } -} diff --git a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/value/FillTransferFromSavingsOperationValue.java b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/value/FillTransferFromSavingsOperationValue.java deleted file mode 100644 index b0e0da33..00000000 --- a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/value/FillTransferFromSavingsOperationValue.java +++ /dev/null @@ -1,53 +0,0 @@ -package eu.bittrade.libs.steemj.protocol.operations.virtual.value; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import eu.bittrade.libs.steemj.protocol.AccountName; -import eu.bittrade.libs.steemj.protocol.Asset; - -public class FillTransferFromSavingsOperationValue { - private AccountName from; - private AccountName to; - private Asset amount; - // Original type is uint32_t here so we have to use long. - @JsonProperty("request_id") - private long requestId; - private String memo; - - /** - * @return the from - */ - public AccountName getFrom() { - return from; - } - - /** - * @return the to - */ - public AccountName getTo() { - return to; - } - - /** - * @return the amount - */ - public Asset getAmount() { - return amount; - } - - /** - * @return the requestId - */ - public long getRequestId() { - return requestId; - } - - /** - * @return the memo - */ - public String getMemo() { - return memo; - } - - -} diff --git a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/value/FillVestingWithdrawOperationValue.java b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/value/FillVestingWithdrawOperationValue.java deleted file mode 100644 index 2f7a6131..00000000 --- a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/value/FillVestingWithdrawOperationValue.java +++ /dev/null @@ -1,30 +0,0 @@ -package eu.bittrade.libs.steemj.protocol.operations.virtual.value; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import eu.bittrade.libs.steemj.protocol.AccountName; -import eu.bittrade.libs.steemj.protocol.Asset; - -public class FillVestingWithdrawOperationValue { - @JsonProperty("from_account") - private AccountName fromAccount; - @JsonProperty("to_account") - private AccountName toAccount; - private Asset withdrawn; - private Asset deposited; - public AccountName getFromAccount() { - return fromAccount; - } - public AccountName getToAccount() { - return toAccount; - } - public Asset getWithdrawn() { - return withdrawn; - } - public Asset getDeposited() { - return deposited; - } - - - -} diff --git a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/value/InterestOperationValue.java b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/value/InterestOperationValue.java deleted file mode 100644 index 0773b1db..00000000 --- a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/value/InterestOperationValue.java +++ /dev/null @@ -1,39 +0,0 @@ -package eu.bittrade.libs.steemj.protocol.operations.virtual.value; - -import org.apache.commons.lang3.builder.ToStringBuilder; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import eu.bittrade.libs.steemj.protocol.AccountName; -import eu.bittrade.libs.steemj.protocol.Asset; - -public class InterestOperationValue { - @JsonProperty("owner") - private AccountName owner; - @JsonProperty("interest") - private Asset interest; - - /** - * @return The owner. - */ - public AccountName getOwner() { - return owner; - } - - /** - * @return The interest. - */ - public Asset getInterest() { - return interest; - } - - private InterestOperationValue() { - super(); - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this); - } - -} diff --git a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/value/ProducerRewardOperationValue.java b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/value/ProducerRewardOperationValue.java deleted file mode 100644 index 03d1ee8f..00000000 --- a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/value/ProducerRewardOperationValue.java +++ /dev/null @@ -1,35 +0,0 @@ -package eu.bittrade.libs.steemj.protocol.operations.virtual.value; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import eu.bittrade.libs.steemj.protocol.AccountName; -import eu.bittrade.libs.steemj.protocol.Asset; - -public class ProducerRewardOperationValue { - - - @JsonProperty("producer") - private AccountName producer; - @JsonProperty("vesting_shares") - private Asset vestingShares; - - /** - * Get the block producer. - * - * @return The block producer. - */ - public AccountName getProducer() { - return producer; - } - - /** - * Get the amount of VESTS the producer got. - * - * @return The vesting shares paid to the producer. - */ - public Asset getVestingShares() { - return vestingShares; - } - - -} diff --git a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/value/ReturnVestingDelegationOperationValue.java b/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/value/ReturnVestingDelegationOperationValue.java deleted file mode 100644 index 1ec3929b..00000000 --- a/core/src/main/java/eu/bittrade/libs/steemj/protocol/operations/virtual/value/ReturnVestingDelegationOperationValue.java +++ /dev/null @@ -1,22 +0,0 @@ -package eu.bittrade.libs.steemj.protocol.operations.virtual.value; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import eu.bittrade.libs.steemj.protocol.AccountName; -import eu.bittrade.libs.steemj.protocol.Asset; - -public class ReturnVestingDelegationOperationValue { - - private AccountName account; - @JsonProperty("vesting_shares") - private Asset vestingShares; - public AccountName getAccount() { - return account; - } - public Asset getVestingShares() { - return vestingShares; - } - - - -} diff --git a/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/AuthorRewardOperationIT.java b/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/AuthorRewardOperationIT.java index 1049de9b..7658b2e0 100644 --- a/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/AuthorRewardOperationIT.java +++ b/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/AuthorRewardOperationIT.java @@ -22,6 +22,7 @@ import java.util.List; +import org.joou.UInteger; import org.junit.BeforeClass; import org.junit.Test; @@ -45,11 +46,11 @@ public class AuthorRewardOperationIT extends BaseITForOperationParsing { private static final String EXPECTED_AUTHOR = "joearnold"; private static final Permlink EXPECTED_PERMLINK = new Permlink( "re-quinneaker-re-joearnold-re-quinneaker-bounties-of-the-land-episode-7-preparing-for-winter-final-harvests-soon-20171003t161412134z"); - /* - * private static final LegacyAssetSymbolType EXPECTED_SBD_ASSET_SYMBOL = LegacyAssetSymbolType.SBD; - * private static final LegacyAssetSymbolType EXPECTED_STEEM_ASSET_SYMBOL = LegacyAssetSymbolType.STEEM; - * private static final LegacyAssetSymbolType EXPECTED_VESTS_ASSET_SYMBOL = LegacyAssetSymbolType.VESTS; - */ + + private static final UInteger EXPECTED_SBD_ASSET_SYMBOL = UInteger.valueOf(3200000003L); + private static final UInteger EXPECTED_STEEM_ASSET_SYMBOL = UInteger.valueOf(3200000035L); + private static final UInteger EXPECTED_VESTS_ASSET_SYMBOL = UInteger.valueOf(3200000070L); + /** * Prepare the environment for this specific test. * @@ -66,21 +67,22 @@ public static void prepareTestClass() throws Exception { public void testOperationParsing() throws SteemCommunicationException, SteemResponseException { List operationsInBlock = steemJ.getOpsInBlock(BLOCK_NUMBER_CONTAINING_OPERATION, true); - Operation authorRewardOperation = operationsInBlock.get(OPERATION_INDEX).getOp(); + Operation authorRewardOperation = operationsInBlock.get(OPERATION_INDEX).getOperationWrapper().getOperation(); assertThat(authorRewardOperation, instanceOf(AuthorRewardOperation.class)); - assertThat(((AuthorRewardOperation) authorRewardOperation).getValue().getAuthor().getName(), equalTo(EXPECTED_AUTHOR)); - assertThat(((AuthorRewardOperation) authorRewardOperation).getValue().getPermlink(), equalTo(EXPECTED_PERMLINK)); - assertThat(Long.toString(((AuthorRewardOperation) authorRewardOperation).getValue().getSbdPayout().getAmount()), equalTo(EXPECTED_SBD_VALUE)); + assertThat(((AuthorRewardOperation) authorRewardOperation).getAuthor().getName(), equalTo(EXPECTED_AUTHOR)); + assertThat(((AuthorRewardOperation) authorRewardOperation).getPermlink(), equalTo(EXPECTED_PERMLINK)); - //TODO: add more assertions - /* assertThat(((AuthorRewardOperation) authorRewardOperation).getValue().getSbdPayout().getSymbol(), + assertThat(Long.toString(((AuthorRewardOperation) authorRewardOperation).getSbdPayout().getAmount()), + equalTo(EXPECTED_SBD_VALUE)); + assertThat(((AuthorRewardOperation) authorRewardOperation).getSbdPayout().getAssetSymbolType().getAssetNumber(), equalTo(EXPECTED_SBD_ASSET_SYMBOL)); - assertThat(((AuthorRewardOperation) authorRewardOperation).getValue().getSteemPayout().getSymbol(), + assertThat( + ((AuthorRewardOperation) authorRewardOperation).getSteemPayout().getAssetSymbolType().getAssetNumber(), equalTo(EXPECTED_STEEM_ASSET_SYMBOL)); - assertThat(((AuthorRewardOperation) authorRewardOperation).getValue().getVestingPayout().getSymbol(), - equalTo(EXPECTED_VESTS_ASSET_SYMBOL));*/ + assertThat(((AuthorRewardOperation) authorRewardOperation).getVestingPayout().getAssetSymbolType() + .getAssetNumber(), equalTo(EXPECTED_VESTS_ASSET_SYMBOL)); } } diff --git a/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/CommentBenefactorRewardOperationIT.java b/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/CommentBenefactorRewardOperationIT.java index 2f66725b..b1916d2e 100644 --- a/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/CommentBenefactorRewardOperationIT.java +++ b/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/CommentBenefactorRewardOperationIT.java @@ -23,6 +23,7 @@ import java.math.BigDecimal; import java.util.List; +import org.joou.UInteger; import org.junit.BeforeClass; import org.junit.Test; @@ -48,11 +49,9 @@ public class CommentBenefactorRewardOperationIT extends BaseITForOperationParsin private static final AccountName EXPECTED_BENEFACTOR = new AccountName("chainbb"); private static final Permlink EXPECTED_PERMLINK = new Permlink( "re-mayvil-que-hacer-cuando-no-sabemos-de-edicion-2017926t205055909z"); - /* - * private static final LegacyAssetSymbolType EXPECTED_REWARD_VESTS_SYMBOL = LegacyAssetSymbolType.VESTS; - * private static final BigDecimal EXPECTED_REWARD_VESTS_VALUE_REAL = BigDecimal.valueOf(4.116952); - * private static final long EXPECTED_REWARD_VESTS_VALUE = 4116952L; - */ + private static final UInteger EXPECTED_REWARD_VESTS_SYMBOL = UInteger.valueOf(3200000070L); + private static final BigDecimal EXPECTED_REWARD_VESTS_VALUE_REAL = BigDecimal.valueOf(4.116953); + private static final long EXPECTED_REWARD_VESTS_VALUE = 4116953L; private static final String EXPECTED_VESTING_PAYOUT = "4116953"; /** @@ -71,22 +70,24 @@ public static void prepareTestClass() throws Exception { public void testOperationParsing() throws SteemCommunicationException, SteemResponseException { List operationsInBlock = steemJ.getOpsInBlock(BLOCK_NUMBER_CONTAINING_OPERATION, true); - Operation commentBenefactorRewardOperation = operationsInBlock.get(OPERATION_INDEX).getOp(); + Operation commentBenefactorRewardOperation = operationsInBlock.get(OPERATION_INDEX).getOperationWrapper() + .getOperation(); assertThat(commentBenefactorRewardOperation, instanceOf(CommentBenefactorRewardOperation.class)); - assertThat(((CommentBenefactorRewardOperation) commentBenefactorRewardOperation).getValue().getAuthor().getName(), + assertThat(((CommentBenefactorRewardOperation) commentBenefactorRewardOperation).getAuthor().getName(), equalTo(EXPECTED_AUTHOR)); - assertThat(((CommentBenefactorRewardOperation) commentBenefactorRewardOperation).getValue().getBenefactor(), + assertThat(((CommentBenefactorRewardOperation) commentBenefactorRewardOperation).getBenefactor(), equalTo(EXPECTED_BENEFACTOR)); - assertThat(((CommentBenefactorRewardOperation) commentBenefactorRewardOperation).getValue().getPermlink(), + assertThat(((CommentBenefactorRewardOperation) commentBenefactorRewardOperation).getPermlink(), equalTo(EXPECTED_PERMLINK)); - //TODO: add more assertions - /* assertThat(((CommentBenefactorRewardOperation) commentBenefactorRewardOperation).getReward().getSymbol(), - equalTo(EXPECTED_REWARD_VESTS_SYMBOL)); - assertThat(((CommentBenefactorRewardOperation) commentBenefactorRewardOperation).getReward().toReal(), - equalTo(EXPECTED_REWARD_VESTS_VALUE_REAL)); - assertThat(((CommentBenefactorRewardOperation) commentBenefactorRewardOperation).getValue().getReward().getAmount(), - equalTo(EXPECTED_REWARD_VESTS_VALUE)); */ - assertThat(Long.toString(((CommentBenefactorRewardOperation) commentBenefactorRewardOperation).getValue().getVestingPayout().getAmount()), equalTo(EXPECTED_VESTING_PAYOUT)); + assertThat(((CommentBenefactorRewardOperation) commentBenefactorRewardOperation).getVestingPayout() + .getAssetSymbolType().getAssetNumber(), equalTo(EXPECTED_REWARD_VESTS_SYMBOL)); + assertThat(((CommentBenefactorRewardOperation) commentBenefactorRewardOperation).getVestingPayout().toReal(), + equalTo(EXPECTED_REWARD_VESTS_VALUE_REAL)); + assertThat(((CommentBenefactorRewardOperation) commentBenefactorRewardOperation).getVestingPayout().getAmount(), + equalTo(EXPECTED_REWARD_VESTS_VALUE)); + assertThat(Long.toString( + ((CommentBenefactorRewardOperation) commentBenefactorRewardOperation).getVestingPayout().getAmount()), + equalTo(EXPECTED_VESTING_PAYOUT)); } } diff --git a/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/CurationRewardOperationIT.java b/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/CurationRewardOperationIT.java index e0a3cd97..34a0c01d 100644 --- a/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/CurationRewardOperationIT.java +++ b/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/CurationRewardOperationIT.java @@ -23,6 +23,7 @@ import java.math.BigDecimal; import java.util.List; +import org.joou.UInteger; import org.junit.BeforeClass; import org.junit.Test; @@ -47,10 +48,8 @@ public class CurationRewardOperationIT extends BaseITForOperationParsing { private static final AccountName EXPECTED_CURATOR = new AccountName("quinneaker"); private static final Permlink EXPECTED_PERMLINK = new Permlink( "re-quinneaker-re-joearnold-re-quinneaker-bounties-of-the-land-episode-7-preparing-for-winter-final-harvests-soon-20171003t161412134z"); - /* - * private static final LegacyAssetSymbolType EXPECTED_REWARD_SYMBOL = LegacyAssetSymbolType.VESTS; - * private static final BigDecimal EXPECTED_REWARD_VALUE_REAL = BigDecimal.valueOf(6.173331); - */ + private static final UInteger EXPECTED_REWARD_SYMBOL = UInteger.valueOf(3200000070L); + private static final BigDecimal EXPECTED_REWARD_VALUE_REAL = BigDecimal.valueOf(6.173331); private static final long EXPECTED_REWARD_VALUE = 6173331L; /** @@ -69,21 +68,21 @@ public static void prepareTestClass() throws Exception { public void testOperationParsing() throws SteemCommunicationException, SteemResponseException { List operationsInBlock = steemJ.getOpsInBlock(BLOCK_NUMBER_CONTAINING_OPERATION, true); - Operation curationRewardOperation = operationsInBlock.get(OPERATION_INDEX).getOp(); + Operation curationRewardOperation = operationsInBlock.get(OPERATION_INDEX).getOperationWrapper().getOperation(); assertThat(curationRewardOperation, instanceOf(CurationRewardOperation.class)); - assertThat(((CurationRewardOperation) curationRewardOperation).getCurationRewardValue().getCommentAuthor().getName(), + assertThat(((CurationRewardOperation) curationRewardOperation).getCommentAuthor().getName(), equalTo(EXPECTED_AUTHOR)); - assertThat(((CurationRewardOperation) curationRewardOperation).getCurationRewardValue().getCurator(), equalTo(EXPECTED_CURATOR)); - assertThat(((CurationRewardOperation) curationRewardOperation).getCurationRewardValue().getCommentPermlink(), + assertThat(((CurationRewardOperation) curationRewardOperation).getCurator(), equalTo(EXPECTED_CURATOR)); + assertThat(((CurationRewardOperation) curationRewardOperation).getCommentPermlink(), equalTo(EXPECTED_PERMLINK)); - //TODO: add more assertions - /* assertThat(((CurationRewardOperation) curationRewardOperation).getCurationRewardValue().getReward().getSymbol(), + assertThat( + ((CurationRewardOperation) curationRewardOperation).getReward().getAssetSymbolType().getAssetNumber(), equalTo(EXPECTED_REWARD_SYMBOL)); - assertThat(((CurationRewardOperation) curationRewardOperation).getCurationRewardValue().getReward().toReal(), - equalTo(EXPECTED_REWARD_VALUE_REAL)); */ - assertThat(((CurationRewardOperation) curationRewardOperation).getCurationRewardValue().getReward().getAmount(), + assertThat(((CurationRewardOperation) curationRewardOperation).getReward().toReal(), + equalTo(EXPECTED_REWARD_VALUE_REAL)); + assertThat(((CurationRewardOperation) curationRewardOperation).getReward().getAmount(), equalTo(EXPECTED_REWARD_VALUE)); } diff --git a/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/FillConvertRequestOperationIT.java b/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/FillConvertRequestOperationIT.java index fbef1644..f206a9d5 100644 --- a/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/FillConvertRequestOperationIT.java +++ b/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/FillConvertRequestOperationIT.java @@ -20,8 +20,10 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.instanceOf; +import java.math.BigDecimal; import java.util.List; +import org.joou.UInteger; import org.junit.BeforeClass; import org.junit.Test; @@ -43,16 +45,11 @@ public class FillConvertRequestOperationIT extends BaseITForOperationParsing { private static final int OPERATION_INDEX = 1; private static final String EXPECTED_OWNER = "jiminykricket"; private static final long EXPECTED_REQUEST_ID = 1506775956L; - /* - * private static final LegacyAssetSymbolType EXPECTED_AMOUNT_IN_SYMBOL = LegacyAssetSymbolType.SBD; - * private static final BigDecimal EXPECTED_AMOUNT_IN_VALUE_REAL = BigDecimal.valueOf(0.024); - - */ + private static final UInteger EXPECTED_AMOUNT_IN_SYMBOL = UInteger.valueOf(3200000003L); + private static final BigDecimal EXPECTED_AMOUNT_IN_VALUE_REAL = BigDecimal.valueOf(0.024); private static final long EXPECTED_AMOUNT_IN_VALUE = 24L; - /* - * private static final LegacyAssetSymbolType EXPECTED_AMOUNT_OUT_SYMBOL = LegacyAssetSymbolType.STEEM; - * private static final BigDecimal EXPECTED_AMOUNT_OUT_VALUE_REAL = BigDecimal.valueOf(0.017); - */ + private static final UInteger EXPECTED_AMOUNT_OUT_SYMBOL = UInteger.valueOf(3200000035L); + private static final BigDecimal EXPECTED_AMOUNT_OUT_VALUE_REAL = BigDecimal.valueOf(0.017); private static final long EXPECTED_AMOUNT_OUT_VALUE = 17L; /** @@ -71,26 +68,26 @@ public static void prepareTestClass() throws Exception { public void testOperationParsing() throws SteemCommunicationException, SteemResponseException { List operationsInBlock = steemJ.getOpsInBlock(BLOCK_NUMBER_CONTAINING_OPERATION, true); - Operation fillConvertRequestOperation = operationsInBlock.get(OPERATION_INDEX).getOp(); + Operation fillConvertRequestOperation = operationsInBlock.get(OPERATION_INDEX).getOperationWrapper() + .getOperation(); assertThat(fillConvertRequestOperation, instanceOf(FillConvertRequestOperation.class)); - assertThat(((FillConvertRequestOperation) fillConvertRequestOperation).getValue().getOwner().getName(), + assertThat(((FillConvertRequestOperation) fillConvertRequestOperation).getOwner().getName(), equalTo(EXPECTED_OWNER)); - assertThat(((FillConvertRequestOperation) fillConvertRequestOperation).getValue().getRequestId(), + assertThat(((FillConvertRequestOperation) fillConvertRequestOperation).getRequestId(), equalTo(EXPECTED_REQUEST_ID)); - //TODO: add more assertions - /* assertThat(((FillConvertRequestOperation) fillConvertRequestOperation).getValue().getAmountIn().getSymbol(), - equalTo(EXPECTED_AMOUNT_IN_SYMBOL)); - assertThat(((FillConvertRequestOperation) fillConvertRequestOperation).getValue().getAmountIn().toReal(), - equalTo(EXPECTED_AMOUNT_IN_VALUE_REAL));*/ - assertThat(((FillConvertRequestOperation) fillConvertRequestOperation).getValue().getAmountIn().getAmount(), + assertThat(((FillConvertRequestOperation) fillConvertRequestOperation).getAmountIn().getAssetSymbolType() + .getAssetNumber(), equalTo(EXPECTED_AMOUNT_IN_SYMBOL)); + assertThat(((FillConvertRequestOperation) fillConvertRequestOperation).getAmountIn().toReal(), + equalTo(EXPECTED_AMOUNT_IN_VALUE_REAL)); + assertThat(((FillConvertRequestOperation) fillConvertRequestOperation).getAmountIn().getAmount(), equalTo(EXPECTED_AMOUNT_IN_VALUE)); - /* assertThat(((FillConvertRequestOperation) fillConvertRequestOperation).getValue().getAmountOut().getSymbol(), - equalTo(EXPECTED_AMOUNT_OUT_SYMBOL)); - assertThat(((FillConvertRequestOperation) fillConvertRequestOperation).getValue().getAmountOut().toReal(), - equalTo(EXPECTED_AMOUNT_OUT_VALUE_REAL));*/ - assertThat(((FillConvertRequestOperation) fillConvertRequestOperation).getValue().getAmountOut().getAmount(), + assertThat(((FillConvertRequestOperation) fillConvertRequestOperation).getAmountOut().getAssetSymbolType() + .getAssetNumber(), equalTo(EXPECTED_AMOUNT_OUT_SYMBOL)); + assertThat(((FillConvertRequestOperation) fillConvertRequestOperation).getAmountOut().toReal(), + equalTo(EXPECTED_AMOUNT_OUT_VALUE_REAL)); + assertThat(((FillConvertRequestOperation) fillConvertRequestOperation).getAmountOut().getAmount(), equalTo(EXPECTED_AMOUNT_OUT_VALUE)); } } diff --git a/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/FillOrderOperationIT.java b/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/FillOrderOperationIT.java index 38e56c85..5b3ab7c7 100644 --- a/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/FillOrderOperationIT.java +++ b/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/FillOrderOperationIT.java @@ -23,6 +23,7 @@ import java.math.BigDecimal; import java.util.List; +import org.joou.UInteger; import org.junit.BeforeClass; import org.junit.Test; @@ -31,7 +32,6 @@ import eu.bittrade.libs.steemj.exceptions.SteemResponseException; import eu.bittrade.libs.steemj.plugins.apis.account.history.models.AppliedOperation; import eu.bittrade.libs.steemj.protocol.AccountName; -import eu.bittrade.libs.steemj.protocol.enums.LegacyAssetSymbolType; import eu.bittrade.libs.steemj.protocol.operations.Operation; import eu.bittrade.libs.steemj.protocol.operations.virtual.FillOrderOperation; import eu.bittrade.libs.steemj.protocol.operations.virtual.ProducerRewardOperation; @@ -48,16 +48,11 @@ public class FillOrderOperationIT extends BaseITForOperationParsing { private static final AccountName EXPECTED_OPEN_OWNER = new AccountName("oscarps"); private static final int EXPECTED_CURRENT_ORDER_ID = 1507078540; private static final long EXPECTED_OPEN_ORDER_ID = 1507059984L; - /* - * private static final LegacyAssetSymbolType EXPECTED_OPEN_PAYS_SYMBOL = LegacyAssetSymbolType.STEEM; - * private static final BigDecimal EXPECTED_OPEN_PAYS_VALUE_REAL = BigDecimal.valueOf(0.015); - - */ + private static final UInteger EXPECTED_OPEN_PAYS_SYMBOL = UInteger.valueOf(3200000035L); + private static final BigDecimal EXPECTED_OPEN_PAYS_VALUE_REAL = new BigDecimal("0.015"); private static final long EXPECTED_OPEN_PAYS_VALUE = 15L; - /* - * private static final LegacyAssetSymbolType EXPECTED_CURRENT_PAYS_SYMBOL = LegacyAssetSymbolType.SBD; - * private static final BigDecimal EXPECTED_CURRENT_PAYS_VALUE_REAL = BigDecimal.valueOf(0.02); - */ + private static final UInteger EXPECTED_CURRENT_PAYS_SYMBOL = UInteger.valueOf(3200000003L); + private static final BigDecimal EXPECTED_CURRENT_PAYS_VALUE_REAL = new BigDecimal("0.020"); private static final long EXPECTED_CURRENT_PAYS_VALUE = 20L; /** @@ -76,27 +71,26 @@ public static void prepareTestClass() throws Exception { public void testOperationParsing() throws SteemCommunicationException, SteemResponseException { List operationsInBlock = steemJ.getOpsInBlock(BLOCK_NUMBER_CONTAINING_OPERATION, true); - Operation fillOrderOperation = operationsInBlock.get(OPERATION_INDEX).getOp(); + Operation fillOrderOperation = operationsInBlock.get(OPERATION_INDEX).getOperationWrapper().getOperation(); assertThat(fillOrderOperation, instanceOf(FillOrderOperation.class)); - assertThat(((FillOrderOperation) fillOrderOperation).getValue().getCurrentOwner().getName(), + assertThat(((FillOrderOperation) fillOrderOperation).getCurrentOwner().getName(), equalTo(EXPECTED_CURRENT_OWNER)); - assertThat(((FillOrderOperation) fillOrderOperation).getValue().getOpenOwner(), equalTo(EXPECTED_OPEN_OWNER)); - assertThat(((FillOrderOperation) fillOrderOperation).getValue().getCurrentOrderId(), equalTo(EXPECTED_CURRENT_ORDER_ID)); - assertThat(((FillOrderOperation) fillOrderOperation).getValue().getOpenOrderId(), equalTo(EXPECTED_OPEN_ORDER_ID)); - //TODO: add more assertions - /* assertThat(((FillOrderOperation) fillOrderOperation).getValue().getOpenPays().getSymbol(), - equalTo(EXPECTED_OPEN_PAYS_SYMBOL)); - assertThat(((FillOrderOperation) fillOrderOperation).getValue().getOpenPays().toReal(), - equalTo(EXPECTED_OPEN_PAYS_VALUE_REAL)); */ - assertThat(((FillOrderOperation) fillOrderOperation).getValue().getOpenPays().getAmount(), + assertThat(((FillOrderOperation) fillOrderOperation).getOpenOwner(), equalTo(EXPECTED_OPEN_OWNER)); + assertThat(((FillOrderOperation) fillOrderOperation).getCurrentOrderId(), equalTo(EXPECTED_CURRENT_ORDER_ID)); + assertThat(((FillOrderOperation) fillOrderOperation).getOpenOrderId(), equalTo(EXPECTED_OPEN_ORDER_ID)); + assertThat(((FillOrderOperation) fillOrderOperation).getOpenPays().getAssetSymbolType().getAssetNumber(), + equalTo(EXPECTED_OPEN_PAYS_SYMBOL)); + assertThat(((FillOrderOperation) fillOrderOperation).getOpenPays().toReal(), + equalTo(EXPECTED_OPEN_PAYS_VALUE_REAL)); + assertThat(((FillOrderOperation) fillOrderOperation).getOpenPays().getAmount(), equalTo(EXPECTED_OPEN_PAYS_VALUE)); - /* assertThat(((FillOrderOperation) fillOrderOperation).getValue().getCurrentPays().getSymbol(), + assertThat(((FillOrderOperation) fillOrderOperation).getCurrentPays().getAssetSymbolType().getAssetNumber(), equalTo(EXPECTED_CURRENT_PAYS_SYMBOL)); - assertThat(((FillOrderOperation) fillOrderOperation).getValue().getCurrentPays().toReal(), - equalTo(EXPECTED_CURRENT_PAYS_VALUE_REAL));*/ - assertThat(((FillOrderOperation) fillOrderOperation).getValue().getCurrentPays().getAmount(), + assertThat(((FillOrderOperation) fillOrderOperation).getCurrentPays().toReal(), + equalTo(EXPECTED_CURRENT_PAYS_VALUE_REAL)); + assertThat(((FillOrderOperation) fillOrderOperation).getCurrentPays().getAmount(), equalTo(EXPECTED_CURRENT_PAYS_VALUE)); } } diff --git a/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/FillTransferFromSavingsOperationIT.java b/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/FillTransferFromSavingsOperationIT.java index 6a0715f9..bda84c37 100644 --- a/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/FillTransferFromSavingsOperationIT.java +++ b/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/FillTransferFromSavingsOperationIT.java @@ -23,6 +23,7 @@ import java.math.BigDecimal; import java.util.List; +import org.joou.UInteger; import org.junit.BeforeClass; import org.junit.Test; @@ -31,7 +32,6 @@ import eu.bittrade.libs.steemj.exceptions.SteemResponseException; import eu.bittrade.libs.steemj.plugins.apis.account.history.models.AppliedOperation; import eu.bittrade.libs.steemj.protocol.AccountName; -import eu.bittrade.libs.steemj.protocol.enums.LegacyAssetSymbolType; import eu.bittrade.libs.steemj.protocol.operations.Operation; import eu.bittrade.libs.steemj.protocol.operations.virtual.FillTransferFromSavingsOperation; import eu.bittrade.libs.steemj.protocol.operations.virtual.ProducerRewardOperation; @@ -48,10 +48,8 @@ public class FillTransferFromSavingsOperationIT extends BaseITForOperationParsin private static final AccountName EXPECTED_TO = new AccountName("anonimous"); private static final String EXPECTED_MEMO = ""; private static final long EXPECTED_REQUEST_ID = 1506820294L; - /* - * private static final LegacyAssetSymbolType EXPECTED_AMOUNT_SYMBOL = LegacyAssetSymbolType.SBD; - * private static final BigDecimal EXPECTED_AMOUNT_VALUE_REAL = BigDecimal.valueOf(7.5); - */ + private static final UInteger EXPECTED_AMOUNT_SYMBOL = UInteger.valueOf(3200000003L); + private static final BigDecimal EXPECTED_AMOUNT_VALUE_REAL = BigDecimal.valueOf(7500, 3); private static final long EXPECTED_AMOUNT_VALUE = 7500L; /** @@ -70,23 +68,23 @@ public static void prepareTestClass() throws Exception { public void testOperationParsing() throws SteemCommunicationException, SteemResponseException { List operationsInBlock = steemJ.getOpsInBlock(BLOCK_NUMBER_CONTAINING_OPERATION, true); - Operation fillTransferFromSavingsOperation = operationsInBlock.get(OPERATION_INDEX).getOp(); + Operation fillTransferFromSavingsOperation = operationsInBlock.get(OPERATION_INDEX).getOperationWrapper() + .getOperation(); assertThat(fillTransferFromSavingsOperation, instanceOf(FillTransferFromSavingsOperation.class)); - assertThat(((FillTransferFromSavingsOperation) fillTransferFromSavingsOperation).getValue().getFrom().getName(), + assertThat(((FillTransferFromSavingsOperation) fillTransferFromSavingsOperation).getFrom().getName(), equalTo(EXPECTED_FROM)); - assertThat(((FillTransferFromSavingsOperation) fillTransferFromSavingsOperation).getValue().getTo(), equalTo(EXPECTED_TO)); - assertThat(((FillTransferFromSavingsOperation) fillTransferFromSavingsOperation).getValue().getMemo(), + assertThat(((FillTransferFromSavingsOperation) fillTransferFromSavingsOperation).getTo(), equalTo(EXPECTED_TO)); + assertThat(((FillTransferFromSavingsOperation) fillTransferFromSavingsOperation).getMemo(), equalTo(EXPECTED_MEMO)); - assertThat(((FillTransferFromSavingsOperation) fillTransferFromSavingsOperation).getValue().getRequestId(), + assertThat(((FillTransferFromSavingsOperation) fillTransferFromSavingsOperation).getRequestId(), equalTo(EXPECTED_REQUEST_ID)); - //TODO: add more assertions - /* assertThat(((FillTransferFromSavingsOperation) fillTransferFromSavingsOperation).getValue().getAmount().getSymbol(), - equalTo(EXPECTED_AMOUNT_SYMBOL)); + assertThat(((FillTransferFromSavingsOperation) fillTransferFromSavingsOperation).getAmount() + .getAssetSymbolType().getAssetNumber(), equalTo(EXPECTED_AMOUNT_SYMBOL)); assertThat(((FillTransferFromSavingsOperation) fillTransferFromSavingsOperation).getAmount().toReal(), - equalTo(EXPECTED_AMOUNT_VALUE_REAL)); */ - assertThat(((FillTransferFromSavingsOperation) fillTransferFromSavingsOperation).getValue().getAmount().getAmount(), + equalTo(EXPECTED_AMOUNT_VALUE_REAL)); + assertThat(((FillTransferFromSavingsOperation) fillTransferFromSavingsOperation).getAmount().getAmount(), equalTo(EXPECTED_AMOUNT_VALUE)); } } diff --git a/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/FillVestingWithdrawOperationIT.java b/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/FillVestingWithdrawOperationIT.java index 2cfe4462..1f1b2f67 100644 --- a/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/FillVestingWithdrawOperationIT.java +++ b/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/FillVestingWithdrawOperationIT.java @@ -23,6 +23,7 @@ import java.math.BigDecimal; import java.util.List; +import org.joou.UInteger; import org.junit.BeforeClass; import org.junit.Test; @@ -31,7 +32,6 @@ import eu.bittrade.libs.steemj.exceptions.SteemResponseException; import eu.bittrade.libs.steemj.plugins.apis.account.history.models.AppliedOperation; import eu.bittrade.libs.steemj.protocol.AccountName; -import eu.bittrade.libs.steemj.protocol.enums.LegacyAssetSymbolType; import eu.bittrade.libs.steemj.protocol.operations.Operation; import eu.bittrade.libs.steemj.protocol.operations.virtual.FillVestingWithdrawOperation; import eu.bittrade.libs.steemj.protocol.operations.virtual.ProducerRewardOperation; @@ -46,15 +46,11 @@ public class FillVestingWithdrawOperationIT extends BaseITForOperationParsing { private static final int OPERATION_INDEX = 3; private static final String EXPECTED_FROM = "chessmonster"; private static final AccountName EXPECTED_TO = new AccountName("chessmonster"); - /* - * private static final LegacyAssetSymbolType EXPECTED_DEPOSIT_SYMBOL = LegacyAssetSymbolType.STEEM; - * private static final BigDecimal EXPECTED_DEPOSIT_VALUE_REAL = BigDecimal.valueOf(926.471); - */ + private static final UInteger EXPECTED_DEPOSIT_SYMBOL = UInteger.valueOf(3200000035L); + private static final BigDecimal EXPECTED_DEPOSIT_VALUE_REAL = BigDecimal.valueOf(926.471); private static final long EXPECTED_DEPOSIT_VALUE = 926471; - /* - * private static final LegacyAssetSymbolType EXPECTED_WITHDRAWN_SYMBOL = LegacyAssetSymbolType.VESTS; - * private static final BigDecimal EXPECTED_WITHDRAWN_VALUE_REAL = BigDecimal.valueOf(1907116.401647); - */ + private static final UInteger EXPECTED_WITHDRAWN_SYMBOL = UInteger.valueOf(3200000070L); + private static final BigDecimal EXPECTED_WITHDRAWN_VALUE_REAL = BigDecimal.valueOf(1907116.401647); private static final long EXPECTED_WITHDRAWN_VALUE = 1907116401647L; /** @@ -73,25 +69,25 @@ public static void prepareTestClass() throws Exception { public void testOperationParsing() throws SteemCommunicationException, SteemResponseException { List operationsInBlock = steemJ.getOpsInBlock(BLOCK_NUMBER_CONTAINING_OPERATION, true); - Operation fillVestingWithdrawOperation = operationsInBlock.get(OPERATION_INDEX).getOp(); + Operation fillVestingWithdrawOperation = operationsInBlock.get(OPERATION_INDEX).getOperationWrapper() + .getOperation(); assertThat(fillVestingWithdrawOperation, instanceOf(FillVestingWithdrawOperation.class)); - assertThat(((FillVestingWithdrawOperation) fillVestingWithdrawOperation).getValue().getFromAccount().getName(), + assertThat(((FillVestingWithdrawOperation) fillVestingWithdrawOperation).getFromAccount().getName(), equalTo(EXPECTED_FROM)); - assertThat(((FillVestingWithdrawOperation) fillVestingWithdrawOperation).getValue().getToAccount(), equalTo(EXPECTED_TO)); - //TODO: add more assertions - /*assertThat(((FillVestingWithdrawOperation) fillVestingWithdrawOperation).getDeposited().getSymbol(), - equalTo(EXPECTED_DEPOSIT_SYMBOL)); + assertThat(((FillVestingWithdrawOperation) fillVestingWithdrawOperation).getToAccount(), equalTo(EXPECTED_TO)); + assertThat(((FillVestingWithdrawOperation) fillVestingWithdrawOperation).getDeposited().getAssetSymbolType() + .getAssetNumber(), equalTo(EXPECTED_DEPOSIT_SYMBOL)); assertThat(((FillVestingWithdrawOperation) fillVestingWithdrawOperation).getDeposited().toReal(), - equalTo(EXPECTED_DEPOSIT_VALUE_REAL)); */ - assertThat(((FillVestingWithdrawOperation) fillVestingWithdrawOperation).getValue().getDeposited().getAmount(), + equalTo(EXPECTED_DEPOSIT_VALUE_REAL)); + assertThat(((FillVestingWithdrawOperation) fillVestingWithdrawOperation).getDeposited().getAmount(), equalTo(EXPECTED_DEPOSIT_VALUE)); - /* assertThat(((FillVestingWithdrawOperation) fillVestingWithdrawOperation).getWithdrawn().getSymbol(), - equalTo(EXPECTED_WITHDRAWN_SYMBOL)); + assertThat(((FillVestingWithdrawOperation) fillVestingWithdrawOperation).getWithdrawn().getAssetSymbolType() + .getAssetNumber(), equalTo(EXPECTED_WITHDRAWN_SYMBOL)); assertThat(((FillVestingWithdrawOperation) fillVestingWithdrawOperation).getWithdrawn().toReal(), - equalTo(EXPECTED_WITHDRAWN_VALUE_REAL)); */ - assertThat(((FillVestingWithdrawOperation) fillVestingWithdrawOperation).getValue().getWithdrawn().getAmount(), + equalTo(EXPECTED_WITHDRAWN_VALUE_REAL)); + assertThat(((FillVestingWithdrawOperation) fillVestingWithdrawOperation).getWithdrawn().getAmount(), equalTo(EXPECTED_WITHDRAWN_VALUE)); } } diff --git a/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/InterestOperationIT.java b/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/InterestOperationIT.java index c304a4b1..d6f7a262 100644 --- a/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/InterestOperationIT.java +++ b/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/InterestOperationIT.java @@ -23,6 +23,7 @@ import java.math.BigDecimal; import java.util.List; +import org.joou.UInteger; import org.junit.BeforeClass; import org.junit.Test; @@ -30,7 +31,6 @@ import eu.bittrade.libs.steemj.exceptions.SteemCommunicationException; import eu.bittrade.libs.steemj.exceptions.SteemResponseException; import eu.bittrade.libs.steemj.plugins.apis.account.history.models.AppliedOperation; -import eu.bittrade.libs.steemj.protocol.enums.LegacyAssetSymbolType; import eu.bittrade.libs.steemj.protocol.operations.Operation; import eu.bittrade.libs.steemj.protocol.operations.virtual.CurationRewardOperation; import eu.bittrade.libs.steemj.protocol.operations.virtual.InterestOperation; @@ -44,10 +44,8 @@ public class InterestOperationIT extends BaseITForOperationParsing { private static final int BLOCK_NUMBER_CONTAINING_OPERATION = 16022103; private static final int OPERATION_INDEX = 0; private static final String EXPECTED_OWNER = "eric818"; - /* - * private static final LegacyAssetSymbolType EXPECTED_INTEREST_SYMBOL = LegacyAssetSymbolType.SBD; - * private static final BigDecimal EXPECTED_INTEREST_VALUE_REAL = BigDecimal.valueOf(0.003); - */ + private static final UInteger EXPECTED_INTEREST_SYMBOL = UInteger.valueOf(3200000003L); + private static final BigDecimal EXPECTED_INTEREST_VALUE_REAL = BigDecimal.valueOf(0.003); private static final long EXPECTED_INTEREST_VALUE = 3L; /** @@ -66,16 +64,15 @@ public static void prepareTestClass() throws Exception { public void testOperationParsing() throws SteemCommunicationException, SteemResponseException { List operationsInBlock = steemJ.getOpsInBlock(BLOCK_NUMBER_CONTAINING_OPERATION, true); - Operation interestOperation = operationsInBlock.get(OPERATION_INDEX).getOp(); + Operation interestOperation = operationsInBlock.get(OPERATION_INDEX).getOperationWrapper().getOperation(); assertThat(interestOperation, instanceOf(InterestOperation.class)); - assertThat(((InterestOperation) interestOperation).getValue().getOwner().getName(), equalTo(EXPECTED_OWNER)); - //TODO: add more assertions - /* assertThat(((InterestOperation) interestOperation).getValue().getInterest().getSymbol(), + assertThat(((InterestOperation) interestOperation).getOwner().getName(), equalTo(EXPECTED_OWNER)); + assertThat(((InterestOperation) interestOperation).getInterest().getAssetSymbolType().getAssetNumber(), equalTo(EXPECTED_INTEREST_SYMBOL)); - assertThat(((InterestOperation) interestOperation).getValue().getInterest().toReal(), - equalTo(EXPECTED_INTEREST_VALUE_REAL)); */ - assertThat(((InterestOperation) interestOperation).getValue().getInterest().getAmount(), equalTo(EXPECTED_INTEREST_VALUE)); + assertThat(((InterestOperation) interestOperation).getInterest().toReal(), + equalTo(EXPECTED_INTEREST_VALUE_REAL)); + assertThat(((InterestOperation) interestOperation).getInterest().getAmount(), equalTo(EXPECTED_INTEREST_VALUE)); } } diff --git a/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/ProducerRewardOperationIT.java b/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/ProducerRewardOperationIT.java index 10d8b4e2..ae81c753 100644 --- a/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/ProducerRewardOperationIT.java +++ b/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/ProducerRewardOperationIT.java @@ -23,6 +23,7 @@ import java.math.BigDecimal; import java.util.List; +import org.joou.UInteger; import org.junit.BeforeClass; import org.junit.Test; @@ -30,7 +31,6 @@ import eu.bittrade.libs.steemj.exceptions.SteemCommunicationException; import eu.bittrade.libs.steemj.exceptions.SteemResponseException; import eu.bittrade.libs.steemj.plugins.apis.account.history.models.AppliedOperation; -import eu.bittrade.libs.steemj.protocol.enums.LegacyAssetSymbolType; import eu.bittrade.libs.steemj.protocol.operations.Operation; import eu.bittrade.libs.steemj.protocol.operations.virtual.ProducerRewardOperation; @@ -43,10 +43,9 @@ public class ProducerRewardOperationIT extends BaseITForOperationParsing { private static final int BLOCK_NUMBER_CONTAINING_OPERATION = 16212111; private static final int OPERATION_INDEX = 0; private static final String EXPECTED_PRODUCER = "xeldal"; - /* - * private static final LegacyAssetSymbolType EXPECTED_VESTS_SYMBOL = LegacyAssetSymbolType.VESTS; - * private static final BigDecimal EXPECTED_VESTS_VALUE_REAL = BigDecimal.valueOf(390.97665); - */ + private static final UInteger EXPECTED_VESTS_SYMBOL = UInteger.valueOf(3200000070L); + private static final BigDecimal EXPECTED_VESTS_VALUE_REAL = BigDecimal.valueOf(390976650, 6); + private static final long EXPECTED_VESTS_VALUE = 390976650L; /** @@ -65,18 +64,17 @@ public static void prepareTestClass() throws Exception { public void testOperationParsing() throws SteemCommunicationException, SteemResponseException { List operationsInBlock = steemJ.getOpsInBlock(BLOCK_NUMBER_CONTAINING_OPERATION, true); - Operation producerRewardOperation = operationsInBlock.get(OPERATION_INDEX).getOp(); + Operation producerRewardOperation = operationsInBlock.get(OPERATION_INDEX).getOperationWrapper().getOperation(); assertThat(producerRewardOperation, instanceOf(ProducerRewardOperation.class)); - assertThat(((ProducerRewardOperation) producerRewardOperation).getValue().getProducer().getName(), + assertThat(((ProducerRewardOperation) producerRewardOperation).getProducer().getName(), equalTo(EXPECTED_PRODUCER)); - //TODO: add more assertions - /* assertThat(((ProducerRewardOperation) producerRewardOperation).getValue().getVestingShares().getSymbol(), - equalTo(EXPECTED_VESTS_SYMBOL)); - assertThat(((ProducerRewardOperation) producerRewardOperation).getValue().getVestingShares().toReal(), - equalTo(EXPECTED_VESTS_VALUE_REAL));*/ - assertThat(((ProducerRewardOperation) producerRewardOperation).getValue().getVestingShares().getAmount(), + assertThat(((ProducerRewardOperation) producerRewardOperation).getVestingShares().getAssetSymbolType() + .getAssetNumber(), equalTo(EXPECTED_VESTS_SYMBOL)); + assertThat(((ProducerRewardOperation) producerRewardOperation).getVestingShares().toReal(), + equalTo(EXPECTED_VESTS_VALUE_REAL)); + assertThat(((ProducerRewardOperation) producerRewardOperation).getVestingShares().getAmount(), equalTo(EXPECTED_VESTS_VALUE)); } } diff --git a/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/ReturnVestingDelegationOperationIT.java b/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/ReturnVestingDelegationOperationIT.java index e5331660..9dd77a39 100644 --- a/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/ReturnVestingDelegationOperationIT.java +++ b/core/src/test/java/eu/bittrade/libs/steemj/base/models/operations/virtual/ReturnVestingDelegationOperationIT.java @@ -20,8 +20,10 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.instanceOf; +import java.math.BigDecimal; import java.util.List; +import org.joou.UInteger; import org.junit.BeforeClass; import org.junit.Test; @@ -42,11 +44,10 @@ public class ReturnVestingDelegationOperationIT extends BaseITForOperationParsin private static final int BLOCK_NUMBER_CONTAINING_OPERATION = 16022132; private static final int OPERATION_INDEX = 0; private static final String EXPECTED_ACCOUNT = "minnowbooster"; - /* - * private static final LegacyAssetSymbolType EXPECTED_VESTS_SYMBOL = LegacyAssetSymbolType.VESTS; - * private static final BigDecimal EXPECTED_VESTS_VALUE_REAL = BigDecimal.valueOf(2362500.0); - */ + // Since SMTs, assets are only representeted through their NAI. + private static final UInteger EXPECTED_VESTS_SYMBOL = UInteger.valueOf(3200000070L); private static final long EXPECTED_VESTS_VALUE = 2362500000000L; + private static final BigDecimal EXPECTED_VESTS_VALUE_REAL = BigDecimal.valueOf(EXPECTED_VESTS_VALUE, 6); /** * Prepare the environment for this specific test. @@ -64,18 +65,18 @@ public static void prepareTestClass() throws Exception { public void testOperationParsing() throws SteemCommunicationException, SteemResponseException { List operationsInBlock = steemJ.getOpsInBlock(BLOCK_NUMBER_CONTAINING_OPERATION, true); - Operation returnVestingDelegationOperation = operationsInBlock.get(OPERATION_INDEX).getOp(); + Operation returnVestingDelegationOperation = operationsInBlock.get(OPERATION_INDEX).getOperationWrapper() + .getOperation(); assertThat(returnVestingDelegationOperation, instanceOf(ReturnVestingDelegationOperation.class)); - assertThat(((ReturnVestingDelegationOperation) returnVestingDelegationOperation).getValue().getAccount().getName(), + assertThat(((ReturnVestingDelegationOperation) returnVestingDelegationOperation).getAccount().getName(), equalTo(EXPECTED_ACCOUNT)); - //TODO: add more assertions - /* assertThat(((ReturnVestingDelegationOperation) returnVestingDelegationOperation).getVestingShares().getSymbol(), - equalTo(EXPECTED_VESTS_SYMBOL)); + assertThat(((ReturnVestingDelegationOperation) returnVestingDelegationOperation).getVestingShares() + .getAssetSymbolType().getAssetNumber(), equalTo(EXPECTED_VESTS_SYMBOL)); assertThat(((ReturnVestingDelegationOperation) returnVestingDelegationOperation).getVestingShares().toReal(), - equalTo(EXPECTED_VESTS_VALUE_REAL));*/ - assertThat(((ReturnVestingDelegationOperation) returnVestingDelegationOperation).getValue().getVestingShares().getAmount(), + equalTo(EXPECTED_VESTS_VALUE_REAL)); + assertThat(((ReturnVestingDelegationOperation) returnVestingDelegationOperation).getVestingShares().getAmount(), equalTo(EXPECTED_VESTS_VALUE)); } } diff --git a/core/src/test/java/eu/bittrade/libs/steemj/plugins/apis/account/history/AccountHistoryApiIT.java b/core/src/test/java/eu/bittrade/libs/steemj/plugins/apis/account/history/AccountHistoryApiIT.java index e2cbf191..06790ff0 100644 --- a/core/src/test/java/eu/bittrade/libs/steemj/plugins/apis/account/history/AccountHistoryApiIT.java +++ b/core/src/test/java/eu/bittrade/libs/steemj/plugins/apis/account/history/AccountHistoryApiIT.java @@ -22,7 +22,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -38,8 +37,9 @@ import eu.bittrade.libs.steemj.exceptions.SteemCommunicationException; import eu.bittrade.libs.steemj.exceptions.SteemResponseException; import eu.bittrade.libs.steemj.plugins.apis.account.history.models.AppliedOperation; +import eu.bittrade.libs.steemj.plugins.apis.account.history.models.EnumVirtualOps; +import eu.bittrade.libs.steemj.plugins.apis.account.history.models.EnumVirtualOpsArgs; import eu.bittrade.libs.steemj.plugins.apis.account.history.models.GetAccountHistoryArgs; -import eu.bittrade.libs.steemj.plugins.apis.account.history.models.GetAccountHistoryArgsTest; import eu.bittrade.libs.steemj.plugins.apis.account.history.models.GetOpsInBlockArgs; import eu.bittrade.libs.steemj.protocol.AccountName; import eu.bittrade.libs.steemj.protocol.AnnotatedSignedTransaction; @@ -47,6 +47,8 @@ import eu.bittrade.libs.steemj.protocol.operations.AccountCreateOperation; import eu.bittrade.libs.steemj.protocol.operations.AccountCreateWithDelegationOperation; import eu.bittrade.libs.steemj.protocol.operations.Operation; +import eu.bittrade.libs.steemj.protocol.operations.virtual.ProducerRewardOperation; +import jdk.nashorn.internal.ir.annotations.Ignore; /** * This class contains all test connected to the @@ -73,7 +75,7 @@ public static void init() throws SteemCommunicationException { /** * Test the - * {@link eu.bittrade.libs.steemj.plugins.apis.account.history.AccountHistoryApi#getOpsInBlock(CommunicationHandler, long, boolean)} + * {@link eu.bittrade.libs.steemj.plugins.apis.account.history.AccountHistoryApi#getOpsInBlock(CommunicationHandler, GetOpsInBlockArgs)} * method. * * @throws SteemCommunicationException @@ -88,15 +90,14 @@ public void testGetOpsInBlock() throws SteemCommunicationException, SteemRespons .getOpsInBlock(COMMUNICATION_HANDLER, new GetOpsInBlockArgs(UInteger.valueOf(13310401), true)) .getOperations(); - // assertThat(signedBlockWithInfo.getTimestamp().getDateTime(), - // equalTo("2017-07-01T19:24:42")); - // assertThat(signedBlockWithInfo.getWitness(), equalTo(new - // AccountName("riverhead"))); + assertThat(operations.size(), equalTo(4)); + assertThat(operations.get(3).getBlock(), equalTo(UInteger.valueOf(13310401))); + assertThat(operations.get(0).getOperationWrapper().getOperation(), instanceOf(ProducerRewardOperation.class)); } /** * Test the - * {@link eu.bittrade.libs.steemj.plugins.apis.account.history.AccountHistoryApi#getTransaction(CommunicationHandler, eu.bittrade.libs.steemj.protocol.TransactionId)} + * {@link eu.bittrade.libs.steemj.plugins.apis.account.history.AccountHistoryApi#getTransaction(CommunicationHandler, TransactionId)} * method. * * @throws SteemCommunicationException @@ -106,24 +107,23 @@ public void testGetOpsInBlock() throws SteemCommunicationException, SteemRespons */ @Category({ IntegrationTest.class }) @Test + // Ignored as the API call is deprecated and not supported by the public + // Steem API nodes provided by Steemit. + @Ignore + @Deprecated public void testGetTransaction() throws SteemCommunicationException, SteemResponseException { - // TODO: Check also null case of optional - // final AnnotatedSignedTransaction annotatedSignedTransaction = AccountHistoryApi.getTransaction( - // COMMUNICATION_HANDLER, - // new GetAccountHistoryArgsTest(new TransactionId("bd8069e6544f658da560b72e93b605dfe2cb0aaf"))); - AccountName account = new AccountName("dez1337"); - ULong start = ULong.valueOf(20); - UInteger limit = UInteger.valueOf(10); - final AnnotatedSignedTransaction annotatedSignedTransaction = AccountHistoryApi.getTransaction(COMMUNICATION_HANDLER, new GetAccountHistoryArgs(account, start, limit)); - // assertThat(annotatedSignedTransaction.getTimestamp().getDateTime(), - // equalTo("2017-07-02T19:15:06")); - // assertThat(blockHeader.getWitness(), equalTo(new - // AccountName("clayop"))); + final TransactionId TRANSACTION_ID_TO_SEARCH = new TransactionId("bd8069e6544f658da560b72e93b605dfe2cb0aaf"); + final AnnotatedSignedTransaction annotatedSignedTransaction = AccountHistoryApi + .getTransaction(COMMUNICATION_HANDLER, TRANSACTION_ID_TO_SEARCH); + + assertThat(annotatedSignedTransaction.getBlockNum(), equalTo(1)); + assertThat(annotatedSignedTransaction.getTransactionId(), equalTo(TRANSACTION_ID_TO_SEARCH)); + assertThat(annotatedSignedTransaction.getTransactionNum(), equalTo(1)); } /** * Test the - * {@link eu.bittrade.libs.steemj.plugins.apis.account.history.AccountHistoryApi#getAccountHistory(CommunicationHandler, AccountName, org.joou.ULong, UInteger)} + * {@link eu.bittrade.libs.steemj.plugins.apis.account.history.AccountHistoryApi#getAccountHistory(CommunicationHandler, GetAccountHistoryArgs)} * method. * * @throws SteemCommunicationException @@ -134,25 +134,50 @@ public void testGetTransaction() throws SteemCommunicationException, SteemRespon @Category({ IntegrationTest.class }) @Test public void testGetAccountHistory() throws SteemCommunicationException, SteemResponseException { - final Map accountHistorySetOne = AccountHistoryApi + final Map accountHistorySetOne = AccountHistoryApi .getAccountHistory(COMMUNICATION_HANDLER, new GetAccountHistoryArgs(new AccountName("dez1337"), ULong.valueOf(10), UInteger.valueOf(10))) .getHistory(); assertEquals("expect response to contain 10 results", 11, accountHistorySetOne.size()); - Operation firstOperation = accountHistorySetOne.get(0).getOp(); + Operation firstOperation = accountHistorySetOne.get(0L).getOperationWrapper().getOperation(); assertTrue("the first operation for each account is the 'account_create_operation'", firstOperation instanceof AccountCreateOperation); - final Map accountHistorySetTwo = AccountHistoryApi.getAccountHistory( + final Map accountHistorySetTwo = AccountHistoryApi.getAccountHistory( COMMUNICATION_HANDLER, new GetAccountHistoryArgs(new AccountName("randowhale"), ULong.valueOf(1000), UInteger.valueOf(1000))) .getHistory(); assertEquals("expect response to contain 1001 results", 1001, accountHistorySetTwo.size()); - assertThat(accountHistorySetTwo.get(0).getOp(), instanceOf(AccountCreateWithDelegationOperation.class)); - assertThat(((AccountCreateWithDelegationOperation) accountHistorySetTwo.get(0).getOp()).getCreator().getName(), - equalTo(new AccountName("anonsteem").getName())); + assertThat(accountHistorySetTwo.get(0L).getOperationWrapper().getOperation(), + instanceOf(AccountCreateWithDelegationOperation.class)); + assertThat(((AccountCreateWithDelegationOperation) accountHistorySetTwo.get(0L).getOperationWrapper() + .getOperation()).getCreator().getName(), equalTo(new AccountName("anonsteem").getName())); + } + + /** + * Test the + * {@link eu.bittrade.libs.steemj.plugins.apis.account.history.AccountHistoryApi#enumVirtualOps(CommunicationHandler, EnumVirtualOpsArgs)} + * method by searching for all virtual operations between block 1 and block + * 1000. + * + * @throws SteemCommunicationException + * If a communication error occurs. + * @throws SteemResponseException + * If the response is an error. + */ + @Category({ IntegrationTest.class }) + @Test + public void testEnumVirtualOps() throws SteemCommunicationException, SteemResponseException { + final EnumVirtualOps enumVirtualOps = AccountHistoryApi.enumVirtualOps(COMMUNICATION_HANDLER, + new EnumVirtualOpsArgs.Builder().startAt(UInteger.valueOf(1)).endAt(UInteger.valueOf(1000)).build()); + + // Next block range. + assertThat(enumVirtualOps.getNextBlockRangeBegin(), equalTo(UInteger.valueOf(1093))); + assertThat(enumVirtualOps.getOperations().size(), equalTo(1)); + assertThat(enumVirtualOps.getOperations().get(0).getOperationWrapper().getOperation(), + instanceOf(ProducerRewardOperation.class)); } }