use of io.nem.symbol.sdk.model.transaction.TransactionType in project nem2-sdk-java by nemtech.
the class GeneralTransactionMapper method resolveMapper.
private TransactionMapper resolveMapper(Object transactionInfoJson) {
Integer type = getJsonHelper().getInteger(transactionInfoJson, "transaction", "type");
if (type == null) {
throw new IllegalArgumentException("Transaction cannot be mapped, object does not not have transaction type.");
}
Integer version = getJsonHelper().getInteger(transactionInfoJson, "transaction", "version");
if (version == null) {
throw new IllegalArgumentException("Transaction cannot be mapped, object does not not have transaction version.");
}
TransactionType transactionType = TransactionType.rawValueOf(type);
return resolveMapper(transactionType, version);
}
use of io.nem.symbol.sdk.model.transaction.TransactionType in project nem2-sdk-java by nemtech.
the class BinarySerializationImpl method toTransactionFactory.
/**
* It converts a {@link TransactionBuilder} to a {@link Transaction}
*
* @param builder the builder
* @return the {@link Transaction} model.
*/
private TransactionFactory<?> toTransactionFactory(TransactionBuilder builder) {
TransactionType transactionType = TransactionType.rawValueOf(SerializationUtils.shortToUnsignedInt(builder.getType().getValue()));
NetworkType networkType = NetworkType.rawValueOf(SerializationUtils.byteToUnsignedInt(builder.getNetwork().getValue()));
Deadline deadline = new Deadline(SerializationUtils.toUnsignedBigInteger(builder.getDeadline().getTimestamp()));
TransactionFactory<?> factory = resolveSerializer(transactionType, builder.getVersion()).fromBodyBuilder(networkType, deadline, builder.getBody());
factory.version(SerializationUtils.byteToUnsignedInt(builder.getVersion()));
factory.maxFee(SerializationUtils.toUnsignedBigInteger(builder.getFee()));
if (!areAllZeros(builder.getSignature().getSignature().array())) {
factory.signature(SerializationUtils.toHexString(builder.getSignature().getSignature()));
}
if (!areAllZeros(builder.getSignerPublicKey().getKey().array())) {
factory.signer(SerializationUtils.toPublicAccount(builder.getSignerPublicKey(), networkType));
}
return factory;
}
use of io.nem.symbol.sdk.model.transaction.TransactionType in project nem2-sdk-java by nemtech.
the class AccountOperationRestrictionTransactionMapper method createFactory.
@Override
protected AccountOperationRestrictionTransactionFactory createFactory(NetworkType networkType, Deadline deadline, AccountOperationRestrictionTransactionDTO transaction) {
AccountOperationRestrictionFlags restrictionFlags = AccountOperationRestrictionFlags.rawValueOf(transaction.getRestrictionFlags().getValue());
List<TransactionType> additions = transaction.getRestrictionAdditions().stream().map(transactionTypeEnum -> TransactionType.rawValueOf(transactionTypeEnum.getValue())).collect(Collectors.toList());
List<TransactionType> deletions = transaction.getRestrictionDeletions().stream().map(transactionTypeEnum -> TransactionType.rawValueOf(transactionTypeEnum.getValue())).collect(Collectors.toList());
return AccountOperationRestrictionTransactionFactory.create(networkType, deadline, restrictionFlags, additions, deletions);
}
use of io.nem.symbol.sdk.model.transaction.TransactionType in project nem2-sdk-java by nemtech.
the class AccountRepositoryIntegrationTest method getMosaicGlobalRegistration.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void getMosaicGlobalRegistration(RepositoryType type) {
TransactionRepository transactionRepository = getRepositoryFactory(type).createTransactionRepository();
Account account = config().getDefaultAccount();
TransactionType transactionType = TransactionType.MOSAIC_GLOBAL_RESTRICTION;
List<Transaction> transactions = get(transactionRepository.search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED).transactionTypes(Collections.singletonList(transactionType)).signerPublicKey(account.getPublicAccount().getPublicKey()).pageSize(10))).getData();
System.out.println(transactions.size());
Assertions.assertFalse(transactions.isEmpty());
transactions.forEach(t -> Assertions.assertEquals(transactionType, t.getType()));
}
use of io.nem.symbol.sdk.model.transaction.TransactionType in project nem2-sdk-java by nemtech.
the class AccountOperationRestrictionTransactionMapper method createFactory.
@Override
protected AccountOperationRestrictionTransactionFactory createFactory(NetworkType networkType, Deadline deadline, AccountOperationRestrictionTransactionDTO transaction) {
AccountOperationRestrictionFlags restrictionFlags = AccountOperationRestrictionFlags.rawValueOf(transaction.getRestrictionFlags().getValue());
List<TransactionType> additions = transaction.getRestrictionAdditions().stream().map(transactionTypeEnum -> TransactionType.rawValueOf(transactionTypeEnum.getValue())).collect(Collectors.toList());
List<TransactionType> deletions = transaction.getRestrictionDeletions().stream().map(transactionTypeEnum -> TransactionType.rawValueOf(transactionTypeEnum.getValue())).collect(Collectors.toList());
return AccountOperationRestrictionTransactionFactory.create(networkType, deadline, restrictionFlags, additions, deletions);
}
Aggregations