Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add Safe smart account reference #624

Merged
merged 67 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
3eb5d38
Owner and module functions
louis-md Oct 17, 2024
17c2481
Remaining events and functions
louis-md Oct 18, 2024
1584b26
Add redirections for root folders
louis-md Oct 18, 2024
43b5368
Fix vale errors
louis-md Oct 18, 2024
b1e24b9
Implement requested changes (owners)
louis-md Oct 21, 2024
d086426
Fix links
louis-md Oct 21, 2024
a81b921
Various fixes
louis-md Oct 21, 2024
28163f2
Format files
louis-md Oct 21, 2024
dfb3542
Minor fix
louis-md Oct 21, 2024
ce903eb
Implement requested changes (utilities)
louis-md Oct 21, 2024
516c344
Implement requested changes (fallback)
louis-md Oct 21, 2024
d4840c4
Implement requested changes (guards)
louis-md Oct 22, 2024
817c659
Implement requested changes (modules)
louis-md Oct 22, 2024
4df0f43
Implement requested changes (signatures)
louis-md Oct 22, 2024
483f38e
Implement requested changes (setup)
louis-md Oct 22, 2024
75e92a9
Implement requested changes (transactions)
louis-md Oct 22, 2024
13dd497
Various fixes
louis-md Oct 22, 2024
ea0cc50
Fix vale errors
louis-md Oct 22, 2024
ee3c536
Merge branch 'main' of https://github.com/safe-global/safe-docs into …
louis-md Oct 22, 2024
12eb395
Fix redirections
louis-md Oct 22, 2024
76bafb1
Fix missing imports
louis-md Oct 22, 2024
6882341
Implement requested formatting; add and remove white spaces; implemen…
louis-md Oct 24, 2024
5fb01f3
Implement requested indentation;
louis-md Oct 25, 2024
f76c471
Fix indentation
louis-md Oct 25, 2024
e10d33a
Capitalize module guards
louis-md Oct 25, 2024
cbe87ef
Edit definition for setModuleGuard
louis-md Oct 25, 2024
a7d547a
Update pages/reference-smart-account/modules/execTransactionFromModul…
louis-md Oct 25, 2024
d96c1bc
Fix indentation
louis-md Oct 25, 2024
e422ea2
Merge branch 'smart-account-reference' of https://github.com/safe-glo…
louis-md Oct 25, 2024
7034a7f
Edit definition for execTransactionFromModuleReturnData
louis-md Oct 25, 2024
71acf9f
Update pages/reference-smart-account/modules/execTransactionFromModul…
louis-md Oct 25, 2024
fd3c7d2
Update pages/reference-smart-account/modules/execTransactionFromModul…
louis-md Oct 25, 2024
3c70cc1
Update pages/reference-smart-account/modules/execTransactionFromModul…
louis-md Oct 25, 2024
c27e97d
Update pages/reference-smart-account/modules/execTransactionFromModul…
louis-md Oct 25, 2024
e8fa7ff
Update pages/reference-smart-account/owners/getThreshold.mdx
louis-md Oct 25, 2024
b1a46a6
Update pages/reference-smart-account/owners/swapOwner.mdx
louis-md Oct 25, 2024
0b1c314
Edit wording
louis-md Oct 25, 2024
c46d045
Merge branch 'smart-account-reference' of https://github.com/safe-glo…
louis-md Oct 25, 2024
6f62a2c
Fix indentation
louis-md Oct 25, 2024
c5dfede
Update pages/reference-smart-account/modules/enableModule.mdx
louis-md Oct 25, 2024
e2a0eea
Merge branch 'smart-account-reference' of https://github.com/safe-glo…
louis-md Oct 25, 2024
401411f
Edit definition for enableModule
louis-md Oct 25, 2024
a493072
Merge branch 'main' into smart-account-reference
germartinez Oct 29, 2024
dd33e75
Implement requested changes
louis-md Nov 19, 2024
38f3ca1
Update pages/reference-smart-account/transactions/encodeTransactionDa…
louis-md Nov 20, 2024
88af402
Update pages/reference-smart-account/signatures/checkNSignatures.mdx
louis-md Nov 20, 2024
a81dbfd
Update pages/reference-smart-account/transactions/execTransaction.mdx
louis-md Nov 20, 2024
26a6742
Update pages/reference-smart-account/transactions/execTransaction.mdx
louis-md Nov 20, 2024
0d11449
Update pages/reference-smart-account/modules/execTransactionFromModul…
louis-md Nov 20, 2024
9de1978
Update pages/reference-smart-account/signatures/checkNSignatures.mdx
louis-md Nov 20, 2024
beef551
Update pages/reference-smart-account/modules/isModuleEnabled.mdx
louis-md Nov 20, 2024
c14c614
Update pages/reference-smart-account/modules/getModulesPaginated.mdx
louis-md Nov 20, 2024
483d8c3
Update pages/reference-smart-account/guards/setGuard.mdx
louis-md Nov 20, 2024
ae052bc
Update pages/reference-smart-account/guards/setGuard.mdx
louis-md Nov 20, 2024
b92d8cc
Update pages/reference-smart-account/fallback/receive.mdx
louis-md Nov 20, 2024
9928073
Update pages/reference-smart-account/signatures/checkNSignatures.mdx
louis-md Nov 20, 2024
18f8bab
Update pages/reference-smart-account/signatures/checkNSignatures.mdx
louis-md Nov 20, 2024
df3201f
Implement requested changes
louis-md Nov 20, 2024
df3ce91
Merge branch 'smart-account-reference' of https://github.com/safe-glo…
louis-md Nov 20, 2024
da6629f
Make `prevOwner` definition more detailed
louis-md Nov 20, 2024
77e56c7
Fix typos
louis-md Nov 20, 2024
565cf14
Update pages/reference-smart-account/signatures/checkSignatures.mdx
tanay1337 Nov 21, 2024
c7048a1
Add Smart account version to reference index
louis-md Nov 21, 2024
4740b9c
Merge branch 'smart-account-reference' of https://github.com/safe-glo…
louis-md Nov 21, 2024
847fd03
Factorize callouts
louis-md Nov 21, 2024
be570c9
Factorize callouts
louis-md Nov 21, 2024
11336b1
Disambiguate `0`, `0x`, `0x...` and `address(0)`
louis-md Nov 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/styles/config/vocabularies/default/accept.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
[Bb]inance
[Bb]lockchain
[Bb]lockchains
[Bb]oolean
[Bb]undler
[Bb]undlers
[Cc]hainlist
Expand Down Expand Up @@ -251,7 +252,6 @@ Zora
address_full_match
auditable
auth_code
boolean
bytestrings
checksummed
createTransaction
Expand Down
5 changes: 5 additions & 0 deletions pages/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
"title": "Advanced",
"type": "page"
},
"reference-smart-account": {
"title": "Smart Account Reference",
"type": "page",
"display": "hidden"
},
"resource-hub": {
"title": "Resource Hub",
"type": "page",
Expand Down
4 changes: 4 additions & 0 deletions pages/advanced/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
},
"smart-account-audits": "Audits",
"smart-account-bug-bounty": "Bug Bounty",
"smart-account-reference": {
"title": "Reference",
"href": "/reference-smart-account/overview"
},
"-- Features": {
"type": "separator",
"title": "Features"
Expand Down
19 changes: 19 additions & 0 deletions pages/reference-smart-account/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"home": {
"title": "← Go Back",
"href": "/advanced/smart-account-overview"
},
"overview": "Overview",
"-- Safe Reference": {
"type": "separator",
"title": "Safe Reference"
},
"setup": "Setup",
"owners": "Owners",
"transactions": "Transactions",
"modules": "Modules",
"guards": "Guards",
"fallback": "Fallback Handler",
"signatures": "Signatures",
"utilities": "Utilities"
}
5 changes: 5 additions & 0 deletions pages/reference-smart-account/fallback/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"fallback": "fallback",
"receive": "receive",
"setFallbackHandler": "setFallbackHandler"
}
31 changes: 31 additions & 0 deletions pages/reference-smart-account/fallback/fallback.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Tabs } from 'nextra/components'

