13: Add decoder for IDL and delegate from service

This commit is contained in:
2026-06-25 10:40:01 +02:00
parent 8d904d7723
commit c130d6c7d4
2 changed files with 24 additions and 11 deletions
@@ -0,0 +1,16 @@
package com.r35157.libs.jupiter.perps.impl.anchoridl;
import com.r35157.libs.jupiter.perps.JupiterPerpsPosition;
import com.r35157.libs.solana.SolanaAccountInfo;
class AnchorIdlJupiterPerpsPositionDecoder {
JupiterPerpsPosition decode(
ΩJupiterPerpsPositionAccountΩ positionAccount,
SolanaAccountInfo accountInfo
) {
throw new UnsupportedOperationException(
"Jupiter Perps position decoding is not implemented yet."
);
}
}
@@ -10,28 +10,25 @@ import java.io.IOException;
public class AnchorIdlJupiterPerpsPositionServiceImpl implements JupiterPerpsPositionService {
private final SolanaBlockChain solanaBlockChain;
private final AnchorIdlJupiterPerpsPositionDecoder positionDecoder;
public AnchorIdlJupiterPerpsPositionServiceImpl(
SolanaBlockChain solanaBlockChain
) {
this.solanaBlockChain = solanaBlockChain;
this.positionDecoder = new AnchorIdlJupiterPerpsPositionDecoder();
}
@Override
public JupiterPerpsPosition getPosition(
ΩJupiterPerpsPositionAccountΩ positionAccount
) throws IOException, InterruptedException {
SolanaAccountInfo accountInfo =
solanaBlockChain.getAccountInfo(positionAccount);
public JupiterPerpsPosition getPosition(ΩJupiterPerpsPositionAccountΩ positionAccount)
throws IOException, InterruptedException {
SolanaAccountInfo accountInfo = solanaBlockChain.getAccountInfo(positionAccount);
if (accountInfo == null) {
throw new IllegalArgumentException(
"Jupiter Perps position account does not exist: " + positionAccount
);
throw new IllegalArgumentException("Jupiter Perps position account does not exist: " + positionAccount);
}
throw new UnsupportedOperationException(
"Jupiter Perps position account decoding is not implemented yet."
);
JupiterPerpsPosition pos = positionDecoder.decode(positionAccount, accountInfo);
return pos;
}
}