Skip to content

Use FastNear RPC for NEAR by default and accept an RPC URL as the network - #177

Merged
illuzen merged 2 commits into
mainfrom
n13/near-fastnear-rpc
Oct 3, 2026
Merged

illuzen merged 2 commits into
mainfrom
n13/near-fastnear-rpc

Conversation

@n13

@n13 n13 commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

rpc.mainnet.near.org / rpc.testnet.near.org are deprecated and rate-limit; against mainnet they made transactions expire before broadcast. Every quantus near command that talks to the chain (send, dao, create-account, keys, sign-cold --send) goes through NearRpcClient::for_network, so the change is in one place:

  • mainnet → https://rpc.mainnet.fastnear.com, testnet → https://test.rpc.fastnear.com
  • --network also accepts an RPC URL directly; --rpc-url still overrides
  • README note in the NEAR section

Test covers the two names, a URL as network, --rpc-url precedence and an unknown name. cargo test --lib near::rpc passes, clippy clean.

Replaces the RPC part of #176; the rest of that PR is covered by #174/#175.

…work

rpc.mainnet.near.org and rpc.testnet.near.org are deprecated and rate-limit,
which made transactions expire before broadcast. --network now resolves
mainnet and testnet to FastNear and also accepts an RPC URL directly.
@n13 n13 added the bot-review Request automated review from review-bot label Oct 3, 2026

@n13 n13 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewer model: GPT-6 Astra

Verdict (advisory): Request changes

Reviewed eb4afb9eedc18bcf575ebd9cc36786842c497a5f against 97b60495905aff0e57398cf1285fe30b568ab547.

[P2] Preserve a canonical network label for cold signing — src/near/rpc.rs:48–49

The newly supported --network https://rpc.mainnet.fastnear.com is accepted by this resolver, but the cold-wallet paths for near send, DAO proposals/votes, and near sign-cold --send pass that same string to sign_transaction_cold. That function calls NearSignRequest::new, whose network allowlist is exactly mainnet/testnet (src/near/cold.rs:157, src/qr/sign_request.rs:114–125). These commands therefore fail before displaying a signing QR with:

NEAR network "https://rpc.mainnet.fastnear.com" is not one of ["mainnet", "testnet"]

I reproduced this against the built PR library: NearRpcClient::for_network(url, None) succeeds, then sign_transaction_cold(..., url, ...) returns that error. Keep URL selection separate from the signing network: either retain URLs exclusively in --rpc-url, or resolve the endpoint's canonical chain label before building the cold-signing request. Add coverage across the resolver/signing boundary; the new resolver-only test misses this failure.

Validation:

  • SKIP_CIRCUIT_BUILD=1 cargo test --locked --lib near::: 37 passed.
  • SKIP_CIRCUIT_BUILD=1 cargo test --locked --lib qr::sign_request::tests::near_: 4 passed.
  • SKIP_CIRCUIT_BUILD=1 cargo build --locked --lib, a standalone cold-signing reproduction, pinned cargo +nightly-2026-08-31 fmt --all -- --check, and git diff --check completed successfully.
  • Read-only status and view_account requests succeeded against both new endpoints and reported the intended chains. Endpoint documentation checked: FastNear RPC, NEAR RPC providers.
  • GitHub's Linux/macOS build-and-test, format, Clippy/docs, security, and dependency checks passed; Examples was still running at the final check. No transactions were broadcast.

@n13 n13 removed the bot-review Request automated review from review-bot label Oct 3, 2026
--network accepts mainnet, testnet, or one of their known endpoints
(FastNear and rpc.*.near.org); the cold-signing request and the explorer
link always use the label, which is what the wallet checks. Any other
endpoint goes in --rpc-url.
@n13

n13 commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

Addressed in dc6f9c6: --network now accepts a label or one of its known endpoints (NETWORKS in src/near/rpc.rs: FastNear and rpc.*.near.org for each of mainnet/testnet) and network_label() resolves either to the canonical label. sign_transaction_cold builds the QR request from that label, so the device never sees a URL, and explorer_tx_url resolves the same way. Arbitrary URLs are rejected by --network and belong in --rpc-url. Tests cover the resolver (networks_resolve_to_fastnear_and_known_endpoints_pass_through) and the resolver/signing boundary (known_endpoints_cold_sign_under_their_network_label).

@n13 n13 added the bot-review Request automated review from review-bot label Oct 3, 2026

@n13 n13 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewer model: GPT-6 Astra

Verdict (advisory): Approve

Reviewed the full diff at dc6f9c65673a7c50efe9f3f001212cce72163c3a against 97b60495905aff0e57398cf1285fe30b568ab547. The earlier cold-signing blocker is resolved: known endpoints become canonical labels before constructing NearSignRequest, and explorer links use the same resolver. RPC overrides retain precedence. No blocking findings remain.

[P3, non-blocking] Canonicalize the printed near-cli submission hint — src/cli/near.rs:458–460

With near sign-cold --network https://rpc.mainnet.fastnear.com without --send, signing now succeeds, but the suggested submission command still contains network-config https://rpc.mainnet.fastnear.com. near-cli looks up that argument as a configured network name, so the hint fails with a normal configuration. Use network_label(network) here too, producing network-config mainnet. This affects the helper text; the signed output and direct --send path remain usable.

Validation:

  • SKIP_CIRCUIT_BUILD=1 cargo test --locked --lib near::: 38 passed, including the new resolver and cold-request regressions.
  • SKIP_CIRCUIT_BUILD=1 cargo test --locked --lib qr::sign_request::tests::near_: 4 passed.
  • cargo +nightly-2026-08-31 fmt --all -- --check and git diff --check: passed.
  • Read-only status and view_account calls succeeded on both defaults; they reported the expected mainnet/testnet chains. Checked endpoint references in FastNear documentation and NEAR's provider list. No transactions were broadcast.
  • GitHub Linux build/tests, format, Clippy/docs, security, and dependency checks passed. macOS build/tests and Examples were still running at the final check.

@n13 n13 removed the bot-review Request automated review from review-bot label Oct 3, 2026
@illuzen
illuzen merged commit 413a6e2 into main Oct 3, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants