Search in sources :

Example 1 with NamespaceId

use of io.nem.sdk.model.namespace.NamespaceId in project nem2-sdk-java by nemtech.

the class MosaicDefinitionTransaction method create.

/**
 * Create a mosaic creation transaction object.
 *
 * @param deadline         The deadline to include the transaction.
 * @param mosaicName       The mosaic name ex: xem.
 * @param namespaceName    The namespace where mosaic will be included ex: nem.
 * @param mosaicProperties The mosaic properties.
 * @param networkType      The network type.
 * @return {@link MosaicDefinitionTransaction}
 */
public static MosaicDefinitionTransaction create(Deadline deadline, String mosaicName, String namespaceName, MosaicProperties mosaicProperties, NetworkType networkType) {
    Validate.notNull(mosaicName, "MosaicName must not be null");
    Validate.notNull(namespaceName, "NamespaceName must not be null");
    return new MosaicDefinitionTransaction(networkType, 2, deadline, BigInteger.valueOf(0), mosaicName, new NamespaceId(namespaceName), new MosaicId(IdGenerator.generateMosaicId(namespaceName, mosaicName)), mosaicProperties);
}
Also used : MosaicId(io.nem.sdk.model.mosaic.MosaicId) NamespaceId(io.nem.sdk.model.namespace.NamespaceId)

Example 2 with NamespaceId

use of io.nem.sdk.model.namespace.NamespaceId in project nem2-sdk-java by nemtech.

the class RegisterNamespaceTransaction method createSubNamespace.

/**
 * Create a sub namespace object.
 *
 * @param deadline      - The deadline to include the transaction.
 * @param namespaceName - The namespace name.
 * @param parentId      - The parent id name.
 * @param networkType   - The network type.
 * @return instance of RegisterNamespaceTransaction
 */
public static RegisterNamespaceTransaction createSubNamespace(Deadline deadline, String namespaceName, NamespaceId parentId, NetworkType networkType) {
    Validate.notNull(namespaceName, "NamespaceName must not be null");
    Validate.notNull(parentId, "ParentId must not be null");
    return new RegisterNamespaceTransaction(networkType, 2, deadline, BigInteger.valueOf(0), namespaceName, new NamespaceId(IdGenerator.generateSubNamespaceIdFromParentId(parentId.getId(), namespaceName)), NamespaceType.SubNamespace, Optional.empty(), Optional.of(parentId));
}
Also used : NamespaceId(io.nem.sdk.model.namespace.NamespaceId)

Example 3 with NamespaceId

use of io.nem.sdk.model.namespace.NamespaceId in project nem2-sdk-java by nemtech.

the class MosaicInfoTest method shouldReturnIsTransferableWhenLevyIsImmutable.

@Test
void shouldReturnIsTransferableWhenLevyIsImmutable() {
    MosaicProperties mosaicProperties = new MosaicProperties(true, true, false, 3, BigInteger.valueOf(10));
    MosaicInfo mosaicInfo = new MosaicInfo(true, 0, "5A3CD9B09CD1E8000159249B", new NamespaceId(new BigInteger("-8884663987180930485")), new MosaicId(new BigInteger("-3087871471161192663")), new BigInteger("100"), new BigInteger("0"), new PublicAccount("B4F12E7C9F6946091E2CB8B6D3A12B50D17CCBBF646386EA27CE2946A7423DCF", NetworkType.MIJIN_TEST), mosaicProperties);
    assertFalse(mosaicInfo.isLevyMutable());
}
Also used : PublicAccount(io.nem.sdk.model.account.PublicAccount) BigInteger(java.math.BigInteger) NamespaceId(io.nem.sdk.model.namespace.NamespaceId) Test(org.junit.jupiter.api.Test)

Example 4 with NamespaceId

use of io.nem.sdk.model.namespace.NamespaceId in project nem2-sdk-java by nemtech.

the class MosaicInfoTest method shouldReturnIsSupplyMutableWhenIsImmutable.

@Test
void shouldReturnIsSupplyMutableWhenIsImmutable() {
    MosaicProperties mosaicProperties = new MosaicProperties(false, true, true, 3, BigInteger.valueOf(10));
    MosaicInfo mosaicInfo = new MosaicInfo(true, 0, "5A3CD9B09CD1E8000159249B", new NamespaceId(new BigInteger("-8884663987180930485")), new MosaicId(new BigInteger("-3087871471161192663")), new BigInteger("100"), new BigInteger("0"), new PublicAccount("B4F12E7C9F6946091E2CB8B6D3A12B50D17CCBBF646386EA27CE2946A7423DCF", NetworkType.MIJIN_TEST), mosaicProperties);
    assertFalse(mosaicInfo.isSupplyMutable());
}
Also used : PublicAccount(io.nem.sdk.model.account.PublicAccount) BigInteger(java.math.BigInteger) NamespaceId(io.nem.sdk.model.namespace.NamespaceId) Test(org.junit.jupiter.api.Test)

Example 5 with NamespaceId

use of io.nem.sdk.model.namespace.NamespaceId in project nem2-sdk-java by nemtech.

the class MosaicInfoTest method shouldReturnIsTransferableWhenItsNotTransferable.

@Test
void shouldReturnIsTransferableWhenItsNotTransferable() {
    MosaicProperties mosaicProperties = new MosaicProperties(true, false, true, 3, BigInteger.valueOf(10));
    MosaicInfo mosaicInfo = new MosaicInfo(true, 0, "5A3CD9B09CD1E8000159249B", new NamespaceId(new BigInteger("-8884663987180930485")), new MosaicId(new BigInteger("-3087871471161192663")), new BigInteger("100"), new BigInteger("0"), new PublicAccount("B4F12E7C9F6946091E2CB8B6D3A12B50D17CCBBF646386EA27CE2946A7423DCF", NetworkType.MIJIN_TEST), mosaicProperties);
    assertFalse(mosaicInfo.isTransferable());
}
Also used : PublicAccount(io.nem.sdk.model.account.PublicAccount) BigInteger(java.math.BigInteger) NamespaceId(io.nem.sdk.model.namespace.NamespaceId) Test(org.junit.jupiter.api.Test)

Aggregations

NamespaceId (io.nem.sdk.model.namespace.NamespaceId)16 PublicAccount (io.nem.sdk.model.account.PublicAccount)11 BigInteger (java.math.BigInteger)10 Test (org.junit.jupiter.api.Test)10 TypeReference (com.fasterxml.jackson.core.type.TypeReference)4 NetworkType (io.nem.sdk.model.blockchain.NetworkType)4 UInt64 (io.nem.sdk.model.transaction.UInt64)4 Observable (io.reactivex.Observable)4 JsonObject (io.vertx.core.json.JsonObject)4 HttpResponse (io.vertx.reactivex.ext.web.client.HttpResponse)4 BodyCodec (io.vertx.reactivex.ext.web.codec.BodyCodec)4 MalformedURLException (java.net.MalformedURLException)4 List (java.util.List)4 Optional (java.util.Optional)4 Collectors (java.util.stream.Collectors)4 MosaicId (io.nem.sdk.model.mosaic.MosaicId)3 Address (io.nem.sdk.model.account.Address)2 MosaicInfo (io.nem.sdk.model.mosaic.MosaicInfo)2 MosaicName (io.nem.sdk.model.mosaic.MosaicName)2 MosaicProperties (io.nem.sdk.model.mosaic.MosaicProperties)2