Search in sources :

Example 6 with TransferTransactionFactory

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

the class TestHelper method basicTransfer.

public void basicTransfer(RepositoryType type, Account nemesisAccount, UnresolvedAddress recipient, BigInteger amount) {
    TransferTransactionFactory factory = TransferTransactionFactory.create(getNetworkType(), getDeadline(), recipient, Collections.singletonList(getCurrency().createAbsolute(amount)));
    factory.maxFee(maxFee);
    TransferTransaction transferTransaction = factory.build();
    TransferTransaction processedTransaction = announceAndValidate(type, nemesisAccount, transferTransaction);
    Assertions.assertEquals(amount, processedTransaction.getMosaics().get(0).getAmount());
}
Also used : TransferTransactionFactory(io.nem.symbol.sdk.model.transaction.TransferTransactionFactory) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction)

Example 7 with TransferTransactionFactory

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

the class TransactionServiceIntegrationTest method transferUsingAliases.

private TransferTransaction transferUsingAliases(Account sender, RepositoryType type, String mosaicAlias, String recipientAlias, BigInteger amount) {
    NamespaceId recipientNamespace = NamespaceId.createFromName(recipientAlias);
    NamespaceId mosaicNamespace = NamespaceId.createFromName(mosaicAlias);
    System.out.println("Sending " + amount + " Mosaic to: " + mosaicAlias);
    TransferTransactionFactory factory = TransferTransactionFactory.create(getNetworkType(), getDeadline(), recipientNamespace, Collections.singletonList(new Mosaic(mosaicNamespace, amount))).message(new PlainMessage("E2ETest:TransactionServiceIntegrationTest"));
    factory.maxFee(maxFee);
    TransferTransaction transferTransaction = factory.build();
    Assertions.assertTrue(transferTransaction.getMosaics().get(0).getId() instanceof NamespaceId);
    Assertions.assertTrue(transferTransaction.getRecipient() instanceof NamespaceId);
    TransferTransaction processedTransferTransaction = announceAndValidate(type, sender, transferTransaction);
    Assertions.assertEquals(amount, processedTransferTransaction.getMosaics().get(0).getAmount());
    System.out.println(toJson(processedTransferTransaction));
    Assertions.assertTrue(processedTransferTransaction.getMosaics().get(0).getId() instanceof NamespaceId);
    Assertions.assertTrue(processedTransferTransaction.getRecipient() instanceof NamespaceId);
    return processedTransferTransaction;
}
Also used : PlainMessage(io.nem.symbol.sdk.model.message.PlainMessage) TransferTransactionFactory(io.nem.symbol.sdk.model.transaction.TransferTransactionFactory) NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) Mosaic(io.nem.symbol.sdk.model.mosaic.Mosaic)

Aggregations

TransferTransactionFactory (io.nem.symbol.sdk.model.transaction.TransferTransactionFactory)7 PlainMessage (io.nem.symbol.sdk.model.message.PlainMessage)4 Mosaic (io.nem.symbol.sdk.model.mosaic.Mosaic)4 AggregateTransaction (io.nem.symbol.sdk.model.transaction.AggregateTransaction)3 TransferTransaction (io.nem.symbol.sdk.model.transaction.TransferTransaction)3 NamespaceId (io.nem.symbol.sdk.model.namespace.NamespaceId)2 HashLockTransaction (io.nem.symbol.sdk.model.transaction.HashLockTransaction)2 SignedTransaction (io.nem.symbol.sdk.model.transaction.SignedTransaction)2 BigInteger (java.math.BigInteger)2 ArrayList (java.util.ArrayList)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 EnumSource (org.junit.jupiter.params.provider.EnumSource)2 UnresolvedMosaic (io.nem.symbol.sdk.openapi.okhttp_gson.model.UnresolvedMosaic)1 UnresolvedMosaic (io.nem.symbol.sdk.openapi.vertx.model.UnresolvedMosaic)1