Search in sources :

Example 1 with CurrencyBuilder

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

the class RepositoryFactoryConfigurationExamplesIntegrationTest method bootAppFullyOffline.

@Test
void bootAppFullyOffline() throws ExecutionException, InterruptedException {
    // Option 1) Client app boot time. The clients defines the configuration to work
    // offline.
    RepositoryFactoryConfiguration configuration = new RepositoryFactoryConfiguration("http://localhost:3000");
    configuration.withNetworkType(NetworkType.MAIN_NET);
    configuration.withGenerationHash("abc");
    Currency currency = new CurrencyBuilder(NamespaceId.createFromName("my.custom.currency"), 6).build();
    Currency harvest = new CurrencyBuilder(NamespaceId.createFromName("my.custom.harvest"), 3).build();
    configuration.withNetworkCurrencies(new NetworkCurrencies(currency, harvest));
    try (RepositoryFactory repositoryFactory = new RepositoryFactoryVertxImpl(configuration)) {
        appDoSomeStuff(repositoryFactory);
    }
}
Also used : CurrencyBuilder(io.nem.symbol.sdk.model.mosaic.CurrencyBuilder) Currency(io.nem.symbol.sdk.model.mosaic.Currency) NetworkCurrencies(io.nem.symbol.sdk.model.mosaic.NetworkCurrencies) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) RepositoryFactoryConfiguration(io.nem.symbol.sdk.api.RepositoryFactoryConfiguration) RepositoryFactoryVertxImpl(io.nem.symbol.sdk.infrastructure.vertx.RepositoryFactoryVertxImpl) Test(org.junit.jupiter.api.Test)

Example 2 with CurrencyBuilder

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

the class CurrencyServiceImpl method createCurrency.

private CurrencyBuilder createCurrency(MosaicInfo mosaicInfo, Optional<NamespaceId> namespaceId) {
    UnresolvedMosaicId unresolvedMosaicId = mosaicInfo.getMosaicId();
    CurrencyBuilder builder = new CurrencyBuilder(unresolvedMosaicId, mosaicInfo.getDivisibility()).withMosaicId(mosaicInfo.getMosaicId()).withSupplyMutable(mosaicInfo.isSupplyMutable()).withTransferable(mosaicInfo.isTransferable()).withRestrictable(mosaicInfo.isRestrictable());
    namespaceId.ifPresent(builder::withNamespaceId);
    return builder;
}
Also used : CurrencyBuilder(io.nem.symbol.sdk.model.mosaic.CurrencyBuilder) UnresolvedMosaicId(io.nem.symbol.sdk.model.mosaic.UnresolvedMosaicId)

Example 3 with CurrencyBuilder

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

the class RepositoryFactoryConfigurationTest method constructorAndSet.

@Test
void constructorAndSet() {
    RepositoryFactoryConfiguration configuration = new RepositoryFactoryConfiguration("http://localhost:3000");
    configuration.setNetworkType(NetworkType.MAIN_NET);
    configuration.setGenerationHash("abc");
    Currency currency = new CurrencyBuilder(NamespaceId.createFromName("my.custom.currency"), 6).build();
    Duration epochAdjustment = Duration.ofMillis(100L);
    configuration.setEpochAdjustment(epochAdjustment);
    Currency harvest = new CurrencyBuilder(NamespaceId.createFromName("my.custom.harvest"), 3).build();
    configuration.setNetworkCurrencies(new NetworkCurrencies(currency, harvest));
    Assertions.assertEquals(Duration.ofMillis(100L), configuration.getEpochAdjustment());
    Assertions.assertEquals("http://localhost:3000", configuration.getBaseUrl());
    Assertions.assertEquals("abc", configuration.getGenerationHash());
    Assertions.assertEquals(NetworkType.MAIN_NET, configuration.getNetworkType());
    Assertions.assertEquals(currency, configuration.getNetworkCurrencies().getCurrency());
    Assertions.assertEquals(harvest, configuration.getNetworkCurrencies().getHarvest());
}
Also used : CurrencyBuilder(io.nem.symbol.sdk.model.mosaic.CurrencyBuilder) Currency(io.nem.symbol.sdk.model.mosaic.Currency) Duration(java.time.Duration) NetworkCurrencies(io.nem.symbol.sdk.model.mosaic.NetworkCurrencies) Test(org.junit.jupiter.api.Test)

Example 4 with CurrencyBuilder

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

the class RepositoryFactoryConfigurationTest method constructorAndWith.

@Test
void constructorAndWith() {
    RepositoryFactoryConfiguration configuration = new RepositoryFactoryConfiguration("http://localhost:3000");
    configuration.withNetworkType(NetworkType.MAIN_NET);
    configuration.withGenerationHash("abc");
    Duration epochAdjustment = Duration.ofMillis(100L);
    configuration.withEpochAdjustment(epochAdjustment);
    Currency currency = new CurrencyBuilder(NamespaceId.createFromName("my.custom.currency"), 6).build();
    Currency harvest = new CurrencyBuilder(NamespaceId.createFromName("my.custom.harvest"), 3).build();
    configuration.withNetworkCurrencies(new NetworkCurrencies(currency, harvest));
    Assertions.assertEquals(epochAdjustment, configuration.getEpochAdjustment());
    Assertions.assertEquals("http://localhost:3000", configuration.getBaseUrl());
    Assertions.assertEquals("abc", configuration.getGenerationHash());
    Assertions.assertEquals(NetworkType.MAIN_NET, configuration.getNetworkType());
    Assertions.assertEquals(currency, configuration.getNetworkCurrencies().getCurrency());
    Assertions.assertEquals(harvest, configuration.getNetworkCurrencies().getHarvest());
}
Also used : CurrencyBuilder(io.nem.symbol.sdk.model.mosaic.CurrencyBuilder) Currency(io.nem.symbol.sdk.model.mosaic.Currency) Duration(java.time.Duration) NetworkCurrencies(io.nem.symbol.sdk.model.mosaic.NetworkCurrencies) Test(org.junit.jupiter.api.Test)

Aggregations

CurrencyBuilder (io.nem.symbol.sdk.model.mosaic.CurrencyBuilder)4 Currency (io.nem.symbol.sdk.model.mosaic.Currency)3 NetworkCurrencies (io.nem.symbol.sdk.model.mosaic.NetworkCurrencies)3 Test (org.junit.jupiter.api.Test)3 Duration (java.time.Duration)2 RepositoryFactory (io.nem.symbol.sdk.api.RepositoryFactory)1 RepositoryFactoryConfiguration (io.nem.symbol.sdk.api.RepositoryFactoryConfiguration)1 RepositoryFactoryVertxImpl (io.nem.symbol.sdk.infrastructure.vertx.RepositoryFactoryVertxImpl)1 UnresolvedMosaicId (io.nem.symbol.sdk.model.mosaic.UnresolvedMosaicId)1