Search in sources :

Example 1 with UnresolvedMosaicId

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

the class TestHelper method createMosaic.

protected MosaicId createMosaic(Account account, RepositoryType type, BigInteger initialSupply, String alias) {
    MosaicNonce nonce = MosaicNonce.createRandom();
    MosaicId mosaicId = MosaicId.createFromNonce(nonce, account.getPublicAccount());
    MosaicDefinitionTransaction mosaicDefinitionTransaction = MosaicDefinitionTransactionFactory.create(getNetworkType(), getDeadline(), nonce, mosaicId, MosaicFlags.create(true, true, true), 4, new BlockDuration(100)).maxFee(maxFee).build();
    MosaicDefinitionTransaction validateTransaction = announceAndValidate(type, account, mosaicDefinitionTransaction);
    Assertions.assertEquals(mosaicId, validateTransaction.getMosaicId());
    UnresolvedMosaicId unresolvedMosaicId = mosaicId;
    if (alias != null) {
        NamespaceId rootNamespaceId = createRootNamespace(type, account, alias);
        unresolvedMosaicId = rootNamespaceId;
        MosaicAliasTransaction addressAliasTransaction = MosaicAliasTransactionFactory.create(getNetworkType(), getDeadline(), AliasAction.LINK, rootNamespaceId, mosaicId).maxFee(maxFee).build();
        announceAggregateAndValidate(type, addressAliasTransaction, account);
    }
    if (initialSupply != null && initialSupply.longValue() > 0) {
        MosaicSupplyChangeTransaction mosaicSupplyChangeTransaction = MosaicSupplyChangeTransactionFactory.create(getNetworkType(), getDeadline(), unresolvedMosaicId, MosaicSupplyChangeActionType.INCREASE, initialSupply).maxFee(maxFee).build();
        announceAndValidate(type, account, mosaicSupplyChangeTransaction);
    }
    return mosaicId;
}
Also used : MosaicSupplyChangeTransaction(io.nem.symbol.sdk.model.transaction.MosaicSupplyChangeTransaction) BlockDuration(io.nem.symbol.sdk.model.blockchain.BlockDuration) UnresolvedMosaicId(io.nem.symbol.sdk.model.mosaic.UnresolvedMosaicId) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) MosaicNonce(io.nem.symbol.sdk.model.mosaic.MosaicNonce) NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) MosaicAliasTransaction(io.nem.symbol.sdk.model.transaction.MosaicAliasTransaction) MosaicDefinitionTransaction(io.nem.symbol.sdk.model.transaction.MosaicDefinitionTransaction) UnresolvedMosaicId(io.nem.symbol.sdk.model.mosaic.UnresolvedMosaicId)

Example 2 with UnresolvedMosaicId

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

the class AccountMosaicRestrictionTransactionMapper method createFactory.

@Override
protected AccountMosaicRestrictionTransactionFactory createFactory(NetworkType networkType, Deadline deadline, AccountMosaicRestrictionTransactionDTO transaction) {
    AccountMosaicRestrictionFlags restrictionFlags = AccountMosaicRestrictionFlags.rawValueOf(transaction.getRestrictionFlags().getValue());
    List<UnresolvedMosaicId> additions = transaction.getRestrictionAdditions().stream().map(MapperUtils::toUnresolvedMosaicId).collect(Collectors.toList());
    List<UnresolvedMosaicId> deletions = transaction.getRestrictionDeletions().stream().map(MapperUtils::toUnresolvedMosaicId).collect(Collectors.toList());
    return AccountMosaicRestrictionTransactionFactory.create(networkType, deadline, restrictionFlags, additions, deletions);
}
Also used : AccountMosaicRestrictionFlags(io.nem.symbol.sdk.model.transaction.AccountMosaicRestrictionFlags) UnresolvedMosaicId(io.nem.symbol.sdk.model.mosaic.UnresolvedMosaicId)

Example 3 with UnresolvedMosaicId

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

the class AccountMosaicRestrictionTransactionMapper method createFactory.

