-
Notifications
You must be signed in to change notification settings - Fork 906
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add failing tests for bigints in RPC errors (#3518)
### Problem I've encountered a new issue with the latest RC when updating program clients. Functions like `isProgramError` that check the custom error code for the program are no longer working because the relevant `SolanaError` context now contains `bigint` error codes or instruction indices instead of the `number` type defined in their context. Unfortunately, we cannot rely on numeric keypaths for these errors because these only transform successful responses. ### Solution Since we already have error factories that, given some RPC error message returns a proper `SolanaError`, we can adjust the logic of these functions such that they return a consistent output no matter if they receive `bigint` or `number` codes or indices. These methods are: - `getSolanaErrorFromJsonRpcError`: The main RPC error entry point. Which may delegate to: - `getSolanaErrorFromTransactionError`: The function that resolves transaction errors. Which may delegate to: - `getSolanaErrorFromInstructionError`: The function that resolves instruction errors. The benefits of doing this is, these methods are used in both RPC calls and RPC subscriptions. Additionally, we can clean up [some custom logic](https://github.com/solana-labs/solana-web3.js/blob/33286743f6818e809a39d6332b435b56548b7907/packages/rpc-transport-http/src/http-transport-for-solana-rpc.ts#L21-L24) we're doing for RPC calls only. ### Plan - First, in this PR, we add some failing tests to show that the current RPC error factories are not able to handle error messages that contain `bigint` error code or indices. - We then make these tests pass in the next PR by adjusting the RPC error factories. That PR also adds a changeset.
- Loading branch information
1 parent
d83eaaf
commit 478bebb
Showing
3 changed files
with
112 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters