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 { public class AnchorIdlJupiterPerpsPositionServiceImpl implements JupiterPerpsPositionService {
private final SolanaBlockChain solanaBlockChain; private final SolanaBlockChain solanaBlockChain;
private final AnchorIdlJupiterPerpsPositionDecoder positionDecoder;
public AnchorIdlJupiterPerpsPositionServiceImpl( public AnchorIdlJupiterPerpsPositionServiceImpl(
SolanaBlockChain solanaBlockChain SolanaBlockChain solanaBlockChain
) { ) {
this.solanaBlockChain = solanaBlockChain; this.solanaBlockChain = solanaBlockChain;
this.positionDecoder = new AnchorIdlJupiterPerpsPositionDecoder();
} }
@Override @Override
public JupiterPerpsPosition getPosition( public JupiterPerpsPosition getPosition(ΩJupiterPerpsPositionAccountΩ positionAccount)
ΩJupiterPerpsPositionAccountΩ positionAccount throws IOException, InterruptedException {
) throws IOException, InterruptedException { SolanaAccountInfo accountInfo = solanaBlockChain.getAccountInfo(positionAccount);
SolanaAccountInfo accountInfo =
solanaBlockChain.getAccountInfo(positionAccount);
if (accountInfo == null) { if (accountInfo == null) {
throw new IllegalArgumentException( throw new IllegalArgumentException("Jupiter Perps position account does not exist: " + positionAccount);
"Jupiter Perps position account does not exist: " + positionAccount
);
} }
throw new UnsupportedOperationException( JupiterPerpsPosition pos = positionDecoder.decode(positionAccount, accountInfo);
"Jupiter Perps position account decoding is not implemented yet." return pos;
);
} }
} }