@Override
protected AccountMosaicRestrictionTransactionFactory createFactory(NetworkType networkType, Deadline deadline, AccountMosaicRestrictionTransactionDTO transaction) {
    AccountMosaicRestrictionFlags restrictionFlags = AccountMosaicRestrictionFlags.rawValueOf(transaction.getRestrictionFlags().getValue());
    List<UnresolvedMosaicId> additions = transaction.getRestrictionAdditions().stream().map(MapperUtils::toUnresolvedMosaicId).collect(Collectors.toList());
    List<UnresolvedMosaicId> deletions = transaction.getRestrictionDeletions().stream().map(MapperUtils::toUnresolvedMosaicId).collect(Collectors.toList());
    return AccountMosaicRestrictionTransactionFactory.create(networkType, deadline, restrictionFlags, additions, deletions);
}
Also used : AccountMosaicRestrictionFlags(io.nem.symbol.sdk.model.transaction.AccountMosaicRestrictionFlags) UnresolvedMosaicId(io.nem.symbol.sdk.model.mosaic.UnresolvedMosaicId)

Example 4 with UnresolvedMosaicId

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

the class MosaicMetadataTransactionMapper method createFactory.

@Override
protected MosaicMetadataTransactionFactory createFactory(NetworkType networkType, Deadline deadline, MosaicMetadataTransactionDTO transaction) {
    UnresolvedAddress targetAddress = 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, targetAddress, targetMosaic, scopedMetaDataKey, value);
    factory.valueSizeDelta(valueSizeDelta);
    Long valueSize = transaction.getValueSize();
    if (valueSize != null) {
        factory.valueSize(valueSize);
    }
    return factory;
}
Also used : BigInteger(java.math.BigInteger) UnresolvedAddress(io.nem.symbol.sdk.model.account.UnresolvedAddress) MapperUtils.toUnresolvedAddress(io.nem.symbol.core.utils.MapperUtils.toUnresolvedAddress) BigInteger(java.math.BigInteger) MosaicMetadataTransactionFactory(io.nem.symbol.sdk.model.transaction.MosaicMetadataTransactionFactory) UnresolvedMosaicId(io.nem.symbol.sdk.model.mosaic.UnresolvedMosaicId)

Example 5 with UnresolvedMosaicId

use of io.nem.symbol.sdk.model.mosaic.UnresolvedMosaicId 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;
}
Also used : BigInteger(java.math.BigInteger) UnresolvedAddress(io.nem.symbol.sdk.model.account.UnresolvedAddress) BigInteger(java.math.BigInteger) MosaicMetadataTransactionFactory(io.nem.symbol.sdk.model.transaction.MosaicMetadataTransactionFactory) UnresolvedMosaicId(io.nem.symbol.sdk.model.mosaic.UnresolvedMosaicId)

Aggregations

UnresolvedMosaicId (io.nem.symbol.sdk.model.mosaic.UnresolvedMosaicId)9 UnresolvedAddress (io.nem.symbol.sdk.model.account.UnresolvedAddress)4 BigInteger (java.math.BigInteger)4 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)3 Address (io.nem.symbol.sdk.model.account.Address)2 NetworkType (io.nem.symbol.sdk.model.network.NetworkType)2 AccountMosaicRestrictionFlags (io.nem.symbol.sdk.model.transaction.AccountMosaicRestrictionFlags)2 MosaicMetadataTransactionFactory (io.nem.symbol.sdk.model.transaction.MosaicMetadataTransactionFactory)2 Optional (java.util.Optional)2 AddressResolutionEntryBuilder (io.nem.symbol.catapult.builders.AddressResolutionEntryBuilder)1 AddressResolutionStatementBuilder (io.nem.symbol.catapult.builders.AddressResolutionStatementBuilder)1 MosaicResolutionEntryBuilder (io.nem.symbol.catapult.builders.MosaicResolutionEntryBuilder)1 MosaicResolutionStatementBuilder (io.nem.symbol.catapult.builders.MosaicResolutionStatementBuilder)1 ReceiptSourceBuilder (io.nem.symbol.catapult.builders.ReceiptSourceBuilder)1 ReceiptTypeDto (io.nem.symbol.catapult.builders.ReceiptTypeDto)1 Serializer (io.nem.symbol.catapult.builders.Serializer)1 Hashes (io.nem.symbol.core.crypto.Hashes)1 ConvertUtils (io.nem.symbol.core.utils.ConvertUtils)1 MapperUtils.toUnresolvedAddress (io.nem.symbol.core.utils.MapperUtils.toUnresolvedAddress)1 AliasService (io.nem.symbol.sdk.api.AliasService)1