fix!: distinguish view function RPC errors - #272
Merged
Conversation
Greptile SummaryThis PR refines view-function RPC error classification and preserves queried block context.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
mitinarseny
reviewed
Jul 30, 2026
Covers the panic-prefix helper directly and asserts the source message's casing survives, using a verbatim testnet call_function payload.
Merged
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.
Closes #270
Summary
RpcError::MethodNotFoundfor missing contract methodsRpcError::ContractPanicRpcError::ContractExecutionblock_heightandblock_hashon applicable view RPC errorsRpcError::block_height()andRpcError::block_hash()accessorsinfo.vm_errorand legacyinfo.errorRPC payloadscontract::methodRpcError::FunctionCallvariant andRpcError::function_callconstructorWhy
NEP-641 falls back to NEP-413 only when
w_resolve_authis unavailable. A missing method (or no contract code) therefore needs to be distinguishable from a method that exists but panics; treating both as one generic execution error makes a safe fallback decision impossible.The RPC also returns the block hash and height for these failures. Preserving that context lets resolvers associate failure and fallback decisions with the exact queried state.
The removed
FunctionCallAPI had no client construction path and overlapped with the typed errors above. Transaction function-call failures remain available astypes::FunctionCallErrorin transaction outcomes.Compatibility
This is a breaking pre-1.0 API change and should ship in
0.15.0.AccountNotFoundandContractNotDeployedare now struct variants, while the view-call error variants include optionalblock_heightandblock_hashfields. The fields remain optional so legacy or string-only RPC errors can retain their typed classification without fabricated block context.Downstream code that manually constructed or matched these variants must migrate to the new fields. Unknown or newly introduced VM error shapes continue to fall back to
RpcError::ContractExecution.Validation
cargo fmt --all -- --checkcargo test --workspacecargo clippy --workspace --all-targets --all-features -- -D warningscargo clippy -p near-kit --all-targets --no-default-features --features sandbox -- -D warningscargo check -p near-kit --all-targets --no-default-featurescargo test -p near-kit --no-default-features --doccargo +1.88 check --workspace --all-targetscargo package -p near-kit --allow-dirty