Search in sources :

Example 1 with MosaicSupplyChangeTransaction

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

the class TransactionMapperVertxTest method shouldCreateStandaloneMosaicSupplyChangeTransaction.

@Test
void shouldCreateStandaloneMosaicSupplyChangeTransaction() {
    TransactionInfoDTO mosaicSupplyChangeTransactionDTO = TestHelperVertx.loadTransactionInfoDTO("standaloneMosaicSupplyChangeTransaction.json");
    Transaction mosaicSupplyChangeTransaction = map(mosaicSupplyChangeTransactionDTO);
    validateStandaloneTransaction(mosaicSupplyChangeTransaction, mosaicSupplyChangeTransactionDTO);
}
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 2 with MosaicSupplyChangeTransaction

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

the class TransactionMapperVertxTest method validateStandaloneTransaction.

void validateStandaloneTransaction(Transaction transaction, TransactionInfoDTO transactionDTO, TransactionInfoDTO parentTransaction) {
    TransactionMetaDTO meta = jsonHelper.convert(transactionDTO.getMeta(), TransactionMetaDTO.class);
    if (transaction.getTransactionInfo().isPresent()) {
        TransactionInfo transactionInfo = transaction.getTransactionInfo().get();
        assertEquals(meta.getHeight(), transactionInfo.getHeight());
        if (transactionInfo.getHash().isPresent()) {
            assertEquals(meta.getHash(), transactionInfo.getHash().get());
        }
        if (transactionInfo.getMerkleComponentHash().isPresent()) {
            assertEquals(meta.getMerkleComponentHash(), transactionInfo.getMerkleComponentHash().get());
        }
        if (transactionInfo.getIndex().isPresent()) {
            assertEquals(transactionInfo.getIndex().get(), meta.getIndex());
        }
    }
    // if (transaction.getTransactionInfo().get().getId().isPresent()) {
    // assertEquals(
    // transactionDTO.getMeta().getId(),
    // transaction.getTransactionInfo().get().getId().get());
    // }
    // if (transaction.getTransactionInfo().get().getAggregateHash().isPresent()) {
    // assertEquals(
    // transactionDTO.getMeta().getAggregateHash(),
    // transaction.getTransactionInfo().get().getAggregateHash().get());
    // }
    // if (transaction.getTransactionInfo().get().getAggregateId().isPresent()) {
    // assertEquals(
    // transactionDTO.getMeta().getAggregateId(),
    // transaction.getTransactionInfo().get().getAggregateId().get());
    // }
    assertEquals(jsonHelper.getString(parentTransaction.getTransaction(), "signature"), transaction.getSignature().get());
    assertEquals(jsonHelper.getString(transactionDTO.getTransaction(), "signerPublicKey"), transaction.getSigner().get().getPublicKey().toHex());
    assertEquals(transaction.getType().getValue(), (int) jsonHelper.getInteger(transactionDTO.getTransaction(), "type"));
    int version = jsonHelper.getInteger(transactionDTO.getTransaction(), "version");
    assertEquals((int) transaction.getVersion(), version);
    int networkType = jsonHelper.getInteger(transactionDTO.getTransaction(), "network");
    assertEquals(transaction.getNetworkType().getValue(), networkType);
    assertEquals(jsonHelper.getBigInteger(parentTransaction.getTransaction(), "maxFee"), transaction.getMaxFee());
    assertNotNull(transaction.getDeadline());
    if (transaction.getType() == TransactionType.TRANSFER) {
        validateTransferTx((TransferTransaction) transaction, transactionDTO);
    } else if (transaction.getType() == TransactionType.NAMESPACE_REGISTRATION) {
        validateNamespaceCreationTx((NamespaceRegistrationTransaction) transaction, transactionDTO);
    } else if (transaction.getType() == TransactionType.MOSAIC_DEFINITION) {
        validateMosaicCreationTx((MosaicDefinitionTransaction) transaction, transactionDTO);
    } else if (transaction.getType() == TransactionType.MOSAIC_SUPPLY_CHANGE) {
        validateMosaicSupplyChangeTx((MosaicSupplyChangeTransaction) transaction, transactionDTO);
    } else if (transaction.getType() == TransactionType.MULTISIG_ACCOUNT_MODIFICATION) {
        validateMultisigModificationTx((MultisigAccountModificationTransaction) transaction, transactionDTO);
    } else if (transaction.getType() == TransactionType.HASH_LOCK) {
        validateLockFundsTx((HashLockTransaction) transaction, transactionDTO);
    } else if (transaction.getType() == TransactionType.SECRET_LOCK) {
        validateSecretLockTx((SecretLockTransaction) transaction, transactionDTO);
    } else if (transaction.getType() == TransactionType.SECRET_PROOF) {
        validateSecretProofTx((SecretProofTransaction) transaction, transactionDTO);
    }
}
Also used : MosaicSupplyChangeTransaction(io.nem.symbol.sdk.model.transaction.MosaicSupplyChangeTransaction) HashLockTransaction(io.nem.symbol.sdk.model.transaction.HashLockTransaction) TransactionInfo(io.nem.symbol.sdk.model.transaction.TransactionInfo) TransactionMetaDTO(io.nem.symbol.sdk.openapi.vertx.model.TransactionMetaDTO) SecretProofTransaction(io.nem.symbol.sdk.model.transaction.SecretProofTransaction) NamespaceRegistrationTransaction(io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction)

Example 3 with MosaicSupplyChangeTransaction

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

the class TestHelper method createMosaic.

protected MosaicId createMosaic(Account account, RepositoryType type, BigInteger initialSupply, String alias) {
    MosaicNonce nonce = MosaicNonce.createRandom();
    MosaicId mosaicId = MosaicId.createFromNonce(nonce, account.getPublicAccount());
    MosaicDefinitionTransaction mosaicDefinitionTransaction = MosaicDefinitionTransactionFactory.create(getNetworkType(), getDeadline(), nonce, mosaicId, MosaicFlags.create(true, true, true), 4, new BlockDuration(100)).maxFee(maxFee).build();
    MosaicDefinitionTransaction validateTransaction = announceAndValidate(type, account, mosaicDefinitionTransaction);
    Assertions.assertEquals(mosaicId, validateTransaction.getMosaicId());
    UnresolvedMosaicId unresolvedMosaicId = mosaicId;
    if (alias != null) {
        NamespaceId rootNamespaceId = createRootNamespace(type, account, alias);
        unresolvedMosaicId = rootNamespaceId;
        MosaicAliasTransaction addressAliasTransaction = MosaicAliasTransactionFactory.create(getNetworkType(), getDeadline(), AliasAction.LINK, rootNamespaceId, mosaicId).maxFee(maxFee).build();
        announceAggregateAndValidate(type, addressAliasTransaction, account);
    }
    if (initialSupply != null && initialSupply.longValue() > 0) {
        MosaicSupplyChangeTransaction mosaicSupplyChangeTransaction = MosaicSupplyChangeTransactionFactory.create(getNetworkType(), getDeadline(), unresolvedMosaicId, MosaicSupplyChangeActionType.INCREASE, initialSupply).maxFee(maxFee).build();
        announceAndValidate(type, account, mosaicSupplyChangeTransaction);
    }
    return mosaicId;
}
Also used : MosaicSupplyChangeTransaction(io.nem.symbol.sdk.model.transaction.MosaicSupplyChangeTransaction) BlockDuration(io.nem.symbol.sdk.model.blockchain.BlockDuration) UnresolvedMosaicId(io.nem.symbol.sdk.model.mosaic.UnresolvedMosaicId) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) MosaicNonce(io.nem.symbol.sdk.model.mosaic.MosaicNonce) NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) MosaicAliasTransaction(io.nem.symbol.sdk.model.transaction.MosaicAliasTransaction) MosaicDefinitionTransaction(io.nem.symbol.sdk.model.transaction.MosaicDefinitionTransaction) UnresolvedMosaicId(io.nem.symbol.sdk.model.mosaic.UnresolvedMosaicId)

