use of io.nem.symbol.sdk.model.account.UnresolvedAddress in project nem2-sdk-java by nemtech.
the class ListenerIntegrationTest method getAllMultisigAddressesAndAliasesWhenBasic.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void getAllMultisigAddressesAndAliasesWhenBasic(RepositoryType type) {
Account testAccount = this.helper().getTestAccount(type).getKey();
Set<NamespaceId> cosignatoryAccount1aliases = get(getRepositoryFactory(type).createNamespaceRepository().getAccountsNames(Collections.singletonList(testAccount.getAddress()))).stream().flatMap(a -> a.getNames().stream().map(NamespaceName::getNamespaceId)).collect(Collectors.toSet());
Listener listener = getRepositoryFactory(type).createListener();
final Set<UnresolvedAddress> unresolvedAddresses = get(listener.getAllMultisigAddressesAndAliases(testAccount.getAddress()));
final Set<UnresolvedAddress> expectedAddresees = Sets.newSet(testAccount.getAddress());
expectedAddresees.addAll(cosignatoryAccount1aliases);
Assertions.assertEquals(expectedAddresees, unresolvedAddresses);
}
use of io.nem.symbol.sdk.model.account.UnresolvedAddress in project nem2-sdk-java by nemtech.
the class MultisigRepositoryIntegrationTest method getMultisigAccountInfo.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void getMultisigAccountInfo(RepositoryType type) {
Account multisigAccount = helper().getMultisigAccount(type).getLeft();
Account cosignatoryAccount = config().getCosignatoryAccount();
Account cosignatory2Account = config().getCosignatory2Account();
System.out.println(multisigAccount.getAddress().plain());
MultisigAccountInfo multisigAccountInfo = get(getRepositoryFactory(type).createMultisigRepository().getMultisigAccountInfo(multisigAccount.getAddress()));
Set<UnresolvedAddress> cosignatoriesSet = new HashSet<>(multisigAccountInfo.getCosignatoryAddresses());
Assertions.assertEquals(Sets.newSet(cosignatoryAccount.getAddress(), cosignatory2Account.getAddress()), cosignatoriesSet);
Assertions.assertTrue(multisigAccountInfo.isMultisig());
assertEquals(multisigAccount.getAddress(), multisigAccountInfo.getAccountAddress());
Assertions.assertEquals(1, multisigAccountInfo.getMinApproval());
Assertions.assertEquals(1, multisigAccountInfo.getMinRemoval());
}
use of io.nem.symbol.sdk.model.account.UnresolvedAddress in project nem2-sdk-java by nemtech.
the class ListenerBase method toStatus.
private TransactionStatusError toStatus(Object message, String channelParams) {
UnresolvedAddress unresolvedAddress = getUnresolvedAddress(channelParams);
String hash = jsonHelper.getString(message, "hash");
String code = jsonHelper.getString(message, "code");
Deadline deadline = new Deadline(new BigInteger(jsonHelper.getString(message, "deadline")));
return (new TransactionStatusError(unresolvedAddress, hash, code, deadline));
}
use of io.nem.symbol.sdk.model.account.UnresolvedAddress in project nem2-sdk-java by nemtech.
the class NamespaceMetadataTransactionMapper method createFactory.
@Override
protected NamespaceMetadataTransactionFactory createFactory(NetworkType networkType, Deadline deadline, NamespaceMetadataTransactionDTO transaction) {
UnresolvedAddress targetAddress = MapperUtils.toUnresolvedAddress(transaction.getTargetAddress());
Integer valueSizeDelta = transaction.getValueSizeDelta();
BigInteger scopedMetaDataKey = MapperUtils.fromHexToBigInteger(transaction.getScopedMetadataKey());
byte[] value = ConvertUtils.fromHexToBytes(transaction.getValue());
NamespaceId targetNamespace = MapperUtils.toNamespaceId(transaction.getTargetNamespaceId());
NamespaceMetadataTransactionFactory factory = NamespaceMetadataTransactionFactory.create(networkType, deadline, targetAddress, targetNamespace, 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 getAllMultisigAddressesAndAliasesWhenCosign.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void getAllMultisigAddressesAndAliasesWhenCosign(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(cosignatoryAccount.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.cosignatoryAccount.getAddress()));
final Set<UnresolvedAddress> expectedAddresees = Sets.newSet(this.cosignatoryAccount.getAddress());
expectedAddresees.addAll(aliases);
Assertions.assertEquals(expectedAddresees, unresolvedAddresses);
}
Aggregations