Search in sources :

Example 36 with MosaicId

use of io.nem.symbol.sdk.model.mosaic.MosaicId in project nem2-sdk-java by nemtech.

the class MosaicDefinitionTransactionIntegrationTest method createMosaic.

private MosaicId createMosaic(RepositoryType type) {
    MosaicNonce nonce = MosaicNonce.createRandom();
    MosaicId mosaicId = MosaicId.createFromNonce(nonce, this.account.getPublicAccount());
    MosaicDefinitionTransaction mosaicDefinitionTransaction = MosaicDefinitionTransactionFactory.create(getNetworkType(), getDeadline(), nonce, mosaicId, MosaicFlags.create(true, true, true), 4, new BlockDuration(100)).maxFee(maxFee).build();
    MosaicDefinitionTransaction processed = announceAndValidate(type, this.account, mosaicDefinitionTransaction);
    Assertions.assertEquals(mosaicId, processed.getMosaicId());
    Assertions.assertEquals(mosaicDefinitionTransaction.getMosaicNonce(), processed.getMosaicNonce());
    return mosaicId;
}
Also used : BlockDuration(io.nem.symbol.sdk.model.blockchain.BlockDuration) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) MosaicNonce(io.nem.symbol.sdk.model.mosaic.MosaicNonce) MosaicDefinitionTransaction(io.nem.symbol.sdk.model.transaction.MosaicDefinitionTransaction)

Example 37 with MosaicId

use of io.nem.symbol.sdk.model.mosaic.MosaicId in project nem2-sdk-java by nemtech.

the class MosaicMetadataIntegrationTest method searchIntegration.

// 
@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchIntegration(RepositoryType type) {
    BigInteger key = MapperUtils.fromHexToBigInteger("000000000000000A");
    Address sourceAddress = Address.createFromEncoded("9852D5EAA9AB038151EEBDD34308B3B2B7D82B92955F298E");
    Address targetAddress = Address.createFromEncoded("9852D5EAA9AB038151EEBDD34308B3B2B7D82B92955F298E");
    MosaicId mosaicId = new MosaicId("213CED6E6BBA6689");
    MetadataType metadataType = MetadataType.MOSAIC;
    Page<Metadata> metadataPage = get(getRepositoryFactory(type).createMetadataRepository().search(new MetadataSearchCriteria().scopedMetadataKey(key).targetId(mosaicId).sourceAddress(sourceAddress).targetAddress(targetAddress).metadataType(metadataType)));
    System.out.println(type + "\n" + toJson(metadataPage));
}
Also used : MetadataSearchCriteria(io.nem.symbol.sdk.api.MetadataSearchCriteria) Address(io.nem.symbol.sdk.model.account.Address) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) MetadataType(io.nem.symbol.sdk.model.metadata.MetadataType) Metadata(io.nem.symbol.sdk.model.metadata.Metadata) BigInteger(java.math.BigInteger) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 38 with MosaicId

use of io.nem.symbol.sdk.model.mosaic.MosaicId in project nem2-sdk-java by nemtech.

the class MosaicGlobalRestrictionIntegrationTest method assertMosaicGlobalRestriction.

private void assertMosaicGlobalRestriction(MosaicGlobalRestrictionTransaction mosaicGlobalRestrictionTransaction, MosaicGlobalRestriction mosaicGlobalRestriction) {
    BigInteger restrictionKey = mosaicGlobalRestrictionTransaction.getRestrictionKey();
    BigInteger newRestrictionValue = mosaicGlobalRestrictionTransaction.getNewRestrictionValue();
    Assertions.assertEquals(restrictionKey, mosaicGlobalRestrictionTransaction.getRestrictionKey());
    Assertions.assertEquals(1, mosaicGlobalRestriction.getRestrictions().size());
    Assertions.assertEquals(Collections.singleton(restrictionKey), mosaicGlobalRestriction.getRestrictions().keySet());
    Assertions.assertEquals(newRestrictionValue, mosaicGlobalRestriction.getRestrictions().get(restrictionKey).getRestrictionValue());
    Assertions.assertEquals(mosaicGlobalRestrictionTransaction.getNewRestrictionType(), mosaicGlobalRestriction.getRestrictions().get(restrictionKey).getRestrictionType());
    Assertions.assertEquals(new MosaicId(BigInteger.ZERO), mosaicGlobalRestriction.getRestrictions().get(restrictionKey).getReferenceMosaicId());
}
Also used : MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) BigInteger(java.math.BigInteger)

Example 39 with MosaicId

use of io.nem.symbol.sdk.model.mosaic.MosaicId in project nem2-sdk-java by nemtech.

the class MosaicRestrictionServiceIntegrationTest method assertMosaicGlobalRestriction.

