feat: migrate from near-openapi-client to near-openrpc-client#131
Draft
feat: migrate from near-openapi-client to near-openrpc-client#131
Conversation
Replace the OpenAPI-based RPC client dependency with the new OpenRPC-generated client. Updates all type imports, query builders, transaction handling, and error types across both the api and types crates to use the near-openrpc-client equivalents.
…tching Remove duplicated RpcError/RpcErrorCause from rpc_client.rs — now imported from near_openrpc_client's errors module. Simplify is_critical_* retry functions in utils.rs to use RpcError::is_retryable() and try_cause_as<RpcTransactionError>() instead of string-matching cause names. Add SendRequestError::try_cause_as<T>() convenience method so downstream users can pattern-match on typed RPC error enums (RpcQueryError, RpcTransactionError, etc.) without unwrapping. Re-export near_openrpc_client::errors as near_api::rpc_errors for easy access to the typed error enums.
94e4caf to
2ffc046
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #131 +/- ##
==========================================
+ Coverage 50.90% 55.19% +4.29%
==========================================
Files 40 41 +1
Lines 5265 4540 -725
==========================================
- Hits 2680 2506 -174
+ Misses 2585 2034 -551 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Extract take_single() and convert_block_hash() helpers in response handlers - Replace duplicated serde_json::from_value().map_err() with From impl via ? - Merge identical is_critical_blocks_error/is_critical_validator_error into is_critical_rpc_error - Remove redundant ContractExecutionError early return in is_critical_query_error - Add ContractExecutionError variant to SendRequestError, replacing synthetic RpcError construction - Remove unused QueryError::UnexpectedResponse variant - Collapse duplicate RpcTransactionResponse match arms in send.rs
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
near-openapi-client/near-openapi-typeswithnear-openrpc-client(OpenRPC-generated types and client)apiandtypescratesRpcError/RpcErrorCausefromrpc_client.rs— now imported fromnear_openrpc_client::errorsutils.rsto useRpcError::is_retryable()andtry_cause_as::<RpcTransactionError>()instead of string-matching cause namesSendRequestError::try_cause_as<T>()convenience for downstream typed error matchingnear_openrpc_client::errorsasnear_api::rpc_errorsDependencies
Test plan
cargo checkpassescargo test --libpassesCargo.tomlgit dep to point to main after feat: add errors module with per-method RPC error enums near-openrpc-client-rs#9 merges