solana-php-sdk icon indicating copy to clipboard operation
solana-php-sdk copied to clipboard

ErrorException during error handling

Open PawelPodkalicki opened this issue 1 year ago • 0 comments

Hi, I tried to transfer funds from empty account on devnet and received an error. I expected the error, but it wasn't handled properly.

Please, change https://github.com/Attestto-com/solana-php-sdk/blob/7e0118fa6e34d66e574d65da627b07136cddbd42/src/SolanaRpcClient.php#L150

to

            $error = $body['params']['error'] ?? $body['error'];

The original JSON response was

{"jsonrpc":"2.0","error":{"code":-32002,"message":"Transaction simulation failed: Attempt to debit an account but found no record of a prior credit.","data":{"accounts":null,"err":"AccountNotFound","innerInstructions":null,"logs":[],"returnData":null,"unitsConsumed":0}},"id":80411175}

PawelPodkalicki avatar Jun 28 '24 10:06 PawelPodkalicki