feat: Add construct-meta-transaction command#562
Merged
Conversation
- Add sign_as_delegate_action: bool to ConstructTransactionContext, ActionContext, TransactionContext, and NetworkForTransactionArgsContext - Propagate sign_as_delegate_action through all action chain context structs (add_action_1/2/3) - Update skip_action to propagate sign_as_delegate_action to ActionContext - Combine sign_as_delegate_action with meta_transaction_relayer_url check in NetworkForTransactionArgsContext - Update info_str to use sign_as_delegate_action instead of relayer URL check - Update all signers to use previous_context.sign_as_delegate_action - Create construct_meta_transaction module that sets sign_as_delegate_action: true - Add ConstructMetaTransaction variant to TransactionActions Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add construct meta-transaction feature
Add Feb 27, 2026
construct-meta-transaction command
Collaborator
frol
approved these changes
Feb 27, 2026
There was a problem hiding this comment.
Pull request overview
Adds an explicit transaction construct-meta-transaction CLI command and consolidates meta-transaction (delegate action) signing behavior behind a single propagated sign_as_delegate_action context flag, so signer implementations no longer consult network config directly.
Changes:
- Introduce
construct-meta-transactionundernear transaction, reusing the existing construct-transaction action chain while forcingsign_as_delegate_action: true. - Propagate
sign_as_delegate_actionthroughConstructTransactionContext → ActionContext → NetworkForTransactionArgsContext → TransactionContext, with network config (meta_transaction_relayer_url) translated into the flag inNetworkForTransactionArgsContext. - Update signer implementations to branch on
previous_context.sign_as_delegate_actioninstead ofnetwork_config.meta_transaction_relayer_url.is_some().
Reviewed changes
Copilot reviewed 79 out of 79 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/commands/mod.rs | Add sign_as_delegate_action to ActionContext and TransactionContext |
| src/network_for_transaction/mod.rs | Compute/propagate sign_as_delegate_action; adjust “Unsigned …” label |
| src/commands/transaction/mod.rs | Register new construct-meta-transaction subcommand |
| src/commands/transaction/construct_meta_transaction/mod.rs | Implement construct-meta-transaction context (forces delegate-action signing) |
| src/commands/transaction/construct_transaction/mod.rs | Add sign_as_delegate_action to construct context (default false) |
| src/commands/transaction/construct_transaction/skip_action/mod.rs | Propagate flag into ActionContext when moving to signing flow |
| src/commands/transaction/construct_transaction/add_action_1/add_action/use_global_contract/mod.rs | Propagate flag through action builder context |
| src/commands/transaction/construct_transaction/add_action_1/add_action/transfer/mod.rs | Propagate flag through action builder context |
| src/commands/transaction/construct_transaction/add_action_1/add_action/stake/mod.rs | Propagate flag through action builder context |
| src/commands/transaction/construct_transaction/add_action_1/add_action/deploy_global_contract/mod.rs | Propagate flag through action builder context |
| src/commands/transaction/construct_transaction/add_action_1/add_action/deploy_contract/mod.rs | Propagate flag through action builder context |
| src/commands/transaction/construct_transaction/add_action_1/add_action/delete_key/mod.rs | Propagate flag through action builder context |
| src/commands/transaction/construct_transaction/add_action_1/add_action/delete_account/mod.rs | Propagate flag through action builder context |
| src/commands/transaction/construct_transaction/add_action_1/add_action/create_account/mod.rs | Propagate flag through action builder context |
| src/commands/transaction/construct_transaction/add_action_1/add_action/call_function/mod.rs | Propagate flag through function-call builder contexts |
| src/commands/transaction/construct_transaction/add_action_1/add_action/add_key/use_public_key/mod.rs | Propagate flag through add-key builder context |
| src/commands/transaction/construct_transaction/add_action_1/add_action/add_key/use_manually_provided_seed_phrase/mod.rs | Propagate flag through add-key builder context |
| src/commands/transaction/construct_transaction/add_action_1/add_action/add_key/access_key_type/mod.rs | Propagate flag through access-key permission contexts |
| src/commands/transaction/construct_transaction/add_action_2/add_action/use_global_contract/mod.rs | Propagate flag through action builder context |
| src/commands/transaction/construct_transaction/add_action_2/add_action/transfer/mod.rs | Propagate flag through action builder context |
| src/commands/transaction/construct_transaction/add_action_2/add_action/stake/mod.rs | Propagate flag through action builder context |
| src/commands/transaction/construct_transaction/add_action_2/add_action/deploy_global_contract/mod.rs | Propagate flag through action builder context |
| src/commands/transaction/construct_transaction/add_action_2/add_action/deploy_contract/mod.rs | Propagate flag through action builder context |
| src/commands/transaction/construct_transaction/add_action_2/add_action/delete_key/mod.rs | Propagate flag through action builder context |
| src/commands/transaction/construct_transaction/add_action_2/add_action/delete_account/mod.rs | Propagate flag through action builder context |
| src/commands/transaction/construct_transaction/add_action_2/add_action/create_account/mod.rs | Propagate flag through action builder context |
| src/commands/transaction/construct_transaction/add_action_2/add_action/call_function/mod.rs | Propagate flag through function-call builder contexts |
| src/commands/transaction/construct_transaction/add_action_2/add_action/add_key/use_public_key/mod.rs | Propagate flag through add-key builder context |
| src/commands/transaction/construct_transaction/add_action_2/add_action/add_key/use_manually_provided_seed_phrase/mod.rs | Propagate flag through add-key builder context |
| src/commands/transaction/construct_transaction/add_action_2/add_action/add_key/access_key_type/mod.rs | Propagate flag through access-key permission contexts |
| src/commands/transaction/construct_transaction/add_action_3/add_action/use_global_contract/mod.rs | Propagate flag through action builder context |
| src/commands/transaction/construct_transaction/add_action_3/add_action/transfer/mod.rs | Propagate flag through action builder context |
| src/commands/transaction/construct_transaction/add_action_3/add_action/stake/mod.rs | Propagate flag through action builder context |
| src/commands/transaction/construct_transaction/add_action_3/add_action/deploy_global_contract/mod.rs | Propagate flag through action builder context |
| src/commands/transaction/construct_transaction/add_action_3/add_action/deploy_contract/mod.rs | Propagate flag through action builder context |
| src/commands/transaction/construct_transaction/add_action_3/add_action/delete_key/mod.rs | Propagate flag through action builder context |
| src/commands/transaction/construct_transaction/add_action_3/add_action/delete_account/mod.rs | Propagate flag through action builder context |
| src/commands/transaction/construct_transaction/add_action_3/add_action/create_account/mod.rs | Propagate flag through action builder context |
| src/commands/transaction/construct_transaction/add_action_3/add_action/call_function/mod.rs | Propagate flag through function-call builder contexts |
| src/commands/transaction/construct_transaction/add_action_3/add_action/add_key/use_public_key/mod.rs | Propagate flag through add-key builder context |
| src/commands/transaction/construct_transaction/add_action_3/add_action/add_key/use_manually_provided_seed_phrase/mod.rs | Propagate flag through add-key builder context |
| src/commands/transaction/construct_transaction/add_action_3/add_action/add_key/access_key_type/mod.rs | Propagate flag through access-key permission contexts |
| src/commands/transaction/sign_transaction/mod.rs | Initialize ActionContext.sign_as_delegate_action |
| src/commands/transaction/send_meta_transaction/sign_as/mod.rs | Initialize ActionContext.sign_as_delegate_action |
| src/transaction_signature_options/sign_with_keychain/mod.rs | Use context flag to decide delegate-action vs tx signing |
| src/transaction_signature_options/sign_with_legacy_keychain/mod.rs | Use context flag to decide delegate-action vs tx signing |
| src/transaction_signature_options/sign_with_private_key/mod.rs | Use context flag to decide delegate-action vs tx signing |
| src/transaction_signature_options/sign_with_seed_phrase/mod.rs | Use context flag to decide delegate-action vs tx signing |
| src/transaction_signature_options/sign_with_access_key_file/mod.rs | Use context flag to decide delegate-action vs tx signing |
| src/transaction_signature_options/sign_with_ledger/mod.rs | Use context flag to decide delegate-action vs tx signing |
| src/transaction_signature_options/sign_with_mpc/mod.rs | Add TransactionContext.sign_as_delegate_action initialization |
| src/transaction_signature_options/submit_dao_proposal/mod.rs | Add TransactionContext.sign_as_delegate_action initialization |
| src/commands/tokens/send_near/mod.rs | Initialize ActionContext.sign_as_delegate_action |
| src/commands/tokens/send_nft/mod.rs | Initialize ActionContext.sign_as_delegate_action |
| src/commands/tokens/send_ft/amount_ft.rs | Initialize ActionContext.sign_as_delegate_action |
| src/commands/staking/delegate/deposit_and_stake.rs | Initialize ActionContext.sign_as_delegate_action |
| src/commands/staking/delegate/stake.rs | Initialize ActionContext.sign_as_delegate_action |
| src/commands/staking/delegate/stake_all.rs | Initialize ActionContext.sign_as_delegate_action |
| src/commands/staking/delegate/unstake.rs | Initialize ActionContext.sign_as_delegate_action |
| src/commands/staking/delegate/unstake_all.rs | Initialize ActionContext.sign_as_delegate_action |
| src/commands/staking/delegate/withdraw.rs | Initialize ActionContext.sign_as_delegate_action |
| src/commands/staking/delegate/withdraw_all.rs | Initialize ActionContext.sign_as_delegate_action |
| src/commands/contract/call_function/as_transaction/mod.rs | Initialize ActionContext.sign_as_delegate_action |
| src/commands/contract/deploy/initialize_mode/mod.rs | Initialize ActionContext.sign_as_delegate_action |
| src/commands/contract/deploy/initialize_mode/call_function_type/mod.rs | Initialize ActionContext.sign_as_delegate_action |
| src/commands/contract/deploy_global/mod.rs | Initialize ActionContext.sign_as_delegate_action |
| src/commands/account/add_key/use_public_key/mod.rs | Initialize ActionContext.sign_as_delegate_action |
| src/commands/account/add_key/use_manually_provided_seed_phrase/mod.rs | Initialize ActionContext.sign_as_delegate_action |
| src/commands/account/add_key/use_mpc/mod.rs | Initialize ActionContext.sign_as_delegate_action |
| src/commands/account/add_key/use_ledger/mod.rs | Initialize ActionContext.sign_as_delegate_action |
| src/commands/account/add_key/autogenerate_new_keypair/print_keypair_to_terminal/mod.rs | Initialize ActionContext.sign_as_delegate_action |
| src/commands/account/add_key/autogenerate_new_keypair/save_keypair_to_keychain/mod.rs | Initialize ActionContext.sign_as_delegate_action |
| src/commands/account/add_key/autogenerate_new_keypair/save_keypair_to_legacy_keychain/mod.rs | Initialize ActionContext.sign_as_delegate_action |
| src/commands/account/create_account/fund_myself_create_account/sign_as/mod.rs | Initialize ActionContext.sign_as_delegate_action |
| src/commands/account/delete_account/mod.rs | Initialize ActionContext.sign_as_delegate_action |
| src/commands/account/delete_key/public_keys_to_delete.rs | Initialize ActionContext.sign_as_delegate_action |
| src/commands/account/storage_management/storage_deposit.rs | Initialize ActionContext.sign_as_delegate_action |
| src/commands/account/storage_management/storage_withdraw.rs | Initialize ActionContext.sign_as_delegate_action |
| src/commands/account/update_social_profile/sign_as.rs | Initialize ActionContext.sign_as_delegate_action |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
frol
requested changes
Feb 27, 2026
Collaborator
frol
left a comment
There was a problem hiding this comment.
I am refactoring it a tiny bit, don't merge yet
…remove panic in send Co-authored-by: frol <304265+frol@users.noreply.github.com>
…ion_relayer_url' is not configured for the network
frol
approved these changes
Feb 27, 2026
construct-meta-transaction commandconstruct-meta-transaction command
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.


