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 = MapperUtils.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 MosaicMetadataTransactionMapper method createFactory.
@Override
protected MosaicMetadataTransactionFactory createFactory(NetworkType networkType, Deadline deadline, MosaicMetadataTransactionDTO transaction) {
UnresolvedAddress targetAccount = MapperUtils.toUnresolvedAddress(transaction.getTargetAddress());
Integer valueSizeDelta = transaction.getValueSizeDelta();
BigInteger scopedMetaDataKey = MapperUtils.fromHexToBigInteger(transaction.getScopedMetadataKey());
byte[] value = ConvertUtils.fromHexToBytes(transaction.getValue());
UnresolvedMosaicId targetMosaic = MapperUtils.toUnresolvedMosaicId(transaction.getTargetMosaicId());
MosaicMetadataTransactionFactory factory = MosaicMetadataTransactionFactory.create(networkType, deadline, targetAccount, targetMosaic, 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 ListenerIntegrationTest method getAllMultisigAddressesAndAliasesWhenMultisig.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void getAllMultisigAddressesAndAliasesWhenMultisig(RepositoryType type) {
final MultisigAccountInfo multisigAccountInfo = get(getRepositoryFactory(type).createMultisigRepository().getMultisigAccountInfo(this.multisigAccount.getAddress()));
Assertions.assertEquals(Arrays.asList(this.cosignatoryAccount.getAddress(), this.cosignatoryAccount2.getAddress()), multisigAccountInfo.getCosignatoryAddresses());
Set<NamespaceId> aliases = get(getRepositoryFactory(type).createNamespaceRepository().getAccountsNames(Arrays.asList(multisigAccount.getAddress(), cosignatoryAccount.getAddress(), cosignatoryAccount2.getAddress()))).stream().flatMap(a -> a.getNames().stream().map(n -> n.getNamespaceId())).collect(Collectors.toSet());
Listener listener = getRepositoryFactory(type).createListener();
final Set<UnresolvedAddress> unresolvedAddresses = get(listener.getAllMultisigAddressesAndAliases(this.multisigAccount.getAddress()));
final Set<UnresolvedAddress> expectedAddresees = Sets.newSet(this.multisigAccount.getAddress(), this.cosignatoryAccount.getAddress(), this.cosignatoryAccount2.getAddress());
expectedAddresees.addAll(aliases);
Assertions.assertEquals(expectedAddresees, unresolvedAddresses);
}
use of io.nem.symbol.sdk.model.account.UnresolvedAddress in project nem2-sdk-java by nemtech.
the class AggregateTransactionServiceIntegrationTest method isMultisigAccountModificationTransactionAdditionComplete.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void isMultisigAccountModificationTransactionAdditionComplete(RepositoryType type) {
Account multisigAccount = helper().getMultisigAccount(type).getKey();
Account cosignatoryAccount = config().getCosignatoryAccount();
Account cosignatory2Account = config().getCosignatory2Account();
List<Account> accounts = Arrays.asList(cosignatoryAccount, cosignatory2Account);
List<UnresolvedAddress> additions = accounts.stream().map(Account::getAddress).collect(Collectors.toList());
MultisigAccountModificationTransaction multisigAccountModificationTransaction = MultisigAccountModificationTransactionFactory.create(getNetworkType(), getDeadline(), (byte) 1, (byte) 1, additions, Collections.emptyList()).maxFee(maxFee).build();
AggregateTransaction aggregateTransaction = AggregateTransactionFactory.createComplete(getNetworkType(), getDeadline(), Collections.singletonList(multisigAccountModificationTransaction.toAggregate(multisigAccount.getPublicAccount()))).maxFee(maxFee).build();
SignedTransaction signedAggregateTransaction = aggregateTransaction.signTransactionWithCosigners(multisigAccount, accounts, getGenerationHash());
AggregateTransactionService aggregateTransactionService = new AggregateTransactionServiceImpl(getRepositoryFactory(type));
Assertions.assertTrue(get(aggregateTransactionService.isComplete(signedAggregateTransaction)));
}
use of io.nem.symbol.sdk.model.account.UnresolvedAddress in project nem2-sdk-java by nemtech.
the class AggregateTransactionServiceIntegrationTest method isMultisigAccountModificationTransactionAdditionNotComplete.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void isMultisigAccountModificationTransactionAdditionNotComplete(RepositoryType type) {
Account testAccount = helper().getTestAccount(type).getLeft();
Account multisigAccount = helper().getMultisigAccount(type).getLeft();
Account cosignatoryAccount = config().getCosignatoryAccount();
Account cosignatory2Account = config().getCosignatory2Account();
List<Account> accounts = Arrays.asList(cosignatoryAccount, cosignatory2Account);
List<UnresolvedAddress> additions = accounts.stream().map(Account::getAddress).collect(Collectors.toList());
MultisigAccountModificationTransaction multisigAccountModificationTransaction = MultisigAccountModificationTransactionFactory.create(getNetworkType(), getDeadline(), (byte) 1, (byte) 1, additions, Collections.emptyList()).maxFee(maxFee).build();
AggregateTransaction aggregateTransaction = AggregateTransactionFactory.createComplete(getNetworkType(), getDeadline(), Collections.singletonList(multisigAccountModificationTransaction.toAggregate(multisigAccount.getPublicAccount()))).maxFee(maxFee).build();
SignedTransaction signedAggregateTransaction = aggregateTransaction.signTransactionWithCosigners(multisigAccount, Collections.singletonList(testAccount), getGenerationHash());
AggregateTransactionService aggregateTransactionService = new AggregateTransactionServiceImpl(getRepositoryFactory(type));
Assertions.assertFalse(get(aggregateTransactionService.isComplete(signedAggregateTransaction)));
}
Aggregations