Skip to content

Commit

Permalink
docs: Add Safe CLI (#400)
Browse files Browse the repository at this point in the history
* feat: add Safe CLI docs

* fix: fix Vale errors

* fix: updates from Uxios review

* fix: fix Vale errors

* Update pages/advanced/cli-installation.mdx

Co-authored-by: Germán Martínez <[email protected]>

* Update pages/advanced/cli-installation.mdx

Co-authored-by: Germán Martínez <[email protected]>

* Update pages/advanced/cli-overview.mdx

Co-authored-by: Germán Martínez <[email protected]>

* Update pages/advanced/cli-overview.mdx

Co-authored-by: Germán Martínez <[email protected]>

* Update pages/advanced/cli-installation.mdx

Co-authored-by: Germán Martínez <[email protected]>

* Update pages/advanced/cli-installation.mdx

Co-authored-by: louis-md <[email protected]>

* feat: improvements to the docs structure

* Update pages/advanced/cli-reference/common-operations.mdx

Co-authored-by: Germán Martínez <[email protected]>

* Update pages/advanced/cli-reference/overview.mdx

Co-authored-by: Germán Martínez <[email protected]>

* Update pages/advanced/cli-reference/tx-service-operations.mdx

Co-authored-by: Germán Martínez <[email protected]>

* Update pages/advanced/cli-reference/tx-service-operations.mdx

Co-authored-by: Germán Martínez <[email protected]>

* Update pages/advanced/cli-reference/tx-service-operations.mdx

Co-authored-by: Germán Martínez <[email protected]>

* Update pages/advanced/cli-reference/common-operations.mdx

Co-authored-by: Germán Martínez <[email protected]>

* Update pages/advanced/cli-guides/recovery-safe-deployment.mdx

Co-authored-by: Germán Martínez <[email protected]>

* Update pages/advanced/cli-reference/common-operations.mdx

Co-authored-by: Germán Martínez <[email protected]>

* Update pages/advanced/cli-reference/common-operations.mdx

Co-authored-by: Germán Martínez <[email protected]>

* Update pages/advanced/cli-reference/common-operations.mdx

Co-authored-by: Germán Martínez <[email protected]>

* Update pages/advanced/cli-reference/common-operations.mdx

Co-authored-by: Germán Martínez <[email protected]>

* Update pages/advanced/cli-reference/common-operations.mdx

Co-authored-by: Germán Martínez <[email protected]>

* Update pages/advanced/cli-reference/overview.mdx

Co-authored-by: Germán Martínez <[email protected]>

* fix: add suggestions from German

---------

Co-authored-by: Tanay Pant <tanaypantprotonmail.com>
Co-authored-by: Germán Martínez <[email protected]>
Co-authored-by: louis-md <[email protected]>
  • Loading branch information
3 people authored Mar 25, 2024
1 parent b84510a commit 55933ed
Show file tree
Hide file tree
Showing 15 changed files with 509 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/styles/config/vocabularies/default/accept.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
[Rr]elayers
[Ss]epolia
[Tt]estnet
[Tt]rezor
[Vv]alidator
[Ww]hitepaper
A1
Expand Down Expand Up @@ -125,6 +126,7 @@ LUKSO
Lightlink
Linea
Lisk
ledgerblue
Mandala
Mantle
Meld
Expand Down Expand Up @@ -210,6 +212,7 @@ auth_code
boolean
bytestrings
checksummed
deployer
eSpace
execTransaction
maxWidth
Expand Down
3 changes: 3 additions & 0 deletions assets/svg/command-line.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/svg/demo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/svg/guides.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/svg/reference.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 10 additions & 1 deletion pages/advanced/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,14 @@
},
"api-service-architecture": "Service Architecture",
"api-rpc-requirements": "RPC Requirements",
"api-supported-networks": "Supported Networks"
"api-supported-networks": "Supported Networks",
"-- Safe CLI": {
"type": "separator",
"title": "Safe CLI"
},
"cli-overview": "Overview",
"cli-installation": "Installation",
"cli-demos": "Demos",
"cli-guides": "Guides",
"cli-reference": "Reference"
}
15 changes: 15 additions & 0 deletions pages/advanced/cli-demos.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Demos

## Create a new Safe

The `PRIVATE_KEY` environment variable for this demo was set to an EOA private key.

