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;
}
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;
}
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());
}
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());
}
Aggregations