From eed839a1c25aafa22a148d82cf4bdabc4d95e491 Mon Sep 17 00:00:00 2001 From: Anton Wiedermann Date: Tue, 3 Sep 2019 22:41:43 +0200 Subject: [PATCH 1/7] issue #111 - rename TransactionType and TransactionVersion rename TransactionType and TransactionVersion to EntityType and EntityVersion --- .../java/io/proximax/sdk/E2EAccountTest.java | 14 ++-- .../infrastructure/TransactionHttpTest.java | 6 +- .../infrastructure/TransactionMapping.java | 18 +++--- .../transaction/AccountLinkTransaction.java | 4 +- .../transaction/AggregateTransaction.java | 12 ++-- .../model/transaction/AliasTransaction.java | 14 ++-- .../BlockchainConfigTransaction.java | 4 +- .../BlockchainUpgradeTransaction.java | 4 +- .../{TransactionType.java => EntityType.java} | 10 ++- ...sactionVersion.java => EntityVersion.java} | 4 +- .../transaction/LockFundsTransaction.java | 4 +- .../ModifyAccountPropertyTransaction.java | 16 ++--- .../ModifyContractTransaction.java | 2 +- .../ModifyMetadataTransaction.java | 2 +- .../ModifyMultisigAccountTransaction.java | 4 +- .../MosaicDefinitionTransaction.java | 2 +- .../MosaicSupplyChangeTransaction.java | 2 +- .../RegisterNamespaceTransaction.java | 2 +- .../transaction/SecretLockTransaction.java | 4 +- .../transaction/SecretProofTransaction.java | 4 +- .../model/transaction/SignedTransaction.java | 6 +- .../sdk/model/transaction/Transaction.java | 6 +- .../transaction/TransferTransaction.java | 4 +- .../AccountLinkTransactionBuilder.java | 6 +- .../builder/AggregateTransactionBuilder.java | 14 ++-- .../builder/AliasTransactionBuilder.java | 14 ++-- .../BlockchainConfigTransactionBuilder.java | 6 +- .../BlockchainUpgradeTransactionBuilder.java | 6 +- .../builder/LockFundsTransactionBuilder.java | 6 +- ...ountPropertyAddressTransactionBuilder.java | 6 +- ...countPropertyEntityTransactionBuilder.java | 12 ++-- ...countPropertyMosaicTransactionBuilder.java | 6 +- ...difyAccountPropertyTransactionBuilder.java | 4 +- .../ModifyContractTransactionBuilder.java | 6 +- .../ModifyMetadataTransactionBuilder.java | 12 ++-- ...difyMultisigAccountTransactionBuilder.java | 6 +- .../MosaicDefinitionTransactionBuilder.java | 6 +- .../MosaicSupplyChangeTransactionBuilder.java | 6 +- .../RegisterNamespaceTransactionBuilder.java | 6 +- .../builder/SecretLockTransactionBuilder.java | 6 +- .../SecretProofTransactionBuilder.java | 6 +- .../builder/TransactionBuilder.java | 10 +-- .../builder/TransferTransactionBuilder.java | 6 +- .../TransactionMappingTest.java | 18 +++--- .../transaction/AliasTransactionTest.java | 24 +++---- .../CosignatureTransactionTest.java | 2 +- .../transaction/FakeTransferTransaction.java | 2 +- .../transaction/LockFundsTransactionTest.java | 10 +-- .../ModifyAccountPropertyTransactionTest.java | 18 +++--- .../ModifyMetadataTransactionTest.java | 16 ++--- .../transaction/SignedTransactionTest.java | 4 +- .../transaction/TransactionTypeTest.java | 64 +++++++++---------- .../AggregateTransactionBuilderTest.java | 12 ++-- .../LockFundsTransactionBuilderTest.java | 4 +- ...tPropertyEntityTransactionBuilderTest.java | 6 +- .../ModifyMetadataTransactionBuilderTest.java | 8 +-- .../builder/TransactionBuilderTest.java | 8 +-- 57 files changed, 246 insertions(+), 248 deletions(-) rename src/main/java/io/proximax/sdk/model/transaction/{TransactionType.java => EntityType.java} (94%) rename src/main/java/io/proximax/sdk/model/transaction/{TransactionVersion.java => EntityVersion.java} (97%) diff --git a/src/e2e/java/io/proximax/sdk/E2EAccountTest.java b/src/e2e/java/io/proximax/sdk/E2EAccountTest.java index b99727b6..cf89c0fd 100644 --- a/src/e2e/java/io/proximax/sdk/E2EAccountTest.java +++ b/src/e2e/java/io/proximax/sdk/E2EAccountTest.java @@ -48,7 +48,7 @@ import io.proximax.sdk.model.namespace.NamespaceInfo; import io.proximax.sdk.model.transaction.ModifyAccountPropertyTransaction; import io.proximax.sdk.model.transaction.Transaction; -import io.proximax.sdk.model.transaction.TransactionType; +import io.proximax.sdk.model.transaction.EntityType; import io.proximax.sdk.model.transaction.UInt64Id; import io.proximax.sdk.utils.dto.UInt64Utils; @@ -126,9 +126,9 @@ void addAllowMosaicProperty() { void addAllowEntityTypeProperty() { Account acct = new Account(new KeyPair(), getNetworkType()); signup(acct.getAddress()); - TransactionType allowedTransType = TransactionType.ACCOUNT_PROPERTIES_ENTITY_TYPE; + EntityType allowedTransType = EntityType.ACCOUNT_PROPERTIES_ENTITY_TYPE; logger.info("going to allow {} by {}", allowedTransType, acct.getPublicAccount()); - ModifyAccountPropertyTransaction trans = transact.accountPropEntityType() + ModifyAccountPropertyTransaction trans = transact.accountPropEntityType() .propertyType(AccountPropertyType.ALLOW_TRANSACTION) .modifications(Arrays.asList(AccountPropertyModification.add(allowedTransType))).build(); // announce the transaction @@ -213,15 +213,15 @@ private void testAccountPropertiesOnSimpleAccount(AccountProperties aps, UInt64I * @param aps account properties * @param blockedAddress address that is blocked */ - private void testAccountPropertiesOnSimpleAccount(AccountProperties aps, TransactionType allowedTransactionType) { + private void testAccountPropertiesOnSimpleAccount(AccountProperties aps, EntityType allowedTransactionType) { boolean gotMatch = false; for (AccountProperty ap : aps.getProperties()) { if (ap.getPropertyType().equals(AccountPropertyType.ALLOW_TRANSACTION)) { for (Object value : ap.getValues()) { try { if (value instanceof Long && isValidTransactionTypeCode(((Long) value).intValue())) { - assertEquals(TransactionType.ACCOUNT_PROPERTIES_ENTITY_TYPE, - TransactionType.rawValueOf(((Long) value).intValue())); + assertEquals(EntityType.ACCOUNT_PROPERTIES_ENTITY_TYPE, + EntityType.rawValueOf(((Long) value).intValue())); gotMatch = true; } } catch (RuntimeException e) { @@ -236,7 +236,7 @@ private void testAccountPropertiesOnSimpleAccount(AccountProperties aps, Transac private static boolean isValidTransactionTypeCode(int code) { try { - TransactionType.rawValueOf(code); + EntityType.rawValueOf(code); return true; } catch (RuntimeException e) { return false; diff --git a/src/e2e/java/io/proximax/sdk/infrastructure/TransactionHttpTest.java b/src/e2e/java/io/proximax/sdk/infrastructure/TransactionHttpTest.java index 7f0cd04c..16c5e356 100644 --- a/src/e2e/java/io/proximax/sdk/infrastructure/TransactionHttpTest.java +++ b/src/e2e/java/io/proximax/sdk/infrastructure/TransactionHttpTest.java @@ -36,7 +36,7 @@ import io.proximax.sdk.TransactionRepository; import io.proximax.sdk.model.transaction.Transaction; import io.proximax.sdk.model.transaction.TransactionStatus; -import io.proximax.sdk.model.transaction.TransactionType; +import io.proximax.sdk.model.transaction.EntityType; import io.reactivex.observers.TestObserver; import io.reactivex.schedulers.Schedulers; @@ -59,7 +59,7 @@ public void getTransaction() throws ExecutionException, InterruptedException { .toFuture() .get(); - assertEquals(TransactionType.TRANSFER.getValue(), transaction.getType().getValue()); + assertEquals(EntityType.TRANSFER.getValue(), transaction.getType().getValue()); assertEquals(TRANSACTION_HASH, transaction.getTransactionInfo().get().getHash().get()); } @@ -70,7 +70,7 @@ public void getTransactions() throws ExecutionException, InterruptedException { .toFuture() .get(); - assertEquals(TransactionType.TRANSFER.getValue(), transaction.get(0).getType().getValue()); + assertEquals(EntityType.TRANSFER.getValue(), transaction.get(0).getType().getValue()); assertEquals(TRANSACTION_HASH, transaction.get(0).getTransactionInfo().get().getHash().get()); } diff --git a/src/main/java/io/proximax/sdk/infrastructure/TransactionMapping.java b/src/main/java/io/proximax/sdk/infrastructure/TransactionMapping.java index 9d879c1e..a880f450 100644 --- a/src/main/java/io/proximax/sdk/infrastructure/TransactionMapping.java +++ b/src/main/java/io/proximax/sdk/infrastructure/TransactionMapping.java @@ -64,7 +64,7 @@ public Transaction apply(JsonObject input) { JsonObject transaction = input.getAsJsonObject("transaction"); int type = transaction.get("type").getAsInt(); - switch (TransactionType.rawValueOf(type)) { + switch (EntityType.rawValueOf(type)) { case TRANSFER: return new TransferTransactionMapping().apply(input); case REGISTER_NAMESPACE: @@ -216,7 +216,7 @@ public ModifyMetadataTransaction apply(JsonObject input) { // version JsonElement version = transaction.get("version"); // transaction type - TransactionType type = TransactionType.rawValueOf(transaction.get("type").getAsInt()); + EntityType type = EntityType.rawValueOf(transaction.get("type").getAsInt()); // modifications List modifications = stream(transaction.getAsJsonArray("modifications")) .map(obj -> (JsonObject) obj).map(ModifyMetadataTransactionMapping::mapModFromJson) @@ -287,7 +287,7 @@ public ModifyAccountPropertyTransaction apply(JsonObject input) { // version JsonElement version = transaction.get("version"); // transaction type - TransactionType type = TransactionType.rawValueOf(transaction.get("type").getAsInt()); + EntityType type = EntityType.rawValueOf(transaction.get("type").getAsInt()); // signer PublicAccount signer = new PublicAccount(transaction.get("signer").getAsString(), extractNetworkType(version)); // signature @@ -348,11 +348,11 @@ static List> getMosaicMods(JsonObject tran * @param transaction the transaction object to get data from * @return the list of entity type account property modifications */ - static List> getEntityTypeMods(JsonObject transaction) { + static List> getEntityTypeMods(JsonObject transaction) { return stream(transaction.getAsJsonArray("modifications")).map(obj -> (JsonObject) obj).map(json -> { AccountPropertyModificationType modType = AccountPropertyModificationType .getByCode(getModType(json).getAsInt()); - return new AccountPropertyModification<>(modType, TransactionType.rawValueOf(json.get("value").getAsInt())); + return new AccountPropertyModification<>(modType, EntityType.rawValueOf(json.get("value").getAsInt())); }).collect(Collectors.toList()); } @@ -480,7 +480,7 @@ public AliasTransaction apply(JsonObject input) { DeadlineBP deadline = new DeadlineBP(GsonUtils.getBigInteger(transaction.getAsJsonArray("deadline"))); JsonElement version = transaction.get("version"); // return instance of mosaic alias definition transaction - return new AliasTransaction(TransactionType.MOSAIC_ALIAS, extractNetworkType(version), + return new AliasTransaction(EntityType.MOSAIC_ALIAS, extractNetworkType(version), extractTransactionVersion(version), deadline, extractFee(transaction), Optional.of(transaction.get("signature").getAsString()), Optional.of(new PublicAccount(transaction.get("signer").getAsString(), extractNetworkType(version))), @@ -505,7 +505,7 @@ public AliasTransaction apply(JsonObject input) { DeadlineBP deadline = new DeadlineBP(GsonUtils.getBigInteger(transaction.getAsJsonArray("deadline"))); JsonElement version = transaction.get("version"); // return instance of mosaic alias definition transaction - return new AliasTransaction(TransactionType.ADDRESS_ALIAS, extractNetworkType(version), + return new AliasTransaction(EntityType.ADDRESS_ALIAS, extractNetworkType(version), extractTransactionVersion(version), deadline, extractFee(transaction), Optional.of(transaction.get("signature").getAsString()), Optional.of(new PublicAccount(transaction.get("signer").getAsString(), extractNetworkType(version))), @@ -644,7 +644,7 @@ public AggregateTransaction apply(JsonObject input) { .collect(Collectors.toList()); } return new AggregateTransaction( - TransactionType.rawValueOf(transaction.get("type").getAsInt()), + EntityType.rawValueOf(transaction.get("type").getAsInt()), networkType, extractTransactionVersion(transaction.get("version")), deadline, @@ -700,7 +700,7 @@ public LockFundsTransaction apply(JsonObject input) { Optional.of(transactionInfo), mosaic, GsonUtils.getBigInteger(transaction.getAsJsonArray("duration")), - new SignedTransaction("", transaction.get("hash").getAsString(), TransactionType.AGGREGATE_BONDED)); + new SignedTransaction("", transaction.get("hash").getAsString(), EntityType.AGGREGATE_BONDED)); } } diff --git a/src/main/java/io/proximax/sdk/model/transaction/AccountLinkTransaction.java b/src/main/java/io/proximax/sdk/model/transaction/AccountLinkTransaction.java index fe69bc5f..f1ab9053 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/AccountLinkTransaction.java +++ b/src/main/java/io/proximax/sdk/model/transaction/AccountLinkTransaction.java @@ -29,7 +29,7 @@ public class AccountLinkTransaction extends Transaction { /** * @param networkType network type - * @param version transaction version. Use {@link TransactionVersion#ACCOUNT_LINK} for current version + * @param version transaction version. Use {@link EntityVersion#ACCOUNT_LINK} for current version * @param deadline transaction deadline * @param maxFee transaction fee * @param signature optional signature @@ -41,7 +41,7 @@ public class AccountLinkTransaction extends Transaction { public AccountLinkTransaction(NetworkType networkType, Integer version, TransactionDeadline deadline, BigInteger maxFee, Optional signature, Optional signer, Optional transactionInfo, PublicAccount remoteAccount, AccountLinkAction action) { - super(TransactionType.ACCOUNT_LINK, networkType, version, deadline, maxFee, signature, signer, transactionInfo); + super(EntityType.ACCOUNT_LINK, networkType, version, deadline, maxFee, signature, signer, transactionInfo); Validate.notNull(remoteAccount, "remoteAccount has to be specified"); Validate.notNull(action, "action has to be specified"); this.remoteAccount = remoteAccount; diff --git a/src/main/java/io/proximax/sdk/model/transaction/AggregateTransaction.java b/src/main/java/io/proximax/sdk/model/transaction/AggregateTransaction.java index 4e0576c5..27c78ae5 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/AggregateTransaction.java +++ b/src/main/java/io/proximax/sdk/model/transaction/AggregateTransaction.java @@ -45,11 +45,11 @@ public class AggregateTransaction extends Transaction { private final List cosignatures; /** - * @param type transaction type which has to be one of {@link TransactionType#AGGREGATE_COMPLETE} or - * {@link TransactionType#AGGREGATE_BONDED} + * @param type transaction type which has to be one of {@link EntityType#AGGREGATE_COMPLETE} or + * {@link EntityType#AGGREGATE_BONDED} * @param networkType network type - * @param version transaction version. For latest {@link TransactionVersion#AGGREGATE_COMPLETE} or - * {@link TransactionVersion#AGGREGATE_BONDED} + * @param version transaction version. For latest {@link EntityVersion#AGGREGATE_COMPLETE} or + * {@link EntityVersion#AGGREGATE_BONDED} * @param deadline transaction deadline * @param maxFee transaction fee * @param signature optional signature @@ -58,7 +58,7 @@ public class AggregateTransaction extends Transaction { * @param innerTransactions inner transactions of this aggregate transaction * @param cosignatures available cosignatures if any */ - public AggregateTransaction(TransactionType type, NetworkType networkType, Integer version, + public AggregateTransaction(EntityType type, NetworkType networkType, Integer version, TransactionDeadline deadline, BigInteger maxFee, Optional signature, Optional signer, Optional transactionInfo, List innerTransactions, @@ -66,7 +66,7 @@ public AggregateTransaction(TransactionType type, NetworkType networkType, Integ super(type, networkType, version, deadline, maxFee, signature, signer, transactionInfo); Validate.notNull(innerTransactions, "InnerTransactions must not be null"); Validate.notNull(cosignatures, "Cosignatures must not be null"); - Validate.validState(type == TransactionType.AGGREGATE_BONDED || type == TransactionType.AGGREGATE_COMPLETE, + Validate.validState(type == EntityType.AGGREGATE_BONDED || type == EntityType.AGGREGATE_COMPLETE, "Transaction type has to be aggregate bonded or complete but was %s", type); this.innerTransactions = Collections.unmodifiableList(innerTransactions); diff --git a/src/main/java/io/proximax/sdk/model/transaction/AliasTransaction.java b/src/main/java/io/proximax/sdk/model/transaction/AliasTransaction.java index 54e5274a..5c59c5b9 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/AliasTransaction.java +++ b/src/main/java/io/proximax/sdk/model/transaction/AliasTransaction.java @@ -45,11 +45,11 @@ public class AliasTransaction extends Transaction { private final AliasAction aliasAction; /** - * @param type transaction type which has to be one of {@link TransactionType#MOSAIC_ALIAS} or - * {@link TransactionType#ADDRESS_ALIAS} + * @param type transaction type which has to be one of {@link EntityType#MOSAIC_ALIAS} or + * {@link EntityType#ADDRESS_ALIAS} * @param networkType network type - * @param version transaction version. For latest {@link TransactionVersion#MOSAIC_ALIAS} or - * {@link TransactionVersion#ADDRESS_ALIAS} + * @param version transaction version. For latest {@link EntityVersion#MOSAIC_ALIAS} or + * {@link EntityVersion#ADDRESS_ALIAS} * @param deadline transaction deadline * @param maxFee transaction fee * @param signature optional signature @@ -60,7 +60,7 @@ public class AliasTransaction extends Transaction { * @param namespaceId namespace Id to get an alias * @param aliasAction link/unlink action */ - public AliasTransaction(TransactionType type, NetworkType networkType, Integer version, TransactionDeadline deadline, + public AliasTransaction(EntityType type, NetworkType networkType, Integer version, TransactionDeadline deadline, BigInteger maxFee, Optional signature, Optional signer, Optional transactionInfo, Optional mosaicId, Optional
address, NamespaceId namespaceId, AliasAction aliasAction) { @@ -70,9 +70,9 @@ public AliasTransaction(TransactionType type, NetworkType networkType, Integer v Validate.notNull(namespaceId, "namespaceId must not be null"); Validate.notNull(aliasAction, "action must not be null"); Validate.isTrue(mosaicId.isPresent() != address.isPresent(), "Address or mosaic has to be specified exclusively"); - Validate.isTrue(mosaicId.isPresent() == (type == TransactionType.MOSAIC_ALIAS), + Validate.isTrue(mosaicId.isPresent() == (type == EntityType.MOSAIC_ALIAS), "Mosaic ID needs to be used with mosaic alias transaction type"); - Validate.isTrue(address.isPresent() == (type == TransactionType.ADDRESS_ALIAS), + Validate.isTrue(address.isPresent() == (type == EntityType.ADDRESS_ALIAS), "Address needs to be used with address alias transaction type"); // make assignments this.mosaicId = mosaicId; diff --git a/src/main/java/io/proximax/sdk/model/transaction/BlockchainConfigTransaction.java b/src/main/java/io/proximax/sdk/model/transaction/BlockchainConfigTransaction.java index ed3d3c75..dfef7ee1 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/BlockchainConfigTransaction.java +++ b/src/main/java/io/proximax/sdk/model/transaction/BlockchainConfigTransaction.java @@ -42,7 +42,7 @@ public class BlockchainConfigTransaction extends Transaction { /** * @param networkType network type - * @param version transaction version. Use {@link TransactionVersion#BLOCKCHAIN_CONFIG} for current version + * @param version transaction version. Use {@link EntityVersion#BLOCKCHAIN_CONFIG} for current version * @param deadline transaction deadline * @param maxFee transaction fee * @param signature optional signature @@ -56,7 +56,7 @@ public BlockchainConfigTransaction(NetworkType networkType, Integer version, Tra BigInteger maxFee, Optional signature, Optional signer, Optional transactionInfo, BigInteger applyHeightDelta, String blockchainConfig, String supportedEntityVersions) { - super(TransactionType.BLOCKCHAIN_CONFIG, networkType, version, deadline, maxFee, signature, signer, transactionInfo); + super(EntityType.BLOCKCHAIN_CONFIG, networkType, version, deadline, maxFee, signature, signer, transactionInfo); // basic input validations Validate.notNull(applyHeightDelta); Validate.notNull(blockchainConfig); diff --git a/src/main/java/io/proximax/sdk/model/transaction/BlockchainUpgradeTransaction.java b/src/main/java/io/proximax/sdk/model/transaction/BlockchainUpgradeTransaction.java index 66e679bb..19255606 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/BlockchainUpgradeTransaction.java +++ b/src/main/java/io/proximax/sdk/model/transaction/BlockchainUpgradeTransaction.java @@ -46,7 +46,7 @@ public class BlockchainUpgradeTransaction extends Transaction { /** * @param networkType network type - * @param version transaction version. Use {@link TransactionVersion#BLOCKCHAIN_UPGRADE} for current version + * @param version transaction version. Use {@link EntityVersion#BLOCKCHAIN_UPGRADE} for current version * @param deadline transaction deadline * @param maxFee transaction fee * @param signature optional signature @@ -58,7 +58,7 @@ public class BlockchainUpgradeTransaction extends Transaction { public BlockchainUpgradeTransaction(NetworkType networkType, Integer version, TransactionDeadline deadline, BigInteger maxFee, Optional signature, Optional signer, Optional transactionInfo, BigInteger upgradePeriod, BlockchainVersion newVersion) { - super(TransactionType.BLOCKCHAIN_UPGRADE, networkType, version, deadline, maxFee, signature, signer, + super(EntityType.BLOCKCHAIN_UPGRADE, networkType, version, deadline, maxFee, signature, signer, transactionInfo); // validations Validate.notNull(upgradePeriod, "upgrade period is mandatory"); diff --git a/src/main/java/io/proximax/sdk/model/transaction/TransactionType.java b/src/main/java/io/proximax/sdk/model/transaction/EntityType.java similarity index 94% rename from src/main/java/io/proximax/sdk/model/transaction/TransactionType.java rename to src/main/java/io/proximax/sdk/model/transaction/EntityType.java index d30d9ee5..76ab3bef 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/TransactionType.java +++ b/src/main/java/io/proximax/sdk/model/transaction/EntityType.java @@ -18,10 +18,8 @@ /** * Enum containing transaction type constants. - * - * @since 1.0 */ -public enum TransactionType { +public enum EntityType { // Mosaic /** @@ -142,7 +140,7 @@ public enum TransactionType { private int value; - TransactionType(int value) { + EntityType(int value) { this.value = value; } @@ -161,8 +159,8 @@ public int getValue() { * @param code of the transaction type * @return transaction type */ - public static TransactionType rawValueOf(int code) { - for (TransactionType type : TransactionType.values()) { + public static EntityType rawValueOf(int code) { + for (EntityType type : EntityType.values()) { if (code == type.value) { return type; } diff --git a/src/main/java/io/proximax/sdk/model/transaction/TransactionVersion.java b/src/main/java/io/proximax/sdk/model/transaction/EntityVersion.java similarity index 97% rename from src/main/java/io/proximax/sdk/model/transaction/TransactionVersion.java rename to src/main/java/io/proximax/sdk/model/transaction/EntityVersion.java index 78065aba..880b1f7e 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/TransactionVersion.java +++ b/src/main/java/io/proximax/sdk/model/transaction/EntityVersion.java @@ -18,7 +18,7 @@ /** * Enum containing transaction type versions. Version are declared by server plug-ins */ -public enum TransactionVersion { +public enum EntityVersion { // Mosaic /** @@ -129,7 +129,7 @@ public enum TransactionVersion { private int code; - TransactionVersion(int code) { + EntityVersion(int code) { this.code = code; } diff --git a/src/main/java/io/proximax/sdk/model/transaction/LockFundsTransaction.java b/src/main/java/io/proximax/sdk/model/transaction/LockFundsTransaction.java index 770b4ee6..d64943fb 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/LockFundsTransaction.java +++ b/src/main/java/io/proximax/sdk/model/transaction/LockFundsTransaction.java @@ -59,11 +59,11 @@ public LockFundsTransaction(NetworkType networkType, Integer version, Transactio BigInteger maxFee, Optional signature, Optional signer, Optional transactionInfo, Mosaic mosaic, BigInteger duration, SignedTransaction signedTransaction) { - super(TransactionType.LOCK, networkType, version, deadline, maxFee, signature, signer, transactionInfo); + super(EntityType.LOCK, networkType, version, deadline, maxFee, signature, signer, transactionInfo); Validate.notNull(mosaic, "Mosaic must not be null"); Validate.notNull(duration, "Duration must not be null"); Validate.notNull(signedTransaction, "Signed transaction must not be null"); - Validate.isTrue(signedTransaction.getType() == TransactionType.AGGREGATE_BONDED, + Validate.isTrue(signedTransaction.getType() == EntityType.AGGREGATE_BONDED, "Signed transaction must be Aggregate Bonded Transaction"); this.mosaic = mosaic; this.duration = duration; diff --git a/src/main/java/io/proximax/sdk/model/transaction/ModifyAccountPropertyTransaction.java b/src/main/java/io/proximax/sdk/model/transaction/ModifyAccountPropertyTransaction.java index 5a82148e..1e52d1d1 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/ModifyAccountPropertyTransaction.java +++ b/src/main/java/io/proximax/sdk/model/transaction/ModifyAccountPropertyTransaction.java @@ -48,7 +48,7 @@ public abstract class ModifyAccountPropertyTransaction extends Transaction { * @param propertyType * @param modifications */ - public ModifyAccountPropertyTransaction(TransactionType type, NetworkType networkType, Integer version, + public ModifyAccountPropertyTransaction(EntityType type, NetworkType networkType, Integer version, TransactionDeadline deadline, BigInteger maxFee, Optional signature, Optional signer, Optional transactionInfo, AccountPropertyType propertyType, List> modifications) { @@ -165,7 +165,7 @@ public AddressModification(NetworkType networkType, Integer version, Transaction BigInteger maxFee, Optional signature, Optional signer, Optional transactionInfo, AccountPropertyType propertyType, List> modifications) { - super(TransactionType.ACCOUNT_PROPERTIES_ADDRESS, networkType, version, deadline, maxFee, signature, signer, + super(EntityType.ACCOUNT_PROPERTIES_ADDRESS, networkType, version, deadline, maxFee, signature, signer, transactionInfo, propertyType, modifications); } @@ -229,7 +229,7 @@ public MosaicModification(NetworkType networkType, Integer version, TransactionD BigInteger maxFee, Optional signature, Optional signer, Optional transactionInfo, AccountPropertyType propertyType, List> modifications) { - super(TransactionType.ACCOUNT_PROPERTIES_MOSAIC, networkType, version, deadline, maxFee, signature, signer, + super(EntityType.ACCOUNT_PROPERTIES_MOSAIC, networkType, version, deadline, maxFee, signature, signer, transactionInfo, propertyType, modifications); } @@ -274,7 +274,7 @@ protected Transaction copyForSigner(PublicAccount signer) { /** * Transaction type account property modification transaction implementation */ - public static class EntityTypeModification extends ModifyAccountPropertyTransaction { + public static class EntityTypeModification extends ModifyAccountPropertyTransaction { private static final int VALUE_BYTES_LENGTH = 2; /** @@ -291,13 +291,13 @@ public static class EntityTypeModification extends ModifyAccountPropertyTransact public EntityTypeModification(NetworkType networkType, Integer version, TransactionDeadline deadline, BigInteger maxFee, Optional signature, Optional signer, Optional transactionInfo, AccountPropertyType propertyType, - List> modifications) { - super(TransactionType.ACCOUNT_PROPERTIES_ENTITY_TYPE, networkType, version, deadline, maxFee, signature, + List> modifications) { + super(EntityType.ACCOUNT_PROPERTIES_ENTITY_TYPE, networkType, version, deadline, maxFee, signature, signer, transactionInfo, propertyType, modifications); } @Override - protected byte[] getValueBytesFromModification(AccountPropertyModification mod) { + protected byte[] getValueBytesFromModification(AccountPropertyModification mod) { // get the bytes from string byte[] valueBytes = new byte[VALUE_BYTES_LENGTH]; ByteBuffer.wrap(valueBytes).order(ByteOrder.LITTLE_ENDIAN).putShort((short) mod.getValue().getValue()); @@ -325,7 +325,7 @@ protected int getPayloadSerializedSize() { protected Transaction copyForSigner(PublicAccount signer) { return new EntityTypeModification(getNetworkType(), getVersion(), getDeadline(), getMaxFee(), getSignature(), Optional.of(signer), getTransactionInfo(), getPropertyType(), - (List>) getPropertyModifications()); + (List>) getPropertyModifications()); } } } diff --git a/src/main/java/io/proximax/sdk/model/transaction/ModifyContractTransaction.java b/src/main/java/io/proximax/sdk/model/transaction/ModifyContractTransaction.java index 1a6c9abb..4b250dc3 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/ModifyContractTransaction.java +++ b/src/main/java/io/proximax/sdk/model/transaction/ModifyContractTransaction.java @@ -61,7 +61,7 @@ public ModifyContractTransaction(NetworkType networkType, Integer transactionVer List customersModifications, List executorsModifications, List verifiersModifications) { - super(TransactionType.MODIFY_CONTRACT, networkType, transactionVersion, deadline, maxFee, signature, signer, + super(EntityType.MODIFY_CONTRACT, networkType, transactionVersion, deadline, maxFee, signature, signer, transactionInfo); // validations Validate.notNull(durationDelta, "durationDelta can not be null"); diff --git a/src/main/java/io/proximax/sdk/model/transaction/ModifyMetadataTransaction.java b/src/main/java/io/proximax/sdk/model/transaction/ModifyMetadataTransaction.java index 2bc0c55c..2d035254 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/ModifyMetadataTransaction.java +++ b/src/main/java/io/proximax/sdk/model/transaction/ModifyMetadataTransaction.java @@ -66,7 +66,7 @@ public class ModifyMetadataTransaction extends Transaction { * @param address * @param modifications */ - public ModifyMetadataTransaction(TransactionType type, NetworkType networkType, Integer version, + public ModifyMetadataTransaction(EntityType type, NetworkType networkType, Integer version, TransactionDeadline deadline, BigInteger maxFee, Optional signature, Optional signer, Optional transactionInfo, MetadataType metadataType, Optional metadataId, Optional
address, List modifications) { diff --git a/src/main/java/io/proximax/sdk/model/transaction/ModifyMultisigAccountTransaction.java b/src/main/java/io/proximax/sdk/model/transaction/ModifyMultisigAccountTransaction.java index 87a1ba52..cff1370d 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/ModifyMultisigAccountTransaction.java +++ b/src/main/java/io/proximax/sdk/model/transaction/ModifyMultisigAccountTransaction.java @@ -46,7 +46,7 @@ public class ModifyMultisigAccountTransaction extends Transaction { /** * @param networkType network type - * @param version transaction version. Use {@link TransactionVersion#MODIFY_MULTISIG_ACCOUNT} for current version + * @param version transaction version. Use {@link EntityVersion#MODIFY_MULTISIG_ACCOUNT} for current version * @param deadline transaction deadline * @param maxFee transaction fee * @param signature optional signature @@ -60,7 +60,7 @@ public ModifyMultisigAccountTransaction(NetworkType networkType, Integer version BigInteger maxFee, Optional signature, Optional signer, Optional transactionInfo, int minApprovalDelta, int minRemovalDelta, List modifications) { - super(TransactionType.MODIFY_MULTISIG_ACCOUNT, networkType, version, deadline, maxFee, signature, signer, + super(EntityType.MODIFY_MULTISIG_ACCOUNT, networkType, version, deadline, maxFee, signature, signer, transactionInfo); // validations Validate.notNull(modifications, "Modifications must not be null"); diff --git a/src/main/java/io/proximax/sdk/model/transaction/MosaicDefinitionTransaction.java b/src/main/java/io/proximax/sdk/model/transaction/MosaicDefinitionTransaction.java index 322a50b5..e5d0c4db 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/MosaicDefinitionTransaction.java +++ b/src/main/java/io/proximax/sdk/model/transaction/MosaicDefinitionTransaction.java @@ -65,7 +65,7 @@ public MosaicDefinitionTransaction(NetworkType networkType, Integer version, Tra BigInteger maxFee, Optional signature, Optional signer, Optional transactionInfo, MosaicNonce nonce, MosaicId mosaicId, MosaicProperties mosaicProperties) { - super(TransactionType.MOSAIC_DEFINITION, networkType, version, deadline, maxFee, signature, signer, + super(EntityType.MOSAIC_DEFINITION, networkType, version, deadline, maxFee, signature, signer, transactionInfo); // validations Validate.notNull(nonce, "nonce must not be null"); diff --git a/src/main/java/io/proximax/sdk/model/transaction/MosaicSupplyChangeTransaction.java b/src/main/java/io/proximax/sdk/model/transaction/MosaicSupplyChangeTransaction.java index 7834012c..07818941 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/MosaicSupplyChangeTransaction.java +++ b/src/main/java/io/proximax/sdk/model/transaction/MosaicSupplyChangeTransaction.java @@ -57,7 +57,7 @@ public MosaicSupplyChangeTransaction(NetworkType networkType, Integer version, T BigInteger maxFee, Optional signature, Optional signer, Optional transactionInfo, MosaicId mosaicId, MosaicSupplyType mosaicSupplyType, BigInteger delta) { - super(TransactionType.MOSAIC_SUPPLY_CHANGE, networkType, version, deadline, maxFee, signature, signer, + super(EntityType.MOSAIC_SUPPLY_CHANGE, networkType, version, deadline, maxFee, signature, signer, transactionInfo); // validations Validate.notNull(mosaicId, "MosaicId must not be null"); diff --git a/src/main/java/io/proximax/sdk/model/transaction/RegisterNamespaceTransaction.java b/src/main/java/io/proximax/sdk/model/transaction/RegisterNamespaceTransaction.java index 2aa0f89e..53da498a 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/RegisterNamespaceTransaction.java +++ b/src/main/java/io/proximax/sdk/model/transaction/RegisterNamespaceTransaction.java @@ -62,7 +62,7 @@ public RegisterNamespaceTransaction(NetworkType networkType, Integer version, TransactionDeadline deadline, BigInteger maxFee, Optional signature, Optional signer, Optional transactionInfo, String namespaceName, NamespaceId namespaceId, Optional duration, Optional parentId, NamespaceType namespaceType) { - super(TransactionType.REGISTER_NAMESPACE, networkType, version, deadline, maxFee, signature, signer, transactionInfo); + super(EntityType.REGISTER_NAMESPACE, networkType, version, deadline, maxFee, signature, signer, transactionInfo); // validations Validate.notNull(namespaceName, "NamespaceName must not be null"); Validate.notNull(namespaceType, "NamespaceType must not be null"); diff --git a/src/main/java/io/proximax/sdk/model/transaction/SecretLockTransaction.java b/src/main/java/io/proximax/sdk/model/transaction/SecretLockTransaction.java index 977fc0a4..64dd6775 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/SecretLockTransaction.java +++ b/src/main/java/io/proximax/sdk/model/transaction/SecretLockTransaction.java @@ -43,7 +43,7 @@ public class SecretLockTransaction extends Transaction { /** * @param networkType network type - * @param version transaction version. Use {@link TransactionVersion#MODIFY_MULTISIG_ACCOUNT} for current version + * @param version transaction version. Use {@link EntityVersion#MODIFY_MULTISIG_ACCOUNT} for current version * @param deadline transaction deadline * @param maxFee transaction fee * @param signature optional signature @@ -59,7 +59,7 @@ public SecretLockTransaction(NetworkType networkType, Integer version, Transacti BigInteger maxFee, Optional signature, Optional signer, Optional transactionInfo, Mosaic mosaic, BigInteger duration, HashType hashType, String secret, Address recipient) { - super(TransactionType.SECRET_LOCK, networkType, version, deadline, maxFee, signature, signer, transactionInfo); + super(EntityType.SECRET_LOCK, networkType, version, deadline, maxFee, signature, signer, transactionInfo); // validations Validate.notNull(mosaic, "Mosaic must not be null"); Validate.notNull(duration, "Duration must not be null"); diff --git a/src/main/java/io/proximax/sdk/model/transaction/SecretProofTransaction.java b/src/main/java/io/proximax/sdk/model/transaction/SecretProofTransaction.java index 5d67ead8..b7843331 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/SecretProofTransaction.java +++ b/src/main/java/io/proximax/sdk/model/transaction/SecretProofTransaction.java @@ -39,7 +39,7 @@ public class SecretProofTransaction extends Transaction { /** * @param networkType network type - * @param version transaction version. Use {@link TransactionVersion#SECRET_PROOF} for current version + * @param version transaction version. Use {@link EntityVersion#SECRET_PROOF} for current version * @param deadline transaction deadline * @param maxFee transaction fee * @param signature optional signature @@ -54,7 +54,7 @@ public SecretProofTransaction(NetworkType networkType, Integer version, Transact BigInteger maxFee, Optional signature, Optional signer, Optional transactionInfo, HashType hashType, String secret, String proof, Recipient recipient) { - super(TransactionType.SECRET_PROOF, networkType, version, deadline, maxFee, signature, signer, transactionInfo); + super(EntityType.SECRET_PROOF, networkType, version, deadline, maxFee, signature, signer, transactionInfo); // validations Validate.notNull(secret, "Secret must not be null"); Validate.notNull(proof, "Proof must not be null"); diff --git a/src/main/java/io/proximax/sdk/model/transaction/SignedTransaction.java b/src/main/java/io/proximax/sdk/model/transaction/SignedTransaction.java index 98af7d55..5ae7a893 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/SignedTransaction.java +++ b/src/main/java/io/proximax/sdk/model/transaction/SignedTransaction.java @@ -25,9 +25,9 @@ public class SignedTransaction { private final String payload; private final String hash; - private final TransactionType type; + private final EntityType type; - public SignedTransaction(String payload, String hash, TransactionType type) { + public SignedTransaction(String payload, String hash, EntityType type) { this.payload = payload; this.hash = hash; this.type = type; @@ -56,5 +56,5 @@ public String getHash() { * * @return transaction type */ - public TransactionType getType() { return type; } + public EntityType getType() { return type; } } diff --git a/src/main/java/io/proximax/sdk/model/transaction/Transaction.java b/src/main/java/io/proximax/sdk/model/transaction/Transaction.java index b77e6b62..858993d0 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/Transaction.java +++ b/src/main/java/io/proximax/sdk/model/transaction/Transaction.java @@ -40,7 +40,7 @@ public abstract class Transaction { /** standard transaction header size */ public static final int HEADER_SIZE = 122; - private final TransactionType type; + private final EntityType type; private final NetworkType networkType; private final Integer version; private final TransactionDeadline deadline; @@ -61,7 +61,7 @@ public abstract class Transaction { * @param signer Transaction signer. * @param transactionInfo Transaction meta data info. */ - public Transaction(TransactionType type, NetworkType networkType, Integer version, TransactionDeadline deadline, + public Transaction(EntityType type, NetworkType networkType, Integer version, TransactionDeadline deadline, BigInteger maxFee, Optional signature, Optional signer, Optional transactionInfo) { Validate.notNull(type, "Type must not be null"); @@ -108,7 +108,7 @@ public static String createTransactionHash(byte[] payloadBytes, byte[] generatio * * @return transaction type */ - public TransactionType getType() { + public EntityType getType() { return type; } diff --git a/src/main/java/io/proximax/sdk/model/transaction/TransferTransaction.java b/src/main/java/io/proximax/sdk/model/transaction/TransferTransaction.java index e3b54eca..056212fd 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/TransferTransaction.java +++ b/src/main/java/io/proximax/sdk/model/transaction/TransferTransaction.java @@ -46,7 +46,7 @@ public class TransferTransaction extends Transaction { /** * @param networkType network type - * @param version transaction version. Use {@link TransactionVersion#TRANSFER} for current version + * @param version transaction version. Use {@link EntityVersion#TRANSFER} for current version * @param deadline transaction deadline * @param maxFee transaction fee * @param signature optional signature @@ -59,7 +59,7 @@ public class TransferTransaction extends Transaction { public TransferTransaction(NetworkType networkType, Integer version, TransactionDeadline deadline, BigInteger maxFee, Optional signature, Optional signer, Optional transactionInfo, Recipient recipient, List mosaics, Message message) { - super(TransactionType.TRANSFER, networkType, version, deadline, maxFee, signature, signer, transactionInfo); + super(EntityType.TRANSFER, networkType, version, deadline, maxFee, signature, signer, transactionInfo); Validate.notNull(recipient, "Recipient must not be null"); Validate.notNull(mosaics, "Mosaics must not be null"); Validate.notNull(message, "Message must not be null"); diff --git a/src/main/java/io/proximax/sdk/model/transaction/builder/AccountLinkTransactionBuilder.java b/src/main/java/io/proximax/sdk/model/transaction/builder/AccountLinkTransactionBuilder.java index a508f5fd..0a0b8fb4 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/builder/AccountLinkTransactionBuilder.java +++ b/src/main/java/io/proximax/sdk/model/transaction/builder/AccountLinkTransactionBuilder.java @@ -10,8 +10,8 @@ import io.proximax.sdk.model.account.PublicAccount; import io.proximax.sdk.model.transaction.AccountLinkAction; import io.proximax.sdk.model.transaction.AccountLinkTransaction; -import io.proximax.sdk.model.transaction.TransactionType; -import io.proximax.sdk.model.transaction.TransactionVersion; +import io.proximax.sdk.model.transaction.EntityType; +import io.proximax.sdk.model.transaction.EntityVersion; /** * builder for {@link AccountLinkTransaction} @@ -23,7 +23,7 @@ public class AccountLinkTransactionBuilder private AccountLinkAction action; public AccountLinkTransactionBuilder() { - super(TransactionType.ACCOUNT_LINK, TransactionVersion.ACCOUNT_LINK.getValue()); + super(EntityType.ACCOUNT_LINK, EntityVersion.ACCOUNT_LINK.getValue()); } @Override diff --git a/src/main/java/io/proximax/sdk/model/transaction/builder/AggregateTransactionBuilder.java b/src/main/java/io/proximax/sdk/model/transaction/builder/AggregateTransactionBuilder.java index d7cf00c2..ea88df73 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/builder/AggregateTransactionBuilder.java +++ b/src/main/java/io/proximax/sdk/model/transaction/builder/AggregateTransactionBuilder.java @@ -13,8 +13,8 @@ import io.proximax.sdk.model.transaction.AggregateTransaction; import io.proximax.sdk.model.transaction.AggregateTransactionCosignature; import io.proximax.sdk.model.transaction.Transaction; -import io.proximax.sdk.model.transaction.TransactionType; -import io.proximax.sdk.model.transaction.TransactionVersion; +import io.proximax.sdk.model.transaction.EntityType; +import io.proximax.sdk.model.transaction.EntityVersion; /** * builder for {@link AggregateTransaction} @@ -24,7 +24,7 @@ public class AggregateTransactionBuilder extends TransactionBuilder innerTransactions; private List cosignatures; - private AggregateTransactionBuilder(TransactionType type, Integer version) { + private AggregateTransactionBuilder(EntityType type, Integer version) { super(type, version); // provide empty lists as defaults this.innerTransactions = new ArrayList<>(); @@ -32,13 +32,13 @@ private AggregateTransactionBuilder(TransactionType type, Integer version) { } public static AggregateTransactionBuilder createBonded() { - return new AggregateTransactionBuilder(TransactionType.AGGREGATE_BONDED, - TransactionVersion.AGGREGATE_BONDED.getValue()); + return new AggregateTransactionBuilder(EntityType.AGGREGATE_BONDED, + EntityVersion.AGGREGATE_BONDED.getValue()); } public static AggregateTransactionBuilder createComplete() { - return new AggregateTransactionBuilder(TransactionType.AGGREGATE_COMPLETE, - TransactionVersion.AGGREGATE_COMPLETE.getValue()); + return new AggregateTransactionBuilder(EntityType.AGGREGATE_COMPLETE, + EntityVersion.AGGREGATE_COMPLETE.getValue()); } @Override diff --git a/src/main/java/io/proximax/sdk/model/transaction/builder/AliasTransactionBuilder.java b/src/main/java/io/proximax/sdk/model/transaction/builder/AliasTransactionBuilder.java index 23655268..640e2a3d 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/builder/AliasTransactionBuilder.java +++ b/src/main/java/io/proximax/sdk/model/transaction/builder/AliasTransactionBuilder.java @@ -15,8 +15,8 @@ import io.proximax.sdk.model.mosaic.MosaicId; import io.proximax.sdk.model.namespace.NamespaceId; import io.proximax.sdk.model.transaction.AliasTransaction; -import io.proximax.sdk.model.transaction.TransactionType; -import io.proximax.sdk.model.transaction.TransactionVersion; +import io.proximax.sdk.model.transaction.EntityType; +import io.proximax.sdk.model.transaction.EntityVersion; /** * builder for {@link AliasTransaction} @@ -28,7 +28,7 @@ public class AliasTransactionBuilder extends TransactionBuilder { public ModifyAccountPropertyAddressTransactionBuilder() { - super(TransactionType.ACCOUNT_PROPERTIES_ADDRESS, TransactionVersion.ACCOUNT_PROPERTIES_ADDRESS.getValue()); + super(EntityType.ACCOUNT_PROPERTIES_ADDRESS, EntityVersion.ACCOUNT_PROPERTIES_ADDRESS.getValue()); } @Override diff --git a/src/main/java/io/proximax/sdk/model/transaction/builder/ModifyAccountPropertyEntityTransactionBuilder.java b/src/main/java/io/proximax/sdk/model/transaction/builder/ModifyAccountPropertyEntityTransactionBuilder.java index ae727c29..2ef89c1c 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/builder/ModifyAccountPropertyEntityTransactionBuilder.java +++ b/src/main/java/io/proximax/sdk/model/transaction/builder/ModifyAccountPropertyEntityTransactionBuilder.java @@ -8,22 +8,22 @@ import java.math.BigInteger; import io.proximax.sdk.model.transaction.ModifyAccountPropertyTransaction; -import io.proximax.sdk.model.transaction.TransactionType; -import io.proximax.sdk.model.transaction.TransactionVersion; +import io.proximax.sdk.model.transaction.EntityType; +import io.proximax.sdk.model.transaction.EntityVersion; /** * Builder for account address property modification */ public class ModifyAccountPropertyEntityTransactionBuilder - extends ModifyAccountPropertyTransactionBuilder { + extends ModifyAccountPropertyTransactionBuilder { public ModifyAccountPropertyEntityTransactionBuilder() { - super(TransactionType.ACCOUNT_PROPERTIES_ENTITY_TYPE, - TransactionVersion.ACCOUNT_PROPERTIES_ENTITY_TYPE.getValue()); + super(EntityType.ACCOUNT_PROPERTIES_ENTITY_TYPE, + EntityVersion.ACCOUNT_PROPERTIES_ENTITY_TYPE.getValue()); } @Override - public ModifyAccountPropertyTransaction build() { + public ModifyAccountPropertyTransaction build() { // use or calculate maxFee BigInteger maxFee = getMaxFee().orElseGet(() -> getMaxFeeCalculation( ModifyAccountPropertyTransaction.EntityTypeModification.calculatePayloadSize(getModifications().size()))); diff --git a/src/main/java/io/proximax/sdk/model/transaction/builder/ModifyAccountPropertyMosaicTransactionBuilder.java b/src/main/java/io/proximax/sdk/model/transaction/builder/ModifyAccountPropertyMosaicTransactionBuilder.java index 93775da4..b5c1839d 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/builder/ModifyAccountPropertyMosaicTransactionBuilder.java +++ b/src/main/java/io/proximax/sdk/model/transaction/builder/ModifyAccountPropertyMosaicTransactionBuilder.java @@ -8,8 +8,8 @@ import java.math.BigInteger; import io.proximax.sdk.model.transaction.ModifyAccountPropertyTransaction; -import io.proximax.sdk.model.transaction.TransactionType; -import io.proximax.sdk.model.transaction.TransactionVersion; +import io.proximax.sdk.model.transaction.EntityType; +import io.proximax.sdk.model.transaction.EntityVersion; import io.proximax.sdk.model.transaction.UInt64Id; /** @@ -18,7 +18,7 @@ public class ModifyAccountPropertyMosaicTransactionBuilder extends ModifyAccountPropertyTransactionBuilder { public ModifyAccountPropertyMosaicTransactionBuilder() { - super(TransactionType.ACCOUNT_PROPERTIES_ADDRESS, TransactionVersion.ACCOUNT_PROPERTIES_ADDRESS.getValue()); + super(EntityType.ACCOUNT_PROPERTIES_ADDRESS, EntityVersion.ACCOUNT_PROPERTIES_ADDRESS.getValue()); } @Override diff --git a/src/main/java/io/proximax/sdk/model/transaction/builder/ModifyAccountPropertyTransactionBuilder.java b/src/main/java/io/proximax/sdk/model/transaction/builder/ModifyAccountPropertyTransactionBuilder.java index 55f8683b..7bf267a6 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/builder/ModifyAccountPropertyTransactionBuilder.java +++ b/src/main/java/io/proximax/sdk/model/transaction/builder/ModifyAccountPropertyTransactionBuilder.java @@ -11,7 +11,7 @@ import io.proximax.sdk.model.account.props.AccountPropertyModification; import io.proximax.sdk.model.account.props.AccountPropertyType; import io.proximax.sdk.model.transaction.ModifyAccountPropertyTransaction; -import io.proximax.sdk.model.transaction.TransactionType; +import io.proximax.sdk.model.transaction.EntityType; /** * builder for {@link ModifyAccountPropertyTransaction} @@ -21,7 +21,7 @@ public abstract class ModifyAccountPropertyTransactionBuilder extends Transac private AccountPropertyType propertyType; private List> modifications; - public ModifyAccountPropertyTransactionBuilder(TransactionType type, Integer version) { + public ModifyAccountPropertyTransactionBuilder(EntityType type, Integer version) { super(type, version); // provide empty lists as defaults this.modifications = new ArrayList<>(); diff --git a/src/main/java/io/proximax/sdk/model/transaction/builder/ModifyContractTransactionBuilder.java b/src/main/java/io/proximax/sdk/model/transaction/builder/ModifyContractTransactionBuilder.java index ab5f0c68..c9a11aea 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/builder/ModifyContractTransactionBuilder.java +++ b/src/main/java/io/proximax/sdk/model/transaction/builder/ModifyContractTransactionBuilder.java @@ -12,8 +12,8 @@ import io.proximax.sdk.model.transaction.ModifyContractTransaction; import io.proximax.sdk.model.transaction.MultisigCosignatoryModification; -import io.proximax.sdk.model.transaction.TransactionType; -import io.proximax.sdk.model.transaction.TransactionVersion; +import io.proximax.sdk.model.transaction.EntityType; +import io.proximax.sdk.model.transaction.EntityVersion; /** * builder for {@link ModifyContractTransaction} @@ -28,7 +28,7 @@ public class ModifyContractTransactionBuilder private List verifiersModifications; public ModifyContractTransactionBuilder() { - super(TransactionType.MODIFY_CONTRACT, TransactionVersion.MODIFY_CONTRACT.getValue()); + super(EntityType.MODIFY_CONTRACT, EntityVersion.MODIFY_CONTRACT.getValue()); // defaults customersModifications = new ArrayList<>(); executorsModifications = new ArrayList<>(); diff --git a/src/main/java/io/proximax/sdk/model/transaction/builder/ModifyMetadataTransactionBuilder.java b/src/main/java/io/proximax/sdk/model/transaction/builder/ModifyMetadataTransactionBuilder.java index 5d25bf24..78986305 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/builder/ModifyMetadataTransactionBuilder.java +++ b/src/main/java/io/proximax/sdk/model/transaction/builder/ModifyMetadataTransactionBuilder.java @@ -17,8 +17,8 @@ import io.proximax.sdk.model.mosaic.MosaicId; import io.proximax.sdk.model.namespace.NamespaceId; import io.proximax.sdk.model.transaction.ModifyMetadataTransaction; -import io.proximax.sdk.model.transaction.TransactionType; -import io.proximax.sdk.model.transaction.TransactionVersion; +import io.proximax.sdk.model.transaction.EntityType; +import io.proximax.sdk.model.transaction.EntityVersion; import io.proximax.sdk.model.transaction.UInt64Id; /** @@ -33,7 +33,7 @@ public class ModifyMetadataTransactionBuilder private List modifications; public ModifyMetadataTransactionBuilder() { - super(null, TransactionVersion.METADATA_MODIFICATION.getValue()); + super(null, EntityVersion.METADATA_MODIFICATION.getValue()); // defaults metadataId = Optional.empty(); address = Optional.empty(); @@ -135,15 +135,15 @@ public List getModifications() { // -------------------------------------- convenience --------------------------------------------// public ModifyMetadataTransactionBuilder forAddress(Address address) { - return type(TransactionType.MODIFY_ADDRESS_METADATA).metadataType(MetadataType.ADDRESS).metadataId(address); + return type(EntityType.MODIFY_ADDRESS_METADATA).metadataType(MetadataType.ADDRESS).metadataId(address); } public ModifyMetadataTransactionBuilder forMosaic(MosaicId mosaicId) { - return type(TransactionType.MODIFY_MOSAIC_METADATA).metadataType(MetadataType.MOSAIC).metadataId(mosaicId); + return type(EntityType.MODIFY_MOSAIC_METADATA).metadataType(MetadataType.MOSAIC).metadataId(mosaicId); } public ModifyMetadataTransactionBuilder forNamespace(NamespaceId namespaceId) { - return type(TransactionType.MODIFY_NAMESPACE_METADATA).metadataType(MetadataType.NAMESPACE) + return type(EntityType.MODIFY_NAMESPACE_METADATA).metadataType(MetadataType.NAMESPACE) .metadataId(namespaceId); } diff --git a/src/main/java/io/proximax/sdk/model/transaction/builder/ModifyMultisigAccountTransactionBuilder.java b/src/main/java/io/proximax/sdk/model/transaction/builder/ModifyMultisigAccountTransactionBuilder.java index c9cbd89c..9e5e1e18 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/builder/ModifyMultisigAccountTransactionBuilder.java +++ b/src/main/java/io/proximax/sdk/model/transaction/builder/ModifyMultisigAccountTransactionBuilder.java @@ -12,8 +12,8 @@ import io.proximax.sdk.model.transaction.ModifyMultisigAccountTransaction; import io.proximax.sdk.model.transaction.MultisigCosignatoryModification; -import io.proximax.sdk.model.transaction.TransactionType; -import io.proximax.sdk.model.transaction.TransactionVersion; +import io.proximax.sdk.model.transaction.EntityType; +import io.proximax.sdk.model.transaction.EntityVersion; /** * builder for {@link ModifyMultisigAccountTransaction} @@ -26,7 +26,7 @@ public class ModifyMultisigAccountTransactionBuilder private List modifications; public ModifyMultisigAccountTransactionBuilder() { - super(TransactionType.MODIFY_MULTISIG_ACCOUNT, TransactionVersion.MODIFY_MULTISIG_ACCOUNT.getValue()); + super(EntityType.MODIFY_MULTISIG_ACCOUNT, EntityVersion.MODIFY_MULTISIG_ACCOUNT.getValue()); // defaults minApprovalDelta = 0; minRemovalDelta = 0; diff --git a/src/main/java/io/proximax/sdk/model/transaction/builder/MosaicDefinitionTransactionBuilder.java b/src/main/java/io/proximax/sdk/model/transaction/builder/MosaicDefinitionTransactionBuilder.java index 38923ed1..aa9d2175 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/builder/MosaicDefinitionTransactionBuilder.java +++ b/src/main/java/io/proximax/sdk/model/transaction/builder/MosaicDefinitionTransactionBuilder.java @@ -11,8 +11,8 @@ import io.proximax.sdk.model.mosaic.MosaicNonce; import io.proximax.sdk.model.mosaic.MosaicProperties; import io.proximax.sdk.model.transaction.MosaicDefinitionTransaction; -import io.proximax.sdk.model.transaction.TransactionType; -import io.proximax.sdk.model.transaction.TransactionVersion; +import io.proximax.sdk.model.transaction.EntityType; +import io.proximax.sdk.model.transaction.EntityVersion; /** * builder for {@link MosaicDefinitionTransaction} @@ -25,7 +25,7 @@ public class MosaicDefinitionTransactionBuilder private MosaicProperties mosaicProperties; public MosaicDefinitionTransactionBuilder() { - super(TransactionType.MOSAIC_DEFINITION, TransactionVersion.MOSAIC_DEFINITION.getValue()); + super(EntityType.MOSAIC_DEFINITION, EntityVersion.MOSAIC_DEFINITION.getValue()); // defaults } diff --git a/src/main/java/io/proximax/sdk/model/transaction/builder/MosaicSupplyChangeTransactionBuilder.java b/src/main/java/io/proximax/sdk/model/transaction/builder/MosaicSupplyChangeTransactionBuilder.java index e96bbc24..7b8320bf 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/builder/MosaicSupplyChangeTransactionBuilder.java +++ b/src/main/java/io/proximax/sdk/model/transaction/builder/MosaicSupplyChangeTransactionBuilder.java @@ -10,8 +10,8 @@ import io.proximax.sdk.model.mosaic.MosaicId; import io.proximax.sdk.model.mosaic.MosaicSupplyType; import io.proximax.sdk.model.transaction.MosaicSupplyChangeTransaction; -import io.proximax.sdk.model.transaction.TransactionType; -import io.proximax.sdk.model.transaction.TransactionVersion; +import io.proximax.sdk.model.transaction.EntityType; +import io.proximax.sdk.model.transaction.EntityVersion; /** * builder for {@link MosaicSupplyChangeTransaction} @@ -24,7 +24,7 @@ public class MosaicSupplyChangeTransactionBuilder private BigInteger delta; public MosaicSupplyChangeTransactionBuilder() { - super(TransactionType.MOSAIC_SUPPLY_CHANGE, TransactionVersion.MOSAIC_SUPPLY_CHANGE.getValue()); + super(EntityType.MOSAIC_SUPPLY_CHANGE, EntityVersion.MOSAIC_SUPPLY_CHANGE.getValue()); } @Override diff --git a/src/main/java/io/proximax/sdk/model/transaction/builder/RegisterNamespaceTransactionBuilder.java b/src/main/java/io/proximax/sdk/model/transaction/builder/RegisterNamespaceTransactionBuilder.java index 7ac20ecb..fae941b4 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/builder/RegisterNamespaceTransactionBuilder.java +++ b/src/main/java/io/proximax/sdk/model/transaction/builder/RegisterNamespaceTransactionBuilder.java @@ -12,8 +12,8 @@ import io.proximax.sdk.model.namespace.NamespaceType; import io.proximax.sdk.model.transaction.IdGenerator; import io.proximax.sdk.model.transaction.RegisterNamespaceTransaction; -import io.proximax.sdk.model.transaction.TransactionType; -import io.proximax.sdk.model.transaction.TransactionVersion; +import io.proximax.sdk.model.transaction.EntityType; +import io.proximax.sdk.model.transaction.EntityVersion; /** * builder for {@link RegisterNamespaceTransaction} @@ -28,7 +28,7 @@ public class RegisterNamespaceTransactionBuilder private NamespaceType namespaceType; public RegisterNamespaceTransactionBuilder() { - super(TransactionType.REGISTER_NAMESPACE, TransactionVersion.REGISTER_NAMESPACE.getValue()); + super(EntityType.REGISTER_NAMESPACE, EntityVersion.REGISTER_NAMESPACE.getValue()); // defaults duration = Optional.empty(); parentId = Optional.empty(); diff --git a/src/main/java/io/proximax/sdk/model/transaction/builder/SecretLockTransactionBuilder.java b/src/main/java/io/proximax/sdk/model/transaction/builder/SecretLockTransactionBuilder.java index 0683a616..676f582b 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/builder/SecretLockTransactionBuilder.java +++ b/src/main/java/io/proximax/sdk/model/transaction/builder/SecretLockTransactionBuilder.java @@ -11,8 +11,8 @@ import io.proximax.sdk.model.mosaic.Mosaic; import io.proximax.sdk.model.transaction.HashType; import io.proximax.sdk.model.transaction.SecretLockTransaction; -import io.proximax.sdk.model.transaction.TransactionType; -import io.proximax.sdk.model.transaction.TransactionVersion; +import io.proximax.sdk.model.transaction.EntityType; +import io.proximax.sdk.model.transaction.EntityVersion; /** * builder for {@link SecretLockTransaction} @@ -27,7 +27,7 @@ public class SecretLockTransactionBuilder private Address recipient; public SecretLockTransactionBuilder() { - super(TransactionType.SECRET_LOCK, TransactionVersion.SECRET_LOCK.getValue()); + super(EntityType.SECRET_LOCK, EntityVersion.SECRET_LOCK.getValue()); } @Override diff --git a/src/main/java/io/proximax/sdk/model/transaction/builder/SecretProofTransactionBuilder.java b/src/main/java/io/proximax/sdk/model/transaction/builder/SecretProofTransactionBuilder.java index 7646183a..67c12465 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/builder/SecretProofTransactionBuilder.java +++ b/src/main/java/io/proximax/sdk/model/transaction/builder/SecretProofTransactionBuilder.java @@ -10,8 +10,8 @@ import io.proximax.sdk.model.transaction.HashType; import io.proximax.sdk.model.transaction.Recipient; import io.proximax.sdk.model.transaction.SecretProofTransaction; -import io.proximax.sdk.model.transaction.TransactionType; -import io.proximax.sdk.model.transaction.TransactionVersion; +import io.proximax.sdk.model.transaction.EntityType; +import io.proximax.sdk.model.transaction.EntityVersion; /** * builder for {@link SecretProofTransaction} @@ -25,7 +25,7 @@ public class SecretProofTransactionBuilder private Recipient recipient; public SecretProofTransactionBuilder() { - super(TransactionType.SECRET_PROOF, TransactionVersion.SECRET_PROOF.getValue()); + super(EntityType.SECRET_PROOF, EntityVersion.SECRET_PROOF.getValue()); } @Override diff --git a/src/main/java/io/proximax/sdk/model/transaction/builder/TransactionBuilder.java b/src/main/java/io/proximax/sdk/model/transaction/builder/TransactionBuilder.java index f2b240be..6d790cdc 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/builder/TransactionBuilder.java +++ b/src/main/java/io/proximax/sdk/model/transaction/builder/TransactionBuilder.java @@ -15,7 +15,7 @@ import io.proximax.sdk.model.transaction.Transaction; import io.proximax.sdk.model.transaction.TransactionDeadline; import io.proximax.sdk.model.transaction.TransactionInfo; -import io.proximax.sdk.model.transaction.TransactionType; +import io.proximax.sdk.model.transaction.EntityType; /** * Transaction builder is base class implementing builder pattern to construct instance of transaction. It is bases of @@ -23,7 +23,7 @@ */ public abstract class TransactionBuilder, T extends Transaction> { - private TransactionType type; + private EntityType type; private Integer version; private NetworkType networkType; private Optional maxFee; @@ -40,7 +40,7 @@ public abstract class TransactionBuilder, T e * @param type * @param version */ - public TransactionBuilder(TransactionType type, Integer version) { + public TransactionBuilder(EntityType type, Integer version) { this.type = type; this.version = version; // initialize defaults @@ -82,7 +82,7 @@ protected BigInteger getMaxFeeCalculation(int transactionPayloadSize) { /** * @param type the type to set */ - public B type(TransactionType type) { + public B type(EntityType type) { this.type = type; return self(); } @@ -165,7 +165,7 @@ public B feeCalculationStrategy(FeeCalculationStrategy feeCalculationStrategy) { /** * @return the type */ - public TransactionType getType() { + public EntityType getType() { return type; } diff --git a/src/main/java/io/proximax/sdk/model/transaction/builder/TransferTransactionBuilder.java b/src/main/java/io/proximax/sdk/model/transaction/builder/TransferTransactionBuilder.java index 2ab4568e..dd312b07 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/builder/TransferTransactionBuilder.java +++ b/src/main/java/io/proximax/sdk/model/transaction/builder/TransferTransactionBuilder.java @@ -16,8 +16,8 @@ import io.proximax.sdk.model.transaction.Message; import io.proximax.sdk.model.transaction.PlainMessage; import io.proximax.sdk.model.transaction.Recipient; -import io.proximax.sdk.model.transaction.TransactionType; -import io.proximax.sdk.model.transaction.TransactionVersion; +import io.proximax.sdk.model.transaction.EntityType; +import io.proximax.sdk.model.transaction.EntityVersion; import io.proximax.sdk.model.transaction.TransferTransaction; /** @@ -29,7 +29,7 @@ public class TransferTransactionBuilder extends TransactionBuilder new AliasTransaction(TransactionType.MOSAIC_ALIAS, NetworkType.MIJIN, - TransactionVersion.ADDRESS_ALIAS.getValue(), new FakeDeadline(), BigInteger.ZERO, Optional.empty(), + () -> new AliasTransaction(EntityType.MOSAIC_ALIAS, NetworkType.MIJIN, + EntityVersion.ADDRESS_ALIAS.getValue(), new FakeDeadline(), BigInteger.ZERO, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(new Address("MB3KUBHATFCPV7UZQLWAQ2EUR6SIHBSBEOEDDDF3", NetworkType.MIJIN)), new NamespaceId("testest"), AliasAction.LINK)); assertThrows(IllegalArgumentException.class, - () -> new AliasTransaction(TransactionType.ADDRESS_ALIAS, NetworkType.MIJIN, - TransactionVersion.ADDRESS_ALIAS.getValue(), new FakeDeadline(), BigInteger.ZERO, + () -> new AliasTransaction(EntityType.ADDRESS_ALIAS, NetworkType.MIJIN, + EntityVersion.ADDRESS_ALIAS.getValue(), new FakeDeadline(), BigInteger.ZERO, Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(new MosaicId( BigInteger.ONE)), Optional.empty(), new NamespaceId("testest"), AliasAction.LINK)); @@ -62,8 +62,8 @@ void genericConstructorThrows() { @Test void addressSerialization() throws IOException { - AliasTransaction trans = new AliasTransaction(TransactionType.ADDRESS_ALIAS, NetworkType.MIJIN, - TransactionVersion.ADDRESS_ALIAS.getValue(), new FakeDeadline(), BigInteger.ZERO, + AliasTransaction trans = new AliasTransaction(EntityType.ADDRESS_ALIAS, NetworkType.MIJIN, + EntityVersion.ADDRESS_ALIAS.getValue(), new FakeDeadline(), BigInteger.ZERO, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(new Address("MB3KUBHATFCPV7UZQLWAQ2EUR6SIHBSBEOEDDDF3", NetworkType.MIJIN)), new NamespaceId("testest"), AliasAction.LINK); // generated by saveBytes @@ -74,8 +74,8 @@ void addressSerialization() throws IOException { @Test void mosaicSerialization() throws IOException { - AliasTransaction trans = new AliasTransaction(TransactionType.MOSAIC_ALIAS, NetworkType.MIJIN, - TransactionVersion.ADDRESS_ALIAS.getValue(), new FakeDeadline(), BigInteger.ZERO, + AliasTransaction trans = new AliasTransaction(EntityType.MOSAIC_ALIAS, NetworkType.MIJIN, + EntityVersion.ADDRESS_ALIAS.getValue(), new FakeDeadline(), BigInteger.ZERO, Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(new MosaicId( BigInteger.ONE)), Optional.empty(), new NamespaceId("testest"), AliasAction.LINK); @@ -89,8 +89,8 @@ void mosaicSerialization() throws IOException { void checkCopyToSigner() { PublicAccount remoteAccount = new Account(new KeyPair(), NetworkType.MIJIN).getPublicAccount(); - AliasTransaction trans = new AliasTransaction(TransactionType.MOSAIC_ALIAS, NetworkType.MIJIN, - TransactionVersion.ADDRESS_ALIAS.getValue(), new FakeDeadline(), BigInteger.ZERO, + AliasTransaction trans = new AliasTransaction(EntityType.MOSAIC_ALIAS, NetworkType.MIJIN, + EntityVersion.ADDRESS_ALIAS.getValue(), new FakeDeadline(), BigInteger.ZERO, Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(new MosaicId( BigInteger.ONE)), Optional.empty(), new NamespaceId("testest"), AliasAction.LINK); diff --git a/src/test/java/io/proximax/sdk/model/transaction/CosignatureTransactionTest.java b/src/test/java/io/proximax/sdk/model/transaction/CosignatureTransactionTest.java index 758aa510..01e1040b 100644 --- a/src/test/java/io/proximax/sdk/model/transaction/CosignatureTransactionTest.java +++ b/src/test/java/io/proximax/sdk/model/transaction/CosignatureTransactionTest.java @@ -66,7 +66,7 @@ void createACosignatureTransactionViaConstructor() throws Exception { @Test void shouldThrowExceptionWhenTransactionToCosignHasNotBeenAnnunced() throws Exception { - AggregateTransaction aggregateTransaction = new AggregateTransaction(TransactionType.AGGREGATE_COMPLETE, NetworkType.MIJIN_TEST, 1, Deadline.create(2, ChronoUnit.HOURS), BigInteger.ZERO, + AggregateTransaction aggregateTransaction = new AggregateTransaction(EntityType.AGGREGATE_COMPLETE, NetworkType.MIJIN_TEST, 1, Deadline.create(2, ChronoUnit.HOURS), BigInteger.ZERO, Optional.empty(), Optional.empty(), Optional.empty(), Collections.emptyList(), Collections.emptyList()); assertThrows(IllegalArgumentException.class, ()->{CosignatureTransaction.create(aggregateTransaction);}, "Transaction to cosign should be announced before being able to cosign it"); diff --git a/src/test/java/io/proximax/sdk/model/transaction/FakeTransferTransaction.java b/src/test/java/io/proximax/sdk/model/transaction/FakeTransferTransaction.java index ef1fc324..07e7a253 100644 --- a/src/test/java/io/proximax/sdk/model/transaction/FakeTransferTransaction.java +++ b/src/test/java/io/proximax/sdk/model/transaction/FakeTransferTransaction.java @@ -27,7 +27,7 @@ public class FakeTransferTransaction extends Transaction { public FakeTransferTransaction(NetworkType networkType, Integer version, TransactionDeadline deadline, BigInteger maxFee, Optional signature, Optional signer, Optional transactionInfo) { - super(TransactionType.TRANSFER, networkType, version, deadline, maxFee, signature, signer, transactionInfo); + super(EntityType.TRANSFER, networkType, version, deadline, maxFee, signature, signer, transactionInfo); } public FakeTransferTransaction(NetworkType networkType, Integer version, TransactionDeadline deadline, BigInteger maxFee) { diff --git a/src/test/java/io/proximax/sdk/model/transaction/LockFundsTransactionTest.java b/src/test/java/io/proximax/sdk/model/transaction/LockFundsTransactionTest.java index f2782869..083db73a 100644 --- a/src/test/java/io/proximax/sdk/model/transaction/LockFundsTransactionTest.java +++ b/src/test/java/io/proximax/sdk/model/transaction/LockFundsTransactionTest.java @@ -40,7 +40,7 @@ class LockFundsTransactionTest extends ResourceBasedTest { @Test void constructor() { SignedTransaction signedTransaction = new SignedTransaction("payload", - "8498B38D89C1DC8A448EA5824938FF828926CD9F7747B1844B59B4B6807E878B", TransactionType.AGGREGATE_BONDED); + "8498B38D89C1DC8A448EA5824938FF828926CD9F7747B1844B59B4B6807E878B", EntityType.AGGREGATE_BONDED); LockFundsTransaction tx = new LockFundsTransaction(NetworkType.MIJIN, 23, new FakeDeadline(), BigInteger.ONE, Optional.of("signaturestring"), Optional.of(new PublicAccount(new KeyPair().getPublicKey().getHexString(), NetworkType.MIJIN)), @@ -55,7 +55,7 @@ void constructor() { @Test void serialization() throws IOException { SignedTransaction signedTransaction = new SignedTransaction("payload", - "8498B38D89C1DC8A448EA5824938FF828926CD9F7747B1844B59B4B6807E878B", TransactionType.AGGREGATE_BONDED); + "8498B38D89C1DC8A448EA5824938FF828926CD9F7747B1844B59B4B6807E878B", EntityType.AGGREGATE_BONDED); LockFundsTransaction lockFundstx = new LockFundsTransaction(NetworkType.MIJIN_TEST, 1, new FakeDeadline(), BigInteger.ZERO, Optional.empty(), Optional.empty(), Optional.empty(), NetworkCurrencyMosaic.TEN, BigInteger.valueOf(100), signedTransaction); @@ -68,7 +68,7 @@ void serialization() throws IOException { void shouldThrowExceptionWhenSignedTransactionIsNotTypeAggregateBonded() { SignedTransaction signedTransaction = new SignedTransaction("payload", - "8498B38D89C1DC8A448EA5824938FF828926CD9F7747B1844B59B4B6807E878B", TransactionType.TRANSFER); + "8498B38D89C1DC8A448EA5824938FF828926CD9F7747B1844B59B4B6807E878B", EntityType.TRANSFER); assertThrows(IllegalArgumentException.class, () -> new LockFundsTransaction(NetworkType.MIJIN_TEST, 1, new FakeDeadline(), BigInteger.ZERO, Optional.empty(), Optional.empty(), Optional.empty(), NetworkCurrencyMosaic.TEN, @@ -79,7 +79,7 @@ void shouldThrowExceptionWhenSignedTransactionIsNotTypeAggregateBonded() { @Test void checkToStringIsImplemented() { SignedTransaction signedTransaction = new SignedTransaction("payload", - "8498B38D89C1DC8A448EA5824938FF828926CD9F7747B1844B59B4B6807E878B", TransactionType.AGGREGATE_BONDED); + "8498B38D89C1DC8A448EA5824938FF828926CD9F7747B1844B59B4B6807E878B", EntityType.AGGREGATE_BONDED); LockFundsTransaction tx = new LockFundsTransaction(NetworkType.MIJIN_TEST, 1, new FakeDeadline(), BigInteger.ZERO, Optional.empty(), Optional.empty(), Optional.empty(), NetworkCurrencyMosaic.TEN, BigInteger.valueOf(100), signedTransaction); @@ -91,7 +91,7 @@ void checkCopyToSigner() throws IOException { PublicAccount remoteAccount = new Account(new KeyPair(), NetworkType.MIJIN).getPublicAccount(); SignedTransaction signedTransaction = new SignedTransaction("payload", - "8498B38D89C1DC8A448EA5824938FF828926CD9F7747B1844B59B4B6807E878B", TransactionType.AGGREGATE_BONDED); + "8498B38D89C1DC8A448EA5824938FF828926CD9F7747B1844B59B4B6807E878B", EntityType.AGGREGATE_BONDED); LockFundsTransaction trans = new LockFundsTransaction(NetworkType.MIJIN_TEST, 1, new FakeDeadline(), BigInteger.ZERO, Optional.empty(), Optional.empty(), Optional.empty(), NetworkCurrencyMosaic.TEN, BigInteger.valueOf(100), signedTransaction); diff --git a/src/test/java/io/proximax/sdk/model/transaction/ModifyAccountPropertyTransactionTest.java b/src/test/java/io/proximax/sdk/model/transaction/ModifyAccountPropertyTransactionTest.java index 7ecc3502..173c67ba 100644 --- a/src/test/java/io/proximax/sdk/model/transaction/ModifyAccountPropertyTransactionTest.java +++ b/src/test/java/io/proximax/sdk/model/transaction/ModifyAccountPropertyTransactionTest.java @@ -42,7 +42,7 @@ void serializationAddress() throws IOException { Arrays.asList(new AccountPropertyModification<>(AccountPropertyModificationType.ADD, address))); // check that values are as expected assertEquals(BigInteger.ZERO, trans.getMaxFee()); - assertEquals(TransactionType.ACCOUNT_PROPERTIES_ADDRESS, trans.getType()); + assertEquals(EntityType.ACCOUNT_PROPERTIES_ADDRESS, trans.getType()); assertEquals(1, trans.getVersion()); assertEquals(deadline.getInstant(), trans.getDeadline().getInstant()); assertEquals(AccountPropertyType.ALLOW_ADDRESS, trans.getPropertyType()); @@ -65,7 +65,7 @@ void serializationMosaic() throws IOException { new MosaicId(BigInteger.ONE)))); // check that values are as expected assertEquals(BigInteger.ZERO, trans.getMaxFee()); - assertEquals(TransactionType.ACCOUNT_PROPERTIES_MOSAIC, trans.getType()); + assertEquals(EntityType.ACCOUNT_PROPERTIES_MOSAIC, trans.getType()); assertEquals(1, trans.getVersion()); assertEquals(deadline.getInstant(), trans.getDeadline().getInstant()); assertEquals(AccountPropertyType.ALLOW_MOSAIC, trans.getPropertyType()); @@ -81,19 +81,19 @@ void serializationMosaic() throws IOException { @Test void serializationEntity() throws IOException { Deadline deadline = new FakeDeadline(); - ModifyAccountPropertyTransaction trans = new ModifyAccountPropertyTransaction.EntityTypeModification( + ModifyAccountPropertyTransaction trans = new ModifyAccountPropertyTransaction.EntityTypeModification( NetworkType.MIJIN_TEST, 1, deadline, BigInteger.ZERO, Optional.empty(), Optional.empty(), Optional.empty(), AccountPropertyType.BLOCK_TRANSACTION, Arrays.asList( - new AccountPropertyModification<>(AccountPropertyModificationType.ADD, TransactionType.LOCK))); + new AccountPropertyModification<>(AccountPropertyModificationType.ADD, EntityType.LOCK))); // check that values are as expected assertEquals(BigInteger.ZERO, trans.getMaxFee()); - assertEquals(TransactionType.ACCOUNT_PROPERTIES_ENTITY_TYPE, trans.getType()); - assertEquals(TransactionVersion.ACCOUNT_PROPERTIES_ENTITY_TYPE.getValue(), trans.getVersion()); + assertEquals(EntityType.ACCOUNT_PROPERTIES_ENTITY_TYPE, trans.getType()); + assertEquals(EntityVersion.ACCOUNT_PROPERTIES_ENTITY_TYPE.getValue(), trans.getVersion()); assertEquals(deadline.getInstant(), trans.getDeadline().getInstant()); assertEquals(AccountPropertyType.BLOCK_TRANSACTION, trans.getPropertyType()); assertEquals(NetworkType.MIJIN_TEST, trans.getNetworkType()); assertEquals(1, trans.getPropertyModifications().size()); - assertEquals(TransactionType.LOCK, trans.getPropertyModifications().get(0).getValue()); + assertEquals(EntityType.LOCK, trans.getPropertyModifications().get(0).getValue()); // check that serialization does not fail byte[] actual = trans.generateBytes(); // saveBytes("account_property_entity", actual); @@ -137,10 +137,10 @@ void checkCopyToSignerentity() throws IOException { PublicAccount remoteAccount = new Account(new KeyPair(), NetworkType.MIJIN).getPublicAccount(); Deadline deadline = new FakeDeadline(); - ModifyAccountPropertyTransaction trans = new ModifyAccountPropertyTransaction.EntityTypeModification( + ModifyAccountPropertyTransaction trans = new ModifyAccountPropertyTransaction.EntityTypeModification( NetworkType.MIJIN_TEST, 1, deadline, BigInteger.ZERO, Optional.empty(), Optional.empty(), Optional.empty(), AccountPropertyType.BLOCK_TRANSACTION, Arrays.asList( - new AccountPropertyModification<>(AccountPropertyModificationType.ADD, TransactionType.LOCK))); + new AccountPropertyModification<>(AccountPropertyModificationType.ADD, EntityType.LOCK))); Transaction t = trans.copyForSigner(remoteAccount); assertEquals(Optional.of(remoteAccount), t.getSigner()); diff --git a/src/test/java/io/proximax/sdk/model/transaction/ModifyMetadataTransactionTest.java b/src/test/java/io/proximax/sdk/model/transaction/ModifyMetadataTransactionTest.java index 3b44a3d6..43d72dfb 100644 --- a/src/test/java/io/proximax/sdk/model/transaction/ModifyMetadataTransactionTest.java +++ b/src/test/java/io/proximax/sdk/model/transaction/ModifyMetadataTransactionTest.java @@ -37,12 +37,12 @@ class ModifyMetadataTransactionTest extends ResourceBasedTest { @Test void genericConstructor() { Deadline deadLine = new FakeDeadline(); - ModifyMetadataTransaction trans = new ModifyMetadataTransaction(TransactionType.MODIFY_ADDRESS_METADATA, + ModifyMetadataTransaction trans = new ModifyMetadataTransaction(EntityType.MODIFY_ADDRESS_METADATA, NetworkType.MIJIN, 63, deadLine, BigInteger.valueOf(765), Optional.of("sign"), Optional.of(new PublicAccount("", NetworkType.MIJIN)), Optional.of(TransactionInfo.create(BigInteger.ONE, "infohash", "merklehash")), MetadataType.ADDRESS, Optional.empty(), Optional.of(new Address("MHAH", NetworkType.MIJIN)), Arrays.asList()); - assertEquals(TransactionType.MODIFY_ADDRESS_METADATA, trans.getType()); + assertEquals(EntityType.MODIFY_ADDRESS_METADATA, trans.getType()); assertEquals(NetworkType.MIJIN, trans.getNetworkType()); assertEquals(63, trans.getVersion()); assertEquals(deadLine, trans.getDeadline()); @@ -60,7 +60,7 @@ void genericConstructor() { @Test void assertFailureWhenTargetMissing() { assertThrows(IllegalArgumentException.class, - () -> new ModifyMetadataTransaction(TransactionType.MODIFY_ADDRESS_METADATA, NetworkType.MIJIN, 63, + () -> new ModifyMetadataTransaction(EntityType.MODIFY_ADDRESS_METADATA, NetworkType.MIJIN, 63, new FakeDeadline(), BigInteger.valueOf(765), Optional.of("sign"), Optional.of(new PublicAccount("", NetworkType.MIJIN)), Optional.of(TransactionInfo.create(BigInteger.ONE, "infohash", "merklehash")), MetadataType.ADDRESS, @@ -70,7 +70,7 @@ void assertFailureWhenTargetMissing() { @Test void assertFailureWhenTargetOverspecified() { assertThrows(IllegalArgumentException.class, - () -> new ModifyMetadataTransaction(TransactionType.MODIFY_ADDRESS_METADATA, NetworkType.MIJIN, 63, + () -> new ModifyMetadataTransaction(EntityType.MODIFY_ADDRESS_METADATA, NetworkType.MIJIN, 63, new FakeDeadline(), BigInteger.valueOf(765), Optional.of("sign"), Optional.of(new PublicAccount("", NetworkType.MIJIN)), Optional.of(TransactionInfo.create(BigInteger.ONE, "infohash", "merklehash")), MetadataType.ADDRESS, @@ -80,7 +80,7 @@ void assertFailureWhenTargetOverspecified() { @Test void serializationAddress() throws IOException { - ModifyMetadataTransaction trans = new ModifyMetadataTransaction(TransactionType.MODIFY_ADDRESS_METADATA, + ModifyMetadataTransaction trans = new ModifyMetadataTransaction(EntityType.MODIFY_ADDRESS_METADATA, NetworkType.MIJIN_TEST, 1, new FakeDeadline(), BigInteger.ZERO, Optional.empty(), Optional.empty(), Optional.empty(), MetadataType.ADDRESS, Optional.empty(), Optional.of(new Address("SDUP5PLHDXKBX3UU5Q52LAY4WYEKGEWC6IB3VBFM", NetworkType.MIJIN_TEST)), @@ -94,7 +94,7 @@ void serializationAddress() throws IOException { @Test void serializationMosaic() throws IOException { - ModifyMetadataTransaction trans = new ModifyMetadataTransaction(TransactionType.MODIFY_MOSAIC_METADATA, + ModifyMetadataTransaction trans = new ModifyMetadataTransaction(EntityType.MODIFY_MOSAIC_METADATA, NetworkType.MIJIN_TEST, 1, new FakeDeadline(), BigInteger.ZERO, Optional.empty(), Optional.empty(), Optional.empty(), MetadataType.MOSAIC, Optional.of(new MosaicId(BigInteger.ONE)), Optional.empty(), @@ -108,7 +108,7 @@ void serializationMosaic() throws IOException { @Test void serializationNamespace() throws IOException { - ModifyMetadataTransaction trans = new ModifyMetadataTransaction(TransactionType.MODIFY_NAMESPACE_METADATA, + ModifyMetadataTransaction trans = new ModifyMetadataTransaction(EntityType.MODIFY_NAMESPACE_METADATA, NetworkType.MIJIN_TEST, 1, new FakeDeadline(), BigInteger.ZERO, Optional.empty(), Optional.empty(), Optional.empty(), MetadataType.NAMESPACE, Optional.of(new NamespaceId("testns")), Optional.empty(), @@ -124,7 +124,7 @@ void serializationNamespace() throws IOException { void checkCopyToSigner() throws IOException { PublicAccount remoteAccount = new Account(new KeyPair(), NetworkType.MIJIN).getPublicAccount(); - ModifyMetadataTransaction trans = new ModifyMetadataTransaction(TransactionType.MODIFY_NAMESPACE_METADATA, + ModifyMetadataTransaction trans = new ModifyMetadataTransaction(EntityType.MODIFY_NAMESPACE_METADATA, NetworkType.MIJIN_TEST, 1, new FakeDeadline(), BigInteger.ZERO, Optional.empty(), Optional.empty(), Optional.empty(), MetadataType.NAMESPACE, Optional.of(new NamespaceId("testns")), Optional.empty(), diff --git a/src/test/java/io/proximax/sdk/model/transaction/SignedTransactionTest.java b/src/test/java/io/proximax/sdk/model/transaction/SignedTransactionTest.java index 402603b3..4e78c3d6 100644 --- a/src/test/java/io/proximax/sdk/model/transaction/SignedTransactionTest.java +++ b/src/test/java/io/proximax/sdk/model/transaction/SignedTransactionTest.java @@ -24,10 +24,10 @@ public class SignedTransactionTest { @Test void createASignedTransactionViaConstructor() { - SignedTransaction signedTransaction = new SignedTransaction("payload", "hash", TransactionType.TRANSFER); + SignedTransaction signedTransaction = new SignedTransaction("payload", "hash", EntityType.TRANSFER); assertEquals("payload", signedTransaction.getPayload()); assertEquals("hash", signedTransaction.getHash()); - assertEquals(TransactionType.TRANSFER, signedTransaction.getType()); + assertEquals(EntityType.TRANSFER, signedTransaction.getType()); } } diff --git a/src/test/java/io/proximax/sdk/model/transaction/TransactionTypeTest.java b/src/test/java/io/proximax/sdk/model/transaction/TransactionTypeTest.java index 1a718761..cdfd4008 100644 --- a/src/test/java/io/proximax/sdk/model/transaction/TransactionTypeTest.java +++ b/src/test/java/io/proximax/sdk/model/transaction/TransactionTypeTest.java @@ -23,129 +23,129 @@ class TransactionTypeTest { @Test void aggregateCompleteType() { - TransactionType transactionType = TransactionType.AGGREGATE_COMPLETE; + EntityType transactionType = EntityType.AGGREGATE_COMPLETE; assertEquals(0x4141, transactionType.getValue()); assertEquals(16705, transactionType.getValue()); - assertEquals(TransactionType.AGGREGATE_COMPLETE, TransactionType.rawValueOf(16705)); + assertEquals(EntityType.AGGREGATE_COMPLETE, EntityType.rawValueOf(16705)); } @Test void aggregateBondedType() { - TransactionType transactionType = TransactionType.AGGREGATE_BONDED; + EntityType transactionType = EntityType.AGGREGATE_BONDED; assertEquals(0x4241, transactionType.getValue()); assertEquals(16961, transactionType.getValue()); - assertEquals(TransactionType.AGGREGATE_BONDED, TransactionType.rawValueOf(16961)); + assertEquals(EntityType.AGGREGATE_BONDED, EntityType.rawValueOf(16961)); } @Test void mosaicCreationType() { - TransactionType transactionType = TransactionType.MOSAIC_DEFINITION; + EntityType transactionType = EntityType.MOSAIC_DEFINITION; assertEquals(0x414d, transactionType.getValue()); assertEquals(16717, transactionType.getValue()); - assertEquals(TransactionType.MOSAIC_DEFINITION, TransactionType.rawValueOf(16717)); + assertEquals(EntityType.MOSAIC_DEFINITION, EntityType.rawValueOf(16717)); } @Test void mosaicSupplyChangeType() { - TransactionType transactionType = TransactionType.MOSAIC_SUPPLY_CHANGE; + EntityType transactionType = EntityType.MOSAIC_SUPPLY_CHANGE; assertEquals(0x424d, transactionType.getValue()); assertEquals(16973, transactionType.getValue()); - assertEquals(TransactionType.MOSAIC_SUPPLY_CHANGE, TransactionType.rawValueOf(16973)); + assertEquals(EntityType.MOSAIC_SUPPLY_CHANGE, EntityType.rawValueOf(16973)); } @Test void multisigModificationType() { - TransactionType transactionType = TransactionType.MODIFY_MULTISIG_ACCOUNT; + EntityType transactionType = EntityType.MODIFY_MULTISIG_ACCOUNT; assertEquals(0x4155, transactionType.getValue()); assertEquals(16725, transactionType.getValue()); - assertEquals(TransactionType.MODIFY_MULTISIG_ACCOUNT, TransactionType.rawValueOf(16725)); + assertEquals(EntityType.MODIFY_MULTISIG_ACCOUNT, EntityType.rawValueOf(16725)); } @Test void namespaceCreationType() { - TransactionType transactionType = TransactionType.REGISTER_NAMESPACE; + EntityType transactionType = EntityType.REGISTER_NAMESPACE; assertEquals(0x414e, transactionType.getValue()); assertEquals(16718, transactionType.getValue()); - assertEquals(TransactionType.REGISTER_NAMESPACE, TransactionType.rawValueOf(16718)); + assertEquals(EntityType.REGISTER_NAMESPACE, EntityType.rawValueOf(16718)); } @Test void transferType() { - TransactionType transactionType = TransactionType.TRANSFER; + EntityType transactionType = EntityType.TRANSFER; assertEquals(0x4154, transactionType.getValue()); assertEquals(16724, transactionType.getValue()); - assertEquals(TransactionType.TRANSFER, TransactionType.rawValueOf(16724)); + assertEquals(EntityType.TRANSFER, EntityType.rawValueOf(16724)); } @Test void lockFundsType() { - TransactionType transactionType = TransactionType.LOCK; + EntityType transactionType = EntityType.LOCK; assertEquals(0x4148, transactionType.getValue()); assertEquals(16712, transactionType.getValue()); - assertEquals(TransactionType.LOCK, TransactionType.rawValueOf(16712)); + assertEquals(EntityType.LOCK, EntityType.rawValueOf(16712)); } @Test void secretLockType() { - TransactionType transactionType = TransactionType.SECRET_LOCK; + EntityType transactionType = EntityType.SECRET_LOCK; assertEquals(0x4152, transactionType.getValue()); assertEquals(16722, transactionType.getValue()); - assertEquals(TransactionType.SECRET_LOCK, TransactionType.rawValueOf(16722)); + assertEquals(EntityType.SECRET_LOCK, EntityType.rawValueOf(16722)); } @Test void secretProofType() { - TransactionType transactionType = TransactionType.SECRET_PROOF; + EntityType transactionType = EntityType.SECRET_PROOF; assertEquals(0x4252, transactionType.getValue()); assertEquals(16978, transactionType.getValue()); - assertEquals(TransactionType.SECRET_PROOF, TransactionType.rawValueOf(16978)); + assertEquals(EntityType.SECRET_PROOF, EntityType.rawValueOf(16978)); } @Test void addressAliasType() { - TransactionType transactionType = TransactionType.ADDRESS_ALIAS; + EntityType transactionType = EntityType.ADDRESS_ALIAS; assertEquals(0x424E, transactionType.getValue()); assertEquals(16974, transactionType.getValue()); - assertEquals(TransactionType.ADDRESS_ALIAS, TransactionType.rawValueOf(16974)); + assertEquals(EntityType.ADDRESS_ALIAS, EntityType.rawValueOf(16974)); } @Test void mosaicAliasType() { - TransactionType transactionType = TransactionType.MOSAIC_ALIAS; + EntityType transactionType = EntityType.MOSAIC_ALIAS; assertEquals(0x434E, transactionType.getValue()); assertEquals(17230, transactionType.getValue()); - assertEquals(TransactionType.MOSAIC_ALIAS, TransactionType.rawValueOf(17230)); + assertEquals(EntityType.MOSAIC_ALIAS, EntityType.rawValueOf(17230)); } @Test void accountPropertiesAddressType() { - TransactionType transactionType = TransactionType.ACCOUNT_PROPERTIES_ADDRESS; + EntityType transactionType = EntityType.ACCOUNT_PROPERTIES_ADDRESS; assertEquals(0x4150, transactionType.getValue()); assertEquals(16720, transactionType.getValue()); - assertEquals(TransactionType.ACCOUNT_PROPERTIES_ADDRESS, TransactionType.rawValueOf(16720)); + assertEquals(EntityType.ACCOUNT_PROPERTIES_ADDRESS, EntityType.rawValueOf(16720)); } @Test void accountPropertiesMosaic() { - TransactionType transactionType = TransactionType.ACCOUNT_PROPERTIES_MOSAIC; + EntityType transactionType = EntityType.ACCOUNT_PROPERTIES_MOSAIC; assertEquals(0x4250, transactionType.getValue()); assertEquals(16976, transactionType.getValue()); - assertEquals(TransactionType.ACCOUNT_PROPERTIES_MOSAIC, TransactionType.rawValueOf(16976)); + assertEquals(EntityType.ACCOUNT_PROPERTIES_MOSAIC, EntityType.rawValueOf(16976)); } @Test void accountPropertiesEntityType() { - TransactionType transactionType = TransactionType.ACCOUNT_PROPERTIES_ENTITY_TYPE; + EntityType transactionType = EntityType.ACCOUNT_PROPERTIES_ENTITY_TYPE; assertEquals(0x4350, transactionType.getValue()); assertEquals(17232, transactionType.getValue()); - assertEquals(TransactionType.ACCOUNT_PROPERTIES_ENTITY_TYPE, TransactionType.rawValueOf(17232)); + assertEquals(EntityType.ACCOUNT_PROPERTIES_ENTITY_TYPE, EntityType.rawValueOf(17232)); } @Test void accountLinkType() { - TransactionType transactionType = TransactionType.ACCOUNT_LINK; + EntityType transactionType = EntityType.ACCOUNT_LINK; assertEquals(0x414C, transactionType.getValue()); assertEquals(16716, transactionType.getValue()); - assertEquals(TransactionType.ACCOUNT_LINK, TransactionType.rawValueOf(16716)); + assertEquals(EntityType.ACCOUNT_LINK, EntityType.rawValueOf(16716)); } } \ No newline at end of file diff --git a/src/test/java/io/proximax/sdk/model/transaction/builder/AggregateTransactionBuilderTest.java b/src/test/java/io/proximax/sdk/model/transaction/builder/AggregateTransactionBuilderTest.java index efede8a8..e890dc6b 100644 --- a/src/test/java/io/proximax/sdk/model/transaction/builder/AggregateTransactionBuilderTest.java +++ b/src/test/java/io/proximax/sdk/model/transaction/builder/AggregateTransactionBuilderTest.java @@ -24,8 +24,8 @@ import io.proximax.sdk.model.transaction.Deadline; import io.proximax.sdk.model.transaction.PlainMessage; import io.proximax.sdk.model.transaction.Recipient; -import io.proximax.sdk.model.transaction.TransactionType; -import io.proximax.sdk.model.transaction.TransactionVersion; +import io.proximax.sdk.model.transaction.EntityType; +import io.proximax.sdk.model.transaction.EntityVersion; import io.proximax.sdk.model.transaction.TransferTransaction; /** @@ -64,8 +64,8 @@ void testCompleteNoCosig() { assertEquals(1, agg.getInnerTransactions().size()); assertEquals(transferTx, agg.getInnerTransactions().get(0)); - assertEquals(TransactionType.AGGREGATE_COMPLETE, agg.getType()); - assertEquals(TransactionVersion.AGGREGATE_COMPLETE.getValue(), agg.getVersion()); + assertEquals(EntityType.AGGREGATE_COMPLETE, agg.getType()); + assertEquals(EntityVersion.AGGREGATE_COMPLETE.getValue(), agg.getVersion()); } @Test @@ -80,8 +80,8 @@ void testBondedNoCosig() { assertEquals(1, agg.getInnerTransactions().size()); assertEquals(transferTx, agg.getInnerTransactions().get(0)); - assertEquals(TransactionType.AGGREGATE_BONDED, agg.getType()); - assertEquals(TransactionVersion.AGGREGATE_BONDED.getValue(), agg.getVersion()); + assertEquals(EntityType.AGGREGATE_BONDED, agg.getType()); + assertEquals(EntityVersion.AGGREGATE_BONDED.getValue(), agg.getVersion()); } diff --git a/src/test/java/io/proximax/sdk/model/transaction/builder/LockFundsTransactionBuilderTest.java b/src/test/java/io/proximax/sdk/model/transaction/builder/LockFundsTransactionBuilderTest.java index 79c9cb14..edd8e43b 100644 --- a/src/test/java/io/proximax/sdk/model/transaction/builder/LockFundsTransactionBuilderTest.java +++ b/src/test/java/io/proximax/sdk/model/transaction/builder/LockFundsTransactionBuilderTest.java @@ -17,7 +17,7 @@ import io.proximax.sdk.model.mosaic.NetworkCurrencyMosaic; import io.proximax.sdk.model.transaction.LockFundsTransaction; import io.proximax.sdk.model.transaction.SignedTransaction; -import io.proximax.sdk.model.transaction.TransactionType; +import io.proximax.sdk.model.transaction.EntityType; /** * {@link LockFundsTransactionBuilder} tests @@ -38,7 +38,7 @@ void setUp() { @Test void test() { SignedTransaction signedTransaction = new SignedTransaction("payload", - "8498B38D89C1DC8A448EA5824938FF828926CD9F7747B1844B59B4B6807E878B", TransactionType.AGGREGATE_BONDED); + "8498B38D89C1DC8A448EA5824938FF828926CD9F7747B1844B59B4B6807E878B", EntityType.AGGREGATE_BONDED); LockFundsTransaction trans = builder.aggregate(BigInteger.ONE).signedTransaction(signedTransaction).build(); assertEquals(BigInteger.ONE, trans.getDuration()); diff --git a/src/test/java/io/proximax/sdk/model/transaction/builder/ModifyAccountPropertyEntityTransactionBuilderTest.java b/src/test/java/io/proximax/sdk/model/transaction/builder/ModifyAccountPropertyEntityTransactionBuilderTest.java index 45c0ca18..d4154049 100644 --- a/src/test/java/io/proximax/sdk/model/transaction/builder/ModifyAccountPropertyEntityTransactionBuilderTest.java +++ b/src/test/java/io/proximax/sdk/model/transaction/builder/ModifyAccountPropertyEntityTransactionBuilderTest.java @@ -18,7 +18,7 @@ import io.proximax.sdk.model.account.props.AccountPropertyType; import io.proximax.sdk.model.blockchain.NetworkType; import io.proximax.sdk.model.transaction.ModifyAccountPropertyTransaction; -import io.proximax.sdk.model.transaction.TransactionType; +import io.proximax.sdk.model.transaction.EntityType; /** * {@link ModifyAccountPropertyEntityTransactionBuilder} tests @@ -39,8 +39,8 @@ void setUp() { @Test void test() { - AccountPropertyModification mod = AccountPropertyModification.add(TransactionType.MODIFY_CONTRACT); - ModifyAccountPropertyTransaction trans = builder.propertyType(AccountPropertyType.ALLOW_TRANSACTION).modifications(Arrays.asList(mod)).build(); + AccountPropertyModification mod = AccountPropertyModification.add(EntityType.MODIFY_CONTRACT); + ModifyAccountPropertyTransaction trans = builder.propertyType(AccountPropertyType.ALLOW_TRANSACTION).modifications(Arrays.asList(mod)).build(); assertEquals(AccountPropertyType.ALLOW_TRANSACTION, trans.getPropertyType()); assertEquals(1, trans.getPropertyModifications().size()); diff --git a/src/test/java/io/proximax/sdk/model/transaction/builder/ModifyMetadataTransactionBuilderTest.java b/src/test/java/io/proximax/sdk/model/transaction/builder/ModifyMetadataTransactionBuilderTest.java index 4e885be9..c7e0c242 100644 --- a/src/test/java/io/proximax/sdk/model/transaction/builder/ModifyMetadataTransactionBuilderTest.java +++ b/src/test/java/io/proximax/sdk/model/transaction/builder/ModifyMetadataTransactionBuilderTest.java @@ -21,7 +21,7 @@ import io.proximax.sdk.model.mosaic.MosaicId; import io.proximax.sdk.model.namespace.NamespaceId; import io.proximax.sdk.model.transaction.ModifyMetadataTransaction; -import io.proximax.sdk.model.transaction.TransactionType; +import io.proximax.sdk.model.transaction.EntityType; /** * {@link ModifyMetadataTransactionBuilder} tests @@ -47,7 +47,7 @@ void testForAddress() { ModifyMetadataTransaction trans = builder.forAddress(addr).modifications(mod).build(); - assertEquals(TransactionType.MODIFY_ADDRESS_METADATA, trans.getType()); + assertEquals(EntityType.MODIFY_ADDRESS_METADATA, trans.getType()); assertEquals(Optional.of(addr), trans.getAddress()); assertEquals(1, trans.getModifications().size()); assertEquals(mod, trans.getModifications().get(0)); @@ -62,7 +62,7 @@ void testForMosaic() { ModifyMetadataTransaction trans = builder.forMosaic(mosid).modifications(mod).build(); - assertEquals(TransactionType.MODIFY_MOSAIC_METADATA, trans.getType()); + assertEquals(EntityType.MODIFY_MOSAIC_METADATA, trans.getType()); assertEquals(Optional.of(mosid), trans.getMetadataId()); assertEquals(1, trans.getModifications().size()); assertEquals(mod, trans.getModifications().get(0)); @@ -76,7 +76,7 @@ void testForNamespace() { ModifyMetadataTransaction trans = builder.forNamespace(nsid).modifications(mod).build(); - assertEquals(TransactionType.MODIFY_NAMESPACE_METADATA, trans.getType()); + assertEquals(EntityType.MODIFY_NAMESPACE_METADATA, trans.getType()); assertEquals(Optional.of(nsid), trans.getMetadataId()); assertEquals(1, trans.getModifications().size()); assertEquals(mod, trans.getModifications().get(0)); diff --git a/src/test/java/io/proximax/sdk/model/transaction/builder/TransactionBuilderTest.java b/src/test/java/io/proximax/sdk/model/transaction/builder/TransactionBuilderTest.java index 61fecaf7..55f06826 100644 --- a/src/test/java/io/proximax/sdk/model/transaction/builder/TransactionBuilderTest.java +++ b/src/test/java/io/proximax/sdk/model/transaction/builder/TransactionBuilderTest.java @@ -22,7 +22,7 @@ import io.proximax.sdk.model.transaction.DeadlineRaw; import io.proximax.sdk.model.transaction.Recipient; import io.proximax.sdk.model.transaction.TransactionInfo; -import io.proximax.sdk.model.transaction.TransactionType; +import io.proximax.sdk.model.transaction.EntityType; import io.proximax.sdk.model.transaction.TransferTransaction; /** @@ -50,7 +50,7 @@ void testEmptyTransferToRecipient() { // create transaction TransferTransaction trans = builder.to(recipient) .version(7) - .type(TransactionType.ACCOUNT_LINK) + .type(EntityType.ACCOUNT_LINK) .maxFee(BigInteger.TEN) .deadline(DeadlineRaw.startNow(BigInteger.valueOf(50000))) .signature("CAFE") @@ -60,8 +60,8 @@ void testEmptyTransferToRecipient() { // check transaction assertEquals(NetworkType.MIJIN_TEST, trans.getNetworkType()); // type of result will be different from the specified - assertEquals(TransactionType.TRANSFER, trans.getType()); - assertEquals(TransactionType.ACCOUNT_LINK, builder.getType()); + assertEquals(EntityType.TRANSFER, trans.getType()); + assertEquals(EntityType.ACCOUNT_LINK, builder.getType()); assertEquals(7, trans.getVersion()); assertEquals(BigInteger.TEN, trans.getMaxFee()); assertEquals(Optional.of(FeeCalculationStrategy.MEDIUM), builder.getFeeCalculationStrategy()); From 17e978a4245f2215e698bdeb61dd05d066c3f148 Mon Sep 17 00:00:00 2001 From: Anton Wiedermann Date: Tue, 3 Sep 2019 23:17:42 +0200 Subject: [PATCH 2/7] issue #118 - uppercase constants + minor code improvements --- .../sdk/infrastructure/AccountHttp.java | 4 ++-- .../sdk/infrastructure/ContractHttp.java | 4 ++-- .../sdk/infrastructure/MosaicHttp.java | 1 - .../infrastructure/TransactionMapping.java | 6 +++--- .../listener/TransactionChannelMessage.java | 5 +++-- .../sdk/model/account/PublicAccount.java | 15 ------------- .../sdk/model/blockchain/BlockInfo.java | 2 +- .../model/mosaic/NetworkHarvestMosaic.java | 6 +----- .../sdk/model/namespace/NamespaceInfo.java | 4 ++-- .../sdk/model/namespace/NamespaceType.java | 21 +++++++++++++------ .../sdk/model/transaction/MessageFactory.java | 6 +++--- .../sdk/model/transaction/PlainMessage.java | 4 +--- .../RegisterNamespaceTransaction.java | 10 ++++++--- .../model/transaction/ScalarAttribute.java | 2 +- .../model/transaction/SchemaAttribute.java | 8 +------ .../RegisterNamespaceTransactionBuilder.java | 4 ++-- .../builder/TransferTransactionBuilder.java | 2 +- .../TransactionMappingTest.java | 2 +- .../model/namespace/NamespaceInfoTest.java | 8 +++---- .../model/namespace/NamespaceTypeTest.java | 2 +- .../transaction/AggregateTransactionTest.java | 4 ++-- .../model/transaction/MessageFactoryTest.java | 2 +- .../RegisterNamespaceTransactionTest.java | 8 +++---- .../transaction/TransferTransactionTest.java | 8 +++---- .../AggregateTransactionBuilderTest.java | 6 +++--- ...gisterNamespaceTransactionBuilderTest.java | 4 ++-- .../TransferTransactionBuilderTest.java | 6 +++--- 27 files changed, 70 insertions(+), 84 deletions(-) diff --git a/src/main/java/io/proximax/sdk/infrastructure/AccountHttp.java b/src/main/java/io/proximax/sdk/infrastructure/AccountHttp.java index 9daa558a..ea0ded36 100644 --- a/src/main/java/io/proximax/sdk/infrastructure/AccountHttp.java +++ b/src/main/java/io/proximax/sdk/infrastructure/AccountHttp.java @@ -85,7 +85,7 @@ private List toAccountProperties(String json) { public Observable> getAccountsInfo(List
addresses) { // prepare JSON array with addresses JsonArray arr = new JsonArray(addresses.size()); - addresses.stream().map(Address::plain).forEachOrdered(addr -> arr.add(addr)); + addresses.stream().map(Address::plain).forEachOrdered(arr::add); JsonObject requestBody = new JsonObject(); requestBody.add("addresses", arr); @@ -123,7 +123,7 @@ public Observable getAccountProperties(Address address) { public Observable> getAccountProperties(List
addresses) { // prepare JSON array with addresses JsonArray arr = new JsonArray(addresses.size()); - addresses.stream().map(Address::plain).forEachOrdered(addr -> arr.add(addr)); + addresses.stream().map(Address::plain).forEachOrdered(arr::add); JsonObject requestBody = new JsonObject(); requestBody.add("addresses", arr); diff --git a/src/main/java/io/proximax/sdk/infrastructure/ContractHttp.java b/src/main/java/io/proximax/sdk/infrastructure/ContractHttp.java index 4ac99a8c..384c109b 100644 --- a/src/main/java/io/proximax/sdk/infrastructure/ContractHttp.java +++ b/src/main/java/io/proximax/sdk/infrastructure/ContractHttp.java @@ -49,7 +49,7 @@ public Observable getContract(Address address) { public Observable> getContracts(Address... addresses) { // prepare JSON array with addresses JsonArray arr = new JsonArray(addresses.length); - Arrays.stream(addresses).map(Address::plain).forEachOrdered(addr -> arr.add(addr)); + Arrays.stream(addresses).map(Address::plain).forEachOrdered(arr::add); JsonObject requestBody = new JsonObject(); requestBody.add("addresses", arr); @@ -76,7 +76,7 @@ public Observable getContract(PublicKey publicKey) { public Observable> getContracts(PublicKey... publicKeys) { // prepare JSON array with public keys JsonArray arr = new JsonArray(publicKeys.length); - Arrays.stream(publicKeys).map(PublicKey::getHexString).forEachOrdered(pubKey -> arr.add(pubKey)); + Arrays.stream(publicKeys).map(PublicKey::getHexString).forEachOrdered(arr::add); JsonObject requestBody = new JsonObject(); requestBody.add("publicKeys", arr); diff --git a/src/main/java/io/proximax/sdk/infrastructure/MosaicHttp.java b/src/main/java/io/proximax/sdk/infrastructure/MosaicHttp.java index 85b8b44a..41cf8eb2 100644 --- a/src/main/java/io/proximax/sdk/infrastructure/MosaicHttp.java +++ b/src/main/java/io/proximax/sdk/infrastructure/MosaicHttp.java @@ -89,7 +89,6 @@ private List toMosaicInfoList(String json) { } private List toMosaicNamesList(String json) { - System.out.println(json); return gson.fromJson(json, MOSAIC_NAMES_LIST_TYPE); } } \ No newline at end of file diff --git a/src/main/java/io/proximax/sdk/infrastructure/TransactionMapping.java b/src/main/java/io/proximax/sdk/infrastructure/TransactionMapping.java index a880f450..c403c835 100644 --- a/src/main/java/io/proximax/sdk/infrastructure/TransactionMapping.java +++ b/src/main/java/io/proximax/sdk/infrastructure/TransactionMapping.java @@ -180,7 +180,7 @@ public TransferTransaction apply(JsonObject input) { String messagePayload = messageObj.get("payload").getAsString(); message = MessageFactory.createMessage(messageType, Hex.decode(messagePayload)); } else { - message = PlainMessage.Empty; + message = PlainMessage.EMPTY; } // version @@ -385,10 +385,10 @@ public RegisterNamespaceTransaction apply(JsonObject input) { DeadlineBP deadline = new DeadlineBP(GsonUtils.getBigInteger(transaction.getAsJsonArray("deadline"))); NamespaceType namespaceType = NamespaceType.rawValueOf(transaction.get("namespaceType").getAsInt()); NamespaceId namespaceId = new NamespaceId(GsonUtils.getBigInteger(transaction.getAsJsonArray("namespaceId"))); - Optional namespaceDuration = namespaceType == NamespaceType.RootNamespace + Optional namespaceDuration = namespaceType == NamespaceType.ROOT_NAMESPACE ? Optional.of(GsonUtils.getBigInteger(transaction.getAsJsonArray("duration"))) : Optional.empty(); - Optional namespaceParentId = namespaceType == NamespaceType.SubNamespace + Optional namespaceParentId = namespaceType == NamespaceType.SUB_NAMESPACE ? Optional.of(new NamespaceId(GsonUtils.getBigInteger(transaction.getAsJsonArray("parentId")))) : Optional.empty(); JsonElement version = transaction.get("version"); diff --git a/src/main/java/io/proximax/sdk/infrastructure/listener/TransactionChannelMessage.java b/src/main/java/io/proximax/sdk/infrastructure/listener/TransactionChannelMessage.java index a4d9d105..1be376ec 100644 --- a/src/main/java/io/proximax/sdk/infrastructure/listener/TransactionChannelMessage.java +++ b/src/main/java/io/proximax/sdk/infrastructure/listener/TransactionChannelMessage.java @@ -15,6 +15,7 @@ import io.proximax.sdk.model.account.Address; import io.proximax.sdk.model.account.PublicAccount; import io.proximax.sdk.model.transaction.AggregateTransaction; +import io.proximax.sdk.model.transaction.Recipient; import io.proximax.sdk.model.transaction.Transaction; import io.proximax.sdk.model.transaction.TransferTransaction; import io.reactivex.Observable; @@ -72,7 +73,7 @@ private static boolean transactionFromAddress(final Transaction transaction, fin // if not signer or recipient and this is aggregate transaction then run some extra checks if (!result.get() && transaction instanceof AggregateTransaction) { final AggregateTransaction aggregateTransaction = (AggregateTransaction) transaction; - // check whether ddress is cosignatory + // check whether address is cosignatory aggregateTransaction.getCosignatures().forEach(cosignature -> { if (cosignature.getSigner().getAddress().equals(address)) { result.set(true); @@ -106,7 +107,7 @@ private static boolean addressIsInvolved(final Transaction transaction, final Ad } // address was not signer so check whether it is recipient if (transaction instanceof TransferTransaction) { - boolean isRecipient = ((TransferTransaction) transaction).getRecipient().equals(address); + boolean isRecipient = ((TransferTransaction) transaction).getRecipient().equals(Recipient.from(address)); if (isRecipient) { return true; } diff --git a/src/main/java/io/proximax/sdk/model/account/PublicAccount.java b/src/main/java/io/proximax/sdk/model/account/PublicAccount.java index c9d80e85..a26cb078 100644 --- a/src/main/java/io/proximax/sdk/model/account/PublicAccount.java +++ b/src/main/java/io/proximax/sdk/model/account/PublicAccount.java @@ -44,21 +44,6 @@ public PublicAccount(String publicKey, NetworkType networkType) { public static PublicAccount createFromPublicKey(String publicKey, NetworkType networkType) { return new PublicAccount(publicKey, networkType); } -// -// /** -// * Compares public accounts for equality. -// * -// * @param o PublicAccount -// * @return boolean -// */ -// @Override -// public boolean equals(Object o) { -// if (this == o) return true; -// if (!(o instanceof PublicAccount)) return false; -// PublicAccount that = (PublicAccount) o; -// return Objects.equals(address, that.address) && -// Objects.equals(publicKey, that.publicKey); -// } /** * Returns account address. diff --git a/src/main/java/io/proximax/sdk/model/blockchain/BlockInfo.java b/src/main/java/io/proximax/sdk/model/blockchain/BlockInfo.java index 28ed20c3..ac2c0248 100644 --- a/src/main/java/io/proximax/sdk/model/blockchain/BlockInfo.java +++ b/src/main/java/io/proximax/sdk/model/blockchain/BlockInfo.java @@ -213,7 +213,7 @@ public static BlockInfo fromDto(BlockInfoDTO dto, NetworkType networkType) { return new BlockInfo(dto.getMeta().getHash(), dto.getMeta().getGenerationHash(), Optional.of(toBigInt(dto.getMeta().getTotalFee())), - Optional.of(dto.getMeta().getNumTransactions().intValue()), + Optional.of(dto.getMeta().getNumTransactions()), dto.getBlock().getSignature(), new PublicAccount(dto.getBlock().getSigner(), networkType), networkType, diff --git a/src/main/java/io/proximax/sdk/model/mosaic/NetworkHarvestMosaic.java b/src/main/java/io/proximax/sdk/model/mosaic/NetworkHarvestMosaic.java index bd75c527..47049a94 100644 --- a/src/main/java/io/proximax/sdk/model/mosaic/NetworkHarvestMosaic.java +++ b/src/main/java/io/proximax/sdk/model/mosaic/NetworkHarvestMosaic.java @@ -49,10 +49,6 @@ public class NetworkHarvestMosaic extends Mosaic { * Is supply mutable */ public static final boolean SUPPLYMUTABLE = true; - /** - * Is levy mutable - */ - public static final boolean LEVYMUTABLE = false; /** * create new instance of network harvest mosaic of specified amount @@ -72,7 +68,7 @@ public NetworkHarvestMosaic(BigInteger amount) { */ public static NetworkHarvestMosaic createRelative(BigInteger amount) { - BigInteger relativeAmount = new BigDecimal(Math.pow(10, NetworkHarvestMosaic.DIVISIBILITY)).toBigInteger() + BigInteger relativeAmount = BigDecimal.valueOf(Math.pow(10, NetworkHarvestMosaic.DIVISIBILITY)).toBigInteger() .multiply(amount); return new NetworkHarvestMosaic(relativeAmount); } diff --git a/src/main/java/io/proximax/sdk/model/namespace/NamespaceInfo.java b/src/main/java/io/proximax/sdk/model/namespace/NamespaceInfo.java index 0c960196..44b178f5 100644 --- a/src/main/java/io/proximax/sdk/model/namespace/NamespaceInfo.java +++ b/src/main/java/io/proximax/sdk/model/namespace/NamespaceInfo.java @@ -176,7 +176,7 @@ public NamespaceId getId() { * @return true if namespace is Root */ public boolean isRoot() { - return this.type == NamespaceType.RootNamespace; + return this.type == NamespaceType.ROOT_NAMESPACE; } /** @@ -185,7 +185,7 @@ public boolean isRoot() { * @return true if namespace is Subnamespace */ public boolean isSubnamespace() { - return this.type == NamespaceType.SubNamespace; + return this.type == NamespaceType.SUB_NAMESPACE; } /** diff --git a/src/main/java/io/proximax/sdk/model/namespace/NamespaceType.java b/src/main/java/io/proximax/sdk/model/namespace/NamespaceType.java index 979c16b2..d1a00795 100644 --- a/src/main/java/io/proximax/sdk/model/namespace/NamespaceType.java +++ b/src/main/java/io/proximax/sdk/model/namespace/NamespaceType.java @@ -18,18 +18,16 @@ /** * Enum containing namespace supply type. - * - * @since 1.0 */ public enum NamespaceType { /** * Root namespace */ - RootNamespace(0), + ROOT_NAMESPACE(0), /** * Sub namespace */ - SubNamespace(1); + SUB_NAMESPACE(1); private int value; @@ -37,17 +35,28 @@ public enum NamespaceType { this.value = value; } + /** + * retrieve namespace type based on the code + * + * @param value the value representing the namespace type + * @return the enum element + */ public static NamespaceType rawValueOf(int value) { switch (value) { case 0: - return NamespaceType.RootNamespace; + return NamespaceType.ROOT_NAMESPACE; case 1: - return NamespaceType.SubNamespace; + return NamespaceType.SUB_NAMESPACE; default: throw new IllegalArgumentException(value + " is not a valid value"); } } + /** + * get the numeric representation of the namespace type + * + * @return the numeric representation + */ public int getValue() { return value; } diff --git a/src/main/java/io/proximax/sdk/model/transaction/MessageFactory.java b/src/main/java/io/proximax/sdk/model/transaction/MessageFactory.java index 9604e6ae..7cb9681d 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/MessageFactory.java +++ b/src/main/java/io/proximax/sdk/model/transaction/MessageFactory.java @@ -4,11 +4,11 @@ /** * The factory to create Message instance. - * - * @since 1.0 */ public class MessageFactory { + /* hiding constructor for utility class */ + private MessageFactory() { /* nothing o do here */ } /** * Create Message instance based on type and encodedPayload * @param type the message type @@ -21,6 +21,6 @@ public static Message createMessage(int type, byte[] encodedPayload) { } else if (type == MessageType.SECURE.getCode()){ return SecureMessage.createFromEncodedPayload(encodedPayload); } - return PlainMessage.Empty; + return PlainMessage.EMPTY; } } diff --git a/src/main/java/io/proximax/sdk/model/transaction/PlainMessage.java b/src/main/java/io/proximax/sdk/model/transaction/PlainMessage.java index 546f5426..29461732 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/PlainMessage.java +++ b/src/main/java/io/proximax/sdk/model/transaction/PlainMessage.java @@ -20,15 +20,13 @@ /** * The plain message model defines a plain string. When sending it to the network we transform the payload to hex-string. - * - * @since 1.0 */ public class PlainMessage extends Message { /** * Plain message containing an empty string. */ - public static PlainMessage Empty = new PlainMessage(""); + public static final PlainMessage EMPTY = new PlainMessage(""); /** * Constructor diff --git a/src/main/java/io/proximax/sdk/model/transaction/RegisterNamespaceTransaction.java b/src/main/java/io/proximax/sdk/model/transaction/RegisterNamespaceTransaction.java index 53da498a..058b8c1c 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/RegisterNamespaceTransaction.java +++ b/src/main/java/io/proximax/sdk/model/transaction/RegisterNamespaceTransaction.java @@ -67,7 +67,7 @@ public RegisterNamespaceTransaction(NetworkType networkType, Integer version, Validate.notNull(namespaceName, "NamespaceName must not be null"); Validate.notNull(namespaceType, "NamespaceType must not be null"); Validate.notNull(namespaceId, "NamespaceId must not be null"); - if (namespaceType == NamespaceType.RootNamespace) { + if (namespaceType == NamespaceType.ROOT_NAMESPACE) { Validate.notNull(duration, "Duration must not be null"); } else { Validate.notNull(parentId, "ParentId must not be null"); @@ -129,6 +129,11 @@ public NamespaceType getNamespaceType() { protected byte[] generateBytes() { FlatBufferBuilder builder = new FlatBufferBuilder(); BigInteger deadlineBigInt = BigInteger.valueOf(getDeadline().getInstant()); + // duration and parent ID are sent in shared field based on Root/Sub namespace status + BigInteger durationParentId = getNamespaceType() == NamespaceType.ROOT_NAMESPACE + ? duration.orElseThrow(() -> new IllegalStateException("Root namespace has to have duration specified")) + : parentId.orElseThrow(() -> new IllegalStateException("Sub namespace has to have parentId specified")) + .getId(); // Create Vectors int signatureVector = RegisterNamespaceTransactionBuffer.createSignatureVector(builder, new byte[64]); @@ -140,8 +145,7 @@ protected byte[] generateBytes() { int namespaceIdVector = RegisterNamespaceTransactionBuffer.createNamespaceIdVector(builder, UInt64Utils.fromBigInteger(namespaceId.getId())); int durationParentIdVector = RegisterNamespaceTransactionBuffer.createDurationParentIdVector(builder, - getNamespaceType() == NamespaceType.RootNamespace ? UInt64Utils.fromBigInteger(duration.get()) - : UInt64Utils.fromBigInteger(parentId.get().getId())); + UInt64Utils.fromBigInteger(durationParentId)); int name = builder.createString(namespaceName); int size = getSerializedSize(); diff --git a/src/main/java/io/proximax/sdk/model/transaction/ScalarAttribute.java b/src/main/java/io/proximax/sdk/model/transaction/ScalarAttribute.java index c3309bbe..0d985111 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/ScalarAttribute.java +++ b/src/main/java/io/proximax/sdk/model/transaction/ScalarAttribute.java @@ -17,7 +17,7 @@ package io.proximax.sdk.model.transaction; class ScalarAttribute extends SchemaAttribute { - final private Constants size; + private final Constants size; ScalarAttribute(String name, Constants typeSize) { super(name); diff --git a/src/main/java/io/proximax/sdk/model/transaction/SchemaAttribute.java b/src/main/java/io/proximax/sdk/model/transaction/SchemaAttribute.java index 156925c8..684665ed 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/SchemaAttribute.java +++ b/src/main/java/io/proximax/sdk/model/transaction/SchemaAttribute.java @@ -20,7 +20,7 @@ import java.util.Arrays; abstract class SchemaAttribute { - final private String name; + private final String name; SchemaAttribute(String name) { this.name = name; @@ -66,9 +66,6 @@ protected int findObjectArrayElementStartPosition(int innerObjectPosition, int p } protected int readInt32(int offset, byte[] buffer) { - /*final ByteBuffer bb = ByteBuffer.wrap(new byte[]{buffer[offset], buffer[offset + 1], buffer[offset + 2], buffer[offset + 3]}); - bb.order(ByteOrder.LITTLE_ENDIAN); - return bb.getInt();*/ int value = (buffer[offset + 3] << (Byte.SIZE * 3)); value |= (buffer[offset + 2] & 0xFF) << (Byte.SIZE * 2); value |= (buffer[offset + 1] & 0xFF) << (Byte.SIZE); @@ -77,9 +74,6 @@ protected int readInt32(int offset, byte[] buffer) { } protected int readInt16(int offset, byte[] buffer) { - /*final ByteBuffer bb = ByteBuffer.wrap(new byte[]{buffer[offset], buffer[offset + 1]}); - bb.order(ByteOrder.LITTLE_ENDIAN); - return bb.getShort();*/ int value = (buffer[offset + 1] & 0xFF) << (Byte.SIZE); value |= (buffer[offset] & 0xFF); return value; diff --git a/src/main/java/io/proximax/sdk/model/transaction/builder/RegisterNamespaceTransactionBuilder.java b/src/main/java/io/proximax/sdk/model/transaction/builder/RegisterNamespaceTransactionBuilder.java index fae941b4..76e0fb55 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/builder/RegisterNamespaceTransactionBuilder.java +++ b/src/main/java/io/proximax/sdk/model/transaction/builder/RegisterNamespaceTransactionBuilder.java @@ -153,7 +153,7 @@ public NamespaceType getNamespaceType() { * @return self */ public RegisterNamespaceTransactionBuilder rootNamespace(String name) { - namespaceType(NamespaceType.RootNamespace); + namespaceType(NamespaceType.ROOT_NAMESPACE); namespaceName(name); namespaceId(new NamespaceId(name)); return self(); @@ -167,7 +167,7 @@ public RegisterNamespaceTransactionBuilder rootNamespace(String name) { * @return self */ public RegisterNamespaceTransactionBuilder subNamespace(NamespaceId parentId, String name) { - namespaceType(NamespaceType.SubNamespace); + namespaceType(NamespaceType.SUB_NAMESPACE); parentId(parentId); namespaceName(name); namespaceId(new NamespaceId(IdGenerator.generateSubNamespaceIdFromParentId(parentId.getId(), name))); diff --git a/src/main/java/io/proximax/sdk/model/transaction/builder/TransferTransactionBuilder.java b/src/main/java/io/proximax/sdk/model/transaction/builder/TransferTransactionBuilder.java index dd312b07..e52e9ce6 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/builder/TransferTransactionBuilder.java +++ b/src/main/java/io/proximax/sdk/model/transaction/builder/TransferTransactionBuilder.java @@ -31,7 +31,7 @@ public class TransferTransactionBuilder extends TransactionBuilder(); } diff --git a/src/test/java/io/proximax/sdk/infrastructure/TransactionMappingTest.java b/src/test/java/io/proximax/sdk/infrastructure/TransactionMappingTest.java index e0c0d11e..80275035 100644 --- a/src/test/java/io/proximax/sdk/infrastructure/TransactionMappingTest.java +++ b/src/test/java/io/proximax/sdk/infrastructure/TransactionMappingTest.java @@ -233,7 +233,7 @@ private void validateNamespaceCreationTx(RegisterNamespaceTransaction transactio assertEquals(extractBigInteger(getFieldOfObject(transactionDTO, "transaction", "namespaceId").getAsJsonArray()), transaction.getNamespaceId().getId()); - if (transaction.getNamespaceType() == NamespaceType.RootNamespace) { + if (transaction.getNamespaceType() == NamespaceType.ROOT_NAMESPACE) { assertEquals(extractBigInteger(getFieldOfObject(transactionDTO, "transaction", "duration").getAsJsonArray()), transaction.getDuration().get()); } else { diff --git a/src/test/java/io/proximax/sdk/model/namespace/NamespaceInfoTest.java b/src/test/java/io/proximax/sdk/model/namespace/NamespaceInfoTest.java index ba149753..cba6a112 100644 --- a/src/test/java/io/proximax/sdk/model/namespace/NamespaceInfoTest.java +++ b/src/test/java/io/proximax/sdk/model/namespace/NamespaceInfoTest.java @@ -39,7 +39,7 @@ void createANamespaceInfoViaConstructor() { NamespaceInfo namespaceInfo = new NamespaceInfo(true, 0, "5A3CD9B09CD1E8000159249B", - NamespaceType.RootNamespace, + NamespaceType.ROOT_NAMESPACE, 1, Arrays.asList(namespaceId), new NamespaceId(new BigInteger("0")), @@ -52,7 +52,7 @@ void createANamespaceInfoViaConstructor() { assertEquals(true, namespaceInfo.isActive()); assertTrue(namespaceInfo.getIndex() == 0); assertEquals("5A3CD9B09CD1E8000159249B", namespaceInfo.getMetaId()); - assertTrue(namespaceInfo.getType() == NamespaceType.RootNamespace); + assertTrue(namespaceInfo.getType() == NamespaceType.ROOT_NAMESPACE); assertTrue(namespaceInfo.getDepth() == 1); assertEquals(namespaceId, namespaceInfo.getLevels().get(0)); Assertions.assertEquals(new PublicAccount("B4F12E7C9F6946091E2CB8B6D3A12B50D17CCBBF646386EA27CE2946A7423DCF", NetworkType.MIJIN_TEST), namespaceInfo.getOwner()); @@ -113,7 +113,7 @@ NamespaceInfo createRootNamespaceInfo() { return new NamespaceInfo(true, 0, "5A3CD9B09CD1E8000159249B", - NamespaceType.RootNamespace, + NamespaceType.ROOT_NAMESPACE, 1, Arrays.asList(new NamespaceId(new BigInteger("-8884663987180930485"))), new NamespaceId(new BigInteger("0")), @@ -128,7 +128,7 @@ NamespaceInfo createSubNamespaceInfo() { return new NamespaceInfo(true, 0, "5A3CD9B09CD1E8000159249B", - NamespaceType.SubNamespace, + NamespaceType.SUB_NAMESPACE, 1, Arrays.asList(new NamespaceId(new BigInteger("-3087871471161192663")), new NamespaceId(new BigInteger("-1087871471161192663"))), new NamespaceId(new BigInteger("-3087871471161192663")), diff --git a/src/test/java/io/proximax/sdk/model/namespace/NamespaceTypeTest.java b/src/test/java/io/proximax/sdk/model/namespace/NamespaceTypeTest.java index 03fcac27..bbd708cd 100644 --- a/src/test/java/io/proximax/sdk/model/namespace/NamespaceTypeTest.java +++ b/src/test/java/io/proximax/sdk/model/namespace/NamespaceTypeTest.java @@ -18,7 +18,7 @@ class NamespaceTypeTest { @Test void checkCode() { // check some random item - assertEquals(0, NamespaceType.RootNamespace.getValue()); + assertEquals(0, NamespaceType.ROOT_NAMESPACE.getValue()); } @Test diff --git a/src/test/java/io/proximax/sdk/model/transaction/AggregateTransactionTest.java b/src/test/java/io/proximax/sdk/model/transaction/AggregateTransactionTest.java index fc26691c..23a0e9cd 100644 --- a/src/test/java/io/proximax/sdk/model/transaction/AggregateTransactionTest.java +++ b/src/test/java/io/proximax/sdk/model/transaction/AggregateTransactionTest.java @@ -53,7 +53,7 @@ void createAAggregateTransactionViaStaticConstructor() { TransferTransaction transferTx = new TransferTransaction(NetworkType.MIJIN_TEST, 3, new Deadline(2, ChronoUnit.HOURS), BigInteger.ZERO, Optional.empty(), Optional.empty(), Optional.empty(), Recipient.from(new Address("SDGLFW-DSHILT-IUHGIB-H5UGX2-VYF5VN-JEKCCD-BR26", NetworkType.MIJIN_TEST)), - Collections.emptyList(), PlainMessage.Empty); + Collections.emptyList(), PlainMessage.EMPTY); PublicAccount innerSigner = new PublicAccount("9A49366406ACA952B88BADF5F1E9BE6CE4968141035A60BE503273EA65456B24", NetworkType.MIJIN_TEST); @@ -75,7 +75,7 @@ void serialization() throws IOException { TransferTransaction transferTx = new TransferTransaction(NetworkType.MIJIN_TEST, 3, new FakeDeadline(), BigInteger.ZERO, Optional.empty(), Optional.empty(), Optional.empty(), Recipient.from(new Address("SBILTA367K2LX2FEXG5TFWAS7GEFYAGY7QLFBYKC", NetworkType.MIJIN_TEST)), - Collections.singletonList(new Mosaic(NetworkCurrencyMosaic.ID, BigInteger.valueOf(10000000))), PlainMessage.Empty); + Collections.singletonList(new Mosaic(NetworkCurrencyMosaic.ID, BigInteger.valueOf(10000000))), PlainMessage.EMPTY); PublicAccount innerSigner = new PublicAccount("846B4439154579A5903B1459C9CF69CB8153F6D0110A7A0ED61DE29AE4810BF2", NetworkType.MIJIN_TEST); diff --git a/src/test/java/io/proximax/sdk/model/transaction/MessageFactoryTest.java b/src/test/java/io/proximax/sdk/model/transaction/MessageFactoryTest.java index 3f055eba..54540387 100644 --- a/src/test/java/io/proximax/sdk/model/transaction/MessageFactoryTest.java +++ b/src/test/java/io/proximax/sdk/model/transaction/MessageFactoryTest.java @@ -49,7 +49,7 @@ public void shouldCreateEmptyPlainMessageForUnknownType() { final byte[] encodedPayload = sampleEncodedPayload(); final Message message = MessageFactory.createMessage(999, encodedPayload); - assertThat(message, is(PlainMessage.Empty)); + assertThat(message, is(PlainMessage.EMPTY)); } private byte[] sampleEncodedPayload() { diff --git a/src/test/java/io/proximax/sdk/model/transaction/RegisterNamespaceTransactionTest.java b/src/test/java/io/proximax/sdk/model/transaction/RegisterNamespaceTransactionTest.java index 9d98e543..08db3cbe 100644 --- a/src/test/java/io/proximax/sdk/model/transaction/RegisterNamespaceTransactionTest.java +++ b/src/test/java/io/proximax/sdk/model/transaction/RegisterNamespaceTransactionTest.java @@ -37,11 +37,11 @@ void constructor() { RegisterNamespaceTransaction tx = new RegisterNamespaceTransaction(NetworkType.MIJIN, 23, new FakeDeadline(), BigInteger.ONE, Optional.empty(), Optional.empty(), Optional.empty(), "prx", new NamespaceId(new BigInteger("4635294387305441662")), Optional.of(BigInteger.ONE), - Optional.of(new NamespaceId(BigInteger.TEN)), NamespaceType.SubNamespace); + Optional.of(new NamespaceId(BigInteger.TEN)), NamespaceType.SUB_NAMESPACE); assertEquals("prx", tx.getNamespaceName()); assertEquals(new NamespaceId(new BigInteger("4635294387305441662")), tx.getNamespaceId()); - assertEquals(NamespaceType.SubNamespace, tx.getNamespaceType()); + assertEquals(NamespaceType.SUB_NAMESPACE, tx.getNamespaceType()); assertEquals(Optional.of(BigInteger.ONE), tx.getDuration()); assertEquals(Optional.of(new NamespaceId(BigInteger.TEN)), tx.getParentId()); } @@ -51,7 +51,7 @@ void serializationRootNamespace() throws IOException { RegisterNamespaceTransaction registerNamespaceTransaction = new RegisterNamespaceTransaction( NetworkType.MIJIN_TEST, 2, new FakeDeadline(), BigInteger.ZERO, Optional.empty(), Optional.empty(), Optional.empty(), "newnamespace", new NamespaceId(IdGenerator.generateNamespaceId("newnamespace")), - Optional.of(BigInteger.valueOf(10000)), Optional.empty(), NamespaceType.RootNamespace); + Optional.of(BigInteger.valueOf(10000)), Optional.empty(), NamespaceType.ROOT_NAMESPACE); byte[] actual = registerNamespaceTransaction.generateBytes(); // saveBytes("register_namespace_root", actual); @@ -66,7 +66,7 @@ void serializationSubNamespace() throws IOException { new NamespaceId(IdGenerator.generateSubNamespaceIdFromParentId(new BigInteger("4635294387305441662"), "subnamespace")), Optional.empty(), Optional.of(new NamespaceId(new BigInteger("4635294387305441662"))), - NamespaceType.SubNamespace); + NamespaceType.SUB_NAMESPACE); byte[] actual = registerNamespaceTransaction.generateBytes(); // saveBytes("register_namespace_child", actual); diff --git a/src/test/java/io/proximax/sdk/model/transaction/TransferTransactionTest.java b/src/test/java/io/proximax/sdk/model/transaction/TransferTransactionTest.java index 0c05e17a..3ff55616 100644 --- a/src/test/java/io/proximax/sdk/model/transaction/TransferTransactionTest.java +++ b/src/test/java/io/proximax/sdk/model/transaction/TransferTransactionTest.java @@ -54,7 +54,7 @@ void createATransferTransaction() { new Deadline(2, ChronoUnit.HOURS), BigInteger.valueOf(37750), Optional.empty(), Optional.empty(), Optional.empty(), Recipient.from(new Address("SDGLFW-DSHILT-IUHGIB-H5UGX2-VYF5VN-JEKCCD-BR26", NetworkType.MIJIN_TEST)), - Arrays.asList(), PlainMessage.Empty); + Arrays.asList(), PlainMessage.EMPTY); assertEquals(NetworkType.MIJIN_TEST, transferTx.getNetworkType()); assertEquals(3, transferTx.getVersion()); @@ -74,7 +74,7 @@ void serialization() throws IOException { BigInteger.ZERO, Optional.empty(), Optional.empty(), Optional.empty(), Recipient.from(new Address("SDUP5PLHDXKBX3UU5Q52LAY4WYEKGEWC6IB3VBFM", NetworkType.MIJIN_TEST)), Arrays.asList(new Mosaic(new MosaicId(new BigInteger("95442763262823")), BigInteger.valueOf(100))), - PlainMessage.Empty); + PlainMessage.EMPTY); byte[] actual = transferTransaction.generateBytes(); // saveBytes("transfer_trans", actual); @@ -88,7 +88,7 @@ void toAggregate() throws IOException { BigInteger.ZERO, Optional.empty(), Optional.empty(), Optional.empty(), Recipient.from(new Address("SDUP5PLHDXKBX3UU5Q52LAY4WYEKGEWC6IB3VBFM", NetworkType.MIJIN_TEST)), Arrays.asList(new Mosaic(new MosaicId(new BigInteger("95442763262823")), BigInteger.valueOf(100))), - PlainMessage.Empty); + PlainMessage.EMPTY); byte[] actual = transferTransaction .toAggregate(new PublicAccount("9A49366406ACA952B88BADF5F1E9BE6CE4968141035A60BE503273EA65456B24", @@ -104,7 +104,7 @@ void serializeAndSignTransaction() { BigInteger.ZERO, Optional.empty(), Optional.empty(), Optional.empty(), Recipient.from(new Address("SDUP5PLHDXKBX3UU5Q52LAY4WYEKGEWC6IB3VBFM", NetworkType.MIJIN_TEST)), Arrays.asList(new Mosaic(new MosaicId(new BigInteger("95442763262823")), BigInteger.valueOf(100))), - PlainMessage.Empty); + PlainMessage.EMPTY); SignedTransaction signedTransaction = transferTransaction.signWith(account, "7B631D803F912B00DC0CBED3014BBD17A302BA50B99D233B9C2D9533B842ABDF"); diff --git a/src/test/java/io/proximax/sdk/model/transaction/builder/AggregateTransactionBuilderTest.java b/src/test/java/io/proximax/sdk/model/transaction/builder/AggregateTransactionBuilderTest.java index e890dc6b..6b5c6a6b 100644 --- a/src/test/java/io/proximax/sdk/model/transaction/builder/AggregateTransactionBuilderTest.java +++ b/src/test/java/io/proximax/sdk/model/transaction/builder/AggregateTransactionBuilderTest.java @@ -58,7 +58,7 @@ void testCompleteNoCosig() { new Deadline(2, ChronoUnit.HOURS), BigInteger.valueOf(37750), Optional.empty(), Optional.empty(), Optional.empty(), Recipient.from(new Address("SDGLFW-DSHILT-IUHGIB-H5UGX2-VYF5VN-JEKCCD-BR26", NetworkType.MIJIN_TEST)), - Arrays.asList(), PlainMessage.Empty); + Arrays.asList(), PlainMessage.EMPTY); AggregateTransaction agg = completeBuilder.innerTransactions(transferTx).build(); @@ -74,7 +74,7 @@ void testBondedNoCosig() { new Deadline(2, ChronoUnit.HOURS), BigInteger.valueOf(37750), Optional.empty(), Optional.empty(), Optional.empty(), Recipient.from(new Address("SDGLFW-DSHILT-IUHGIB-H5UGX2-VYF5VN-JEKCCD-BR26", NetworkType.MIJIN_TEST)), - Arrays.asList(), PlainMessage.Empty); + Arrays.asList(), PlainMessage.EMPTY); AggregateTransaction agg = bondedBuilder.innerTransactions(transferTx).build(); @@ -91,7 +91,7 @@ void testCompleteWithCosig() { new Deadline(2, ChronoUnit.HOURS), BigInteger.valueOf(37750), Optional.empty(), Optional.empty(), Optional.empty(), Recipient.from(new Address("SDGLFW-DSHILT-IUHGIB-H5UGX2-VYF5VN-JEKCCD-BR26", NetworkType.MIJIN_TEST)), - Arrays.asList(), PlainMessage.Empty); + Arrays.asList(), PlainMessage.EMPTY); PublicAccount puba = new PublicAccount("9A49366406ACA952B88BADF5F1E9BE6CE4968141035A60BE503273EA65456B24", NetworkType.MIJIN_TEST); diff --git a/src/test/java/io/proximax/sdk/model/transaction/builder/RegisterNamespaceTransactionBuilderTest.java b/src/test/java/io/proximax/sdk/model/transaction/builder/RegisterNamespaceTransactionBuilderTest.java index 8234ebc7..c0703e5b 100644 --- a/src/test/java/io/proximax/sdk/model/transaction/builder/RegisterNamespaceTransactionBuilderTest.java +++ b/src/test/java/io/proximax/sdk/model/transaction/builder/RegisterNamespaceTransactionBuilderTest.java @@ -41,7 +41,7 @@ void rootNamespace() { final String ID = "test.ns"; RegisterNamespaceTransaction trans = builder.rootNamespace(ID).build(); - assertEquals(NamespaceType.RootNamespace, trans.getNamespaceType()); + assertEquals(NamespaceType.ROOT_NAMESPACE, trans.getNamespaceType()); assertEquals(new NamespaceId(ID), trans.getNamespaceId()); assertEquals(ID, trans.getNamespaceName()); assertEquals(Optional.empty(), trans.getDuration()); @@ -53,7 +53,7 @@ void childNamespace() { final String ID = "test.ns"; RegisterNamespaceTransaction trans = builder.subNamespace(new NamespaceId(ID), "hello").duration(BigInteger.TEN).build(); - assertEquals(NamespaceType.SubNamespace, trans.getNamespaceType()); + assertEquals(NamespaceType.SUB_NAMESPACE, trans.getNamespaceType()); assertEquals(new NamespaceId(ID + ".hello"), trans.getNamespaceId()); assertEquals("hello", trans.getNamespaceName()); assertEquals(Optional.of(BigInteger.TEN), trans.getDuration()); diff --git a/src/test/java/io/proximax/sdk/model/transaction/builder/TransferTransactionBuilderTest.java b/src/test/java/io/proximax/sdk/model/transaction/builder/TransferTransactionBuilderTest.java index 515a0327..b371b955 100644 --- a/src/test/java/io/proximax/sdk/model/transaction/builder/TransferTransactionBuilderTest.java +++ b/src/test/java/io/proximax/sdk/model/transaction/builder/TransferTransactionBuilderTest.java @@ -50,7 +50,7 @@ void testEmptyTransferToRecipient() { // check transaction assertEquals(NetworkType.MIJIN_TEST, trans.getNetworkType()); assertTrue(trans.getMosaics().isEmpty()); - assertEquals(PlainMessage.Empty, trans.getMessage()); + assertEquals(PlainMessage.EMPTY, trans.getMessage()); assertEquals(recipient, trans.getRecipient()); } @@ -63,7 +63,7 @@ void testEmptyTransferToAddress() { // check transaction assertEquals(NetworkType.MIJIN_TEST, trans.getNetworkType()); assertTrue(trans.getMosaics().isEmpty()); - assertEquals(PlainMessage.Empty, trans.getMessage()); + assertEquals(PlainMessage.EMPTY, trans.getMessage()); assertEquals(Recipient.from(recipient), trans.getRecipient()); } @@ -76,7 +76,7 @@ void testEmptyTransferToNamespace() { // check transaction assertEquals(NetworkType.MIJIN_TEST, trans.getNetworkType()); assertTrue(trans.getMosaics().isEmpty()); - assertEquals(PlainMessage.Empty, trans.getMessage()); + assertEquals(PlainMessage.EMPTY, trans.getMessage()); assertEquals(Recipient.from(recipient), trans.getRecipient()); } From 3d6dc35fdea257dad510be51e281cfc36bc52345 Mon Sep 17 00:00:00 2001 From: Anton Wiedermann Date: Tue, 3 Sep 2019 23:55:41 +0200 Subject: [PATCH 3/7] covered some more code by tests --- .../io/proximax/sdk/BlockchainApiTest.java | 15 ++++++ .../model/namespace/NamespaceInfoTest.java | 46 +++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/test/java/io/proximax/sdk/BlockchainApiTest.java b/src/test/java/io/proximax/sdk/BlockchainApiTest.java index 75152fcb..4af0ac32 100644 --- a/src/test/java/io/proximax/sdk/BlockchainApiTest.java +++ b/src/test/java/io/proximax/sdk/BlockchainApiTest.java @@ -16,6 +16,7 @@ package io.proximax.sdk; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.net.MalformedURLException; import java.net.URL; @@ -45,4 +46,18 @@ void testRetrieveTransactionFactory() throws MalformedURLException { TransactionBuilderFactory fac = api.transact(); assertEquals(NETWORK, fac.getNetworkType()); } + + @Test + void testRetrieveRepositories() throws MalformedURLException { + BlockchainApi api = new BlockchainApi(new URL("http://localhost:3000"), NETWORK); + + assertNotNull(api.createAccountRepository()); + assertNotNull(api.createBlockchainRepository()); + assertNotNull(api.createContractRepository()); + assertNotNull(api.createListener()); + assertNotNull(api.createMetadataRepository()); + assertNotNull(api.createMosaicRepository()); + assertNotNull(api.createNamespaceRepository()); + assertNotNull(api.createTransactionRepository()); + } } diff --git a/src/test/java/io/proximax/sdk/model/namespace/NamespaceInfoTest.java b/src/test/java/io/proximax/sdk/model/namespace/NamespaceInfoTest.java index cba6a112..a1072ee1 100644 --- a/src/test/java/io/proximax/sdk/model/namespace/NamespaceInfoTest.java +++ b/src/test/java/io/proximax/sdk/model/namespace/NamespaceInfoTest.java @@ -28,8 +28,13 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import io.proximax.sdk.gen.model.NamespaceDTO; +import io.proximax.sdk.gen.model.NamespaceInfoDTO; +import io.proximax.sdk.gen.model.NamespaceMetaDTO; +import io.proximax.sdk.gen.model.NamespaceTypeEnum; import io.proximax.sdk.model.account.PublicAccount; import io.proximax.sdk.model.blockchain.NetworkType; +import io.proximax.sdk.utils.dto.UInt64Utils; class NamespaceInfoTest { @@ -50,6 +55,7 @@ void createANamespaceInfoViaConstructor() { Optional.empty()); assertEquals(true, namespaceInfo.isActive()); + assertEquals(namespaceInfo.isActive(), !namespaceInfo.isExpired()); assertTrue(namespaceInfo.getIndex() == 0); assertEquals("5A3CD9B09CD1E8000159249B", namespaceInfo.getMetaId()); assertTrue(namespaceInfo.getType() == NamespaceType.ROOT_NAMESPACE); @@ -58,6 +64,8 @@ void createANamespaceInfoViaConstructor() { Assertions.assertEquals(new PublicAccount("B4F12E7C9F6946091E2CB8B6D3A12B50D17CCBBF646386EA27CE2946A7423DCF", NetworkType.MIJIN_TEST), namespaceInfo.getOwner()); assertEquals(new BigInteger("1"), namespaceInfo.getStartHeight()); assertEquals(new BigInteger("-1"), namespaceInfo.getEndHeight()); + assertEquals(Optional.empty(), namespaceInfo.getAddressAlias()); + assertEquals(Optional.empty(), namespaceInfo.getMosaicAlias()); } @Test @@ -108,6 +116,44 @@ void shouldParentNamespaceIdThrowErrorWhenNamespaceInfoIsFromRootNamespace() { assertThrows(Error.class, ()->{namespaceInfo.parentNamespaceId();}, "Is A Root Namespace"); } + @Test + void testFromDto() { + NamespaceId namespaceId = new NamespaceId(new BigInteger("-8884663987180930485")); + + // namespace meta data + NamespaceMetaDTO nmdto = new NamespaceMetaDTO(); + nmdto.setActive(true); + nmdto.setId("5A3CD9B09CD1E8000159249B"); + nmdto.setIndex(0); + // namespace description + NamespaceDTO ndto = new NamespaceDTO(); + ndto.setType(NamespaceTypeEnum.NUMBER_0); + ndto.setParentId(UInt64Utils.dtoFromBigInt(BigInteger.ZERO)); + ndto.setOwner("B4F12E7C9F6946091E2CB8B6D3A12B50D17CCBBF646386EA27CE2946A7423DCF"); + ndto.setStartHeight(UInt64Utils.dtoFromBigInt(BigInteger.ONE)); + ndto.setEndHeight(UInt64Utils.dtoFromBigInt(BigInteger.TEN)); + ndto.setDepth(1); + ndto.setLevel0(UInt64Utils.dtoFromBigInt(BigInteger.valueOf(-8884663987180930485l))); + // namespace info + NamespaceInfoDTO nidto = new NamespaceInfoDTO(); + nidto.setMeta(nmdto); + nidto.setNamespace(ndto); + + NamespaceInfo namespaceInfo = NamespaceInfo.fromDto(nidto, NetworkType.MIJIN_TEST); + + assertEquals(true, namespaceInfo.isActive()); + assertEquals(namespaceInfo.isActive(), !namespaceInfo.isExpired()); + assertEquals(0, namespaceInfo.getIndex()); + assertEquals("5A3CD9B09CD1E8000159249B", namespaceInfo.getMetaId()); + assertEquals(NamespaceType.ROOT_NAMESPACE, namespaceInfo.getType()); + assertEquals(1, namespaceInfo.getDepth()); + assertEquals(namespaceId, namespaceInfo.getLevels().get(0)); + Assertions.assertEquals(new PublicAccount("B4F12E7C9F6946091E2CB8B6D3A12B50D17CCBBF646386EA27CE2946A7423DCF", NetworkType.MIJIN_TEST), namespaceInfo.getOwner()); + assertEquals(new BigInteger("1"), namespaceInfo.getStartHeight()); + assertEquals(BigInteger.TEN, namespaceInfo.getEndHeight()); + assertEquals(Optional.empty(), namespaceInfo.getAddressAlias()); + assertEquals(Optional.empty(), namespaceInfo.getMosaicAlias()); + } NamespaceInfo createRootNamespaceInfo() { return new NamespaceInfo(true, From 968a1fdd01b8988c6b045e7a9d43b160f0e0aebc Mon Sep 17 00:00:00 2001 From: Anton Wiedermann Date: Wed, 4 Sep 2019 00:15:48 +0200 Subject: [PATCH 4/7] issue #119 - allow request for incoming transactions by address --- .../java/io/proximax/sdk/E2EAccountTest.java | 6 +++- .../io/proximax/sdk/AccountRepository.java | 20 +++++++++++++ .../sdk/infrastructure/AccountHttp.java | 30 ++++++++++++------- 3 files changed, 45 insertions(+), 11 deletions(-) diff --git a/src/e2e/java/io/proximax/sdk/E2EAccountTest.java b/src/e2e/java/io/proximax/sdk/E2EAccountTest.java index cf89c0fd..97981c9e 100644 --- a/src/e2e/java/io/proximax/sdk/E2EAccountTest.java +++ b/src/e2e/java/io/proximax/sdk/E2EAccountTest.java @@ -46,9 +46,9 @@ import io.proximax.sdk.model.mosaic.NetworkCurrencyMosaic; import io.proximax.sdk.model.namespace.NamespaceId; import io.proximax.sdk.model.namespace.NamespaceInfo; +import io.proximax.sdk.model.transaction.EntityType; import io.proximax.sdk.model.transaction.ModifyAccountPropertyTransaction; import io.proximax.sdk.model.transaction.Transaction; -import io.proximax.sdk.model.transaction.EntityType; import io.proximax.sdk.model.transaction.UInt64Id; import io.proximax.sdk.utils.dto.UInt64Utils; @@ -293,8 +293,12 @@ void transactionsWithPagination() throws ExecutionException, InterruptedExceptio void incomingTransactions() throws ExecutionException, InterruptedException { List transactions = accountHttp.incomingTransactions(simpleAccount.getPublicAccount()).toFuture() .get(); + List transactionsByAddr = accountHttp.incomingTransactions(simpleAccount.getPublicAccount().getAddress()).toFuture() + .get(); assertEquals(1, transactions.size()); + assertEquals(1, transactionsByAddr.size()); + assertEquals(transactions.get(0).getSignature(), transactionsByAddr.get(0).getSignature()); } @Test diff --git a/src/main/java/io/proximax/sdk/AccountRepository.java b/src/main/java/io/proximax/sdk/AccountRepository.java index 3763454b..1d39dccc 100644 --- a/src/main/java/io/proximax/sdk/AccountRepository.java +++ b/src/main/java/io/proximax/sdk/AccountRepository.java @@ -121,6 +121,26 @@ public interface AccountRepository { */ Observable> incomingTransactions(PublicAccount publicAccount, QueryParams queryParams); + /** + * Gets an list of transactions for which an account is the recipient of a transaction. + * A transaction is said to be incoming with respect to an account if the account is the recipient of a transaction. + * + * @param address the address + * @return Observable of {@link Transaction} list + */ + Observable> incomingTransactions(Address address); + + /** + * Gets an list of transactions for which an account is the recipient of a transaction. + * A transaction is said to be incoming with respect to an account if the account is the recipient of a transaction. + * With pagination. + * + * @param address the address + * @param queryParams QueryParams + * @return Observable of {@link Transaction} list + */ + Observable> incomingTransactions(Address address, QueryParams queryParams); + /** * Gets an list of transactions for which an account is the sender a transaction. * A transaction is said to be outgoing with respect to an account if the account is the sender of a transaction. diff --git a/src/main/java/io/proximax/sdk/infrastructure/AccountHttp.java b/src/main/java/io/proximax/sdk/infrastructure/AccountHttp.java index ea0ded36..e535bce7 100644 --- a/src/main/java/io/proximax/sdk/infrastructure/AccountHttp.java +++ b/src/main/java/io/proximax/sdk/infrastructure/AccountHttp.java @@ -146,22 +146,32 @@ public Observable> transactions(PublicAccount publicAccount, Q } private Observable> transactions(PublicAccount publicAccount, Optional queryParams) { - return this.findTransactions(publicAccount, queryParams, "/transactions"); + return this.findTransactions(publicAccount.getPublicKey(), queryParams, "/transactions"); } @Override public Observable> incomingTransactions(PublicAccount publicAccount) { - return this.incomingTransactions(publicAccount, Optional.empty()); + return this.incomingTransactions(publicAccount.getPublicKey(), Optional.empty()); } @Override public Observable> incomingTransactions(PublicAccount publicAccount, QueryParams queryParams) { - return this.incomingTransactions(publicAccount, Optional.of(queryParams)); + return this.incomingTransactions(publicAccount.getPublicKey(), Optional.of(queryParams)); } - private Observable> incomingTransactions(PublicAccount publicAccount, + @Override + public Observable> incomingTransactions(Address address) { + return this.incomingTransactions(address.plain(), Optional.empty()); + } + + @Override + public Observable> incomingTransactions(Address address, QueryParams queryParams) { + return this.incomingTransactions(address.plain(), Optional.of(queryParams)); + } + + private Observable> incomingTransactions(String accountKey, Optional queryParams) { - return this.findTransactions(publicAccount, queryParams, "/transactions/incoming"); + return this.findTransactions(accountKey, queryParams, "/transactions/incoming"); } @Override @@ -176,7 +186,7 @@ public Observable> outgoingTransactions(PublicAccount publicAc private Observable> outgoingTransactions(PublicAccount publicAccount, Optional queryParams) { - return this.findTransactions(publicAccount, queryParams, "/transactions/outgoing"); + return this.findTransactions(publicAccount.getPublicKey(), queryParams, "/transactions/outgoing"); } @Override @@ -192,7 +202,7 @@ public Observable> aggregateBondedTransactions(Public private Observable> aggregateBondedTransactions(PublicAccount publicAccount, Optional queryParams) { - return this.findTransactions(publicAccount, queryParams, "/transactions/partial").flatMapIterable(item -> item) + return this.findTransactions(publicAccount.getPublicKey(), queryParams, "/transactions/partial").flatMapIterable(item -> item) .map(item -> (AggregateTransaction) item).toList().toObservable(); } @@ -208,14 +218,14 @@ public Observable> unconfirmedTransactions(PublicAccount publi private Observable> unconfirmedTransactions(PublicAccount publicAccount, Optional queryParams) { - return this.findTransactions(publicAccount, queryParams, "/transactions/unconfirmed"); + return this.findTransactions(publicAccount.getPublicKey(), queryParams, "/transactions/unconfirmed"); } - private Observable> findTransactions(PublicAccount publicAccount, + private Observable> findTransactions(String accountKey, Optional queryParams, String path) { return this.client .get(ROUTE - + publicAccount.getPublicKey() + path + (queryParams.isPresent() ? queryParams.get().toUrl() : "")) + + accountKey + path + (queryParams.isPresent() ? queryParams.get().toUrl() : "")) .map(Http::mapStringOrError) .map(str -> stream(new Gson().fromJson(str, JsonArray.class)).map(s -> (JsonObject) s) .collect(Collectors.toList())) From aa6e60b7e9dee887e630dadf4b505b23b3631d63 Mon Sep 17 00:00:00 2001 From: Anton Wiedermann Date: Wed, 4 Sep 2019 00:23:45 +0200 Subject: [PATCH 5/7] version update, changelog and readme cleanup --- CHANGELOG.md | 10 ++++++++++ README.md | 4 +--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd491ade..6a21eecd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # CHANGELOG +## 0.5.0 MaxFee calculation and transaction builders + +See [milestone](https://github.com/proximax-storage/java-xpx-chain-sdk/milestone/5?closed=1) for fixed issues +* introduced fee calculation strategies +* introduced transaction builders as primary API to create transaction instances +* unified constructors and moved logic to transaction builders +* version field changes (breaks server backward compatibility) +* support for blockchain configuration and upgrade transactions/endpoints +* update of dependency versions + ## 0.4.0 Dragon release support See [milestone](https://github.com/proximax-storage/java-xpx-chain-sdk/milestone/4?closed=1) for fixed issues diff --git a/README.md b/README.md index 3bab69cb..d1822055 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@

ProximaX Sirius Blockchain Java SDK

[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) -[![star this repo](http://githubbadges.com/star.svg?user=proximax-storage&repo=java-xpx-chain-sdk&style=flat)](https://github.com/proximax-storage/java-xpx-chain-sdk) -[![fork this repo](http://githubbadges.com/fork.svg?user=proximax-storage&repo=java-xpx-chain-sdk&style=flat)](https://github.com/proximax-storage/java-xpx-chain-sdk/fork) [![Coverage Status](https://coveralls.io/repos/github/proximax-storage/java-xpx-chain-sdk/badge.svg?branch=master)](https://coveralls.io/github/proximax-storage/java-xpx-chain-sdk?branch=master) [![Build Status](https://travis-ci.com/proximax-storage/java-xpx-chain-sdk.svg?branch=master)](https://travis-ci.com/proximax-storage/java-xpx-chain-sdk) @@ -14,7 +12,7 @@ The ProximaX Sirius Chain Java SDK is a Java library for interacting with the Si ## Use the library ## -Current version of the library is 0.4.0 +Current version of the library is 0.5.0 This library requires use of Java8. Library is published to [Maven Central](https://search.maven.org/). To include library and its dependencies, add following to your build script: From 832b9d3d6796b5f3a485c341a76ba0b9a64b3fbe Mon Sep 17 00:00:00 2001 From: Anton Wiedermann Date: Wed, 4 Sep 2019 00:45:05 +0200 Subject: [PATCH 6/7] javadoc fixes prior to the release --- .../model/blockchain/BlockchainUpgrade.java | 4 +- .../model/blockchain/BlockchainVersion.java | 10 +-- .../transaction/LockFundsTransaction.java | 20 ++--- .../ModifyAccountPropertyTransaction.java | 81 ++++++++++--------- .../ModifyMetadataTransaction.java | 24 +++--- .../ModifyMultisigAccountTransaction.java | 2 +- .../MosaicDefinitionTransaction.java | 20 ++--- .../MosaicSupplyChangeTransaction.java | 20 ++--- .../RegisterNamespaceTransaction.java | 24 +++--- .../builder/TransactionBuilder.java | 16 +++- .../builder/TransactionBuilderFactory.java | 2 +- 11 files changed, 118 insertions(+), 105 deletions(-) diff --git a/src/main/java/io/proximax/sdk/model/blockchain/BlockchainUpgrade.java b/src/main/java/io/proximax/sdk/model/blockchain/BlockchainUpgrade.java index 0b74a022..ceb39222 100644 --- a/src/main/java/io/proximax/sdk/model/blockchain/BlockchainUpgrade.java +++ b/src/main/java/io/proximax/sdk/model/blockchain/BlockchainUpgrade.java @@ -18,8 +18,8 @@ public class BlockchainUpgrade { private final BlockchainVersion version; /** - * @param height - * @param version + * @param height the height at which specified version became required + * @param version the node version */ public BlockchainUpgrade(BigInteger height, BlockchainVersion version) { this.height = height; diff --git a/src/main/java/io/proximax/sdk/model/blockchain/BlockchainVersion.java b/src/main/java/io/proximax/sdk/model/blockchain/BlockchainVersion.java index 15852649..fbc3b239 100644 --- a/src/main/java/io/proximax/sdk/model/blockchain/BlockchainVersion.java +++ b/src/main/java/io/proximax/sdk/model/blockchain/BlockchainVersion.java @@ -26,10 +26,10 @@ public class BlockchainVersion { private final int build; /** - * @param major - * @param minor - * @param revision - * @param build + * @param major major version number + * @param minor minor version number + * @param revision revision + * @param build build */ public BlockchainVersion(int major, int minor, int revision, int build) { // validate input is in range @@ -85,7 +85,7 @@ public BigInteger getVersionValue() { /** * create new instance using the big integer of 8 bytes * - * @param version + * @param version serialized version represented as one number * @return the version instance representing the version value */ public static BlockchainVersion fromVersionValue(BigInteger version) { diff --git a/src/main/java/io/proximax/sdk/model/transaction/LockFundsTransaction.java b/src/main/java/io/proximax/sdk/model/transaction/LockFundsTransaction.java index d64943fb..2540924f 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/LockFundsTransaction.java +++ b/src/main/java/io/proximax/sdk/model/transaction/LockFundsTransaction.java @@ -44,16 +44,16 @@ public class LockFundsTransaction extends Transaction { private final SignedTransaction signedTransaction; /** - * @param networkType - * @param version - * @param deadline - * @param maxFee - * @param signature - * @param signer - * @param transactionInfo - * @param mosaic - * @param duration - * @param signedTransaction + * @param networkType network type + * @param version transaction version. Use {@link EntityVersion#LOCK} for current version + * @param deadline transaction deadline + * @param maxFee transaction fee + * @param signature optional signature + * @param signer optional signer + * @param transactionInfo optional transaction info + * @param mosaic mosaic to lock + * @param duration number of blocks to hold lock for + * @param signedTransaction the transaction which will release the lock when confirmed */ public LockFundsTransaction(NetworkType networkType, Integer version, TransactionDeadline deadline, BigInteger maxFee, Optional signature, Optional signer, diff --git a/src/main/java/io/proximax/sdk/model/transaction/ModifyAccountPropertyTransaction.java b/src/main/java/io/proximax/sdk/model/transaction/ModifyAccountPropertyTransaction.java index 1e52d1d1..9512b372 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/ModifyAccountPropertyTransaction.java +++ b/src/main/java/io/proximax/sdk/model/transaction/ModifyAccountPropertyTransaction.java @@ -37,16 +37,18 @@ public abstract class ModifyAccountPropertyTransaction extends Transaction { private final List> modifications; /** - * @param type - * @param networkType - * @param version - * @param deadline - * @param maxFee - * @param signature - * @param signer - * @param transactionInfo - * @param propertyType - * @param modifications + * @param type transaction type + * @param networkType network type + * @param version transaction version. Use {@link EntityVersion#ACCOUNT_PROPERTIES_ADDRESS}, + * {@link EntityVersion#ACCOUNT_PROPERTIES_MOSAIC}, {@link EntityVersion#ACCOUNT_PROPERTIES_ENTITY_TYPE} for current + * version + * @param deadline transaction deadline + * @param maxFee transaction fee + * @param signature optional signature + * @param signer optional signer + * @param transactionInfo optional transaction info + * @param propertyType type of the account property + * @param modifications modifications to the property type */ public ModifyAccountPropertyTransaction(EntityType type, NetworkType networkType, Integer version, TransactionDeadline deadline, BigInteger maxFee, Optional signature, Optional signer, @@ -151,15 +153,15 @@ public static class AddressModification extends ModifyAccountPropertyTransaction private static final int VALUE_BYTES_LENGTH = 25; /** - * @param networkType - * @param version - * @param deadline - * @param maxFee - * @param signature - * @param signer - * @param transactionInfo - * @param propertyType - * @param modifications + * @param networkType network type + * @param version transaction version. Use {@link EntityVersion#ACCOUNT_PROPERTIES_ADDRESS} for current version + * @param deadline transaction deadline + * @param maxFee transaction fee + * @param signature optional signature + * @param signer optional signer + * @param transactionInfo optional transaction info + * @param propertyType type of the account property + * @param modifications modifications to the property type */ public AddressModification(NetworkType networkType, Integer version, TransactionDeadline deadline, BigInteger maxFee, Optional signature, Optional signer, @@ -215,15 +217,15 @@ public static class MosaicModification extends ModifyAccountPropertyTransaction< private static final int VALUE_BYTES_LENGTH = 8; /** - * @param networkType - * @param version - * @param deadline - * @param maxFee - * @param signature - * @param signer - * @param transactionInfo - * @param propertyType - * @param modifications + * @param networkType network type + * @param version transaction version. Use {@link EntityVersion#ACCOUNT_PROPERTIES_MOSAIC} for current version + * @param deadline transaction deadline + * @param maxFee transaction fee + * @param signature optional signature + * @param signer optional signer + * @param transactionInfo optional transaction info + * @param propertyType type of the account property + * @param modifications modifications to the property type */ public MosaicModification(NetworkType networkType, Integer version, TransactionDeadline deadline, BigInteger maxFee, Optional signature, Optional signer, @@ -278,22 +280,23 @@ public static class EntityTypeModification extends ModifyAccountPropertyTransact private static final int VALUE_BYTES_LENGTH = 2; /** - * @param networkType - * @param version - * @param deadline - * @param maxFee - * @param signature - * @param signer - * @param transactionInfo - * @param propertyType - * @param modifications + * @param networkType network type + * @param version transaction version. Use {@link EntityVersion#ACCOUNT_PROPERTIES_ENTITY_TYPE} for current + * version + * @param deadline transaction deadline + * @param maxFee transaction fee + * @param signature optional signature + * @param signer optional signer + * @param transactionInfo optional transaction info + * @param propertyType type of the account property + * @param modifications modifications to the property type */ public EntityTypeModification(NetworkType networkType, Integer version, TransactionDeadline deadline, BigInteger maxFee, Optional signature, Optional signer, Optional transactionInfo, AccountPropertyType propertyType, List> modifications) { - super(EntityType.ACCOUNT_PROPERTIES_ENTITY_TYPE, networkType, version, deadline, maxFee, signature, - signer, transactionInfo, propertyType, modifications); + super(EntityType.ACCOUNT_PROPERTIES_ENTITY_TYPE, networkType, version, deadline, maxFee, signature, signer, + transactionInfo, propertyType, modifications); } @Override diff --git a/src/main/java/io/proximax/sdk/model/transaction/ModifyMetadataTransaction.java b/src/main/java/io/proximax/sdk/model/transaction/ModifyMetadataTransaction.java index 2d035254..97bdc6c2 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/ModifyMetadataTransaction.java +++ b/src/main/java/io/proximax/sdk/model/transaction/ModifyMetadataTransaction.java @@ -53,18 +53,18 @@ public class ModifyMetadataTransaction extends Transaction { private final List modifications; /** - * @param type - * @param networkType - * @param version - * @param deadline - * @param maxFee - * @param signature - * @param signer - * @param transactionInfo - * @param metadataType - * @param metadataId - * @param address - * @param modifications + * @param type transaction type ADDRESS / MOSAIC / NAMESPACE + * @param networkType network type + * @param version transaction version. Use {@link EntityVersion} for current version + * @param deadline transaction deadline + * @param maxFee transaction fee + * @param signature optional signature + * @param signer optional signer + * @param transactionInfo optional transaction info + * @param metadataType type of the metadata + * @param metadataId mosaic or namespace ID for which metadata is modified (used only when address is not specified) + * @param address address for which metadata is modified (only to be used when metadataId is not specified) + * @param modifications the modification to make */ public ModifyMetadataTransaction(EntityType type, NetworkType networkType, Integer version, TransactionDeadline deadline, BigInteger maxFee, Optional signature, Optional signer, diff --git a/src/main/java/io/proximax/sdk/model/transaction/ModifyMultisigAccountTransaction.java b/src/main/java/io/proximax/sdk/model/transaction/ModifyMultisigAccountTransaction.java index cff1370d..7cb1d13a 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/ModifyMultisigAccountTransaction.java +++ b/src/main/java/io/proximax/sdk/model/transaction/ModifyMultisigAccountTransaction.java @@ -54,7 +54,7 @@ public class ModifyMultisigAccountTransaction extends Transaction { * @param transactionInfo optional transaction info * @param minApprovalDelta minimum number of cosignatures for transaction approval * @param minRemovalDelta minimum number of cosignatures for cosignatory removal - * @param modifications + * @param modifications the modifications to the account */ public ModifyMultisigAccountTransaction(NetworkType networkType, Integer version, TransactionDeadline deadline, BigInteger maxFee, Optional signature, Optional signer, diff --git a/src/main/java/io/proximax/sdk/model/transaction/MosaicDefinitionTransaction.java b/src/main/java/io/proximax/sdk/model/transaction/MosaicDefinitionTransaction.java index e5d0c4db..9ceaecc5 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/MosaicDefinitionTransaction.java +++ b/src/main/java/io/proximax/sdk/model/transaction/MosaicDefinitionTransaction.java @@ -50,16 +50,16 @@ public class MosaicDefinitionTransaction extends Transaction { private final MosaicProperties mosaicProperties; /** - * @param networkType - * @param version - * @param deadline - * @param maxFee - * @param signature - * @param signer - * @param transactionInfo - * @param nonce - * @param mosaicId - * @param mosaicProperties + * @param networkType network type + * @param version transaction version. Use {@link EntityVersion#MOSAIC_DEFINITION} for current version + * @param deadline transaction deadline + * @param maxFee transaction fee + * @param signature optional signature + * @param signer optional signer + * @param transactionInfo optional transaction info + * @param nonce nonce used to generate unique mosaic ID + * @param mosaicId mosaic ID + * @param mosaicProperties mosaic properties */ public MosaicDefinitionTransaction(NetworkType networkType, Integer version, TransactionDeadline deadline, BigInteger maxFee, Optional signature, Optional signer, diff --git a/src/main/java/io/proximax/sdk/model/transaction/MosaicSupplyChangeTransaction.java b/src/main/java/io/proximax/sdk/model/transaction/MosaicSupplyChangeTransaction.java index 07818941..83831893 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/MosaicSupplyChangeTransaction.java +++ b/src/main/java/io/proximax/sdk/model/transaction/MosaicSupplyChangeTransaction.java @@ -42,16 +42,16 @@ public class MosaicSupplyChangeTransaction extends Transaction { private final BigInteger delta; /** - * @param networkType - * @param version - * @param deadline - * @param maxFee - * @param signature - * @param signer - * @param transactionInfo - * @param mosaicId - * @param mosaicSupplyType - * @param delta + * @param networkType network type + * @param version transaction version. Use {@link EntityVersion#MOSAIC_SUPPLY_CHANGE} for current version + * @param deadline transaction deadline + * @param maxFee transaction fee + * @param signature optional signature + * @param signer optional signer + * @param transactionInfo optional transaction info + * @param mosaicId ID of mosaic that will change + * @param mosaicSupplyType type of the supply change (increase/decrease) + * @param delta the change to the supply */ public MosaicSupplyChangeTransaction(NetworkType networkType, Integer version, TransactionDeadline deadline, BigInteger maxFee, Optional signature, Optional signer, diff --git a/src/main/java/io/proximax/sdk/model/transaction/RegisterNamespaceTransaction.java b/src/main/java/io/proximax/sdk/model/transaction/RegisterNamespaceTransaction.java index 058b8c1c..08abd78f 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/RegisterNamespaceTransaction.java +++ b/src/main/java/io/proximax/sdk/model/transaction/RegisterNamespaceTransaction.java @@ -45,18 +45,18 @@ public class RegisterNamespaceTransaction extends Transaction { /** - * @param networkType - * @param version - * @param deadline - * @param maxFee - * @param signature - * @param signer - * @param transactionInfo - * @param namespaceName - * @param namespaceId - * @param duration - * @param parentId - * @param namespaceType + * @param networkType network type + * @param version transaction version. Use {@link EntityVersion#REGISTER_NAMESPACE} for current version + * @param deadline transaction deadline + * @param maxFee transaction fee + * @param signature optional signature + * @param signer optional signer + * @param transactionInfo optional transaction info + * @param namespaceName name of the namespace + * @param namespaceId id of the namespace (generated from name and optionally parent) + * @param duration number of blocks for which the namespace will exist + * @param parentId parent namespace ID for sub-namespaces + * @param namespaceType root or sub namespace */ public RegisterNamespaceTransaction(NetworkType networkType, Integer version, TransactionDeadline deadline, BigInteger maxFee, Optional signature, Optional signer, diff --git a/src/main/java/io/proximax/sdk/model/transaction/builder/TransactionBuilder.java b/src/main/java/io/proximax/sdk/model/transaction/builder/TransactionBuilder.java index 6d790cdc..6723d058 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/builder/TransactionBuilder.java +++ b/src/main/java/io/proximax/sdk/model/transaction/builder/TransactionBuilder.java @@ -12,10 +12,10 @@ import io.proximax.sdk.model.account.PublicAccount; import io.proximax.sdk.model.blockchain.NetworkType; import io.proximax.sdk.model.transaction.DeadlineRaw; +import io.proximax.sdk.model.transaction.EntityType; import io.proximax.sdk.model.transaction.Transaction; import io.proximax.sdk.model.transaction.TransactionDeadline; import io.proximax.sdk.model.transaction.TransactionInfo; -import io.proximax.sdk.model.transaction.EntityType; /** * Transaction builder is base class implementing builder pattern to construct instance of transaction. It is bases of @@ -37,8 +37,8 @@ public abstract class TransactionBuilder, T e private Optional deadlineMillis; /** - * @param type - * @param version + * @param type type of the transaction + * @param version vesion of the transaction */ public TransactionBuilder(EntityType type, Integer version) { this.type = type; @@ -81,6 +81,7 @@ protected BigInteger getMaxFeeCalculation(int transactionPayloadSize) { /** * @param type the type to set + * @return the builder */ public B type(EntityType type) { this.type = type; @@ -89,6 +90,7 @@ public B type(EntityType type) { /** * @param version the version to set + * @return the builder */ public B version(Integer version) { this.version = version; @@ -97,6 +99,7 @@ public B version(Integer version) { /** * @param networkType the networkType to set + * @return the builder */ public B networkType(NetworkType networkType) { this.networkType = networkType; @@ -105,6 +108,7 @@ public B networkType(NetworkType networkType) { /** * @param deadline the fixed deadline to use + * @return the builder */ public B deadline(TransactionDeadline deadline) { this.deadline = Optional.of(deadline); @@ -114,6 +118,7 @@ public B deadline(TransactionDeadline deadline) { /** * @param deadlineMillis the deadline specified as duration in milliseconds after {@link TransactionBuilder#build()} * is invoked + * @return the builder */ public B deadlineDuration(BigInteger deadlineMillis) { this.deadlineMillis = Optional.of(deadlineMillis); @@ -122,6 +127,7 @@ public B deadlineDuration(BigInteger deadlineMillis) { /** * @param maxFee the maxFee to set + * @return the builder */ public B maxFee(BigInteger maxFee) { this.maxFee = Optional.of(maxFee); @@ -130,6 +136,7 @@ public B maxFee(BigInteger maxFee) { /** * @param signature the signature to set + * @return the builder */ public B signature(String signature) { this.signature = Optional.of(signature); @@ -138,6 +145,7 @@ public B signature(String signature) { /** * @param signer the signer to set + * @return the builder */ public B signer(PublicAccount signer) { this.signer = Optional.of(signer); @@ -146,6 +154,7 @@ public B signer(PublicAccount signer) { /** * @param transactionInfo the transactionInfo to set + * @return the builder */ public B transactionInfo(TransactionInfo transactionInfo) { this.transactionInfo = Optional.of(transactionInfo); @@ -154,6 +163,7 @@ public B transactionInfo(TransactionInfo transactionInfo) { /** * @param feeCalculationStrategy the feeCalculationStrategy to set + * @return the builder */ public B feeCalculationStrategy(FeeCalculationStrategy feeCalculationStrategy) { this.feeCalculationStrategy = Optional.of(feeCalculationStrategy); diff --git a/src/main/java/io/proximax/sdk/model/transaction/builder/TransactionBuilderFactory.java b/src/main/java/io/proximax/sdk/model/transaction/builder/TransactionBuilderFactory.java index 8b561605..1500b1f6 100644 --- a/src/main/java/io/proximax/sdk/model/transaction/builder/TransactionBuilderFactory.java +++ b/src/main/java/io/proximax/sdk/model/transaction/builder/TransactionBuilderFactory.java @@ -72,7 +72,7 @@ public TransactionBuilderFactory setFeeCalculationStrategy(FeeCalculationStrateg /** * initialize default values for the builder * - * @param builder + * @param builder the transaction builder to initialize */ protected void initDefaults(TransactionBuilder builder) { builder.networkType(networkType); From b39b0cf688c5455f2307f2f29b784a8509fbf07a Mon Sep 17 00:00:00 2001 From: Anton Wiedermann Date: Wed, 4 Sep 2019 00:57:43 +0200 Subject: [PATCH 7/7] default fee calculation strategy is now used by transaction builders --- src/main/java/io/proximax/sdk/BlockchainApi.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/io/proximax/sdk/BlockchainApi.java b/src/main/java/io/proximax/sdk/BlockchainApi.java index 06b2168d..d3e3bd8a 100644 --- a/src/main/java/io/proximax/sdk/BlockchainApi.java +++ b/src/main/java/io/proximax/sdk/BlockchainApi.java @@ -227,6 +227,7 @@ private NetworkType queryForNetworkType() { public TransactionBuilderFactory transact() { TransactionBuilderFactory fac = new TransactionBuilderFactory(); fac.setNetworkType(getNetworkType()); + fac.setFeeCalculationStrategy(DEFAULT_FEE_CALCULATION_STRATEGY); return fac; } }