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 {
|
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;
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user