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

Update security docs #794

Merged
merged 29 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
331844d
fix: link (#545)
ericnordelo Jan 20, 2023
2e7758e
Merge branch 'main' of github.com:OpenZeppelin/cairo-contracts
ericnordelo Oct 6, 2023
77cca2d
Merge branch 'main' of github.com:OpenZeppelin/cairo-contracts
ericnordelo Oct 10, 2023
8a19908
Merge branch 'main' of github.com:OpenZeppelin/cairo-contracts
ericnordelo Oct 18, 2023
0dabc59
feat: add API Reference to docs
ericnordelo Oct 19, 2023
9850dd5
feat: update docs page
ericnordelo Oct 19, 2023
2e28266
feat: shorten imports
ericnordelo Oct 19, 2023
cb6fd01
Update docs/modules/ROOT/pages/api/security.adoc
ericnordelo Oct 20, 2023
05d7bef
feat: apply review updates
ericnordelo Oct 20, 2023
5207a65
Merge branch 'feat/update-security-docs-#565' of github.com:ericnorde…
ericnordelo Oct 20, 2023
d2876e9
Update docs/modules/ROOT/pages/security.adoc
ericnordelo Oct 23, 2023
643e97a
docs: flatten events in examples
ericnordelo Oct 24, 2023
a624d29
Merge branch 'feat/update-security-docs-#565' of github.com:ericnorde…
ericnordelo Oct 24, 2023
3eb8cb8
Merge branch 'main' of github.com:OpenZeppelin/cairo-contracts into f…
ericnordelo Nov 2, 2023
b51d3bf
docs: update headers
ericnordelo Nov 2, 2023
710ed6f
feat: remove external trait
ericnordelo Nov 10, 2023
1f39593
Update docs/modules/ROOT/pages/security.adoc
ericnordelo Nov 10, 2023
2a6afe2
Update docs/modules/ROOT/pages/api/security.adoc
ericnordelo Nov 10, 2023
4a07f9f
Update docs/modules/ROOT/pages/api/security.adoc
ericnordelo Nov 10, 2023
be95dc7
Update docs/modules/ROOT/pages/api/security.adoc
ericnordelo Nov 10, 2023
2b8354a
feat: apply review updates
ericnordelo Nov 10, 2023
48fb908
Merge branch 'feat/update-security-docs-#565' of github.com:ericnorde…
ericnordelo Nov 10, 2023
38f1b22
Update docs/modules/ROOT/pages/security.adoc
ericnordelo Nov 10, 2023
2c6dc8e
Update docs/modules/ROOT/pages/api/security.adoc
ericnordelo Nov 10, 2023
4a2c109
Update docs/modules/ROOT/pages/api/security.adoc
ericnordelo Nov 10, 2023
44aceec
Update docs/modules/ROOT/pages/api/security.adoc
ericnordelo Nov 10, 2023
25b76f2
Update docs/modules/ROOT/pages/api/security.adoc
ericnordelo Nov 10, 2023
45e860d
feat: apply review updates
ericnordelo Nov 10, 2023
3acf822
Merge branch 'feat/update-security-docs-#565' of github.com:ericnorde…
ericnordelo Nov 10, 2023
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
3 changes: 2 additions & 1 deletion docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
// ** xref:erc721.adoc[ERC721]
// ** xref:erc1155.adoc[ERC1155]

// * xref:security.adoc[Security]
* xref:security.adoc[Security]
** xref:/api/security.adoc[API Reference]

* xref:introspection.adoc[Introspection]
** xref:/api/introspection.adoc[API Reference]
Expand Down
200 changes: 200 additions & 0 deletions docs/modules/ROOT/pages/api/security.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
:github-icon: pass:[<svg class="icon"><use href="#github-icon"/></svg>]

= Security

Reference of components, interfaces and utilities found in the library's `security/` directory.

== Initializable

[.contract]
[[Initializable]]
=== `++Initializable++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.7.0/src/security/initializable.cairo[{github-icon},role=heading-link]

```javascript
use openzeppelin::security::Initializable;
```

Component enabling one-time initialization for contracts.

[.contract-index]
.Embeddable Implementations
--
.InitializableImpl

* xref:#Initializable-is_initialized[`++is_initialized(self)++`]
--

[.contract-index]
.Internal Functions
--
.InternalImpl

* xref:#Initializable-initialize[`++initialize(self)++`]
--

[#Initializable-Embeddable-Functions]
==== Embeddable Functions

[.contract-item]
[[Initializable-is_initialized]]
==== `[.contract-item-name]#++is_initialized++#++(self: @ComponentState)++ → bool` [.item-kind]#external#

Returns whether the contract has been initialized.

[#Initializable-Internal-Functions]
==== Internal Functions

[.contract-item]
[[Initializable-initialize]]
==== `[.contract-item-name]#++initialize++#++(ref self: ComponentState)++` [.item-kind]#internal#

Ensures the calling function can only be called once.
ericnordelo marked this conversation as resolved.
Show resolved Hide resolved

Requirements:

- the contract must not have been initialized before.

== Pausable

[.contract]
[[Pausable]]
=== `++Pausable++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.7.0/src/security/pausable.cairo[{github-icon},role=heading-link]

:Paused: xref:Pausable-Paused[Paused]
:Unpaused: xref:Pausable-Unpaused[Unpaused]

```javascript
use openzeppelin::security::Pausable;
```

Component to implement an emergency stop mechanism.

[.contract-index]
.Embeddable Implementations
--
.PausableImpl

* xref:#Pausable-is_paused[`++is_paused(self)++`]
--

[.contract-index]
.Internal Functions
--
.InternalImpl

* xref:#Pausable-assert_not_paused[`++assert_not_paused(self)++`]
* xref:#Pausable-assert_paused[`++assert_paused(self)++`]
* xref:#Pausable-_pause[`++_pause(self)++`]
* xref:#Pausable-_unpause[`++_unpause(self)++`]
ericnordelo marked this conversation as resolved.
Show resolved Hide resolved
--

[.contract-index]
.Events
--
* xref:#Pausable-Paused[`++Paused(account)++`]
* xref:#Pausable-Unpaused[`++Unpaused(account)++`]
--

[#Pausable-Embeddable-Functions]
==== Embeddable Functions

[.contract-item]
[[Pausable-is_paused]]
==== `[.contract-item-name]#++is_paused++#++(self: @ComponentState)++ → bool` [.item-kind]#external#

Returns whether the contract is currently on pause.
ericnordelo marked this conversation as resolved.
Show resolved Hide resolved

[#Pausable-Internal-Functions]
==== Internal Functions

[.contract-item]
[[Pausable-assert_not_paused]]
==== `[.contract-item-name]#++assert_not_paused++#++(self: @ComponentState)++` [.item-kind]#internal#

Makes a function only callable when the contract is not paused.
ericnordelo marked this conversation as resolved.
Show resolved Hide resolved

[.contract-item]
[[Pausable-assert_paused]]
==== `[.contract-item-name]#++assert_paused++#++(self: @ComponentState)++` [.item-kind]#internal#

Makes a function only callable when the contract is paused.
ericnordelo marked this conversation as resolved.
Show resolved Hide resolved

[.contract-item]
[[Pausable-_pause]]
==== `[.contract-item-name]#++_pause++#++(ref self: ComponentState)++` [.item-kind]#internal#

Pauses the contract.

Requirements:

- the contract must not be paused.
martriay marked this conversation as resolved.
Show resolved Hide resolved

Emits a {Paused} event.

[.contract-item]
[[Pausable-_unpause]]
==== `[.contract-item-name]#++_unpause++#++(ref self: ComponentState)++` [.item-kind]#internal#

Unpauses the contract.

Requirements:

- the contract must be paused.

Emits an {Unpaused} event.


[#Pausable-Events]
==== Events

[.contract-item]
[[Pausable-Paused]]
==== `[.contract-item-name]#++Paused++#++(account: ContractAddress)++` [.item-kind]#event#

Emitted when the pause is triggered by `account`.
ericnordelo marked this conversation as resolved.
Show resolved Hide resolved

[.contract-item]
[[Pausable-Unpaused]]
==== `[.contract-item-name]#++Unpaused++#++(account: ContractAddress)++` [.item-kind]#event#

Emitted when the pause is lifted by `account`.
ericnordelo marked this conversation as resolved.
Show resolved Hide resolved

== ReentrancyGuard

[.contract]
[[ReentrancyGuard]]
=== `++ReentrancyGuard++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.7.0/src/security/reentrancyguard.cairo[{github-icon},role=heading-link]

```javascript
use openzeppelin::security::ReentrancyGuard;
```

Component to help prevent nested (reentrant) calls.
ericnordelo marked this conversation as resolved.
Show resolved Hide resolved

[.contract-index]
.Internal Functions
--
.InternalImpl

* xref:#ReentrancyGuard-start[`++start(self)++`]
* xref:#ReentrancyGuard-end[`++end(self)++`]
--

[#ReentrancyGuard-Internal-Functions]
==== Internal Functions

[.contract-item]
[[ReentrancyGuard-start]]
==== `[.contract-item-name]#++start++#++(ref self: ComponentState)++` [.item-kind]#internal#

Prevents a contract's function from calling itself or another protected function, directly or indirectly.

Requirements:

- the contract must not be currently in a guarded state.
martriay marked this conversation as resolved.
Show resolved Hide resolved

[.contract-item]
[[ReentrancyGuard-end]]
==== `[.contract-item-name]#++end++#++(ref self: ComponentState)++` [.item-kind]#internal#

Removes the reentrant guard.
Loading