Skip to content

refactor: Allow custom on_sending_delegate_action_callback handler for transactions and on_after_signing_callback for sign-message#583

Merged
frol merged 6 commits into
mainfrom
refactor/allow-custom-send-delegate-action
Apr 16, 2026
Merged

refactor: Allow custom on_sending_delegate_action_callback handler for transactions and on_after_signing_callback for sign-message#583
frol merged 6 commits into
mainfrom
refactor/allow-custom-send-delegate-action

Conversation

@frol

@frol frol commented Apr 14, 2026

Copy link
Copy Markdown
Collaborator

I need it for trezu CLI, which leverages a custom meta-transaction relayer backend that requires auth, so it is better to just enable customization here and let trezu CLI to reuse parts of near-cli-rs nicely

Copilot AI review requested due to automatic review settings April 14, 2026 21:33
@frol frol requested a review from a team as a code owner April 14, 2026 21:33
@github-project-automation github-project-automation Bot moved this to NEW❗ in DevTools Apr 14, 2026
@frol frol force-pushed the refactor/allow-custom-send-delegate-action branch from 1f477fe to a7d7298 Compare April 14, 2026 21:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Refactors transaction submission to support a customizable handler for sending SignedDelegateAction (useful for external/meta-transaction relayers requiring custom auth).

Changes:

  • Introduces OnSendingDelegateActionCallback and threads it through SubmitContext, ActionContext, and TransactionContext.
  • Propagates the optional callback through most signing flows (seed phrase, private key, keychain/legacy keychain, ledger).
  • Updates the send flow to invoke the custom delegate-action sender when present, otherwise falling back to the configured relayer URL or display fallback.

Reviewed changes

Copilot reviewed 43 out of 43 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/transaction_signature_options/mod.rs Adds OnSendingDelegateActionCallback type + optional field on SubmitContext.
src/transaction_signature_options/send/mod.rs Invokes custom delegate-action sender callback before relayer-url fallback.
src/network_for_transaction/mod.rs Threads optional callback through network selection context.
src/commands/mod.rs Adds optional callback to ActionContext and TransactionContext.
src/transaction_signature_options/sign_with_seed_phrase/mod.rs Carries callback through seed-phrase signing context into SubmitContext.
src/transaction_signature_options/sign_with_private_key/mod.rs Carries callback through private-key signing context into SubmitContext.
src/transaction_signature_options/sign_with_access_key_file/mod.rs Carries callback through access-key-file signing context into SubmitContext.
src/transaction_signature_options/sign_with_keychain/mod.rs Carries callback through keychain signing context into SubmitContext.
src/transaction_signature_options/sign_with_legacy_keychain/mod.rs Carries callback through legacy-keychain signing context into SubmitContext.
src/transaction_signature_options/sign_with_ledger/mod.rs Carries callback through ledger signing contexts (USB/BLE).
src/transaction_signature_options/sign_with_mpc/mod.rs Initializes callback to None in MPC flows (see review comment re: propagation).
src/transaction_signature_options/submit_dao_proposal/mod.rs Initializes callback to None for DAO proposal conversion (see review comment re: propagation).
src/commands/transaction/sign_transaction/mod.rs Initializes callback to None in this command’s default ActionContext.
src/commands/transaction/send_meta_transaction/sign_as/mod.rs Initializes callback to None in this command’s default ActionContext.
src/commands/transaction/construct_transaction/skip_action/mod.rs Initializes callback to None when constructing ActionContext.
src/commands/tokens/send_near/mod.rs Initializes callback to None when constructing ActionContext.
src/commands/tokens/send_nft/mod.rs Initializes callback to None when constructing ActionContext.
src/commands/tokens/send_ft/amount_ft.rs Initializes callback to None when constructing ActionContext.
src/commands/tokens/send_ft_call/amount_ft.rs Initializes callback to None when constructing ActionContext.
src/commands/staking/delegate/deposit_and_stake.rs Initializes callback to None when constructing ActionContext.
src/commands/staking/delegate/stake.rs Initializes callback to None when constructing ActionContext.
src/commands/staking/delegate/stake_all.rs Initializes callback to None when constructing ActionContext.
src/commands/staking/delegate/unstake.rs Initializes callback to None when constructing ActionContext.
src/commands/staking/delegate/unstake_all.rs Initializes callback to None when constructing ActionContext.
src/commands/staking/delegate/withdraw.rs Initializes callback to None when constructing ActionContext.
src/commands/staking/delegate/withdraw_all.rs Initializes callback to None when constructing ActionContext.
src/commands/contract/deploy_global/mod.rs Initializes callback to None when constructing ActionContext.
src/commands/contract/deploy/initialize_mode/mod.rs Initializes callback to None when constructing ActionContext.
src/commands/contract/deploy/initialize_mode/call_function_type/mod.rs Initializes callback to None when constructing ActionContext.
src/commands/contract/call_function/as_transaction/mod.rs Initializes callback to None when constructing ActionContext.
src/commands/account/update_social_profile/sign_as.rs Initializes callback to None when constructing ActionContext.
src/commands/account/storage_management/storage_withdraw.rs Initializes callback to None when constructing ActionContext.
src/commands/account/storage_management/storage_deposit.rs Initializes callback to None when constructing ActionContext.
src/commands/account/delete_key/public_keys_to_delete.rs Initializes callback to None when constructing ActionContext.
src/commands/account/delete_account/mod.rs Initializes callback to None when constructing ActionContext.
src/commands/account/create_account/fund_myself_create_account/sign_as/mod.rs Initializes callback to None when constructing ActionContext.
src/commands/account/add_key/use_public_key/mod.rs Initializes callback to None when constructing ActionContext.
src/commands/account/add_key/use_mpc/mod.rs Initializes callback to None when constructing ActionContext.
src/commands/account/add_key/use_manually_provided_seed_phrase/mod.rs Initializes callback to None when constructing ActionContext.
src/commands/account/add_key/use_ledger/mod.rs Initializes callback to None when constructing ActionContext (USB/BLE).
src/commands/account/add_key/autogenerate_new_keypair/save_keypair_to_legacy_keychain/mod.rs Initializes callback to None when constructing ActionContext.
src/commands/account/add_key/autogenerate_new_keypair/save_keypair_to_keychain/mod.rs Initializes callback to None when constructing ActionContext.
src/commands/account/add_key/autogenerate_new_keypair/print_keypair_to_terminal/mod.rs Initializes callback to None when constructing ActionContext.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/transaction_signature_options/send/mod.rs
Comment thread src/transaction_signature_options/mod.rs
Comment thread src/transaction_signature_options/submit_dao_proposal/mod.rs Outdated
Comment thread src/transaction_signature_options/sign_with_mpc/mod.rs Outdated
…as_delegate_action down to sign-with-MPC and submit-as-DAO contexts
@frol frol force-pushed the refactor/allow-custom-send-delegate-action branch from ed1615d to 6bf9511 Compare April 15, 2026 13:35
@frol frol requested a review from Copilot April 15, 2026 13:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 51 out of 51 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/commands/message/sign_nep413/mod.rs
Comment thread src/commands/message/sign_nep413/mod.rs
Comment thread src/transaction_signature_options/send/mod.rs
@frol frol changed the title refactor: Allow custom on_sending_delegate_action_callback handler refactor: Allow custom on_sending_delegate_action_callback handler for transactions and on_after_signing_callback for sign-message Apr 15, 2026
@vsavchyn-dev

