diff --git a/README.md b/README.md index 291fd22..ebeaa77 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,8 @@ AllMyCoins is a simple crypto portfolio manager. - E-Money E-Money - Lum Lum - Desmos Desmos +- Neutron Neutron +- Celestia Celestia ##### MultiversX ecosystem * Elrond MultiversX diff --git a/privateConfig.template.properties b/privateConfig.template.properties index a1b23f1..2f32992 100644 --- a/privateConfig.template.properties +++ b/privateConfig.template.properties @@ -99,5 +99,11 @@ # Desmos public address #DESMOS_ADDRESS = ... +# Neutron public address +#NEUTRON_ADDRESS = ... + +# Celestia public address +#CELESTIA_ADDRESS = ... + # Avalanche C public address #AVALANCHE_C_ADDRESS = ... diff --git a/src/main/java/com/allmycoins/balance/cosmosjs/CosmosJsProvider.java b/src/main/java/com/allmycoins/balance/cosmosjs/CosmosJsProvider.java index ffdf1ac..b5899dd 100644 --- a/src/main/java/com/allmycoins/balance/cosmosjs/CosmosJsProvider.java +++ b/src/main/java/com/allmycoins/balance/cosmosjs/CosmosJsProvider.java @@ -23,16 +23,23 @@ public final class CosmosJsProvider implements PublicAddressSingleBalanceProvide private final String baseUrl; private final String denom; private final String token; + private final boolean requestDelegation; private CosmosJsBalanceJson[] cosmosJsBalances; public CosmosJsProvider(String pPrivateConfigKey, String pNetwork, String pDenom, String pToken) { + this(pPrivateConfigKey, pNetwork, pDenom, pToken, true); + } + + CosmosJsProvider(String pPrivateConfigKey, String pNetwork, String pDenom, String pToken, + boolean aRequestDelegation) { privateConfigKey = pPrivateConfigKey; network = pNetwork; denom = pDenom; token = pToken; cosmosJsBalances = null; baseUrl = COSMOS_DIRECTORY_BASE_URL + pNetwork.toLowerCase(); + requestDelegation = aRequestDelegation; } private String denom() { @@ -51,8 +58,8 @@ public String privateConfigKey() { @Override public BalanceJson singleBalance(String publicAddress) { float qty = requestBalance(publicAddress); - float delegationQty = requestDelegation(publicAddress); - float rewardQty = requestReward(publicAddress); + float delegationQty = requestDelegation ? requestDelegation(publicAddress) : 0; + float rewardQty = requestDelegation ? requestReward(publicAddress) : 0; return new BalanceJson(token, qty + delegationQty + rewardQty, network + " wallet"); } diff --git a/src/main/java/com/allmycoins/balance/cosmosjs/CosmosJsProviders.java b/src/main/java/com/allmycoins/balance/cosmosjs/CosmosJsProviders.java index e36fb65..4057058 100644 --- a/src/main/java/com/allmycoins/balance/cosmosjs/CosmosJsProviders.java +++ b/src/main/java/com/allmycoins/balance/cosmosjs/CosmosJsProviders.java @@ -35,9 +35,15 @@ public final class CosmosJsProviders { public static final CosmosJsProvider DESMOS_PROVIDER = new CosmosJsProvider("DESMOS_ADDRESS", "Desmos", "udsm", "DSM"); + public static final CosmosJsProvider NEUTRON_PROVIDER = new CosmosJsProvider("NEUTRON_ADDRESS", "Neutron", "untrn", + "NTRN", false); + + public static final CosmosJsProvider CELESTIA_PROVIDER = new CosmosJsProvider("CELESTIA_ADDRESS", "Celestia", + "utia", "TIA"); + private static final List PROVIDERS = List.of(COSMOS_PROVIDER, AKASH_PROVIDER, IRISNET_PROVIDER, JUNO_PROVIDER, COMDEX_PROVIDER, CHIHUAHA_PROVIDER, STARGAZE_PROVIDER, REGEN_PROVIDER, EMONEY_PROVIDER, - LUM_PROVIDER, DESMOS_PROVIDER); + LUM_PROVIDER, DESMOS_PROVIDER, NEUTRON_PROVIDER, CELESTIA_PROVIDER); public static final List providers() { return PROVIDERS; diff --git a/src/test/java/com/allmycoins/balance/CelestiaProviderTest.java b/src/test/java/com/allmycoins/balance/CelestiaProviderTest.java new file mode 100644 index 0000000..b529b0f --- /dev/null +++ b/src/test/java/com/allmycoins/balance/CelestiaProviderTest.java @@ -0,0 +1,43 @@ +package com.allmycoins.balance; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.List; +import java.util.function.Supplier; + +import org.junit.jupiter.api.Test; + +import com.allmycoins.PrivateConfig; +import com.allmycoins.balance.cosmosjs.CosmosJsProvider; +import com.allmycoins.balance.cosmosjs.CosmosJsProviders; +import com.allmycoins.json.BalanceJson; + +final class CelestiaProviderTest { + + private static final Supplier GET_PROVIDER = () -> CosmosJsProviders.CELESTIA_PROVIDER; + + @Test + void testBalances() { + PrivateConfig.loadConfigurationFromClassLoader(); + + CosmosJsProvider provider = GET_PROVIDER.get(); + List balances = provider.balances(); + assertEquals(1, balances.size()); + + BalanceJson balance = balances.get(0); + + assertEquals("TIA", balance.getAsset()); + assertEquals("Celestia wallet", balance.getSrc()); + assertTrue(balance.getQty() >= 0.0f); + } + + @Test + void testNoBalances() { + PrivateConfig.clearConfiguration(); + + CosmosJsProvider provider = GET_PROVIDER.get(); + List balances = provider.balances(); + assertTrue(balances.isEmpty()); + } +} diff --git a/src/test/java/com/allmycoins/balance/NeutronProviderTest.java b/src/test/java/com/allmycoins/balance/NeutronProviderTest.java new file mode 100644 index 0000000..8ea25ce --- /dev/null +++ b/src/test/java/com/allmycoins/balance/NeutronProviderTest.java @@ -0,0 +1,43 @@ +package com.allmycoins.balance; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.List; +import java.util.function.Supplier; + +import org.junit.jupiter.api.Test; + +import com.allmycoins.PrivateConfig; +import com.allmycoins.balance.cosmosjs.CosmosJsProvider; +import com.allmycoins.balance.cosmosjs.CosmosJsProviders; +import com.allmycoins.json.BalanceJson; + +final class NeutronProviderTest { + + private static final Supplier GET_PROVIDER = () -> CosmosJsProviders.NEUTRON_PROVIDER; + + @Test + void testBalances() { + PrivateConfig.loadConfigurationFromClassLoader(); + + CosmosJsProvider provider = GET_PROVIDER.get(); + List balances = provider.balances(); + assertEquals(1, balances.size()); + + BalanceJson balance = balances.get(0); + + assertEquals("NTRN", balance.getAsset()); + assertEquals("Neutron wallet", balance.getSrc()); + assertTrue(balance.getQty() >= 0.0f); + } + + @Test + void testNoBalances() { + PrivateConfig.clearConfiguration(); + + CosmosJsProvider provider = GET_PROVIDER.get(); + List balances = provider.balances(); + assertTrue(balances.isEmpty()); + } +} diff --git a/src/test/resources/privateConfig.properties b/src/test/resources/privateConfig.properties index 8287f53..fad63cd 100644 --- a/src/test/resources/privateConfig.properties +++ b/src/test/resources/privateConfig.properties @@ -60,4 +60,10 @@ EMONEY_ADDRESS = emoney140g8fnnl46mlvfhygj3zvjqlku6x0fwuylucan LUM_ADDRESS = lum1axqn30kead92gdsg7pusc6ezxx8ltq46t5cyh4 # Desmos public address for tests -DESMOS_ADDRESS = desmos1gwr9l765vfxv4l4zz8glsxwkkphj2084clxvs4 \ No newline at end of file +DESMOS_ADDRESS = desmos1gwr9l765vfxv4l4zz8glsxwkkphj2084clxvs4 + +# Neutron public address +NEUTRON_ADDRESS = neutron1yghndrffay859ma2ue4pa2cltw640vtaqx2096 + +# Celestia public address +CELESTIA_ADDRESS = celestia12s888zz8x2tdn4eq0y9uv0gdkmx79whypzu28m \ No newline at end of file