private void assertMosaicGlobalRestriction(MosaicGlobalRestrictionTransaction mosaicGlobalRestrictionTransaction, MosaicGlobalRestriction mosaicGlobalRestriction) {
    BigInteger restrictionKey = mosaicGlobalRestrictionTransaction.getRestrictionKey();
    BigInteger newRestrictionValue = mosaicGlobalRestrictionTransaction.getNewRestrictionValue();
    Assertions.assertEquals(restrictionKey, mosaicGlobalRestrictionTransaction.getRestrictionKey());
    Assertions.assertEquals(1, mosaicGlobalRestriction.getRestrictions().size());
    Assertions.assertEquals(Collections.singleton(restrictionKey), mosaicGlobalRestriction.getRestrictions().keySet());
    Assertions.assertEquals(newRestrictionValue, mosaicGlobalRestriction.getRestrictions().get(restrictionKey).getRestrictionValue());
    Assertions.assertEquals(mosaicGlobalRestrictionTransaction.getNewRestrictionType(), mosaicGlobalRestriction.getRestrictions().get(restrictionKey).getRestrictionType());
    Assertions.assertEquals(new MosaicId(BigInteger.ZERO), mosaicGlobalRestriction.getRestrictions().get(restrictionKey).getReferenceMosaicId());
}
Also used : MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) BigInteger(java.math.BigInteger)

Example 40 with MosaicId

use of io.nem.symbol.sdk.model.mosaic.MosaicId in project nem2-sdk-java by nemtech.

the class TransactionServiceImpl method resolveTransactionFactory.

private Observable<TransactionFactory<? extends Transaction>> resolveTransactionFactory(MosaicGlobalRestrictionTransaction transaction, ReceiptSource expectedReceiptSource, Observable<List<MosaicResolutionStatement>> mosaicResolutionStatements) {
    Observable<MosaicId> resolvedMosaicId = getResolvedMosaicId(transaction, transaction.getMosaicId(), mosaicResolutionStatements, expectedReceiptSource);
    Observable<MosaicId> resolvedReferenceMosaicId = getResolvedMosaicId(transaction, transaction.getReferenceMosaicId(), mosaicResolutionStatements, expectedReceiptSource);
    return Observable.combineLatest(resolvedMosaicId, resolvedReferenceMosaicId, (mosaicId, referenceMosaicId) -> {
        MosaicGlobalRestrictionTransactionFactory factory = MosaicGlobalRestrictionTransactionFactory.create(transaction.getNetworkType(), transaction.getDeadline(), mosaicId, transaction.getRestrictionKey(), transaction.getNewRestrictionValue(), transaction.getNewRestrictionType());
        if (referenceMosaicId != null) {
            factory.referenceMosaicId(referenceMosaicId);
        }
        return factory.previousRestrictionValue(transaction.getPreviousRestrictionValue()).previousRestrictionType(transaction.getPreviousRestrictionType());
    });
}
Also used : MosaicGlobalRestrictionTransactionFactory(io.nem.symbol.sdk.model.transaction.MosaicGlobalRestrictionTransactionFactory) UnresolvedMosaicId(io.nem.symbol.sdk.model.mosaic.UnresolvedMosaicId) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId)

Aggregations

MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)138 Test (org.junit.jupiter.api.Test)92 Address (io.nem.symbol.sdk.model.account.Address)53 BigInteger (java.math.BigInteger)53 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)24 EnumSource (org.junit.jupiter.params.provider.EnumSource)23 Mosaic (io.nem.symbol.sdk.model.mosaic.Mosaic)19 PlainMessage (io.nem.symbol.sdk.model.message.PlainMessage)18 NamespaceId (io.nem.symbol.sdk.model.namespace.NamespaceId)17 Account (io.nem.symbol.sdk.model.account.Account)16 MosaicInfo (io.nem.symbol.sdk.model.mosaic.MosaicInfo)15 ArrayList (java.util.ArrayList)13 MosaicRestrictionSearchCriteria (io.nem.symbol.sdk.api.MosaicRestrictionSearchCriteria)12 RestrictionMosaicRepository (io.nem.symbol.sdk.api.RestrictionMosaicRepository)10 MosaicGlobalRestrictionTransaction (io.nem.symbol.sdk.model.transaction.MosaicGlobalRestrictionTransaction)10 TransferTransaction (io.nem.symbol.sdk.model.transaction.TransferTransaction)10 PublicAccount (io.nem.symbol.sdk.model.account.PublicAccount)7 Currency (io.nem.symbol.sdk.model.mosaic.Currency)7 MosaicNames (io.nem.symbol.sdk.model.mosaic.MosaicNames)7 MosaicNonce (io.nem.symbol.sdk.model.mosaic.MosaicNonce)7