Skip to content

Commit 800ea46

Browse files
ericnordeloimmrsdgap-editordependabot[bot]dizer-ti
authored
Document erc4626 hooks reentrancy potential (#1449)
* Release v2.0.0-alpha.1 (#1423) * Add version changelog * Bump version to 2.0.0-alpha.1 and update presets page * Bump snforge to 0.42.0 (#1429) * Bump snforge to 0.42.0 * Add changelog entry * Support snforge changes in tests * Fix expected error messages * Release openzeppelin_testing v4.0.0 (#1430) * Add new version to the changelog * Bump openzeppelin_testing version to 4.0.0 and update docs * add docs badge (#1435) * Chore(deps): Bump DavidAnson/markdownlint-cli2-action (#1434) Bumps [DavidAnson/markdownlint-cli2-action](https://github.com/davidanson/markdownlint-cli2-action) from 19.1.0 to 20.0.0. - [Release notes](https://github.com/davidanson/markdownlint-cli2-action/releases) - [Commits](DavidAnson/markdownlint-cli2-action@05f3221...992badc) --- updated-dependencies: - dependency-name: DavidAnson/markdownlint-cli2-action dependency-version: 20.0.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Fix broken Components chapter link (#1433) * Bump snforge to 0.43.1 (#1436) * Bump snforge to 0.43.1 * Add changelog entry * Release openzeppelin_testing v4.0.1 (#1438) * Add changelog for openzeppelin_testing v4.0.1 * Bump openzeppelin_testing version to 4.0.1 and update docs * Bump snforge to 0.44.0 (#1439) * Bump snforge to 0.44.0 * Add changelog entry for new version of openzeppelin_testing * Release openzeppelin_testing v4.1.0 (#1442) * Add version changelog for openzeppelin_testing 4.1.0 * Bump openzeppelin_testing version to 4.1.0 and update docs * Chore(deps): Bump crate-ci/typos from 1.31.1 to 1.33.1 (#1448) Bumps [crate-ci/typos](https://github.com/crate-ci/typos) from 1.31.1 to 1.33.1. - [Release notes](https://github.com/crate-ci/typos/releases) - [Changelog](https://github.com/crate-ci/typos/blob/master/CHANGELOG.md) - [Commits](crate-ci/typos@b1a1ef3...b1ae8d9) --- updated-dependencies: - dependency-name: crate-ci/typos dependency-version: 1.33.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * feat: add comment to hooks * docs: update hooks in ERC4626 docs * Chore(deps-dev): Bump @openzeppelin/docs-utils in /docs (#1450) Bumps @openzeppelin/docs-utils from 0.1.5 to 0.1.6. --- updated-dependencies: - dependency-name: "@openzeppelin/docs-utils" dependency-version: 0.1.6 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: immrsd <103599616+immrsd@users.noreply.github.com> Co-authored-by: Maximilian Hubert <64627729+gap-editor@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: James Niken <danylonepritvoreniy@gmail.com>
1 parent 1f792f5 commit 800ea46

File tree

100 files changed

+191
-369
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+191
-369
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
run: curl -L https://raw.githubusercontent.com/software-mansion/cairo-coverage/main/scripts/install.sh | sh
3939

4040
- name: Markdown lint
41-
uses: DavidAnson/markdownlint-cli2-action@05f32210e84442804257b2a6f20b273450ec8265 # v16
41+
uses: DavidAnson/markdownlint-cli2-action@992badcdf24e3b8eb7e87ff9287fe931bcb00c6e # v16
4242
with:
4343
globs: |
4444
*.md

.github/workflows/typos.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ jobs:
1010
uses: actions/checkout@v4
1111

1212
- name: Check for typos
13-
uses: crate-ci/typos@b1a1ef3893ff35ade0cfa71523852a49bfd05d19
13+
uses: crate-ci/typos@b1ae8d918b6e85bd611117d3d9a3be4f903ee5e4

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
[![Lint and test](https://github.com/OpenZeppelin/cairo-contracts/actions/workflows/test.yml/badge.svg)](https://github.com/OpenZeppelin/cairo-contracts/actions/workflows/test.yml)
44
[![License](https://img.shields.io/github/license/OpenZeppelin/cairo-contracts)](https://github.com/OpenZeppelin/cairo-contracts/blob/main/LICENSE)
5+
[![Docs](https://img.shields.io/badge/docs-%F0%9F%93%84-yellow)](https://docs.openzeppelin.com/contracts-cairo/1.0.0/)
56

67
**A library for secure smart contract development** written in Cairo for [Starknet](https://starkware.co/product/starknet/), a decentralized ZK Rollup.
78

Scarb.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ dependencies = [
133133

134134
[[package]]
135135
name = "openzeppelin_testing"
136-
version = "3.0.0"
136+
version = "4.1.0"
137137
dependencies = [
138138
"snforge_std",
139139
]
@@ -171,15 +171,15 @@ dependencies = [
171171

172172
[[package]]
173173
name = "snforge_scarb_plugin"
174-
version = "0.41.0"
174+
version = "0.44.0"
175175
source = "registry+https://scarbs.xyz/"
176-
checksum = "sha256:7228a3ea74d8decfb2294cee9251b537bbd58b3e243e9327f55e72a99ab5fb53"
176+
checksum = "sha256:ec8c7637b33392a53153c1e5b87a4617ddcb1981951b233ea043cad5136697e2"
177177

178178
[[package]]
179179
name = "snforge_std"
180-
version = "0.41.0"
180+
version = "0.44.0"
181181
source = "registry+https://scarbs.xyz/"
182-
checksum = "sha256:edf116cbf62cbe2487f188cf28ceb9f42b08cfa14e197524281c3ce932f4a5e6"
182+
checksum = "sha256:d4affedfb90715b1ac417b915c0a63377ae6dd69432040e5d933130d65114702"
183183
dependencies = [
184184
"snforge_scarb_plugin",
185185
]

Scarb.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ keywords = [
4444
[workspace.dependencies]
4545
assert_macros = "2.11.4"
4646
starknet = "2.11.4"
47-
snforge_std = "0.41.0"
47+
snforge_std = "0.44.0"
4848

4949
[dependencies]
5050
starknet.workspace = true

docs/modules/ROOT/pages/api/erc20.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,14 @@ use openzeppelin_token::erc20::extensions::erc4626::ERC4626Component;
906906
Extension of ERC20 that implements the <<IERC4626,IERC4626>> interface which allows the minting and burning of "shares" in exchange for an underlying "asset."
907907
The component leverages traits to configure fees, limits, and decimals.
908908

909+
CAUTION: Note on hooks. Special care must be taken when calling external contracts from them. In
910+
that case, consider implementing reentrancy protections. For example, in the
911+
`withdraw` flow, the `withdraw_limit` is checked *before* the `before_withdraw` hook
912+
is invoked. If this hook performs a reentrant call that invokes `withdraw` again, the
913+
subsequent check on `withdraw_limit` will be done before the first withdrawal’s core logic
914+
(e.g., burning shares and transferring assets) is executed. This could
915+
lead to bypassing withdrawal constraints or draining funds.
916+
909917
[.contract-index]
910918
.{immutable-config}
911919
--

docs/modules/ROOT/pages/components.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
The following documentation provides reasoning and examples on how to use Contracts for Cairo components.
44

55
:shamans-post: https://community.starknet.io/t/cairo-components/101136#components-1[Starknet Shamans post]
6-
:cairo-book: https://book.cairo-lang.org/ch99-01-05-00-components.html[Cairo book]
6+
:cairo-book: https://book.cairo-lang.org/ch103-02-00-composability-and-components.html[Cairo book]
77

88
Starknet components are separate modules that contain storage, events, and implementations that can be integrated into a contract.
99
Components themselves cannot be declared or deployed.

docs/modules/ROOT/pages/erc4626.adoc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,11 @@ pub mod ERC4626Fees {
276276

277277
const _BASIS_POINT_SCALE: u256 = 10_000;
278278

279+
///
279280
/// Hooks
280-
impl ERC4626HooksEmptyImpl of ERC4626Component::ERC4626HooksTrait<ContractState> {
281+
///
282+
283+
impl ERC4626HooksImpl of ERC4626Component::ERC4626HooksTrait<ContractState> {
281284
fn after_deposit(
282285
ref self: ERC4626Component::ComponentState<ContractState>, assets: u256, shares: u256,
283286
) {

docs/package-lock.json

Lines changed: 11 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
"author": "",
1111
"license": "ISC",
1212
"devDependencies": {
13-
"@openzeppelin/docs-utils": "^0.1.2"
13+
"@openzeppelin/docs-utils": "^0.1.6"
1414
}
1515
}

0 commit comments

Comments
 (0)