Skip to content

feat!(wallet): future-compatibility with External Contract Calls#320

Open
mitinarseny wants to merge 9 commits into
mainfrom
feat/wallet/external-request-msg
Open

feat!(wallet): future-compatibility with External Contract Calls#320
mitinarseny wants to merge 9 commits into
mainfrom
feat/wallet/external-request-msg

Conversation

@mitinarseny

@mitinarseny mitinarseny commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Added support for specifying whether a wallet request should pay for gas.
    • Requests that enable gas payment are currently rejected as unsupported.
  • Bug Fixes

    • Updated wallet signing and verification behavior to consistently handle the new gas-payment setting.
    • Refreshed signature verification fixtures and validation coverage.
  • Documentation

    • Clarified request message examples and hash expectations.
    • Marked wallet errors as open to future additions.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

RequestMessage now includes pay_for_gas, wallet SDK construction sets it to false, and signed wallet execution rejects enabled requests. Ed25519 and WebAuthn fixtures and signing tests were updated for the new message shape.

Changes

Wallet request handling

Layer / File(s) Summary
Request message contract and construction
contracts/wallet/src/message.rs, crates/wallet/sdk/src/lib.rs
RequestMessage adds a serde-aware pay_for_gas field, hash documentation and fixtures are updated, and SDK-wrapped requests set it to false.
Signed request rejection
contracts/wallet/src/contract.rs, contracts/wallet/src/error.rs
execute_signed rejects requests with pay_for_gas enabled, and ContractError is marked non-exhaustive.
Signature fixture and integration coverage
contracts/wallet/signatures/ed25519/*, contracts/wallet/signatures/webauthn/src/*
Ed25519 and WebAuthn request vectors and proofs are updated, and an asynchronous Ed25519 sign-and-verify test is added.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • near/intents#245: Introduces overlapping wallet SDK request-wrapping and signing logic.
  • near/intents#309: Modifies the wallet SDK signing path where pay_for_gas: false is now wired.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title matches the main theme of wallet changes for external contract call compatibility and is specific enough.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/wallet/external-request-msg

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mitinarseny
mitinarseny marked this pull request as ready for review July 23, 2026 18:33

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🧹 Nitpick comments (2)
contracts/wallet/src/message.rs (1)

220-222: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Test serialization of the enabled flag.

The fixture only verifies that an omitted field defaults to false. Add a serde round-trip assertion that pay_for_gas: true is emitted and preserved for the future external-call wire path.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@contracts/wallet/src/message.rs` around lines 220 - 222, Extend the
serialization test around the external-call fixture to cover the enabled flag:
construct or update the relevant message with pay_for_gas set to true, serialize
it through serde, and deserialize it again, asserting the emitted field is
present and the value remains true. Keep the existing
omitted-field/default-false fixture coverage unchanged.
contracts/wallet/src/contract.rs (1)

182-189: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Lock down the rejection path with a contract-level test.

Add or confirm a test that pay_for_gas: true aborts before nonce commit, event emission, or request execution, and explicitly records whether the public failure should be the raw panic or a ContractError.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@contracts/wallet/src/contract.rs` around lines 182 - 189, Update the
contract-level test covering the request path to submit a message with
pay_for_gas: true and verify that it aborts before nonce commit, event emission,
or request execution; assert the intended public failure representation
explicitly, distinguishing the raw panic from a ContractError, while keeping the
existing unsupported-feature rejection in the pay_for_gas handling unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@contracts/wallet/signatures/ed25519/src/lib.rs`:
- Around line 50-53: Keep the existing verification keys unchanged in the
Ed25519 fixture at contracts/wallet/signatures/ed25519/src/lib.rs:50-53 and the
P-256 fixture at contracts/wallet/signatures/webauthn/src/p256.rs:31-34; update
only the message-schema data. Regenerate the corresponding proofs at
contracts/wallet/signatures/ed25519/src/lib.rs:78 and
contracts/wallet/signatures/webauthn/src/p256.rs:49 for the updated messages and
retained keys, or explicitly document intentional key rotation at each site.

---

Nitpick comments:
In `@contracts/wallet/src/contract.rs`:
- Around line 182-189: Update the contract-level test covering the request path
to submit a message with pay_for_gas: true and verify that it aborts before
nonce commit, event emission, or request execution; assert the intended public
failure representation explicitly, distinguishing the raw panic from a
ContractError, while keeping the existing unsupported-feature rejection in the
pay_for_gas handling unchanged.

In `@contracts/wallet/src/message.rs`:
- Around line 220-222: Extend the serialization test around the external-call
fixture to cover the enabled flag: construct or update the relevant message with
pay_for_gas set to true, serialize it through serde, and deserialize it again,
asserting the emitted field is present and the value remains true. Keep the
existing omitted-field/default-false fixture coverage unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 35410de4-7afd-424f-8fc3-07ba9b74c4c1

📥 Commits

Reviewing files that changed from the base of the PR and between 0f31600 and 06d3e8e.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (9)
  • contracts/wallet/signatures/ed25519/Cargo.toml
  • contracts/wallet/signatures/ed25519/src/lib.rs
  • contracts/wallet/signatures/ed25519/src/signer.rs
  • contracts/wallet/signatures/webauthn/src/ed25519.rs
  • contracts/wallet/signatures/webauthn/src/p256.rs
  • contracts/wallet/src/contract.rs
  • contracts/wallet/src/error.rs
  • contracts/wallet/src/message.rs
  • crates/wallet/sdk/src/lib.rs

Comment on lines 50 to +53
#[case(
hex!("8565df94b8caab08f28cdd2ee014b800915741d4694fa840e50cca02ae5c6466"),
hex!("42be545513aacf13e895cae91e4ecd04498d7e9556795855c8787dbdccf55e9c"),
RequestMessage {
pay_for_gas: false,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Keep verification keys stable across message-schema fixture updates.

The pay_for_gas field changes the signed payload and proof, but not the verification key. Preserve the existing keys and regenerate only proofs, or document intentional key rotation at each site.

  • contracts/wallet/signatures/ed25519/src/lib.rs#L50-L53: retain the existing Ed25519 public key while updating the message.
  • contracts/wallet/signatures/ed25519/src/lib.rs#L78-L78: regenerate the proof for the updated message and retained key.
  • contracts/wallet/signatures/webauthn/src/p256.rs#L31-L34: retain the existing P-256 public key while updating the message.
  • contracts/wallet/signatures/webauthn/src/p256.rs#L49-L49: regenerate the WebAuthn proof for the updated message and retained key.
📍 Affects 2 files
  • contracts/wallet/signatures/ed25519/src/lib.rs#L50-L53 (this comment)
  • contracts/wallet/signatures/ed25519/src/lib.rs#L78-L78
  • contracts/wallet/signatures/webauthn/src/p256.rs#L31-L34
  • contracts/wallet/signatures/webauthn/src/p256.rs#L49-L49
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@contracts/wallet/signatures/ed25519/src/lib.rs` around lines 50 - 53, Keep
the existing verification keys unchanged in the Ed25519 fixture at
contracts/wallet/signatures/ed25519/src/lib.rs:50-53 and the P-256 fixture at
contracts/wallet/signatures/webauthn/src/p256.rs:31-34; update only the
message-schema data. Regenerate the corresponding proofs at
contracts/wallet/signatures/ed25519/src/lib.rs:78 and
contracts/wallet/signatures/webauthn/src/p256.rs:49 for the updated messages and
retained keys, or explicitly document intentional key rotation at each site.

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.

1 participant