Example 4 with MosaicSupplyChangeTransaction

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

the class MosaicDefinitionTransactionIntegrationTest method aggregateMosaicSupplyChangeTransaction.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void aggregateMosaicSupplyChangeTransaction(RepositoryType type) {
    MosaicId mosaicId = createMosaic(type);
    MosaicSupplyChangeTransaction mosaicSupplyChangeTransaction = MosaicSupplyChangeTransactionFactory.create(getNetworkType(), getDeadline(), mosaicId, MosaicSupplyChangeActionType.INCREASE, BigInteger.valueOf(12)).maxFee(maxFee).build();
    announceAggregateAndValidate(type, mosaicSupplyChangeTransaction, account);
}
Also used : MosaicSupplyChangeTransaction(io.nem.symbol.sdk.model.transaction.MosaicSupplyChangeTransaction) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with MosaicSupplyChangeTransaction

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

the class TransactionMapperOkHttpTest method shouldCreateStandaloneMosaicSupplyChangeTransaction.

@Test
void shouldCreateStandaloneMosaicSupplyChangeTransaction() {
    TransactionInfoDTO mosaicSupplyChangeTransactionDTO = TestHelperOkHttp.loadTransactionInfoDTO("standaloneMosaicSupplyChangeTransaction.json");
    Transaction mosaicSupplyChangeTransaction = map(mosaicSupplyChangeTransactionDTO);
    validateStandaloneTransaction(mosaicSupplyChangeTransaction, mosaicSupplyChangeTransactionDTO);
}
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.okhttp_gson.model.TransactionInfoDTO) Test(org.junit.jupiter.api.Test)

Aggregations

MosaicSupplyChangeTransaction (io.nem.symbol.sdk.model.transaction.MosaicSupplyChangeTransaction)8 HashLockTransaction (io.nem.symbol.sdk.model.transaction.HashLockTransaction)4 NamespaceRegistrationTransaction (io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction)4 SecretProofTransaction (io.nem.symbol.sdk.model.transaction.SecretProofTransaction)4 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)3 MosaicAliasTransaction (io.nem.symbol.sdk.model.transaction.MosaicAliasTransaction)3 MosaicDefinitionTransaction (io.nem.symbol.sdk.model.transaction.MosaicDefinitionTransaction)3 Test (org.junit.jupiter.api.Test)3 AccountAddressRestrictionTransaction (io.nem.symbol.sdk.model.transaction.AccountAddressRestrictionTransaction)2 AccountKeyLinkTransaction (io.nem.symbol.sdk.model.transaction.AccountKeyLinkTransaction)2 AccountMetadataTransaction (io.nem.symbol.sdk.model.transaction.AccountMetadataTransaction)2 AccountMosaicRestrictionTransaction (io.nem.symbol.sdk.model.transaction.AccountMosaicRestrictionTransaction)2 AccountOperationRestrictionTransaction (io.nem.symbol.sdk.model.transaction.AccountOperationRestrictionTransaction)2 AddressAliasTransaction (io.nem.symbol.sdk.model.transaction.AddressAliasTransaction)2 AggregateTransaction (io.nem.symbol.sdk.model.transaction.AggregateTransaction)2 MosaicMetadataTransaction (io.nem.symbol.sdk.model.transaction.MosaicMetadataTransaction)2 MultisigAccountModificationTransaction (io.nem.symbol.sdk.model.transaction.MultisigAccountModificationTransaction)2 NamespaceMetadataTransaction (io.nem.symbol.sdk.model.transaction.NamespaceMetadataTransaction)2 SecretLockTransaction (io.nem.symbol.sdk.model.transaction.SecretLockTransaction)2 Transaction (io.nem.symbol.sdk.model.transaction.Transaction)2