diff --git a/src/main/tjava/com/r35157/libs/solana/SolanaBlockChain.tjava b/src/main/tjava/com/r35157/libs/solana/SolanaBlockChain.tjava index 7bd94d6..724486a 100644 --- a/src/main/tjava/com/r35157/libs/solana/SolanaBlockChain.tjava +++ b/src/main/tjava/com/r35157/libs/solana/SolanaBlockChain.tjava @@ -55,6 +55,7 @@ public interface SolanaBlockChain { * @return a map of SPL mint addresses to token holding information * @throws IOException if the token holdings could not be fetched or parsed * @throws InterruptedException if the calling thread is interrupted while fetching token holdings + * @throws IllegalStateException if multiple token accounts for the same mint is detected, as this is not supported yet. */ Map<ΩSPLMintAddressΩ, SPLTokenHolding> getSPLTokenHoldings( ΩSolanaAddressΩ ownerAddress, diff --git a/src/main/tjava/com/r35157/libs/solana/impl/ref/SolanaBlockChainImpl.tjava b/src/main/tjava/com/r35157/libs/solana/impl/ref/SolanaBlockChainImpl.tjava index 0140484..5f5bc61 100644 --- a/src/main/tjava/com/r35157/libs/solana/impl/ref/SolanaBlockChainImpl.tjava +++ b/src/main/tjava/com/r35157/libs/solana/impl/ref/SolanaBlockChainImpl.tjava @@ -149,14 +149,25 @@ public class SolanaBlockChainImpl implements SolanaBlockChain { String uiAmountString = tokenAmount.path("uiAmountString").asText(); BigDecimal uiAmount = new BigDecimal(uiAmountString); - result.put(mint, new SPLTokenHolding( + SPLTokenHolding holding = new SPLTokenHolding( tokenAccount, mint, uiAmount, rawAmount, decimals, splProgram.getAddress() - )); + ); + + SPLTokenHolding previous = result.putIfAbsent(mint, holding); + + if (previous != null) { + throw new IllegalStateException( + "Multiple SPL token accounts found for mint " + + mint + + " and owner " + + ownerAddress + ); + } } return result;