Skip to content

Commit 230acb0

Browse files
committed
docs(Userguides): update production userguide to clarify some things
1 parent 5c222da commit 230acb0

1 file changed

Lines changed: 35 additions & 25 deletions

File tree

docs/userguides/production.md

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,23 @@ When co-managing a Safe with a larger team, ape-safe brings extra tools to the t
44

55
## Queue Scripts
66

7-
You can define "queue scripts" which are scripts under your project's `scripts/` folder that follow
8-
a naming convention (either `scripts/nonce<N>.py` or `scripts/<ecosystem>_<network>_nonce<N>.py`),
9-
and then use the [`propose_from_simulation`](../../methoddocs/cli) decorator.
7+
You can define "queue scripts" which are scripts under your project's `scripts/` folder that use
8+
the [`propose_from_simulation`](../methoddocs/cli) decorator in your script.
109

11-
```{note}
12-
The value of the nonce `N` must correspond to a specific nonce above the current on-chain
13-
value of `nonce` from the safe, or it will not be recognized by our other queue management command.
10+
```{important}
11+
These scripts should follow a recommended naming convention by naming them either
12+
`scripts/nonce<N>.py` or `scripts/<ecosystem>_<network>_nonce<N>.py`).
13+
This will automatically registry with the [queue management](#queue-management)
14+
subcommand that ships with ape-safe.
15+
16+
The value of the nonce `N` must correspond to a specific nonce above the current on-chain contract
17+
value of `nonce` from the Safe, or it will not be collected by the queue management command.
1418
```
1519

1620
An example:
1721

1822
```py
23+
# scripts/nonce<N>.py
1924
from ape_safe.cli import propose_from_simulation
2025

2126

@@ -26,7 +31,7 @@ def cli():
2631
# Use normal Ape features
2732
my_contract = Contract("<address>")
2833

29-
# Any transaction is performed as if `sender=safe.address`
34+
# Any transaction is performed as if `sender=safe.address` (using Ape's default sender support)
3035
my_contract.mutableMethod(...)
3136

3237
# You can make assertions that will cause your simulation to fail if tripped
@@ -35,18 +40,26 @@ def cli():
3540
# You can also add conditional calls
3641
if my_contract.viewMethod() < some_number:
3742
my_contract.mutableMethod()
43+
```
3844

39-
# Once you are done with your transactions, the simulation will complete after exiting
45+
```{warning}
46+
The callback function **MUST** be named `cli` or it won't work with Ape's script runner.
4047
```
4148

4249
Once the simulation is complete, the decorator will collect all receipts it finds from the `safe`'s
4350
history during that session, and collect them into a single SafeTx to propose to a public network.
4451

45-
```{important}
46-
The name of the decorated function in your queue script **must** be `cli` for it to work.
52+
```{note}
53+
If only one transaction is detected, it will "condense" that as a direct call,
54+
instead of using `MultiSend` (which is used for >1 detected transactions).
4755
```
4856

49-
The decorated function may have `safe` or `submitter` args in it, in order to access their values.
57+
The decorated function may have `safe` or `submitter` args in it,
58+
in order to access their values within your simulation.
59+
60+
```{note}
61+
If `submitter` is needed, `safe` must also be present in the args.
62+
```
5063

5164
```py
5265
@propose_from_simulation()
@@ -59,29 +72,26 @@ def cli(safe, submitter):
5972
assert token.balanceOf(submitter) == bal_before + amount
6073
```
6174

62-
You can run the script directly using the following command, and it will dry-run the transaction:
75+
You can run the script directly using the following command, and it will "dry-run" the `SafeTx`:
6376

6477
```sh
6578
$ ape run nonce<N> your-safe --network ethereum:mainnet-fork --submitter TEST::0
6679
```
6780

81+
## Queue Management
82+
6883
We also provide a command [`ape safe pending ensure`](../../commands/pending#ape-safe-pending-ensure)
69-
that allows you to execute all matching nonce commands up to the latest you have defined in sequence.
70-
This allows you to check for side-effects of commands in the queue, helping to reduce human error.
84+
that allows you to execute **all** matching queue scripts you have defined in `scripts/`.
85+
This allows you to check side-effects from running all commands in the queue,
86+
helping to reduce human error.
7187

72-
To execute a dry-run of all matching queue scripts for your safe, execute the following:
88+
To execute a dry-run of all matching queue scripts for your Safe, execute the following:
7389

7490
```sh
7591
$ ape safe pending ensure --safe your-safe --network ethereum:mainnet-fork --submitter TEST::0
7692
```
7793

78-
Once you are ready, you can "propose" your queue script to the Safe API via the following:
79-
80-
```sh
81-
$ ape run nonce<N> your-safe --network ethereum:mainnet --submitter local-wallet
82-
```
83-
84-
You can also propose all of your queue scripts (if there are discrepencies) to the Safe API via:
94+
Once you are ready, you can "push" your queue scripts to the Safe API via the following:
8595

8696
```sh
8797
$ ape safe pending ensure --safe your-safe --network ethereum:mainnet --submitter local-wallet
@@ -93,10 +103,10 @@ by the Safe API as a delegate for another signer, otherwise it will fail to prop
93103
```
94104

95105
```{note}
96-
It is recommended to use our ensure command in a secure context, such as Github Actions, where all
106+
It is recommended to use our `ensure` command in a secure context, such as Github Actions, where all
97107
scripts can be reviewed by signers, and access is controlled behind Github's access control system.
98108
```
99109

100-
<!-- TODO: Add Github Action? -->
110+
<!-- TODO: Add Github Action for `pending ensure` command? -->
101111

102-
<!-- TODO: Add self-hosted API? -->
112+
<!-- TODO: Add self-hosting the Safe API w/ `ape safe host`? -->

0 commit comments

Comments
 (0)