use of io.nem.symbol.sdk.model.network.NetworkType in project nem2-sdk-java by nemtech.
the class TestnetTester method sendVotingKey2.
private static void sendVotingKey2(RepositoryFactory repositoryFactory) throws Exception {
NetworkType networkType = repositoryFactory.getNetworkType().toFuture().get();
Account account = Account.createFromPrivateKey(PRIVATE_KEY, networkType);
System.out.println(account.getAddress().plain());
Duration duration = repositoryFactory.getEpochAdjustment().toFuture().get();
Deadline deadline = Deadline.create(duration);
PublicKey votingKey = PublicKey.fromHexString("463CCC639B5306DD06E56A273E13EF08CAB8D46A8ACA1D3919F19AF89DE116C5");
VotingKeyLinkTransaction transaction = VotingKeyLinkTransactionFactory.create(networkType, deadline, votingKey, (1), (26280), LinkAction.LINK).maxFee(MAX_FEE).build();
announceTransaction(repositoryFactory, account, transaction);
}
use of io.nem.symbol.sdk.model.network.NetworkType in project nem2-sdk-java by nemtech.
the class NetworkRepositoryIntegrationTest method testNetworkType.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void testNetworkType(RepositoryType type) {
NetworkType networkType = get(getNetworkRepository(type).getNetworkType());
assertEquals(getNetworkType(), networkType);
}
use of io.nem.symbol.sdk.model.network.NetworkType in project nem2-sdk-java by nemtech.
the class RepositoryFactoryConfigurationExamplesIntegrationTest method appDoSomeStuff.
public void appDoSomeStuff(RepositoryFactory repositoryFactory) throws ExecutionException, InterruptedException {
// The application logic is exactly the same regardless of how the repository
// factory was
// set
// Note: if rest is used, these values are cached form rest
Currency currency = repositoryFactory.getNetworkCurrency().toFuture().get();
String generationHash = repositoryFactory.getGenerationHash().toFuture().get();
NetworkType networkType = repositoryFactory.getNetworkType().toFuture().get();
Account sender = Account.generateNewAccount(networkType);
Account recipient = Account.generateNewAccount(networkType);
Duration epochAdjustment = repositoryFactory.getEpochAdjustment().toFuture().get();
TransferTransaction transferTransaction = TransferTransactionFactory.create(networkType, Deadline.create(epochAdjustment), recipient.getAddress(), Collections.singletonList(currency.createRelative(BigInteger.TEN))).message(new PlainMessage("")).build();
SignedTransaction signedTransaction = transferTransaction.signWith(sender, generationHash);
// Announce or store somewhere....
}
use of io.nem.symbol.sdk.model.network.NetworkType in project nem2-sdk-java by nemtech.
the class AccountTest method shouldAcceptKeyPairAsConstructor.
@Test
void shouldAcceptKeyPairAsConstructor() {
NetworkType networkType = NetworkType.MIJIN_TEST;
KeyPair random = KeyPair.random(new Ed25519CryptoEngine());
Account account = new Account(random, networkType);
assertEquals(random.getPrivateKey().toHex().toUpperCase(), account.getPrivateKey());
assertEquals(networkType, account.getAddress().getNetworkType());
}
use of io.nem.symbol.sdk.model.network.NetworkType in project nem2-sdk-java by nemtech.
the class ResolutionStatement method serialize.
/**
* Serializes the statement using the catuffer builders
*
* @param networkType the network type.
* @return the serialized content.
*/
private byte[] serialize(NetworkType networkType) {
ReceiptType type = this.resolutionType == ResolutionType.ADDRESS ? ReceiptType.ADDRESS_ALIAS_RESOLUTION : ReceiptType.MOSAIC_ALIAS_RESOLUTION;
ReceiptTypeDto recipientTypeDto = ReceiptTypeDto.rawValueOf((short) type.getValue());
short version = (short) ReceiptVersion.RESOLUTION_STATEMENT.getValue();
Serializer serializer = this.resolutionType == ResolutionType.ADDRESS ? AddressResolutionStatementBuilder.create(version, recipientTypeDto, SerializationUtils.toUnresolvedAddress((UnresolvedAddress) this.unresolved, networkType), this.resolutionEntries.stream().map((entry) -> AddressResolutionEntryBuilder.create(ReceiptSourceBuilder.create((int) entry.getReceiptSource().getPrimaryId(), (int) entry.getReceiptSource().getSecondaryId()), SerializationUtils.toAddressDto((Address) entry.getResolved()))).collect(Collectors.toList())) : MosaicResolutionStatementBuilder.create(version, recipientTypeDto, SerializationUtils.toUnresolvedMosaicIdDto((UnresolvedMosaicId) this.unresolved), this.resolutionEntries.stream().map((entry) -> MosaicResolutionEntryBuilder.create(ReceiptSourceBuilder.create((int) entry.getReceiptSource().getPrimaryId(), (int) entry.getReceiptSource().getSecondaryId()), SerializationUtils.toMosaicIdDto((MosaicId) entry.getResolved()))).collect(Collectors.toList()));
return serializer.serialize();
}
Aggregations