13: Add decoder for IDL and delegate from service
This commit is contained in:
+16
@@ -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."
|
||||
);
|
||||
}
|
||||
}
|
||||
+8
-11
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user