feat(near): port baseline NEAR transaction parser - #426
Draft
shahan-khatchadourian-anchorage wants to merge 1 commit into
Draft
feat(near): port baseline NEAR transaction parser#426shahan-khatchadourian-anchorage wants to merge 1 commit into
shahan-khatchadourian-anchorage wants to merge 1 commit into
Conversation
shahan-khatchadourian-anchorage
force-pushed
the
shahankhatchadourian/near-a2-chain
branch
from
July 30, 2026 19:17
a23f854 to
f9246e6
Compare
Ports the baseline chain-parsing code: borsh Transaction/SignedTransaction decode via near-primitives (tx.rs), per-action rendering plus a fail-closed args decoder for ft_transfer/ft_transfer_call/ft_withdraw (actions.rs), the NearVisualSignConverter (convert.rs), and yoctoNEAR/Tgas formatting (fmt.rs, networks.rs). Two deliberate deviations from a verbatim port: - tx.rs decodes hex/base64 input via the shared visualsign::encodings::SupportedEncodings::detect + decode_hex convention (matching visualsign-solana) instead of hand-rolled 0x-prefix stripping. - convert.rs omits near-intents-feature-gated execute_intents decoding; that depends on presets/intents/, which lands in a later PR, compiled unconditionally rather than behind a feature flag. A1's placeholder NearParserError is removed as dead code now that this PR uses visualsign::vsptrait::TransactionParseError directly. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
shahan-khatchadourian-anchorage
force-pushed
the
shahankhatchadourian/near-a2-chain
branch
from
July 30, 2026 20:23
f9246e6 to
ee2adaf
Compare
Copilot started reviewing on behalf of
shahan-khatchadourian-anchorage
July 30, 2026 22:59
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Ports a baseline NEAR chain parser into the workspace’s VisualSign conventions by adding NEAR transaction envelope decoding, per-action rendering, and a NearVisualSignConverter that assembles NEAR transactions into SignablePayload fields.
Changes:
- Added NEAR transaction decoding from hex/base64 (including
0x-prefixed hex) into aNearTransactionwrapper. - Implemented baseline NEAR action rendering (Transfer + FunctionCall with fail-closed decoding for select NEP-141 methods) and payload assembly via
NearVisualSignConverter. - Removed now-dead NEAR-specific error type and dropped the
thiserrordependency.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/chain_parsers/visualsign-near/src/tx.rs | Adds NEAR borsh decoding from hex/base64 into NearTransaction + regression tests. |
| src/chain_parsers/visualsign-near/src/actions.rs | Renders NEAR Action variants into VisualSign fields; includes selective JSON args decoding for common FT methods. |
| src/chain_parsers/visualsign-near/src/convert.rs | Converts NearTransaction into SignablePayload with network/from/to headers and per-action fields. |
| src/chain_parsers/visualsign-near/src/fmt.rs | Adds yoctoNEAR + Tgas fixed-decimal formatting helpers and tests. |
| src/chain_parsers/visualsign-near/src/networks.rs | Introduces NearNetwork enum and display names + tests. |
| src/chain_parsers/visualsign-near/src/lib.rs | Exposes NEAR modules and re-exports NearVisualSignConverter/NearTransaction; removes dead error enum. |
| src/chain_parsers/visualsign-near/Cargo.toml | Drops thiserror dependency from the NEAR chain crate. |
| src/Cargo.lock | Removes thiserror from the NEAR crate dependency list. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+26
to
+32
| impl NearVisualSignConverter { | ||
| /// Construct a converter for mainnet (the default for wallet display). | ||
| #[must_use] | ||
| pub fn new() -> Self { | ||
| Self::default() | ||
| } | ||
| } |
| @@ -0,0 +1,65 @@ | |||
| //! yoctoNEAR, Tgas, base58 formatting helpers. | |||
| @@ -0,0 +1,39 @@ | |||
| //! NearNetwork enum and system-account recognition. | |||
This was referenced Jul 31, 2026
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.
Second PR of the NEAR-consolidation stack (stacked on #425). Ports baseline NEAR transaction parsing from an existing, already-built and already-tested reference implementation into this crate's conventions.
Stack: A1 (#425) -> A2 (this) -> A3 (intents preset) -> A4 (signature verification) -> B (identity + wiring) -> C (docs site).
What this PR does
Adds baseline NEAR chain decoding to
chain_parsers/visualsign-near:tx.rs: borsh-decodes a NEARTransaction/SignedTransactionfrom hex or base64 input.actions.rs: renders eachActionvariant (Transfer, FunctionCall with a fail-closed JSON args decoder forft_transfer/ft_transfer_call/ft_withdraw, generic label fallback for the rest).convert.rs: assembles the final payload (Network/From/To + per-action fields) viaNearVisualSignConverter.fmt.rs/networks.rs: yoctoNEAR/Tgas decimal formatting, Mainnet/Testnet display.This is a port, not new development -- the source repo's code is the reference implementation. Two deliberate deviations from a verbatim port:
tx.rs's input decoding uses this repo's sharedvisualsign::encodings::SupportedEncodings::detect+decode_hexconvention (matchingvisualsign-solana's ownfrom_string) instead of the source repo's hand-rolled0x-prefix stripping -- this repo's convention is to reuse the shared mechanism rather than hand-roll per chain. Added a regression test for the0x-prefixed case.convert.rsomits the source repo'snear-intents-feature-gatedexecute_intentsdecoding -- that code depends onpresets/intents/, which lands in A3, compiled unconditionally there (no feature gate in the final design, since every other preset in this repo is unconditional too).A1's placeholder
NearParserErrorenum is removed as dead code now that the real port usesvisualsign::vsptrait::TransactionParseErrordirectly, matching the source repo; the now-unusedthiserrordependency is dropped with it.Verification
cargo test -p visualsign-near-- 20/20 pass (all of the source repo's original cases preserved, plus the new0x-prefix test).cargo clippy -p visualsign-near --all-targets -- -D warnings,cargo fmt --check-- clean.cargo check/clippy -p parser_app --no-default-features --features near-- clean (narrow-build variant).make -C src lint,make -C src test-- clean (default features; stock builds unaffected).