Commit ef87d0e
feat: Add
There was no way to explicitly construct and sign a meta-transaction
(delegate action) — the only path was implicit via
`meta_transaction_relayer_url` in network config. This adds `transaction
construct-meta-transaction` as 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-transaction` command** — same CLI structure as
`construct-transaction` (sender, receiver, action chain); reuses
`add_action_1`/`2`/`3`/`skip_action` entirely without duplication;
outputs `ConstructTransactionContext` with `sign_as_delegate_action:
true`
- **`sign_as_delegate_action: bool` flag** propagated through the
context chain:
- `ConstructTransactionContext` → `ActionContext` (via `skip_action`) →
`NetworkForTransactionArgsContext` → `TransactionContext`
- Set in `NetworkForTransactionArgsContext` as
`context.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
only
- **All 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 check `previous_context.sign_as_delegate_action`
instead of `network_config.meta_transaction_relayer_url.is_some()`
- **`submit_dao_proposal` and `sign_with_mpc`** now derive
`sign_as_delegate_action` from
`network_config.meta_transaction_relayer_url.is_some()`, preserving
existing behavior for those flows when a relayer URL is configured
- **`send` step** now returns a user-facing error instead of panicking
when a `SignedDelegateAction` is produced but no
`meta_transaction_relayer_url` is configured (e.g. when using
`construct-meta-transaction` without a relayer), with a message guiding
the user to configure the relayer URL or use `transaction
send-meta-transaction`
Example usage:
```sh
near transaction construct-meta-transaction alice.near bob.near \
add-action transfer 1NEAR \
skip \
network-config mainnet \
sign-with-keychain display
```
<!-- START COPILOT ORIGINAL PROMPT -->
<details>
<summary>Original prompt</summary>
>
> ----
>
> *This section details on the original issue you should resolve*
>
> <issue_title>[Task] Add `construct-meta-transaction`</issue_title>
> <issue_description>### Background
>
> Meta-transactions on near are basically just a transaction with a
single action
[`DelegateAction`](https://github.com/near/nearcore/blob/master/core/primitives/src/action/delegate.rs).
>
> The `DelegateAction` is basically a `SignedTransaction` with
`max_block_height` which controls the expiration of the signed payload.
>
> near-cli-rs already has support for creating and sending
Meta-transactions if the network config has
`meta_transaction_relayer_url`, so currently signer implementations
(e.g.
[1](https://github.com/near/near-cli-rs/blob/b067abdefa0306a13395e512f5453dda4b3579d4/src/transaction_signature_options/sign_with_legacy_keychain/mod.rs#L195))
make the decision based on this config setting, but there is no way to
explicitly create and sign the Delegate Action.
>
> ### User Story
>
> As a NEAR CLI user, who uses dApps that support meta-transactions and
use NEAR Connect with NEAR CLI plugin, I need CLI to support
construction of meta-transactions just like `construct-transaction`.
>
> ### Acceptance Criteria
>
> I would like to have a new subcommand under `transaction`, so next to
`construct-transaction` we could have `construct-meta-transaction`, the
`construct-transaction` implementations should be reused without
copy-pasting them, and the only change that is expected is to the
signers implementation that would use the context flag to make the
decision whether they should construct & sign a transaction or delegate
action. As for the `meta_transaction_relayer_url` config option, it
should be translated into the context flag setting as well, so signers
don't need to check two places for the decision.
>
> ### Resources & Additional Notes
>
> _No response_</issue_description>
>
> ## Comments on the Issue (you are @copilot in this section)
>
> <comments>
> </comments>
>
</details>
<!-- START COPILOT CODING AGENT SUFFIX -->
- Fixes #561
<!-- START COPILOT CODING AGENT TIPS -->
---
💡 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](https://gh.io/copilot-coding-agent-tips) in the docs.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: frol <304265+frol@users.noreply.github.com>
Co-authored-by: Vlad Frolov <frolvlad@gmail.com>construct-meta-transaction command (#562)1 parent b067abd commit ef87d0e
File tree
80 files changed
+188
-12
lines changed- src
- commands
- account
- add_key
- autogenerate_new_keypair
- print_keypair_to_terminal
- save_keypair_to_keychain
- save_keypair_to_legacy_keychain
- use_ledger
- use_manually_provided_seed_phrase
- use_mpc
- use_public_key
- create_account/fund_myself_create_account/sign_as
- delete_account
- delete_key
- storage_management
- update_social_profile
- contract
- call_function/as_transaction
- deploy_global
- deploy/initialize_mode
- call_function_type
- staking/delegate
- tokens
- send_ft
- send_near
- send_nft
- transaction
- construct_meta_transaction
- construct_transaction
- add_action_1/add_action
- add_key
- access_key_type
- use_manually_provided_seed_phrase
- use_public_key
- call_function
- create_account
- delete_account
- delete_key
- deploy_contract
- deploy_global_contract
- stake
- transfer
- use_global_contract
- add_action_2/add_action
- add_key
- access_key_type
- use_manually_provided_seed_phrase
- use_public_key
- call_function
- create_account
- delete_account
- delete_key
- deploy_contract
- deploy_global_contract
- stake
- transfer
- use_global_contract
- add_action_3/add_action
- add_key
- access_key_type
- use_manually_provided_seed_phrase
- use_public_key
- call_function
- create_account
- delete_account
- delete_key
- deploy_contract
- deploy_global_contract
- stake
- transfer
- use_global_contract
- skip_action
- send_meta_transaction/sign_as
- sign_transaction
- network_for_transaction
- transaction_signature_options
- send
- sign_with_access_key_file
- sign_with_keychain
- sign_with_ledger
- sign_with_legacy_keychain
- sign_with_mpc
- sign_with_private_key
- sign_with_seed_phrase
- submit_dao_proposal
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
80 files changed
+188
-12
lines changedLines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| 100 | + | |
100 | 101 | | |
101 | 102 | | |
102 | 103 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| 77 | + | |
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
| 242 | + | |
242 | 243 | | |
243 | 244 | | |
244 | 245 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| 157 | + | |
157 | 158 | | |
158 | 159 | | |
159 | 160 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| 109 | + | |
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| 77 | + | |
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
| |||
0 commit comments