There was no way to explicitly construct and sign a meta-transaction (delegate action) — the only path was implicit via
meta_transaction_relayer_urlin network config. This addstransaction construct-meta-transactionas an explicit command, and consolidates the delegate-action decision into a single context flag so signers don't check two places.Key changes
New
construct-meta-transactioncommand — same CLI structure asconstruct-transaction(sender, receiver, action chain); reusesadd_action_1/2/3/skip_actionentirely without duplication; outputsConstructTransactionContextwithsign_as_delegate_action: truesign_as_delegate_action: boolflag propagated through the context chain:ConstructTransactionContext→ActionContext(viaskip_action) →NetworkForTransactionArgsContext→TransactionContextNetworkForTransactionArgsContextascontext.sign_as_delegate_action || network_config.meta_transaction_relayer_url.is_some(), so the relayer URL config is translated into the flag — signers now check one place onlyAll signers updated (
sign_with_keychain,sign_with_legacy_keychain,sign_with_private_key,sign_with_seed_phrase,sign_with_access_key_file,sign_with_ledger) to checkprevious_context.sign_as_delegate_actioninstead ofnetwork_config.meta_transaction_relayer_url.is_some()submit_dao_proposalandsign_with_mpcnow derivesign_as_delegate_actionfromnetwork_config.meta_transaction_relayer_url.is_some(), preserving existing behavior for those flows when a relayer URL is configuredsendstep now returns a user-facing error instead of panicking when aSignedDelegateActionis produced but nometa_transaction_relayer_urlis configured (e.g. when usingconstruct-meta-transactionwithout a relayer), with a message guiding the user to configure the relayer URL or usetransaction send-meta-transactionExample usage:
Original prompt
construct-meta-transaction#561💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.