Search in sources :

Example 76 with AggregateTransaction

use of io.nem.symbol.sdk.model.transaction.AggregateTransaction in project nem2-sdk-java by nemtech.

the class TransactionMapperVertxTest method shouldCreateAggregateMosaicAddressRestrictionTransaction.

@Test
void shouldCreateAggregateMosaicAddressRestrictionTransaction() {
    TransactionInfoDTO aggregateMosaicAddressRestrictionTransactionDTO = TestHelperVertx.loadTransactionInfoDTO("aggregateMosaicAddressRestrictionTransaction.json");
    Transaction aggregateMosaicAddressRestrictionTransaction = map(aggregateMosaicAddressRestrictionTransactionDTO);
    validateAggregateTransaction((AggregateTransaction) aggregateMosaicAddressRestrictionTransaction, aggregateMosaicAddressRestrictionTransactionDTO);
}
Also used : SecretProofTransaction(io.nem.symbol.sdk.model.transaction.SecretProofTransaction) HashLockTransaction(io.nem.symbol.sdk.model.transaction.HashLockTransaction) AccountOperationRestrictionTransaction(io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionTransaction) AccountAddressRestrictionTransaction(io.nem.symbol.sdk.model.transaction.AccountAddressRestrictionTransaction) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) NamespaceRegistrationTransaction(io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) MosaicDefinitionTransaction(io.nem.symbol.sdk.model.transaction.MosaicDefinitionTransaction) MultisigAccountModificationTransaction(io.nem.symbol.sdk.model.transaction.MultisigAccountModificationTransaction) AccountMosaicRestrictionTransaction(io.nem.symbol.sdk.model.transaction.AccountMosaicRestrictionTransaction) MosaicMetadataTransaction(io.nem.symbol.sdk.model.transaction.MosaicMetadataTransaction) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) AccountKeyLinkTransaction(io.nem.symbol.sdk.model.transaction.AccountKeyLinkTransaction) NamespaceMetadataTransaction(io.nem.symbol.sdk.model.transaction.NamespaceMetadataTransaction) AccountMetadataTransaction(io.nem.symbol.sdk.model.transaction.AccountMetadataTransaction) AddressAliasTransaction(io.nem.symbol.sdk.model.transaction.AddressAliasTransaction) MosaicAliasTransaction(io.nem.symbol.sdk.model.transaction.MosaicAliasTransaction) MosaicSupplyChangeTransaction(io.nem.symbol.sdk.model.transaction.MosaicSupplyChangeTransaction) SecretLockTransaction(io.nem.symbol.sdk.model.transaction.SecretLockTransaction) TransactionInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.TransactionInfoDTO) Test(org.junit.jupiter.api.Test)

Example 77 with AggregateTransaction

use of io.nem.symbol.sdk.model.transaction.AggregateTransaction in project nem2-sdk-java by nemtech.

the class TransactionMapperVertxTest method shouldCreateAggregateMultisigModificationTransaction.

@Test
void shouldCreateAggregateMultisigModificationTransaction() {
    TransactionInfoDTO aggregateMultisigModificationTransactionDTO = TestHelperVertx.loadTransactionInfoDTO("aggregateMultisigModificationTransaction.json");
    Transaction aggregateMultisigModificationTransaction = map(aggregateMultisigModificationTransactionDTO);
    validateAggregateTransaction((AggregateTransaction) aggregateMultisigModificationTransaction, aggregateMultisigModificationTransactionDTO);
}
Also used : SecretProofTransaction(io.nem.symbol.sdk.model.transaction.SecretProofTransaction) HashLockTransaction(io.nem.symbol.sdk.model.transaction.HashLockTransaction) AccountOperationRestrictionTransaction(io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionTransaction) AccountAddressRestrictionTransaction(io.nem.symbol.sdk.model.transaction.AccountAddressRestrictionTransaction) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) NamespaceRegistrationTransaction(io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) MosaicDefinitionTransaction(io.nem.symbol.sdk.model.transaction.MosaicDefinitionTransaction) MultisigAccountModificationTransaction(io.nem.symbol.sdk.model.transaction.MultisigAccountModificationTransaction) AccountMosaicRestrictionTransaction(io.nem.symbol.sdk.model.transaction.AccountMosaicRestrictionTransaction) MosaicMetadataTransaction(io.nem.symbol.sdk.model.transaction.MosaicMetadataTransaction) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) AccountKeyLinkTransaction(io.nem.symbol.sdk.model.transaction.AccountKeyLinkTransaction) NamespaceMetadataTransaction(io.nem.symbol.sdk.model.transaction.NamespaceMetadataTransaction) AccountMetadataTransaction(io.nem.symbol.sdk.model.transaction.AccountMetadataTransaction) AddressAliasTransaction(io.nem.symbol.sdk.model.transaction.AddressAliasTransaction) MosaicAliasTransaction(io.nem.symbol.sdk.model.transaction.MosaicAliasTransaction) MosaicSupplyChangeTransaction(io.nem.symbol.sdk.model.transaction.MosaicSupplyChangeTransaction) SecretLockTransaction(io.nem.symbol.sdk.model.transaction.SecretLockTransaction) TransactionInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.TransactionInfoDTO) Test(org.junit.jupiter.api.Test)

