sava-software / sava

Solana Java SDK
MIT License
4 stars 0 forks source link

TxInstructionError#code can contain values bigger than int #3

Closed imaykay closed 1 week ago

imaykay commented 1 week ago

Hi team,

while trying to deserialize Meteora transactions, I came across some txs whose error code seems to be bigger than int and the deserialization breaks with a JsonException. In the below given tx, the error code is 3_735_928_559 while int max is 2_147_483_647. The following code snippet might help to reproduce the exception:

try (final var httpClient = HttpClient.newHttpClient()) {
    final var rpcClient = SolanaRpcClient.createClient(SolanaNetwork.MAIN_NET.getEndpoint(), httpClient);
    String txSig = "4oYrNJcgMDEKWdH7goybDjfoDEQ9ubE6gmF5dyG7eWkJQ5rUSkwqyNNjLYbt4ggunn7KmbfMHVC6Gd3Yg1CLVsYG";
    CompletableFuture<Tx> txFuture = rpcClient.getTransaction(Commitment.FINALIZED, txSig, 0, RpcEncoding.base64.name());
    Tx tx = txFuture.join();
}

Or am I doing sth wrong here when using the framework?

Cheers!

jpe7s commented 1 week ago

Awesome bug report, thank you!

Fixed in 1.9.4 with 0fc08ea

Should get this if you print that tx to the console now.

Tx[slot=293506042, blockTime=OptionalLong[1727980637], meta=TxMeta[error=TxInstructionError[instructionIndex=2, type=Custom, code=3735928559], computeUnitsConsumed=115170, fee=10341, ....