13: Add check for correct Perps program

This commit is contained in:
2026-06-25 15:16:00 +02:00
parent 1532a96e9b
commit 32a40433b2
@@ -9,9 +9,6 @@ import java.io.IOException;
public class AnchorIdlJupiterPerpsPositionServiceImpl implements JupiterPerpsPositionService {
private final SolanaBlockChain solanaBlockChain;
private final AnchorIdlJupiterPerpsPositionDecoder positionDecoder;
public AnchorIdlJupiterPerpsPositionServiceImpl(
SolanaBlockChain solanaBlockChain
) {
@@ -28,7 +25,19 @@ public class AnchorIdlJupiterPerpsPositionServiceImpl implements JupiterPerpsPos
throw new IllegalArgumentException("Jupiter Perps position account does not exist: " + positionAccount);
}
if (!JUPITER_PERPS_PROGRAM_ID.equals(accountInfo.owner())) {
throw new IllegalArgumentException(
"Account is not owned by Jupiter Perps program: " + positionAccount
);
}
JupiterPerpsPosition pos = positionDecoder.decode(positionAccount, accountInfo);
return pos;
}
private static final ΩJupiterPerpsProgramIdΩ JUPITER_PERPS_PROGRAM_ID =
"PERPHjGBqRHArX4DySjwM6UJHiR3sWAatqfdBS2qQJu";
private final SolanaBlockChain solanaBlockChain;
private final AnchorIdlJupiterPerpsPositionDecoder positionDecoder;
}