[![Create a new Safe](https://asciinema.org/a/0jdHGLVRrkS9URxPoZ8ZJ7W2C.svg)](https://asciinema.org/a/0jdHGLVRrkS9URxPoZ8ZJ7W2C)

## Send ether using a Trezor hardware wallet

[![Send Ether using a Trezor hardware wallet](https://asciinema.org/a/9BrQKYQRXbysmEL8rw1jDWZhn.svg)](https://asciinema.org/a/9BrQKYQRXbysmEL8rw1jDWZhn)

## Create a transaction in the Safe Transaction Service to remove an owner

[![Create a transaction in the Safe Transaction Service to remove an owner](https://asciinema.org/a/oV5UbXW2g1VZo2yKDQIxi0jYb.svg)](https://asciinema.org/a/oV5UbXW2g1VZo2yKDQIxi0jYb)
4 changes: 4 additions & 0 deletions pages/advanced/cli-guides/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"recovery-safe-deployment": "Deploy a Recovery Safe"
}

45 changes: 45 additions & 0 deletions pages/advanced/cli-guides/recovery-safe-deployment.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { Callout } from 'nextra/components'

# Deploy a Recovery Safe

This guide will walk you through recreating a Safe with the same address on the desired network if you send funds to your Safe address in an incorrect chain.

<Callout type='info' emoji='ℹ️'>
It's not always possible to recover a Safe, learn more [here](https://help.safe.global/en/articles/40812-i-sent-assets-to-a-safe-address-on-the-wrong-network-any-chance-to-recover).
</Callout>

## Recreate Safe 1.3.0 or 1.1.1

To recreate a Safe (version 1.3.0 or 1.1.1), you'll need the following essential data:

- The `Singleton` address
- The `ProxyFactory` address
- The `FallbackHandler` address
- The `Owners` addresses with which Safe was created
- The `SaltNonce` value
- The `Threshold` value
- RPC node provider for the target chain.
- The private-key of the deployer address

The necessary addresses can be collected from [safe-deployments](https://github.com/safe-global/safe-deployments/tree/main/src/assets) and the salt nonce from the Safe creation transaction in a block explorer.

<Callout type="warning" emoji="⚠️">
Ensure that the `Singleton`, `ProxyFactory`, and `FallbackHandler` are deployed in the target chain in the same addresses as the origin chain.
</Callout>

To recreate the Safe, it is necessary to execute the `safe-creator` as follows:

```bash
safe-creator --owners <owners-addresses> --safe-contract <singleton-address>
--callback-handler <fallback-handler-address> --proxy-factory <proxy-factory-address>
--threshold <threshold-value> --salt-nonce <salt-nonce-value> <url-rpc-node> <deployer-private-key>
```

The Safe should have been successfully recreated with the same address on the target chain. If not, double-check the data collected from the transaction and ensure that all the necessary contracts are deployed in the chain.

## Migrate a Safe from non-L2 to L2

Our services cannot index if you've recreated a Safe from an L1 network (like mainnet) on an L2 network. That's because for L1, we use trace-based indexing, and for L2 events indexing, L1 Safe singleton does not emit events.

To address this, you'll need to update it to the L2 singleton with the command `update_to_l2` or consider transferring the funds to a new Safe on L2 that you control with the `drain` command.
For detailed instructions on running these commands, please refer to the [common operations](../cli-reference/common-operations) section for more information.
27 changes: 27 additions & 0 deletions pages/advanced/cli-installation.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Get the Safe CLI

The Safe CLI can be run using [Docker](https://www.docker.com) or [pip](https://pip.pypa.io/en/stable).

## Using Docker

**Prerequisite:** Install [Docker Desktop](https://www.docker.com/products/docker-desktop/).

Once Docker is installed on your system, run the following command to create new Safe accounts:

```bash
docker run -it safeglobal/safe-cli safe-creator
```

You can also run the following command to run the Safe CLI with an existing Safe:
```bash
docker run -it safeglobal/safe-cli safe-cli <checksummed_safe_address> <ethereum_node_url>
```

## Using Python pip

**Prerequisite:** [Python](https://www.python.org/downloads/) >= 3.7 (Python 3.10 is recommended).

Once Python is installed on your system, run the following command to install the Safe CLI:
```bash
pip3 install -U safe-cli
```
18 changes: 18 additions & 0 deletions pages/advanced/cli-overview.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Cards, Card } from 'nextra/components'
import Installation from '../../assets/svg/command-line.svg'
import Demo from '../../assets/svg/demo.svg'
import Guides from '../../assets/svg/guides.svg'
import Reference from '../../assets/svg/reference.svg'

# Safe CLI

Safe CLI is a command-line utility for [Safe Smart Account](./smart-account-overview.md). You can use it to manage your Safe account from the command line.

It does not rely on Safe\{Core\} API and can also be used in networks where the Safe services are unavailable.

<Cards>
<Card icon={<Installation />} title="Installation" href="./cli-installation"/>
<Card icon={<Demo />} title="Demos" href="./cli-demos" />
<Card icon={<Guides />} title="Guides" href="./cli-guides/recovery-safe-deployment" />
<Card icon={<Reference />} title="Reference" href="./cli-reference" />
</Cards>
21 changes: 21 additions & 0 deletions pages/advanced/cli-reference.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Cards, Card } from 'nextra/components'
import Guides from '../../assets/svg/guides.svg'
import Reference from '../../assets/svg/reference.svg'

# Reference

The Safe CLI has two operation modes:

- **blockchain**: The default mode. Use the `blockchain` command to enable it. Transactions are sent to the blockchain.
- **tx-service**: Use the `tx-service` command to enable it. Transactions are sent to the Safe Transaction Service (if available on the network), and you can see them on Safe\{Wallet\}. At least one signer is needed to send transactions to the service. Transactions are not executed. It requires Safe\{Core\} API running on the network.

<Cards>
<Card icon={<Guides />} title="Common Operations" href="./cli-reference/common-operations" />
<Card icon={<Reference />} title="Transaction Service Operations" href="./cli-reference/tx-service-operations" />
</Cards>

## Use custom contracts

The Safe CLI comes with the official deterministic Safe Smart Account addresses deployed on multiple chains configured by default. You can edit the `safe_cli/safe_addresses.py` file if you want to use your own.

Be careful when modifying these addresses, as the funds in a Safe can get stuck if an invalid address is used when updating to an invalid Safe Master Copy.
4 changes: 4 additions & 0 deletions pages/advanced/cli-reference/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"common-operations": "Common Operations",
"tx-service-operations": "Transaction Service Operations"
}
Loading

0 comments on commit 55933ed

Please sign in to comment.