Example 78 with AggregateTransaction

use of io.nem.symbol.sdk.model.transaction.AggregateTransaction in project nem2-sdk-java by nemtech.

the class TransactionMapperVertxTest method shouldCreateAggregateTransferTransactionUsingAlias.

@Test
void shouldCreateAggregateTransferTransactionUsingAlias() {
    TransactionInfoDTO aggregateTransferTransactionDTO = TestHelperVertx.loadTransactionInfoDTO("aggregateTransferTransactionUsingAlias.json");
    Transaction aggregateTransferTransaction = map(aggregateTransferTransactionDTO);
    validateAggregateTransaction((AggregateTransaction) aggregateTransferTransaction, aggregateTransferTransactionDTO);
}
Also used : SecretProofTransaction(io.nem.symbol.sdk.model.transaction.SecretProofTransaction) HashLockTransaction(io.nem.symbol.sdk.model.transaction.HashLockTransaction) AccountOperationRestrictionTransaction(io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionTransaction) AccountAddressRestrictionTransaction(io.nem.symbol.sdk.model.transaction.AccountAddressRestrictionTransaction) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) NamespaceRegistrationTransaction(io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) MosaicDefinitionTransaction(io.nem.symbol.sdk.model.transaction.MosaicDefinitionTransaction) MultisigAccountModificationTransaction(io.nem.symbol.sdk.model.transaction.MultisigAccountModificationTransaction) AccountMosaicRestrictionTransaction(io.nem.symbol.sdk.model.transaction.AccountMosaicRestrictionTransaction) MosaicMetadataTransaction(io.nem.symbol.sdk.model.transaction.MosaicMetadataTransaction) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) AccountKeyLinkTransaction(io.nem.symbol.sdk.model.transaction.AccountKeyLinkTransaction) NamespaceMetadataTransaction(io.nem.symbol.sdk.model.transaction.NamespaceMetadataTransaction) AccountMetadataTransaction(io.nem.symbol.sdk.model.transaction.AccountMetadataTransaction) AddressAliasTransaction(io.nem.symbol.sdk.model.transaction.AddressAliasTransaction) MosaicAliasTransaction(io.nem.symbol.sdk.model.transaction.MosaicAliasTransaction) MosaicSupplyChangeTransaction(io.nem.symbol.sdk.model.transaction.MosaicSupplyChangeTransaction) SecretLockTransaction(io.nem.symbol.sdk.model.transaction.SecretLockTransaction) TransactionInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.TransactionInfoDTO) Test(org.junit.jupiter.api.Test)

Example 79 with AggregateTransaction

use of io.nem.symbol.sdk.model.transaction.AggregateTransaction in project nem2-sdk-java by nemtech.

the class VertxCosignatureTransactionTest method shouldThrowExceptionWhenTransactionToCosignHasNotBeenAnnunced.

@Test
void shouldThrowExceptionWhenTransactionToCosignHasNotBeenAnnunced() throws Exception {
    AggregateTransaction aggregateTransaction = AggregateTransactionFactory.createComplete(NetworkType.MIJIN_TEST, new Deadline(BigInteger.ONE), Collections.emptyList()).build();
    assertThrows(IllegalArgumentException.class, () -> {
        CosignatureTransaction.create(aggregateTransaction);
    }, "Transaction to cosign should be announced before being able to cosign it");
}
Also used : AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) Deadline(io.nem.symbol.sdk.model.transaction.Deadline) Test(org.junit.jupiter.api.Test)

Example 80 with AggregateTransaction

use of io.nem.symbol.sdk.model.transaction.AggregateTransaction in project nem2-sdk-java by nemtech.

the class TestHelper method announceAggregateAndValidate.