# `fallback`

This function emits the [`SafeReceived`](./fallback/receive.mdx#safereceived) event when it receives a payment.

## Usage

{/* <!-- vale off --> */}

<Tabs items={['example.sol']}>
<Tabs.Tab>
```solidity
interface ISafe {
fallback() external;
}

contract Example {
function example() ... {
(ISafe safe).fallback();
}
}
```
</Tabs.Tab>
</Tabs>

{/* <!-- vale on --> */}

## Events

### [`SafeReceived`](./receive.mdx#safereceived)
35 changes: 35 additions & 0 deletions pages/reference-smart-account/fallback/receive.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Tabs } from 'nextra/components'

# `receive`

Receive function accepts native currency transactions.
louis-md marked this conversation as resolved.
Show resolved Hide resolved

## Usage

{/* <!-- vale off --> */}

<Tabs items={['example.sol']}>
<Tabs.Tab>
```solidity
interface ISafe {
receive() external payable;
}

contract Example {
function example() ... {
(ISafe safe).receive();
}
}
```
</Tabs.Tab>
</Tabs>

## Events

### `SafeReceived`

```solidity
event SafeReceived(address sender, uint256 value)
```

Emitted when the Safe contract receives a payment.
56 changes: 56 additions & 0 deletions pages/reference-smart-account/fallback/setFallbackHandler.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { Tabs, Callout } from 'nextra/components'

# `setFallbackHandler`

Set Fallback Handler to `handler` for the Safe.

<Callout type='warning'>
Only fallback calls without value and with data will be forwarded. This can
only be done via a Safe transaction. Cannot be set to the Safe itself.
</Callout>

## Usage

{/* <!-- vale off --> */}

<Tabs items={['example.sol']}>
<Tabs.Tab>
```solidity
interface ISafe {
function setFallbackHandler(address handler) external;
}

contract Example {
function example() ... {
(ISafe safe).setFallbackHandler("0x...");
}
}
```
</Tabs.Tab>
</Tabs>

