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 61 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
23 changes: 23 additions & 0 deletions pages/reference-smart-account/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"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",
"events": {
"type": "page",
"display": "hidden"
}
}
7 changes: 7 additions & 0 deletions pages/reference-smart-account/events/AddedOwner.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### `AddedOwner`

```solidity
event AddedOwner(address owner);
```

Emitted when an owner is added to the Safe.
7 changes: 7 additions & 0 deletions pages/reference-smart-account/events/ApproveHash.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### `ApproveHash`

```solidity
event ApproveHash(bytes32 approvedHash, address owner);
```

Emitted when a hash is approved by an owner.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### `ChangedFallbackHandler`

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

Emitted when the Fallback Handler is changed.
7 changes: 7 additions & 0 deletions pages/reference-smart-account/events/ChangedGuard.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### `ChangedGuard`

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

Emitted when a guard is set for the Safe.
7 changes: 7 additions & 0 deletions pages/reference-smart-account/events/ChangedModuleGuard.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### `ChangedModuleGuard`

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

Emitted when a Module Guard is set for the Safe.
7 changes: 7 additions & 0 deletions pages/reference-smart-account/events/ChangedThreshold.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### `ChangedThreshold`

```solidity
event ChangedThreshold(uint256 threshold);
```

Emitted when the threshold for confirmations is changed.
7 changes: 7 additions & 0 deletions pages/reference-smart-account/events/DisabledModule.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### `DisabledModule`

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

Emitted when a module is disabled for the Safe.
7 changes: 7 additions & 0 deletions pages/reference-smart-account/events/EnabledModule.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### `EnabledModule`

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

Emitted when a module is enabled for the Safe.
7 changes: 7 additions & 0 deletions pages/reference-smart-account/events/ExecutionFailure.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### `ExecutionFailure`

```solidity
event ExecutionFailure(bytes32 txHash, uint256 payment);
```

Emitted when a transaction fails.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### `ExecutionFromModuleFailure`

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

Emitted when a transaction executed by a module fails.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### `ExecutionFromModuleSuccess`

```solidity
event ExecutionFromModuleSuccess(address to, uint256 value, bytes data);
```

Emitted when a transaction executed by a module succeeds.
7 changes: 7 additions & 0 deletions pages/reference-smart-account/events/ExecutionSuccess.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### `ExecutionSuccess`

```solidity
event ExecutionSuccess(bytes32 txHash, uint256 payment);
```

Emitted when a transaction is executed successfully.
7 changes: 7 additions & 0 deletions pages/reference-smart-account/events/RemovedOwner.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### `RemovedOwner`

```solidity
event RemovedOwner(address owner);
```

Emitted when an owner is removed from the Safe.
7 changes: 7 additions & 0 deletions pages/reference-smart-account/events/SafeReceived.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### `SafeReceived`

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

Emitted when the Safe contract receives a payment.
13 changes: 13 additions & 0 deletions pages/reference-smart-account/events/SafeSetup.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### `SafeSetup`

```solidity
event SafeSetup(
address initiator,
address[] owners,
uint256 threshold,
address initializer,
address fallbackHandler
);
```

Emitted when the Safe is set up.
7 changes: 7 additions & 0 deletions pages/reference-smart-account/events/SignMsg.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### `SignMsg`

```solidity
event SignMsg(bytes32 msgHash);
```

Emitted when a message is signed by an owner.
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"
}
32 changes: 32 additions & 0 deletions pages/reference-smart-account/fallback/fallback.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Tabs } from 'nextra/components'
import SafeReceived from '../events/SafeReceived.mdx'

# `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 />
30 changes: 30 additions & 0 deletions pages/reference-smart-account/fallback/receive.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Tabs } from 'nextra/components'
import SafeReceived from '../events/SafeReceived.mdx'

# `receive`

Receive function accepts native token transactions.

## 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 />
51 changes: 51 additions & 0 deletions pages/reference-smart-account/fallback/setFallbackHandler.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { Tabs, Callout } from 'nextra/components'
import ChangedFallbackHandler from '../events/ChangedFallbackHandler.mdx'

# `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 />
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"
}
51 changes: 51 additions & 0 deletions pages/reference-smart-account/guards/setGuard.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { Tabs, Callout } from 'nextra/components'
import ChangedGuard from '../events/ChangedGuard.mdx'

# `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 the full power to block Safe transaction executions, a broken
guard can cause a denial of service for the Safe. Make sure to carefully audit
the guard code, and design recovery mechanisms.
</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 `0x` address to disable the guard.

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

## Events

<ChangedGuard />
Loading
Loading