<T extends Transaction> Pair<T, AggregateTransaction> announceAggregateAndValidate(RepositoryType type, T transaction, Account signer, Account... cosigners) {
    System.out.println("Announcing Aggregate Transaction: " + transaction.getType() + " signer " + signer.getAddress().plain() + " cosigners: " + Arrays.stream(cosigners).map(s -> s.getAddress().plain()).collect(Collectors.joining(", ")));
    AggregateTransaction aggregateTransaction = AggregateTransactionFactory.createComplete(getNetworkType(), getDeadline(), Collections.singletonList(transaction.toAggregate(signer.getPublicAccount()))).maxFee(maxFee).build();
    SignedTransaction signedTransaction = signer.signTransactionWithCosignatories(aggregateTransaction, Arrays.asList(cosigners), getGenerationHash());
    if (transaction.getType() != TransactionType.AGGREGATE_COMPLETE) {
        System.out.println("Announcing Transaction Transaction: " + transaction.getType() + " Address: " + signer.getAddress().plain() + " Public Key: " + signer.getPublicAccount().getPublicKey().toHex() + " hash " + signedTransaction.getHash());
    }
    TransactionService transactionService = new TransactionServiceImpl(getRepositoryFactory(type));
    AggregateTransaction announcedAggregateTransaction = (AggregateTransaction) getTransactionOrFail(transactionService.announce(getListener(type), signedTransaction), transaction);
    T announcedCorrectly = (T) announcedAggregateTransaction.getInnerTransactions().get(0);
    System.out.println("Transaction completed, Transaction hash " + announcedAggregateTransaction.getTransactionInfo().get().getHash().get());
    return Pair.of(announcedCorrectly, announcedAggregateTransaction);
}
Also used : MultisigAccountInfo(io.nem.symbol.sdk.model.account.MultisigAccountInfo) Arrays(java.util.Arrays) HashLockTransaction(io.nem.symbol.sdk.model.transaction.HashLockTransaction) HashLockRepository(io.nem.symbol.sdk.api.HashLockRepository) Account(io.nem.symbol.sdk.model.account.Account) AccountRepository(io.nem.symbol.sdk.api.AccountRepository) Future(java.util.concurrent.Future) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) Pair(org.apache.commons.lang3.tuple.Pair) Duration(java.time.Duration) Map(java.util.Map) AccountInfo(io.nem.symbol.sdk.model.account.AccountInfo) NamespaceRegistrationTransaction(io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction) TransactionType(io.nem.symbol.sdk.model.transaction.TransactionType) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) BigInteger(java.math.BigInteger) Listener(io.nem.symbol.sdk.api.Listener) MosaicDefinitionTransaction(io.nem.symbol.sdk.model.transaction.MosaicDefinitionTransaction) MultisigAccountModificationTransaction(io.nem.symbol.sdk.model.transaction.MultisigAccountModificationTransaction) MosaicDefinitionTransactionFactory(io.nem.symbol.sdk.model.transaction.MosaicDefinitionTransactionFactory) UnresolvedMosaicId(io.nem.symbol.sdk.model.mosaic.UnresolvedMosaicId) NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) BlockDuration(io.nem.symbol.sdk.model.blockchain.BlockDuration) AddressAliasTransactionFactory(io.nem.symbol.sdk.model.transaction.AddressAliasTransactionFactory) MosaicNames(io.nem.symbol.sdk.model.mosaic.MosaicNames) Set(java.util.Set) RepositoryCallException(io.nem.symbol.sdk.api.RepositoryCallException) LockStatus(io.nem.symbol.sdk.model.transaction.LockStatus) MultisigAccountModificationTransactionFactory(io.nem.symbol.sdk.model.transaction.MultisigAccountModificationTransactionFactory) HashLockSearchCriteria(io.nem.symbol.sdk.api.HashLockSearchCriteria) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) Collectors(java.util.stream.Collectors) Executors(java.util.concurrent.Executors) Currency(io.nem.symbol.sdk.model.mosaic.Currency) List(java.util.List) TransferTransactionFactory(io.nem.symbol.sdk.model.transaction.TransferTransactionFactory) JsonHelper(io.nem.symbol.sdk.model.transaction.JsonHelper) ExceptionUtils(io.nem.symbol.core.utils.ExceptionUtils) AggregateTransactionFactory(io.nem.symbol.sdk.model.transaction.AggregateTransactionFactory) Address(io.nem.symbol.sdk.model.account.Address) Page(io.nem.symbol.sdk.api.Page) MosaicSupplyChangeTransactionFactory(io.nem.symbol.sdk.model.transaction.MosaicSupplyChangeTransactionFactory) HashLockTransactionFactory(io.nem.symbol.sdk.model.transaction.HashLockTransactionFactory) Mosaic(io.nem.symbol.sdk.model.mosaic.Mosaic) HashMap(java.util.HashMap) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) Stored(io.nem.symbol.sdk.model.Stored) LinkedHashMap(java.util.LinkedHashMap) MosaicAliasTransactionFactory(io.nem.symbol.sdk.model.transaction.MosaicAliasTransactionFactory) MultisigRepository(io.nem.symbol.sdk.api.MultisigRepository) TransactionService(io.nem.symbol.sdk.api.TransactionService) MosaicNonce(io.nem.symbol.sdk.model.mosaic.MosaicNonce) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) MosaicSupplyChangeActionType(io.nem.symbol.sdk.model.mosaic.MosaicSupplyChangeActionType) Observable(io.reactivex.Observable) JsonHelperJackson2(io.nem.symbol.sdk.infrastructure.vertx.JsonHelperJackson2) UnresolvedAddress(io.nem.symbol.sdk.model.account.UnresolvedAddress) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) AddressAliasTransaction(io.nem.symbol.sdk.model.transaction.AddressAliasTransaction) File(java.io.File) AccountNames(io.nem.symbol.sdk.model.account.AccountNames) TimeUnit(java.util.concurrent.TimeUnit) MosaicAliasTransaction(io.nem.symbol.sdk.model.transaction.MosaicAliasTransaction) TransactionGroup(io.nem.symbol.sdk.model.transaction.TransactionGroup) Deadline(io.nem.symbol.sdk.model.transaction.Deadline) RepositoryFactoryOkHttpImpl(io.nem.symbol.sdk.infrastructure.okhttp.RepositoryFactoryOkHttpImpl) NamespaceRegistrationTransactionFactory(io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransactionFactory) Assertions(org.junit.jupiter.api.Assertions) HashLockInfo(io.nem.symbol.sdk.model.transaction.HashLockInfo) RepositoryFactoryVertxImpl(io.nem.symbol.sdk.infrastructure.vertx.RepositoryFactoryVertxImpl) NetworkType(io.nem.symbol.sdk.model.network.NetworkType) MosaicFlags(io.nem.symbol.sdk.model.mosaic.MosaicFlags) AliasAction(io.nem.symbol.sdk.model.namespace.AliasAction) MosaicSupplyChangeTransaction(io.nem.symbol.sdk.model.transaction.MosaicSupplyChangeTransaction) Collections(java.util.Collections) TransactionRepository(io.nem.symbol.sdk.api.TransactionRepository) TransactionService(io.nem.symbol.sdk.api.TransactionService) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction)