{/* <!-- vale on --> */}

## Parameters

### `handler`

- **Type:** `address`

Contract to handle fallback calls.

```solidity focus=2
(ISafe safe).setFallbackHandler(
"0x..."
);
```

## Events

### `ChangedFallbackHandler`

```solidity
event ChangedFallbackHandler(address handler);
```

Emitted when the fallback handler is changed.
tanay1337 marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 4 additions & 0 deletions pages/reference-smart-account/guards/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"setGuard": "setGuard",
"setModuleGuard": "setModuleGuard"
}
56 changes: 56 additions & 0 deletions pages/reference-smart-account/guards/setGuard.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { Tabs, Callout } from 'nextra/components'

# `setGuard`

Set Transaction Guard `guard` that checks transactions before execution.

<Callout type='warning'>This action can only be done via a Safe transaction.</Callout>
<Callout type='error' emoji='🚨'>
Since a guard has full power to block Safe transaction execution, a broken
louis-md marked this conversation as resolved.
Show resolved Hide resolved
guard can cause a denial of service for the Safe. Make sure to carefully audit
the guard code and design recovery mechanisms.
louis-md marked this conversation as resolved.
Show resolved Hide resolved
</Callout>

## Usage

{/* <!-- vale off --> */}

<Tabs items={['example.sol']}>
<Tabs.Tab>
```solidity
interface ISafe {
function setGuard(address guard) external;
}

contract Example {
function example() ... {
(ISafe safe).setGuard("0x...");
}
}
```
</Tabs.Tab>
</Tabs>

## Parameters

### `guard`

- **Type:** `address`

The address of the guard to be used or the 0 address to disable the guard.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add in brackets the 0 address?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@louis-md I am still not sure what this means: "or the 0x address to disable the guard".


```solidity focus=2
(ISafe safe).setGuard(
"0x..."
);
```

## Events

### `ChangedGuard`

```solidity
event ChangedGuard(address guard);
```

Emitted when a guard is set for the Safe.
63 changes: 63 additions & 0 deletions pages/reference-smart-account/guards/setModuleGuard.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { Tabs, Callout } from 'nextra/components'

# `setModuleGuard`

Set a Module Guard that checks transactions initiated by the module before
execution.

<Callout type='warning'>
This action can only be done via a Safe transaction.
</Callout>

<Callout type='error' emoji='🚨'>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same copy edit as suggested above.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Since a Module Guard has full power to block Safe transaction execution
initiated via a module, a broken Module Guard can cause a denial of service
for the Safe Modules. Make sure to carefully audit the Module Guard code and
design recovery mechanisms.
</Callout>

## Usage

{/* <!-- vale off --> */}

<Tabs items={['example.sol']}>
<Tabs.Tab>
```solidity
interface ISafe {
function setModuleGuard(address moduleGuard) external;
}

contract Example {
function example() ... {
(ISafe safe).setModuleGuard("0x...");
}
}
```
</Tabs.Tab>
</Tabs>

{/* <!-- vale on --> */}

## Parameters

### `moduleGuard`

- **Type:** `address`

The address of the Module Guard to be used or the zero address to disable the Module Guard.
tanay1337 marked this conversation as resolved.
Show resolved Hide resolved

```solidity focus=2
(ISafe safe).setModuleGuard(
"0x..."
);
```

## Events

### `ChangedModuleGuard`

```solidity
event ChangedModuleGuard(address moduleGuard);
```

Emitted when a Module Guard is set for the Safe.
8 changes: 8 additions & 0 deletions pages/reference-smart-account/modules/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"enableModule": "enableModule",
"disableModule": "disableModule",
"execTransactionFromModule": "execTransactionFromModule",
"execTransactionFromModuleReturnData": "execTransactionFromModuleReturnData",
"getModulesPaginated": "getModulesPaginated",
"isModuleEnabled": "isModuleEnabled"
}
67 changes: 67 additions & 0 deletions pages/reference-smart-account/modules/disableModule.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { Tabs, Callout } from 'nextra/components'

# `disableModule`

Disables the module `module` for the Safe.

<Callout type='warning'>This action can only be done via a Safe transaction.</Callout>

## Usage

{/* <!-- vale off --> */}

<Tabs items={['example.sol']}>
<Tabs.Tab>
```solidity
interface ISafe {
function disableModule(address prevModule, address module) external;
}

contract Example {
function example() ... {
(ISafe safe).disableModule("0x...", "0x...");
}
}
```
</Tabs.Tab>
</Tabs>

{/* <!-- vale on --> */}

## Parameters

### `prevModule`

- **Type:** `address`

Previous module in the modules linked list.

```solidity focus=2
(ISafe safe).disableModule(
"0x...",
"0x..."
);
```

### `module`

- **Type:** `address`

Module to be removed.

```solidity focus=3
(ISafe safe).disableModule(
"0x...",
"0x..."
);
```

## Events

### `DisabledModule`

```solidity
event DisabledModule(address module);
```

Emitted when a module is disabled for the Safe.
Loading
Loading