Search in sources :

Example 6 with TransactionType

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);
}
Also used : TransactionType(io.nem.symbol.sdk.model.transaction.TransactionType)

Example 7 with TransactionType

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;
}
Also used : TransactionType(io.nem.symbol.sdk.model.transaction.TransactionType) NetworkType(io.nem.symbol.sdk.model.network.NetworkType) Deadline(io.nem.symbol.sdk.model.transaction.Deadline)

Example 8 with TransactionType

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);
}
Also used : AccountRestrictionFlagsEnum(io.nem.symbol.sdk.openapi.okhttp_gson.model.AccountRestrictionFlagsEnum) Deadline(io.nem.symbol.sdk.model.transaction.Deadline) List(java.util.List) AccountOperationRestrictionTransactionDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.AccountOperationRestrictionTransactionDTO) JsonHelper(io.nem.symbol.sdk.model.transaction.JsonHelper) AccountOperationRestrictionTransaction(io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionTransaction) TransactionType(io.nem.symbol.sdk.model.transaction.TransactionType) AccountOperationRestrictionFlags(io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionFlags) NetworkType(io.nem.symbol.sdk.model.network.NetworkType) TransactionTypeEnum(io.nem.symbol.sdk.openapi.okhttp_gson.model.TransactionTypeEnum) Collectors(java.util.stream.Collectors) AccountOperationRestrictionTransactionFactory(io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionTransactionFactory) AccountOperationRestrictionFlags(io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionFlags) TransactionType(io.nem.symbol.sdk.model.transaction.TransactionType)

Example 9 with TransactionType

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()));
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) PublicAccount(io.nem.symbol.sdk.model.account.PublicAccount) TransactionType(io.nem.symbol.sdk.model.transaction.TransactionType) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) TransactionRepository(io.nem.symbol.sdk.api.TransactionRepository) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 10 with TransactionType

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);
}
Also used : Deadline(io.nem.symbol.sdk.model.transaction.Deadline) List(java.util.List) AccountRestrictionFlagsEnum(io.nem.symbol.sdk.openapi.vertx.model.AccountRestrictionFlagsEnum) AccountOperationRestrictionTransactionDTO(io.nem.symbol.sdk.openapi.vertx.model.AccountOperationRestrictionTransactionDTO) JsonHelper(io.nem.symbol.sdk.model.transaction.JsonHelper) AccountOperationRestrictionTransaction(io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionTransaction) TransactionType(io.nem.symbol.sdk.model.transaction.TransactionType) AccountOperationRestrictionFlags(io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionFlags) NetworkType(io.nem.symbol.sdk.model.network.NetworkType) TransactionTypeEnum(io.nem.symbol.sdk.openapi.vertx.model.TransactionTypeEnum) Collectors(java.util.stream.Collectors) AccountOperationRestrictionTransactionFactory(io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionTransactionFactory) AccountOperationRestrictionFlags(io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionFlags) TransactionType(io.nem.symbol.sdk.model.transaction.TransactionType)

Aggregations

TransactionType (io.nem.symbol.sdk.model.transaction.TransactionType)10 NetworkType (io.nem.symbol.sdk.model.network.NetworkType)4 Deadline (io.nem.symbol.sdk.model.transaction.Deadline)4 AccountOperationRestrictionFlags (io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionFlags)3 AccountOperationRestrictionTransaction (io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionTransaction)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 EnumSource (org.junit.jupiter.params.provider.EnumSource)3 TransactionRepository (io.nem.symbol.sdk.api.TransactionRepository)2 TransactionSearchCriteria (io.nem.symbol.sdk.api.TransactionSearchCriteria)2 Account (io.nem.symbol.sdk.model.account.Account)2 PublicAccount (io.nem.symbol.sdk.model.account.PublicAccount)2 AccountOperationRestrictionTransactionFactory (io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionTransactionFactory)2 JsonHelper (io.nem.symbol.sdk.model.transaction.JsonHelper)2 Transaction (io.nem.symbol.sdk.model.transaction.Transaction)2 TransferTransaction (io.nem.symbol.sdk.model.transaction.TransferTransaction)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 AccountOperationRestrictionTransactionDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.AccountOperationRestrictionTransactionDTO)1 AccountRestrictionFlagsEnum (io.nem.symbol.sdk.openapi.okhttp_gson.model.AccountRestrictionFlagsEnum)1 TransactionTypeEnum (io.nem.symbol.sdk.openapi.okhttp_gson.model.TransactionTypeEnum)1