Search in sources :

Example 1 with MosaicDefinitionTransaction

use of io.nem.symbol.sdk.model.transaction.MosaicDefinitionTransaction 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 2 with MosaicDefinitionTransaction

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

the class MosaicDefinitionTransactionIntegrationTest method createMosaic.

private MosaicId createMosaic(RepositoryType type) {
    MosaicNonce nonce = MosaicNonce.createRandom();
    MosaicId mosaicId = MosaicId.createFromNonce(nonce, this.account.getPublicAccount());
    MosaicDefinitionTransaction mosaicDefinitionTransaction = MosaicDefinitionTransactionFactory.create(getNetworkType(), getDeadline(), nonce, mosaicId, MosaicFlags.create(true, true, true), 4, new BlockDuration(100)).maxFee(maxFee).build();
    MosaicDefinitionTransaction processed = announceAndValidate(type, this.account, mosaicDefinitionTransaction);
    Assertions.assertEquals(mosaicId, processed.getMosaicId());
    Assertions.assertEquals(mosaicDefinitionTransaction.getMosaicNonce(), processed.getMosaicNonce());
    return mosaicId;
}
Also used : BlockDuration(io.nem.symbol.sdk.model.blockchain.BlockDuration) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) MosaicNonce(io.nem.symbol.sdk.model.mosaic.MosaicNonce) MosaicDefinitionTransaction(io.nem.symbol.sdk.model.transaction.MosaicDefinitionTransaction)

Example 3 with MosaicDefinitionTransaction

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

the class TransactionServiceTest method mosaicDefinitionTransactionResolveAlias.

@Test
void mosaicDefinitionTransactionResolveAlias() throws ExecutionException, InterruptedException {
    String transactionHash = "aaaa";
    TransactionFactory<MosaicDefinitionTransaction> factory = MosaicDefinitionTransactionFactory.create(NetworkType.MIJIN_TEST, new Deadline(BigInteger.ONE), MosaicNonce.createFromBigInteger(new BigInteger("0")), mosaicId2, MosaicFlags.create(true, true, true), 4, new BlockDuration(10000)).transactionInfo(TransactionInfo.create(height, 4, "ABC", transactionHash, ""));
    MosaicDefinitionTransaction transaction = factory.build();
    simulateStatement(height, 5, 0);
    List<String> hashes = Collections.singletonList(transactionHash);
    Mockito.when(transactionRepositoryMock.getTransactions(Mockito.eq(TransactionGroup.CONFIRMED), Mockito.eq(hashes))).thenReturn(Observable.just(Collections.singletonList(transaction)));
    MosaicDefinitionTransaction resolvedTransaction = (MosaicDefinitionTransaction) service.resolveAliases(hashes).toFuture().get().get(0);
    Assertions.assertEquals(mosaicId2, resolvedTransaction.getMosaicId());
}
Also used : BlockDuration(io.nem.symbol.sdk.model.blockchain.BlockDuration) Deadline(io.nem.symbol.sdk.model.transaction.Deadline) BigInteger(java.math.BigInteger) MosaicDefinitionTransaction(io.nem.symbol.sdk.model.transaction.MosaicDefinitionTransaction) Test(org.junit.jupiter.api.Test)

Example 4 with MosaicDefinitionTransaction

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

the class MosaicDefinitionTransactionIntegrationTest method aggregateMosaicDefinitionTransaction.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void aggregateMosaicDefinitionTransaction(RepositoryType type) {
    MosaicNonce nonce = MosaicNonce.createRandom();
    MosaicId mosaicId = MosaicId.createFromNonce(nonce, this.account.getPublicAccount());
    MosaicDefinitionTransaction mosaicDefinitionTransaction = MosaicDefinitionTransactionFactory.create(getNetworkType(), getDeadline(), nonce, mosaicId, MosaicFlags.create(true, false, true), 4, new BlockDuration(100)).maxFee(maxFee).build();
    MosaicDefinitionTransaction processed = announceAggregateAndValidate(type, mosaicDefinitionTransaction, this.account).getLeft();
    Assertions.assertEquals(mosaicDefinitionTransaction.getMosaicNonce(), processed.getMosaicNonce());
    Assertions.assertEquals(mosaicId, processed.getMosaicId());
}
Also used : BlockDuration(io.nem.symbol.sdk.model.blockchain.BlockDuration) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) MosaicNonce(io.nem.symbol.sdk.model.mosaic.MosaicNonce) MosaicDefinitionTransaction(io.nem.symbol.sdk.model.transaction.MosaicDefinitionTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

BlockDuration (io.nem.symbol.sdk.model.blockchain.BlockDuration)4 MosaicDefinitionTransaction (io.nem.symbol.sdk.model.transaction.MosaicDefinitionTransaction)4 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)3 MosaicNonce (io.nem.symbol.sdk.model.mosaic.MosaicNonce)3 UnresolvedMosaicId (io.nem.symbol.sdk.model.mosaic.UnresolvedMosaicId)1 NamespaceId (io.nem.symbol.sdk.model.namespace.NamespaceId)1 Deadline (io.nem.symbol.sdk.model.transaction.Deadline)1 MosaicAliasTransaction (io.nem.symbol.sdk.model.transaction.MosaicAliasTransaction)1 MosaicSupplyChangeTransaction (io.nem.symbol.sdk.model.transaction.MosaicSupplyChangeTransaction)1 BigInteger (java.math.BigInteger)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 EnumSource (org.junit.jupiter.params.provider.EnumSource)1