Search in sources :

Example 11 with MultisigAccountInfo

use of io.nem.symbol.sdk.model.account.MultisigAccountInfo in project nem2-sdk-java by nemtech.

the class MerkleLoaderIntegrationTest method multisigMerkles.

@Test
void multisigMerkles() {
    RepositoryFactory repositoryFactory = getRepositoryFactory(DEFAULT_REPOSITORY_TYPE);
    MultisigAccountInfo state = get(repositoryFactory.createMultisigRepository().getMultisigAccountInfo(Address.createFromRawAddress("TCFAEINOWAAPSGT2OCBCZYMH2Q3PGHQPEYTIUKI")));
    StateProofServiceImpl service = new StateProofServiceImpl(repositoryFactory);
    StateMerkleProof<MultisigAccountInfo> proof = get(service.multisig(state));
    Assertions.assertTrue(proof.isValid(), "Invalid proof " + proof.getState().getAccountAddress().plain());
}
Also used : MultisigAccountInfo(io.nem.symbol.sdk.model.account.MultisigAccountInfo) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 12 with MultisigAccountInfo

use of io.nem.symbol.sdk.model.account.MultisigAccountInfo in project nem2-sdk-java by nemtech.

the class AAASetupIntegrationTest method createMultisigAccountBondedUsingNemesis.

@Test
@Order(7)
void createMultisigAccountBondedUsingNemesis() {
    Account multisig = config().getNemesisAccount8();
    RepositoryFactory repositoryFactory = getRepositoryFactory(DEFAULT_REPOSITORY_TYPE);
    MultisigAccountInfo info = helper().createMultisigAccountBonded(type, multisig, config().getNemesisAccount9(), config().getNemesisAccount10());
    StateProofService service = new StateProofServiceImpl(repositoryFactory);
    StateMerkleProof<MultisigAccountInfo> proof = get(service.multisig(info));
    Assertions.assertTrue(proof.isValid());
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) StateProofService(io.nem.symbol.sdk.api.StateProofService) MultisigAccountInfo(io.nem.symbol.sdk.model.account.MultisigAccountInfo) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 13 with MultisigAccountInfo

use of io.nem.symbol.sdk.model.account.MultisigAccountInfo in project nem2-sdk-java by nemtech.

the class AAASetupIntegrationTest method createMultisigAccountCompleteUsingNemesis.

@Test
@Order(6)
void createMultisigAccountCompleteUsingNemesis() {
    Account multisig = config().getNemesisAccount8();
    System.out.println(multisig.getAddress().plain());
    RepositoryFactory repositoryFactory = getRepositoryFactory(DEFAULT_REPOSITORY_TYPE);
    MultisigAccountInfo info = helper().createMultisigAccountComplete(type, multisig, config().getNemesisAccount9(), config().getNemesisAccount10());
    StateProofService service = new StateProofServiceImpl(repositoryFactory);
    StateMerkleProof<MultisigAccountInfo> proof = get(service.multisig(info));
    Assertions.assertTrue(proof.isValid());
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) StateProofService(io.nem.symbol.sdk.api.StateProofService) MultisigAccountInfo(io.nem.symbol.sdk.model.account.MultisigAccountInfo) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 14 with MultisigAccountInfo

use of io.nem.symbol.sdk.model.account.MultisigAccountInfo in project nem2-sdk-java by nemtech.

the class TestHelper method isMultisig.

public boolean isMultisig(RepositoryType type, Account multisigAccount) {
    try {
        MultisigRepository multisigRepository = getRepositoryFactory(type).createMultisigRepository();
        MultisigAccountInfo multisigAccountInfo = get(multisigRepository.getMultisigAccountInfo(multisigAccount.getAddress()));
        return multisigAccountInfo != null;
    } catch (RepositoryCallException e) {
        Assertions.assertEquals(404, e.getStatusCode());
        return false;
    }
}
Also used : MultisigRepository(io.nem.symbol.sdk.api.MultisigRepository) RepositoryCallException(io.nem.symbol.sdk.api.RepositoryCallException) MultisigAccountInfo(io.nem.symbol.sdk.model.account.MultisigAccountInfo)

Example 15 with MultisigAccountInfo

use of io.nem.symbol.sdk.model.account.MultisigAccountInfo in project nem2-sdk-java by nemtech.

the class TestHelper method createMultisigAccountComplete.

public MultisigAccountInfo createMultisigAccountComplete(RepositoryType type, Account multisigAccount, Account... accounts) {
    AccountRepository accountRepository = getRepositoryFactory(type).createAccountRepository();
    MultisigRepository multisigRepository = getRepositoryFactory(type).createMultisigRepository();
    AccountInfo accountInfo = get(accountRepository.getAccountInfo(multisigAccount.getAddress()));
    System.out.println(getJsonHelper().print(accountInfo));
    try {
        MultisigAccountInfo multisigAccountInfo = get(multisigRepository.getMultisigAccountInfo(multisigAccount.getAddress()));
        System.out.println("Multisig account with address " + multisigAccount.getAddress().plain() + " already exist");
        System.out.println(getJsonHelper().print(multisigAccountInfo));
        return multisigAccountInfo;
    } catch (RepositoryCallException e) {
        System.out.println("Multisig account with address " + multisigAccount.getAddress().plain() + " does not exist. Creating");
    }
    System.out.println("Creating multisg account " + multisigAccount.getAddress().plain());
    List<UnresolvedAddress> additions = Arrays.stream(accounts).map(Account::getAddress).collect(Collectors.toList());
    MultisigAccountModificationTransaction convertIntoMultisigTransaction = MultisigAccountModificationTransactionFactory.create(getNetworkType(), getDeadline(), (byte) 1, (byte) 1, additions, Collections.emptyList()).maxFee(maxFee).build();
    AggregateTransaction aggregateTransaction = AggregateTransactionFactory.createComplete(getNetworkType(), getDeadline(), Collections.singletonList(convertIntoMultisigTransaction.toAggregate(multisigAccount.getPublicAccount()))).maxFee(maxFee).build();
    SignedTransaction signedAggregateTransaction = aggregateTransaction.signTransactionWithCosigners(multisigAccount, Arrays.asList(accounts), getGenerationHash());
    Transaction aggregateTransaciton = get(getTransactionService(type).announce(getListener(type), signedAggregateTransaction));
    sleep(1000);
    Assertions.assertEquals(aggregateTransaciton.getTransactionInfo().get().getHash().get(), signedAggregateTransaction.getHash());
    return get(multisigRepository.getMultisigAccountInfo(multisigAccount.getAddress()));
}
Also used : MultisigAccountModificationTransaction(io.nem.symbol.sdk.model.transaction.MultisigAccountModificationTransaction) MultisigRepository(io.nem.symbol.sdk.api.MultisigRepository) UnresolvedAddress(io.nem.symbol.sdk.model.account.UnresolvedAddress) HashLockTransaction(io.nem.symbol.sdk.model.transaction.HashLockTransaction) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) NamespaceRegistrationTransaction(io.nem.symbol.sdk.model.transaction.NamespaceRegistrationTransaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) MosaicDefinitionTransaction(io.nem.symbol.sdk.model.transaction.MosaicDefinitionTransaction) MultisigAccountModificationTransaction(io.nem.symbol.sdk.model.transaction.MultisigAccountModificationTransaction) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) AddressAliasTransaction(io.nem.symbol.sdk.model.transaction.AddressAliasTransaction) MosaicAliasTransaction(io.nem.symbol.sdk.model.transaction.MosaicAliasTransaction) MosaicSupplyChangeTransaction(io.nem.symbol.sdk.model.transaction.MosaicSupplyChangeTransaction) RepositoryCallException(io.nem.symbol.sdk.api.RepositoryCallException) AggregateTransaction(io.nem.symbol.sdk.model.transaction.AggregateTransaction) AccountRepository(io.nem.symbol.sdk.api.AccountRepository) MultisigAccountInfo(io.nem.symbol.sdk.model.account.MultisigAccountInfo) MultisigAccountInfo(io.nem.symbol.sdk.model.account.MultisigAccountInfo) AccountInfo(io.nem.symbol.sdk.model.account.AccountInfo) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction)

Aggregations

MultisigAccountInfo (io.nem.symbol.sdk.model.account.MultisigAccountInfo)16 Test (org.junit.jupiter.api.Test)9 RepositoryFactory (io.nem.symbol.sdk.api.RepositoryFactory)7 Account (io.nem.symbol.sdk.model.account.Account)6 MultisigRepository (io.nem.symbol.sdk.api.MultisigRepository)5 Address (io.nem.symbol.sdk.model.account.Address)5 UnresolvedAddress (io.nem.symbol.sdk.model.account.UnresolvedAddress)5 AggregateTransaction (io.nem.symbol.sdk.model.transaction.AggregateTransaction)5 SignedTransaction (io.nem.symbol.sdk.model.transaction.SignedTransaction)5 Transaction (io.nem.symbol.sdk.model.transaction.Transaction)5 List (java.util.List)5 MultisigAccountGraphInfo (io.nem.symbol.sdk.model.account.MultisigAccountGraphInfo)4 HashLockTransaction (io.nem.symbol.sdk.model.transaction.HashLockTransaction)4 TransactionType (io.nem.symbol.sdk.model.transaction.TransactionType)4 Observable (io.reactivex.Observable)4 Set (java.util.Set)4 Collectors (java.util.stream.Collectors)4 Listener (io.nem.symbol.sdk.api.Listener)3 RepositoryCallException (io.nem.symbol.sdk.api.RepositoryCallException)3 TransactionRepository (io.nem.symbol.sdk.api.TransactionRepository)3