Aggregations

AggregateTransaction (io.nem.symbol.sdk.model.transaction.AggregateTransaction)94 TransferTransaction (io.nem.symbol.sdk.model.transaction.TransferTransaction)68 Test (org.junit.jupiter.api.Test)66 HashLockTransaction (io.nem.symbol.sdk.model.transaction.HashLockTransaction)44 MultisigAccountModificationTransaction (io.nem.symbol.sdk.model.transaction.MultisigAccountModificationTransaction)43 Transaction (io.nem.symbol.sdk.model.transaction.Transaction)41 AddressAliasTransaction (io.nem.symbol.sdk.model.transaction.AddressAliasTransaction)36 NamespaceRegistrationTransaction (io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction)36 MosaicAliasTransaction (io.nem.symbol.sdk.model.transaction.MosaicAliasTransaction)35 MosaicDefinitionTransaction (io.nem.symbol.sdk.model.transaction.MosaicDefinitionTransaction)35 MosaicMetadataTransaction (io.nem.symbol.sdk.model.transaction.MosaicMetadataTransaction)35 MosaicSupplyChangeTransaction (io.nem.symbol.sdk.model.transaction.MosaicSupplyChangeTransaction)35 NamespaceMetadataTransaction (io.nem.symbol.sdk.model.transaction.NamespaceMetadataTransaction)35 SignedTransaction (io.nem.symbol.sdk.model.transaction.SignedTransaction)35 AccountMetadataTransaction (io.nem.symbol.sdk.model.transaction.AccountMetadataTransaction)34 AccountAddressRestrictionTransaction (io.nem.symbol.sdk.model.transaction.AccountAddressRestrictionTransaction)33 AccountOperationRestrictionTransaction (io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionTransaction)33 PlainMessage (io.nem.symbol.sdk.model.message.PlainMessage)32 AccountKeyLinkTransaction (io.nem.symbol.sdk.model.transaction.AccountKeyLinkTransaction)32 AccountMosaicRestrictionTransaction (io.nem.symbol.sdk.model.transaction.AccountMosaicRestrictionTransaction)32