Skip to content

Map dAPI block and transaction queries to NEP-21 types - #114

Open
Jim8y wants to merge 1 commit into
neoorder:masterfrom
Jim8y:fix/audit-p2-13
Open

Jim8y wants to merge 1 commit into
neoorder:masterfrom
Jim8y:fix/audit-p2-13

Conversation

@Jim8y

@Jim8y Jim8y commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix audit P2-13: adapt verbose node JSON returned by dAPI getBlock and getTransaction to the NEP-21 query field names and types.

  • Convert node field names to camelCase, and decode sender/next-consensus addresses to script hashes using the configured address version.
  • Preserve atomic fee strings exactly, including values above JavaScript's safe-integer range; do not rescale them or round through floating point.
  • Convert every nested transaction, supplying metadata from its enclosing block while leaving unconfirmed standalone metadata absent.
  • Preserve signer restrictions, witness rules and unrelated response fields, without mutating the source RPC object.

Validation

  • dotnet test tests/p2-13/OneGate.DapiQuery.Tests.csproj --no-restore --nologo: 11/11 passed. Fixtures use the application's Neo 3.10.0 serialization.
  • iOS 26.5 simulator and Android API 36 arm64 emulator: 12 JavaScript assertions passed on each through the actual injected NEP-21 provider, native BridgeWebView, RpcServer, LaunchDAppPage, RpcClient, mapper and callback. Three responses retained matching IDs and completed real JS promises; the upstream sequence was getrawtransaction/getblock/getrawtransaction. Checks covered exact fees, field names, hashes, signer restrictions, nested metadata and unconfirmed transactions.
  • Only upstream HTTP responses were controlled. The external fixture was removed before separate fixture-free product rebuild/install/launch checks on both platforms; normal Home/four tabs rendered with no OneGate app crash observed.
  • Final tested source patch SHA-256: 479bae85c68333104a2ca1fffaa0a6d790872d940533765dd9e8b53f08ea785f; matched to both platform evidence sets before committing.

Limitations and integration

No live-chain query, signing, approval or broadcast was performed. Clients relying on nonstandard lowercase node fields must use the NEP-21 names; screenshots and QA fixtures remain outside the repository and are not attached here, and no hosted CI pass is claimed.

Independently based and validated on master@623603d; preserve solution project entries as a union and revalidate after integration rather than treating this as combined audit validation. This query-mapping change has no dependency on a bridge-origin authorization redesign.

Copilot AI lite review requested due to automatic review settings September 5, 2026 07:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The mapper changes are narrow, match the stated requirements, and are backed by targeted regression tests that validate immutability, fee precision, and nested-transaction metadata behavior.

Pull request overview

This PR addresses audit item P2-13 by introducing a mapper that adapts verbose Neo node RPC JSON from dAPI getBlock / getTransaction into NEP-21-aligned field names and types (camelCase names; sender/next-consensus decoded to UInt160 script hashes) while preserving fee string precision and leaving the source RPC JSON unmodified.

Changes:

  • Added DapiQueryResponseMapper to deep-clone and transform getblock / getrawtransaction verbose results into NEP-21 query shapes (including nested tx metadata propagation from enclosing blocks).
  • Wired the mapper into the dAPI surface in LaunchDAppPage for GetBlock and GetTransaction.
  • Added a dedicated regression-test project (plus coverage runsettings and documentation) to validate field mapping, immutability, nested transaction behavior, and fee-string precision.
File summaries
File Description
tests/p2-13/README.md Documents the mapping contract, invariants (immutability, fee precision), and validation steps for P2-13 regression tests.
tests/p2-13/OneGate.DapiQuery.Tests.csproj Adds a focused test project that links the production mapper and uses Neo 3.10.0 for fixtures.
tests/p2-13/DapiQueryResponseMapperTests.cs Introduces unit tests covering field renames, address decoding, nested tx metadata propagation, and non-mutation guarantees.
tests/p2-13/coverage.runsettings Adds coverage configuration targeting the mapper for the new test project.
OneGateApp/Services/RPC/DapiQueryResponseMapper.cs Implements the RPC-to-NEP-21 JSON adaptation while preserving fee string precision and avoiding mutation of the input JSON.
OneGateApp/Pages/LaunchDAppPage.xaml.dAPI.cs Updates dAPI GetBlock / GetTransaction to return mapped NEP-21-shaped responses.
OneGateApp.slnx Registers the new P2-13 test project in the solution.
Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants