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);
}
}
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;
}
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());
}
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());
}
Aggregations