use of io.nem.symbol.sdk.model.network.NetworkType in project nem2-sdk-java by nemtech.
the class TestnetTester method readTransactions.
private static void readTransactions(RepositoryFactory repositoryFactory) throws Exception {
String generationHash = repositoryFactory.getGenerationHash().toFuture().get();
NetworkType networkType = repositoryFactory.getNetworkType().toFuture().get();
List<Transaction> transactions = repositoryFactory.createTransactionRepository().streamer().search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED).order(OrderBy.DESC).transactionTypes(Arrays.asList(TransactionType.VOTING_KEY_LINK))).take(50).toList().blockingGet();
transactions.forEach(t -> {
System.out.println(t.getVersion());
System.out.println(t.getTransactionInfo().get().getHash().get());
System.out.println(t.createTransactionHash(ConvertUtils.toHex(t.serialize()), ConvertUtils.fromHexToBytes(generationHash)));
});
}
use of io.nem.symbol.sdk.model.network.NetworkType in project nem2-sdk-java by nemtech.
the class TransferTransactionIntegrationTest method transferTransactionNotEnoughFundAccount.
@ParameterizedTest
@EnumSource(RepositoryType.class)
public void transferTransactionNotEnoughFundAccount(RepositoryType type) {
Address recipient = config().getTestAccount2().getAddress();
NetworkType networkType = getNetworkType();
Account account = Account.generateNewAccount(networkType);
TransferTransaction transferTransaction = TransferTransactionFactory.create(getNetworkType(), getDeadline(), recipient, Collections.singletonList(getNetworkCurrency().createAbsolute(BigInteger.valueOf(1000000000)))).message(new PlainMessage("")).maxFee(maxFee).build();
IllegalArgumentException exceptions = Assertions.assertThrows(IllegalArgumentException.class, () -> announceAndValidate(type, account, transferTransaction));
Assertions.assertTrue(exceptions.getMessage().contains("Failure_Core_Insufficient_Balance"));
}
use of io.nem.symbol.sdk.model.network.NetworkType in project nem2-sdk-java by nemtech.
the class BinarySerializationImpl method toTransaction.
/**
* It converts a {@link EmbeddedTransactionBuilder} to a {@link Transaction}
*
* @param builder the builder
* @return the {@link Transaction} model.
*/
private Transaction toTransaction(EmbeddedTransactionBuilder builder) {
TransactionType transactionType = TransactionType.rawValueOf(SerializationUtils.shortToUnsignedInt(builder.getType().getValue()));
NetworkType networkType = NetworkType.rawValueOf(SerializationUtils.byteToUnsignedInt(builder.getNetwork().getValue()));
TransactionFactory<?> factory = resolveSerializer(transactionType, builder.getVersion()).fromBodyBuilder(networkType, new Deadline(BigInteger.ZERO), builder.getBody());
factory.signer(SerializationUtils.toPublicAccount(builder.getSignerPublicKey(), networkType));
factory.version(SerializationUtils.byteToUnsignedInt(builder.getVersion()));
return factory.build();
}
use of io.nem.symbol.sdk.model.network.NetworkType in project nem2-sdk-java by nemtech.
the class NetworkRepositoryOkHttpImplTest method shouldGetNetworkType.
@Test
void shouldGetNetworkType() throws Exception {
NodeInfoDTO dto = new NodeInfoDTO();
dto.setNetworkIdentifier(NetworkType.MIJIN_TEST.getValue());
mockRemoteCall(dto);
NetworkType info = repository.getNetworkType().toFuture().get();
Assertions.assertNotNull(info);
Assertions.assertEquals(NetworkType.MIJIN_TEST, info);
}
use of io.nem.symbol.sdk.model.network.NetworkType in project nem2-sdk-java by nemtech.
the class BlockRepositoryVertxImpl method toBlockInfo.
public static BlockInfo toBlockInfo(BlockInfoDTO blockInfoDTO, JsonHelper jsonHelper) {
ImportanceBlockDTO block = jsonHelper.convert(blockInfoDTO.getBlock(), ImportanceBlockDTO.class);
NetworkType networkType = NetworkType.rawValueOf(block.getNetwork().getValue());
BlockType type = BlockType.rawValueOf(block.getType());
// Remove before public net release
if (type == BlockType.NORMAL_BLOCK || block.getVotingEligibleAccountsCount() == null)
return new BlockInfo(blockInfoDTO.getId(), block.getSize(), blockInfoDTO.getMeta().getHash(), blockInfoDTO.getMeta().getGenerationHash(), blockInfoDTO.getMeta().getTotalFee(), blockInfoDTO.getMeta().getStateHashSubCacheMerkleRoots(), blockInfoDTO.getMeta().getTransactionsCount(), blockInfoDTO.getMeta().getTotalTransactionsCount(), blockInfoDTO.getMeta().getStatementsCount(), blockInfoDTO.getMeta().getStateHashSubCacheMerkleRoots(), block.getSignature(), PublicAccount.createFromPublicKey(block.getSignerPublicKey(), networkType), networkType, block.getVersion(), type, block.getHeight(), block.getTimestamp(), block.getDifficulty(), block.getFeeMultiplier(), block.getPreviousBlockHash(), block.getTransactionsHash(), block.getReceiptsHash(), block.getStateHash(), block.getProofGamma(), block.getProofScalar(), block.getProofVerificationHash(), MapperUtils.toAddress(block.getBeneficiaryAddress()));
else {
return new ImportanceBlockInfo(blockInfoDTO.getId(), block.getSize(), blockInfoDTO.getMeta().getHash(), blockInfoDTO.getMeta().getGenerationHash(), blockInfoDTO.getMeta().getTotalFee(), blockInfoDTO.getMeta().getStateHashSubCacheMerkleRoots(), blockInfoDTO.getMeta().getTransactionsCount(), blockInfoDTO.getMeta().getTotalTransactionsCount(), blockInfoDTO.getMeta().getStatementsCount(), blockInfoDTO.getMeta().getStateHashSubCacheMerkleRoots(), block.getSignature(), PublicAccount.createFromPublicKey(block.getSignerPublicKey(), networkType), networkType, block.getVersion(), type, block.getHeight(), block.getTimestamp(), block.getDifficulty(), block.getFeeMultiplier(), block.getPreviousBlockHash(), block.getTransactionsHash(), block.getReceiptsHash(), block.getStateHash(), block.getProofGamma(), block.getProofScalar(), block.getProofVerificationHash(), MapperUtils.toAddress(block.getBeneficiaryAddress()), block.getVotingEligibleAccountsCount(), block.getHarvestingEligibleAccountsCount(), block.getTotalVotingBalance(), block.getPreviousImportanceBlockHash());
}
}
Aggregations