Search in sources :

Example 11 with MosaicId

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

the class ArtifactExpiryReceiptTest method shouldCreateMosaicExpiryReceipt.

@Test
void shouldCreateMosaicExpiryReceipt() {
    MosaicId mosaicId = new MosaicId("85BBEA6CC462B244");
    ArtifactExpiryReceipt<MosaicId> mosaicExpiryReceipt = new ArtifactExpiryReceipt<>(mosaicId, ReceiptType.MOSAIC_EXPIRED, ReceiptVersion.ARTIFACT_EXPIRY);
    assertEquals(ReceiptType.MOSAIC_EXPIRED, mosaicExpiryReceipt.getType());
    assertFalse(mosaicExpiryReceipt.getSize().isPresent());
    assertEquals(ReceiptVersion.ARTIFACT_EXPIRY, mosaicExpiryReceipt.getVersion());
    assertEquals("85BBEA6CC462B244", mosaicExpiryReceipt.getArtifactId().getIdAsHex().toUpperCase());
    String hex = ConvertUtils.toHex(mosaicExpiryReceipt.serialize());
    Assertions.assertEquals("01004D4144B262C46CEABB85", hex);
}
Also used : MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) Test(org.junit.jupiter.api.Test)

Example 12 with MosaicId

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

the class BalanceTransferReceiptTest method shouldSerializeTheSameAsTypescript.

@Test
void shouldSerializeTheSameAsTypescript() {
    Address sender = Address.generateRandom(networkType);
    Address recipient = Address.generateRandom(networkType);
    BalanceTransferReceipt balanceTransferReceipt = new BalanceTransferReceipt(sender, recipient, new MosaicId("941299B2B7E1291C"), BigInteger.valueOf(1000), ReceiptType.MOSAIC_RENTAL_FEE, ReceiptVersion.BALANCE_TRANSFER);
    String hex = ConvertUtils.toHex(balanceTransferReceipt.serialize());
    Assertions.assertEquals("01004D121C29E1B7B2991294E803000000000000" + sender.encoded() + recipient.encoded(), hex.toUpperCase());
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) Test(org.junit.jupiter.api.Test)

Example 13 with MosaicId

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

the class MosaicRepositoryOkHttpImpl method getMosaics.

@Override
public Observable<List<MosaicInfo>> getMosaics(List<MosaicId> ids) {
    MosaicIds mosaicIds = new MosaicIds();
    mosaicIds.mosaicIds(ids.stream().map(MosaicId::getIdAsHex).collect(Collectors.toList()));
    Callable<List<MosaicInfoDTO>> callback = () -> getClient().getMosaics(mosaicIds);
    return exceptionHandling(call(callback).flatMapIterable(item -> item).map(this::createMosaicInfo).toList().toObservable());
}
Also used : MapperUtils.toMosaicId(io.nem.symbol.core.utils.MapperUtils.toMosaicId) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) List(java.util.List) MosaicIds(io.nem.symbol.sdk.openapi.okhttp_gson.model.MosaicIds)

Example 14 with MosaicId

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

the class NamespaceRepositoryOkHttpImpl method getMosaicsNames.

@Override
public Observable<List<MosaicNames>> getMosaicsNames(List<MosaicId> ids) {
    MosaicIds mosaicIds = new MosaicIds();
    mosaicIds.mosaicIds(ids.stream().map(MosaicId::getIdAsHex).collect(Collectors.toList()));
    Callable<MosaicsNamesDTO> callback = () -> getClient().getMosaicsNames(mosaicIds);
    return exceptionHandling(call(callback).map(MosaicsNamesDTO::getMosaicNames).flatMapIterable(item -> item).map(this::toMosaicNames).toList().toObservable());
}
Also used : MosaicsNamesDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.MosaicsNamesDTO) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) MosaicIds(io.nem.symbol.sdk.openapi.okhttp_gson.model.MosaicIds)

Example 15 with MosaicId

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

the class TransferTransactionTest method shouldGenerateBytes.

@Test
void shouldGenerateBytes() {
    String expected = "B10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000019054410000000000000000010000000000000090F36CA680C35D630662A0C38DC89D4978D10B511B3D241A0100010000000000672B0000CE560000640000000000000000";
    TransferTransaction transaction = TransferTransactionFactory.create(networkType, new Deadline(BigInteger.ONE), new Address("SDZWZJUAYNOWGBTCUDBY3SE5JF4NCC2RDM6SIGQ", networkType), Collections.singletonList(new Mosaic(new MosaicId(new BigInteger("95442763262823")), BigInteger.valueOf(100)))).message(new PlainMessage("")).build();
    assertSerialization(expected, transaction);
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) PlainMessage(io.nem.symbol.sdk.model.message.PlainMessage) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) BigInteger(java.math.BigInteger) Mosaic(io.nem.symbol.sdk.model.mosaic.Mosaic) Test(org.junit.jupiter.api.Test)

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