Copy link
Copy Markdown
Contributor

@race-of-sloths score 5

@race-of-sloths

race-of-sloths commented Apr 16, 2026

Copy link
Copy Markdown

@frol Thank you for your contribution! Your pull request is now a part of the Race of Sloths!
Do you want to apply for monthly streak? Get 8+ score for a single PR this month and receive boost for race-of-sloths!

Shows inviting banner with latest news.

Shows profile picture for the author of the PR

Current status: executed
Reviewer Score
@vsavchyn-dev 5

Your contribution is much appreciated with a final score of 5!
You have received 60 (50 base + 10 weekly bonus) Sloth points for this contribution

@vsavchyn-dev received 25 Sloth Points for reviewing and scoring this pull request.

Another weekly streak completed, well done @frol! To keep your weekly streak and get another bonus make pull request next week! Looking forward to see you in race-of-sloths

What is the Race of Sloths

Race of Sloths is a friendly competition where you can participate in challenges and compete with other open-source contributors within your normal workflow

For contributors:

  • Tag @race-of-sloths inside your pull requests
  • Wait for the maintainer to review and score your pull request
  • Check out your position in the Leaderboard
  • Keep weekly and monthly streaks to reach higher positions
  • Boast your contributions with a dynamic picture of your Profile

For maintainers:

  • Score pull requests that participate in the Race of Sloths and receive a reward
  • Engage contributors with fair scoring and fast responses so they keep their streaks
  • Promote the Race to the point where the Race starts promoting you
  • Grow the community of your contributors

Feel free to check our website for additional details!

Bot commands
  • For contributors
    • Include a PR: @race-of-sloths include to enter the Race with your PR
  • For maintainers:
    • Invite contributor @race-of-sloths invite to invite the contributor to participate in a race or include it, if it's already a runner.
    • Assign points: @race-of-sloths score [1/2/3/5/8/13] to award points based on your assessment.
    • Reject this PR: @race-of-sloths exclude to send this PR back to the drawing board.
    • Exclude repo: @race-of-sloths pause to stop bot activity in this repo until @race-of-sloths unpause command is called

@frol frol enabled auto-merge (squash) April 16, 2026 16:24
@frol frol merged commit 350d74d into main Apr 16, 2026
10 checks passed
@frol frol deleted the refactor/allow-custom-send-delegate-action branch April 16, 2026 16:24
@github-project-automation github-project-automation Bot moved this from NEW❗ to Shipped 🚀 in DevTools Apr 16, 2026
r-near added a commit that referenced this pull request Apr 16, 2026
Resolve conflicts: keep near-kit types throughout, incorporate new
on_sending_delegate_action_callback from #583, convert state-init
command (#560) from near-primitives to near-kit, adopt near-slip10
from #584.
frol added a commit to NEAR-DevHub/trezu that referenced this pull request Apr 17, 2026
<img width="998" height="592" alt="image"
src="https://github.com/user-attachments/assets/fdb3a264-1c00-46fe-b995-58675150d4f8"
/>

There are still a couple of bugs here and there, but it mostly works.

This PR is blocked on near/near-cli-rs#583
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Shipped 🚀

Development

Successfully merging this pull request may close these issues.

5 participants