use of io.nem.symbol.sdk.model.transaction.MosaicGlobalRestrictionTransactionFactory in project nem2-sdk-java by nemtech.
the class TransactionServiceImpl method resolveTransactionFactory.
private Observable<TransactionFactory<? extends Transaction>> resolveTransactionFactory(MosaicGlobalRestrictionTransaction transaction, ReceiptSource expectedReceiptSource, Observable<List<MosaicResolutionStatement>> mosaicResolutionStatements) {
Observable<MosaicId> resolvedMosaicId = getResolvedMosaicId(transaction, transaction.getMosaicId(), mosaicResolutionStatements, expectedReceiptSource);
Observable<MosaicId> resolvedReferenceMosaicId = getResolvedMosaicId(transaction, transaction.getReferenceMosaicId(), mosaicResolutionStatements, expectedReceiptSource);
return Observable.combineLatest(resolvedMosaicId, resolvedReferenceMosaicId, (mosaicId, referenceMosaicId) -> {
MosaicGlobalRestrictionTransactionFactory factory = MosaicGlobalRestrictionTransactionFactory.create(transaction.getNetworkType(), transaction.getDeadline(), mosaicId, transaction.getRestrictionKey(), transaction.getNewRestrictionValue(), transaction.getNewRestrictionType());
if (referenceMosaicId != null) {
factory.referenceMosaicId(referenceMosaicId);
}
return factory.previousRestrictionValue(transaction.getPreviousRestrictionValue()).previousRestrictionType(transaction.getPreviousRestrictionType());
});
}
use of io.nem.symbol.sdk.model.transaction.MosaicGlobalRestrictionTransactionFactory in project nem2-sdk-java by nemtech.
the class MosaicGlobalRestrictionTransactionMapper method createFactory.
@Override
protected TransactionFactory<MosaicGlobalRestrictionTransaction> createFactory(NetworkType networkType, Deadline deadline, MosaicGlobalRestrictionTransactionDTO transaction) {
byte prevRestrictionType = transaction.getPreviousRestrictionType().getValue().byteValue();
byte newRestrictionType = transaction.getNewRestrictionType().getValue().byteValue();
MosaicGlobalRestrictionTransactionFactory factory = MosaicGlobalRestrictionTransactionFactory.create(networkType, deadline, toUnresolvedMosaicId(transaction.getMosaicId()), MapperUtils.fromHexToBigInteger(transaction.getRestrictionKey()), transaction.getNewRestrictionValue(), MosaicRestrictionType.rawValueOf(newRestrictionType));
if (transaction.getReferenceMosaicId() != null) {
factory.referenceMosaicId(MapperUtils.toUnresolvedMosaicId(transaction.getReferenceMosaicId()));
}
return factory.previousRestrictionValue(transaction.getPreviousRestrictionValue()).previousRestrictionType(MosaicRestrictionType.rawValueOf(prevRestrictionType));
}
use of io.nem.symbol.sdk.model.transaction.MosaicGlobalRestrictionTransactionFactory in project nem2-sdk-java by nemtech.
the class MosaicGlobalRestrictionTransactionMapper method createFactory.
@Override
protected TransactionFactory<MosaicGlobalRestrictionTransaction> createFactory(NetworkType networkType, Deadline deadline, MosaicGlobalRestrictionTransactionDTO transaction) {
byte prevRestrictionType = transaction.getPreviousRestrictionType().getValue().byteValue();
byte newRestrictionType = transaction.getNewRestrictionType().getValue().byteValue();
MosaicGlobalRestrictionTransactionFactory factory = MosaicGlobalRestrictionTransactionFactory.create(networkType, deadline, toUnresolvedMosaicId(transaction.getMosaicId()), MapperUtils.fromHexToBigInteger(transaction.getRestrictionKey()), transaction.getNewRestrictionValue(), MosaicRestrictionType.rawValueOf(newRestrictionType));
if (transaction.getReferenceMosaicId() != null) {
factory.referenceMosaicId(MapperUtils.toUnresolvedMosaicId(transaction.getReferenceMosaicId()));
}
return factory.previousRestrictionValue(transaction.getPreviousRestrictionValue()).previousRestrictionType(MosaicRestrictionType.rawValueOf(prevRestrictionType));
}
use of io.nem.symbol.sdk.model.transaction.MosaicGlobalRestrictionTransactionFactory in project nem2-sdk-java by nemtech.
the class TransactionServiceTest method mosaicGlobalRestrictionTransactionResolveAlias.
@Test
void mosaicGlobalRestrictionTransactionResolveAlias() throws ExecutionException, InterruptedException {
String transactionHash = "aaaa";
MosaicGlobalRestrictionTransactionFactory mosaicGlobalRestrictionTransactionFactory = MosaicGlobalRestrictionTransactionFactory.create(NetworkType.MIJIN_TEST, new Deadline(BigInteger.ONE), mosaicNamespace2, BigInteger.TEN, BigInteger.ONE, MosaicRestrictionType.GT);
mosaicGlobalRestrictionTransactionFactory.referenceMosaicId(mosaicNamespace3);
mosaicGlobalRestrictionTransactionFactory.previousRestrictionType(MosaicRestrictionType.EQ);
mosaicGlobalRestrictionTransactionFactory.previousRestrictionValue(BigInteger.valueOf(3));
TransactionFactory<MosaicGlobalRestrictionTransaction> factory = mosaicGlobalRestrictionTransactionFactory.transactionInfo(TransactionInfo.create(height, 0, "ABC", transactionHash, ""));
MosaicGlobalRestrictionTransaction transaction = factory.build();
simulateStatement(height, 1, 0);
List<String> hashes = Collections.singletonList(transactionHash);
Mockito.when(transactionRepositoryMock.getTransactions(Mockito.eq(TransactionGroup.CONFIRMED), Mockito.eq(hashes))).thenReturn(Observable.just(Collections.singletonList(transaction)));
MosaicGlobalRestrictionTransaction resolvedTransaction = (MosaicGlobalRestrictionTransaction) service.resolveAliases(hashes).toFuture().get().get(0);
Assertions.assertEquals(mosaicId2, resolvedTransaction.getMosaicId());
Assertions.assertEquals(mosaicId3, resolvedTransaction.getReferenceMosaicId());
}
Aggregations