use of io.nem.symbol.sdk.model.account.UnresolvedAddress in project nem2-sdk-java by nemtech.
the class AccountRestrictionIntegrationTest method sendAccountRestrictionAddress.
private void sendAccountRestrictionAddress(RepositoryType type, UnresolvedAddress unresolvedAddress, boolean add, AccountAddressRestrictionFlags accountRestrictionFlags) {
List<UnresolvedAddress> additions = add ? Collections.singletonList(unresolvedAddress) : Collections.emptyList();
List<UnresolvedAddress> deletions = !add ? Collections.singletonList(unresolvedAddress) : Collections.emptyList();
AccountAddressRestrictionTransaction transaction = AccountAddressRestrictionTransactionFactory.create(getNetworkType(), getDeadline(), accountRestrictionFlags, additions, deletions).maxFee(maxFee).build();
AccountAddressRestrictionTransaction processedTransaction = announceAndValidate(type, testAccount, transaction);
Assertions.assertEquals(accountRestrictionFlags, processedTransaction.getRestrictionFlags());
Assertions.assertEquals(accountRestrictionFlags, processedTransaction.getRestrictionFlags());
Assertions.assertEquals(additions, processedTransaction.getRestrictionAdditions());
Assertions.assertEquals(deletions, processedTransaction.getRestrictionDeletions());
}
use of io.nem.symbol.sdk.model.account.UnresolvedAddress in project nem2-sdk-java by nemtech.
the class ListenerVertxTest method subscribeValid.
@ParameterizedTest
@ValueSource(strings = { "CONFIRMED_ADDED", "AGGREGATE_BONDED_ADDED" })
public void subscribeValid(ListenerChannel channel) throws InterruptedException, ExecutionException, TimeoutException {
simulateWebSocketStartup();
TransactionInfoDTO transactionInfo = TestHelperVertx.loadTransactionInfoDTO("aggregateMosaicCreationTransaction.json");
ObjectNode transactionInfoDtoJsonObject = jsonHelper.convert(transactionInfo, ObjectNode.class);
Address address = Address.createFromPublicKey(jsonHelper.getString(transactionInfoDtoJsonObject, "transaction", "signerPublicKey"), NETWORK_TYPE);
String channelName = channel.toString();
List<Transaction> transactions = new ArrayList<>();
List<Throwable> exceptions = new ArrayList<>();
BiFunction<UnresolvedAddress, String, Observable<? extends Transaction>> subscriber = channel == ListenerChannel.CONFIRMED_ADDED ? listener::confirmedOrError : listener::aggregateBondedAddedOrError;
TransactionMetaDTO meta = jsonHelper.convert(transactionInfo.getMeta(), TransactionMetaDTO.class);
subscriber.apply(address, meta.getHash()).doOnError(exceptions::add).forEach(transactions::add);
handle(transactionInfoDtoJsonObject, channelName + "/" + address.plain());
Assertions.assertEquals(1, transactions.size());
Assertions.assertEquals(0, exceptions.size());
Assertions.assertEquals(address, transactions.get(0).getSigner().get().getAddress());
Mockito.verify(webSocketMock).handler(Mockito.any());
Mockito.verify(webSocketMock).writeTextMessage(jsonHelper.print(new ListenerSubscribeMessage(this.wsId, channelName + "/" + address.plain())));
Mockito.verify(webSocketMock).writeTextMessage(jsonHelper.print(new ListenerSubscribeMessage(this.wsId, "status" + "/" + address.plain())));
}
use of io.nem.symbol.sdk.model.account.UnresolvedAddress in project nem2-sdk-java by nemtech.
the class AccountAddressRestrictionTransactionMapper method createFactory.
@Override
protected AccountAddressRestrictionTransactionFactory createFactory(NetworkType networkType, Deadline deadline, AccountAddressRestrictionTransactionDTO transaction) {
AccountAddressRestrictionFlags restrictionFlags = AccountAddressRestrictionFlags.rawValueOf(transaction.getRestrictionFlags().getValue());
List<UnresolvedAddress> restrictionAdditions = transaction.getRestrictionAdditions().stream().map(MapperUtils::toUnresolvedAddress).collect(Collectors.toList());
List<UnresolvedAddress> restrictionDeletions = transaction.getRestrictionDeletions().stream().map(MapperUtils::toUnresolvedAddress).collect(Collectors.toList());
return AccountAddressRestrictionTransactionFactory.create(networkType, deadline, restrictionFlags, restrictionAdditions, restrictionDeletions);
}
use of io.nem.symbol.sdk.model.account.UnresolvedAddress in project nem2-sdk-java by nemtech.
the class AccountMetadataTransactionMapper method createFactory.
@Override
protected AccountMetadataTransactionFactory createFactory(NetworkType networkType, Deadline deadline, AccountMetadataTransactionDTO transaction) {
UnresolvedAddress targetAddress = toUnresolvedAddress(transaction.getTargetAddress());
Integer valueSizeDelta = transaction.getValueSizeDelta();
BigInteger scopedMetaDataKey = MapperUtils.fromHexToBigInteger(transaction.getScopedMetadataKey());
byte[] value = ConvertUtils.fromHexToBytes(transaction.getValue());
AccountMetadataTransactionFactory factory = AccountMetadataTransactionFactory.create(networkType, deadline, targetAddress, scopedMetaDataKey, value);
factory.valueSizeDelta(valueSizeDelta);
Long valueSize = transaction.getValueSize();
if (valueSize != null) {
factory.valueSize(valueSize);
}
return factory;
}
use of io.nem.symbol.sdk.model.account.UnresolvedAddress in project nem2-sdk-java by nemtech.
the class TransactionServiceTest method secretProofTransactionResolveAlias.
@Test
void secretProofTransactionResolveAlias() throws ExecutionException, InterruptedException {
UnresolvedAddress recipient = addressNamespace1;
String transactionHash = "aaaa";
String secret = "1118ba10229ab5778d05d9c4b7f56676a88bf9295c185acfc0f961db5408cafe";
String proof = "2228ba10229ab5778d05d9c4b7f56676a88bf9295c185acfc0f961db5408cafe";
TransactionFactory<SecretProofTransaction> factory = SecretProofTransactionFactory.create(NetworkType.MIJIN_TEST, new Deadline(BigInteger.ONE), LockHashAlgorithm.SHA3_256, recipient, secret, proof).transactionInfo(TransactionInfo.create(height, 0, "ABC", transactionHash, ""));
simulateStatement(height, 1, 0);
SecretProofTransaction transaction = factory.build();
List<String> hashes = Collections.singletonList(transactionHash);
Mockito.when(transactionRepositoryMock.getTransactions(Mockito.eq(TransactionGroup.CONFIRMED), Mockito.eq(hashes))).thenReturn(Observable.just(Collections.singletonList(transaction)));
SecretProofTransaction resolvedTransaction = (SecretProofTransaction) service.resolveAliases(hashes).toFuture().get().get(0);
Assertions.assertEquals(address1, resolvedTransaction.getRecipient());
}
Aggregations