Skip to content

feat: migrate from near-openapi-client to near-openrpc-client#131

Draft
r-near wants to merge 3 commits intomainfrom
feat/migrate-openrpc
Draft

feat: migrate from near-openapi-client to near-openrpc-client#131
r-near wants to merge 3 commits intomainfrom
feat/migrate-openrpc

Conversation

@r-near
Copy link
Contributor

@r-near r-near commented Mar 4, 2026

Summary

  • Replace near-openapi-client / near-openapi-types with near-openrpc-client (OpenRPC-generated types and client)
  • Update all type imports, query builders, transaction handling, and error types across both api and types crates
  • Remove duplicated RpcError/RpcErrorCause from rpc_client.rs — now imported from near_openrpc_client::errors
  • Simplify retry logic 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 for downstream typed error matching
  • Re-export near_openrpc_client::errors as near_api::rpc_errors

Dependencies

Test plan

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.
@r-near r-near force-pushed the feat/migrate-openrpc branch from 94e4caf to 2ffc046 Compare March 4, 2026 19:26
@codecov
Copy link

codecov bot commented Mar 4, 2026

Codecov Report

❌ Patch coverage is 54.94071% with 228 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.19%. Comparing base (37fee2c) to head (2ffc046).

Files with missing lines Patch % Lines
types/src/transaction/actions.rs 27.90% 62 Missing ⚠️
api/src/common/query/handlers/mod.rs 69.16% 37 Missing ⚠️
api/src/stake.rs 0.00% 25 Missing ⚠️
api/src/common/query/query_request.rs 72.60% 20 Missing ⚠️
types/src/transaction/delegate_action.rs 0.00% 20 Missing ⚠️
api/src/common/send.rs 54.05% 17 Missing ⚠️
api/src/common/utils.rs 37.03% 17 Missing ⚠️
api/src/errors.rs 26.66% 11 Missing ⚠️
api/src/common/query/mod.rs 33.33% 4 Missing ⚠️
api/src/rpc_client.rs 90.90% 3 Missing ⚠️
... and 8 more
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: NEW❗

Development

Successfully merging this pull request may close these issues.

1 participant