-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MultiversX provider improvement - get chosen ESDTs
- Loading branch information
Showing
13 changed files
with
266 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
src/main/java/com/allmycoins/balance/multiversx/ESDT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
package com.allmycoins.balance.multiversx; | ||
|
||
enum ESDT { | ||
/* BTC. */ | ||
ASH("ASH", "ASH-a642d1"), | ||
/* BHAT. */ | ||
BHAT("BHAT", "BHAT-c1fde3"), | ||
/* BTC. */ | ||
BTC("WBTC", "WBTC-5349b3"), | ||
/* BUSD. */ | ||
BUSD("BUSD", "BUSD-40b57e"), | ||
/* CRT. */ | ||
CRT("CRT", "CRT-52decf"), | ||
/* ETH. */ | ||
ETH("WETH", "WETH-b4ca29"), | ||
/* HSEGLD - Deposited Hatom Staked EGLD. */ | ||
HSEGLD("EGLD", "HSEGLD", "HSEGLD-c13a4e", "HSEGLD"), | ||
/* HTM. */ | ||
HTM("HTM", "HTM-f51d55"), | ||
/* ITHEUM. */ | ||
ITHEUM("ITHEUM", "ITHEUM-df6f26"), | ||
/* MEX. */ | ||
MEX("MEX", "MEX-455c57"), | ||
/* SUTK. */ | ||
RIDE("RIDE", "RIDE-7d18e9"), | ||
/* SBHAT. */ | ||
SBHAT("BHAT", "SBHAT", "SBHAT-89efd3", "Staked BHAT"), | ||
/* SCRT. */ | ||
SCRT("CRT", "SCRT", "SCRT-acbd64", "Staked CRT"), | ||
/* SHTM. */ | ||
SHTM("HTM", "SHTM", "SHTM-b8b430", "Staked HTM"), | ||
/* SEGLD - Hatom Staked EGLD. */ | ||
SEGLD("EGLD", "SEGLD", "SEGLD-3ad2d0", "SEGLD"), | ||
/* SITHEUM. */ | ||
SITHEUM("ITHEUM", "SITHEUM", "SITHEUM-e05083"), | ||
/* SRIDE. */ | ||
SRIDE("RIDE", "SRIDE", "SRIDE-4ab1d4", "Staked RIDE"), | ||
/* SUTK. */ | ||
SUTK("UTK", "SUTK", "SUTK-ba35f3", "Staked UTK"), | ||
/* SZPAY. */ | ||
SZPAY("ZPAY", "SZPAY", "SZPAY-9f1b39", "Staked ZPAY"), | ||
/* USDT. */ | ||
USDC("USDC", "USDC-c76f1f"), | ||
/* USDT. */ | ||
USDT("USDT", "USDT-f8c08c"), | ||
/* UTK. */ | ||
UTK("UTK", "UTK-2f80e9"), | ||
/* WEGLD. */ | ||
WEGLD("EGLD", "WEGLD", "WEGLD-bd4d79"), | ||
/* XMEX. */ | ||
XMEX("MEX", "XMEX", "XMEX-fda355"), | ||
/* SZPAY. */ | ||
ZPAY("ZPAY", "ZPAY-247875"); | ||
|
||
/* | ||
* Multiple ESDTs can be different version of the same coin. For simplicity, | ||
* they are gathered under the reference token. | ||
*/ | ||
private String referenceSymbol; | ||
|
||
private String ticker; | ||
|
||
private String identifier; | ||
|
||
private String source; | ||
|
||
ESDT(String aTicker, String aIdentifier) { | ||
referenceSymbol = null; | ||
ticker = aTicker; | ||
identifier = aIdentifier; | ||
source = null; | ||
} | ||
|
||
ESDT(String aReferenceSymbol, String aTicker, String aIdentifier) { | ||
referenceSymbol = aReferenceSymbol; | ||
ticker = aTicker; | ||
identifier = aIdentifier; | ||
source = null; | ||
} | ||
|
||
ESDT(String aReferenceSymbol, String aTicker, String aIdentifier, String aSource) { | ||
referenceSymbol = aReferenceSymbol; | ||
ticker = aTicker; | ||
identifier = aIdentifier; | ||
source = aSource; | ||
} | ||
|
||
public String getTicker() { | ||
return ticker; | ||
} | ||
|
||
public String getIdentifier() { | ||
return identifier; | ||
} | ||
|
||
public String getReferenceSymbol() { | ||
return referenceSymbol != null ? referenceSymbol : ticker; | ||
} | ||
|
||
public String getSource() { | ||
return source == null ? "MVX W" : source; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/allmycoins/balance/multiversx/ESDTs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.allmycoins.balance.multiversx; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* Utility class for ESDT tokens. | ||
*/ | ||
final class ESDTs { | ||
|
||
private static final List<ESDT> ESDTS = List.of(ESDT.values()); | ||
|
||
private ESDTs() { | ||
/* Empty. */ | ||
} | ||
|
||
static final List<String> getIdentifiers() { | ||
return ESDTS.stream().map(ESDT::getIdentifier).collect(Collectors.toList()); | ||
} | ||
|
||
static final ESDT getEsdt(final String ticker) { | ||
return ESDTS.stream().filter(esdt -> esdt.getTicker().equals(ticker)).findFirst().get(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/java/com/allmycoins/balance/multiversx/MultiversXEsdtBalanceJson.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.allmycoins.balance.multiversx; | ||
|
||
import java.math.BigDecimal; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
final class MultiversXEsdtBalanceJson { | ||
|
||
private String ticker; | ||
|
||
private Long decimals; | ||
|
||
private BigDecimal balance; | ||
|
||
public BigDecimal getBalance() { | ||
return balance; | ||
} | ||
|
||
public String getTicker() { | ||
return ticker; | ||
} | ||
|
||
public Long getDecimals() { | ||
return decimals; | ||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/com/allmycoins/balance/multiversx/MultiversXEsdtBalancesRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.allmycoins.balance.multiversx; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import com.allmycoins.request.GetRequest; | ||
|
||
public final class MultiversXEsdtBalancesRequest implements GetRequest<MultiversXEsdtBalanceJson[]> { | ||
|
||
private final String address; | ||
|
||
public MultiversXEsdtBalancesRequest(String pAddress) { | ||
address = pAddress; | ||
} | ||
|
||
@Override | ||
public String baseUrl() { | ||
return "https://api.multiversx.com"; | ||
} | ||
|
||
@Override | ||
public String endPoint() { | ||
return "/accounts/" + address + "/tokens"; | ||
} | ||
|
||
@Override | ||
public Map<String, String> headers() { | ||
return Collections.emptyMap(); | ||
} | ||
|
||
@Override | ||
public Class<MultiversXEsdtBalanceJson[]> jsonResponseClass() { | ||
return MultiversXEsdtBalanceJson[].class; | ||
} | ||
|
||
@Override | ||
public String parameters() { | ||
String meta = "includeMetaESDT=true"; | ||
String fields = "fields=ticker,decimals,balance"; | ||
String identifiers = "identifiers=" + String.join(",", ESDTs.getIdentifiers()); | ||
return String.join("&", List.of(meta, fields, identifiers)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters