Skip to content

Commit 2aa2899

Browse files
committed
fix: components
1 parent 046c616 commit 2aa2899

6 files changed

Lines changed: 41 additions & 35 deletions

File tree

content/contracts-cairo/api/access.mdx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ This crate provides ways to restrict who can access the functions of a contract
1313
Starting from version `3.x.x`, the interfaces are no longer part of the `openzeppelin_access` package. The references documented here are contained in the `openzeppelin_interfaces` package version `v2.1.0`.
1414
</Callout>
1515

16+
import { UMBRELLA_VERSION } from "../utils/constants.ts";
17+
1618
### `IAccessControl` [toc]
1719
<APIGithubLinkHeader
1820
moduleName="IAccessControl"
19-
link="https://github.com/OpenZeppelin/cairo-contracts/blob/release-v3.0.0-alpha.1/packages/interfaces/src/access/accesscontrol.cairo"
21+
link={`https://github.com/OpenZeppelin/cairo-contracts/blob/release-${UMBRELLA_VERSION}/packages/interfaces/src/access/accesscontrol.cairo`}
2022
/>
2123

2224
```rust
@@ -148,7 +150,7 @@ Emitted when `account` is revoked `role`.
148150
### `IAccessControlWithDelay` [toc]
149151
<APIGithubLinkHeader
150152
moduleName="IAccessControlWithDelay"
151-
link="https://github.com/OpenZeppelin/cairo-contracts/blob/release-v3.0.0-alpha.1/packages/interfaces/src/access/accesscontrol.cairo"
153+
link="https://github.com/OpenZeppelin/cairo-contracts/blob/release-{{umbrella_version}}/packages/interfaces/src/access/accesscontrol.cairo"
152154
/>
153155

154156
```rust
@@ -211,7 +213,7 @@ Emitted when `account` is granted `role` with a delay.
211213
### `IAccessControlDefaultAdminRules` [toc]
212214
<APIGithubLinkHeader
213215
moduleName="IAccessControlDefaultAdminRules"
214-
link="https://github.com/OpenZeppelin/cairo-contracts/blob/release-v3.0.0-alpha.1/packages/interfaces/src/access/accesscontrol_default_admin_rules.cairo"
216+
link="https://github.com/OpenZeppelin/cairo-contracts/blob/release-{{umbrella_version}}/packages/interfaces/src/access/accesscontrol_default_admin_rules.cairo"
215217
/>
216218

217219
```rust
@@ -439,10 +441,10 @@ Emitted when a [pending\_default\_admin\_delay](#IAccessControlDefaultAdminRules
439441

440442
## Core
441443

442-
### `OwnableComponent` [toc]
444+
### `OwnableComponent` [toc] [#OwnableComponent]
443445
<APIGithubLinkHeader
444446
moduleName="OwnableComponent"
445-
link="https://github.com/OpenZeppelin/cairo-contracts/blob/release-v3.0.0-alpha.1/packages/access/src/ownable/ownable.cairo"
447+
link="https://github.com/OpenZeppelin/cairo-contracts/blob/release-{{umbrella_version}}/packages/access/src/ownable/ownable.cairo"
446448
/>
447449

448450
```rust
@@ -706,7 +708,7 @@ Emitted when the ownership is transferred.
706708
### `AccessControlComponent` [toc]
707709
<APIGithubLinkHeader
708710
moduleName="AccessControlComponent"
709-
link="https://github.com/OpenZeppelin/cairo-contracts/blob/release-v3.0.0-alpha.1/packages/access/src/accesscontrol/accesscontrol.cairo"
711+
link="https://github.com/OpenZeppelin/cairo-contracts/blob/release-{{umbrella_version}}/packages/access/src/accesscontrol/accesscontrol.cairo"
710712
/>
711713

712714
```rust
@@ -1102,7 +1104,7 @@ See [IAccessControl::RoleRevoked](#IAccessControl-RoleRevoked).
11021104
### `AccessControlDefaultAdminRulesComponent` [toc]
11031105
<APIGithubLinkHeader
11041106
moduleName="AccessControlDefaultAdminRulesComponent"
1105-
link="https://github.com/OpenZeppelin/cairo-contracts/blob/release-v3.0.0-alpha.1/packages/access/src/accesscontrol/extensions/accesscontrol_default_admin_rules.cairo"
1107+
link="https://github.com/OpenZeppelin/cairo-contracts/blob/release-{{umbrella_version}}/packages/access/src/accesscontrol/extensions/accesscontrol_default_admin_rules.cairo"
11061108
/>
11071109

11081110
```rust

content/contracts-cairo/components.mdx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ mod MyContract {
3232
}
3333
```
3434

35-
The `path` argument should be the imported component itself (in this case, [InitializableComponent](/contracts-cairo/security#initializable)).
35+
The `path` argument should be the imported component itself (in this case, [InitializableComponent](security#initializable)).
3636
The `storage` and `event` arguments are the variable names that will be set in the `Storage` struct and `Event` enum, respectively.
3737
Note that even if the component doesn’t define any events, the compiler will still create an empty event enum inside the component module.
3838

@@ -128,8 +128,7 @@ mod MyContract {
128128
`InitializableImpl` defines the `is_initialized` method in the component.
129129
By adding the embed attribute, `is_initialized` becomes a contract entrypoint for `MyContract`.
130130

131-
132-
131+
<Callout type='info'>
133132
Embeddable implementations, when available in this library’s components, are segregated from the internal component implementation which makes it easier to safely expose.
134133
Components also separate granular implementations from [mixin](/contracts-cairo/components#mixins) implementations.
135134
The API documentation design reflects these groupings.
@@ -139,6 +138,7 @@ See [ERC20Component](/contracts-cairo/api/erc20#erc20component) as an example wh
139138
* **Embeddable Implementations**
140139
* **Internal Implementations**
141140
* **Events**
141+
</Callout>
142142

143143

144144
### Mixins
@@ -232,13 +232,15 @@ mod Account {
232232

233233
<Callout type='warn'>
234234
Failing to use a component’s `initializer` can result in irreparable contract deployments.
235+
236+
Always read the API Reference documentation for each integrated component.
235237
</Callout>
236-
Always read the API documentation for each integrated component.
238+
237239

238240
Some components require some sort of setup upon construction.
239241
Usually, this would be a job for a constructor; however, components themselves cannot implement constructors.
240242
Components instead offer ``initializer``s within their `InternalImpl` to call from the contract’s constructor.
241-
Let’s look at how a contract would integrate [OwnableComponent](/contracts-cairo/api/access#ownablecomponent):
243+
Let’s look at how a contract would integrate [OwnableComponent](/contracts-cairo/api/access#OwnableComponent):
242244

243245
```rust
244246
#[starknet::contract]
@@ -441,8 +443,10 @@ mod MyContract {
441443

442444
<Callout type='warn'>
443445
Customizing implementations and accessing component storage can potentially corrupt the state, bypass security checks, and undermine the component logic.
444-
</Callout>
446+
445447
**Exercise extreme caution**. See [Security](#security).
448+
</Callout>
449+
446450

447451
### Hooks
448452

content/contracts-cairo/index.mdx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,16 @@ Install the library by declaring it as a dependency in the project’s `Scarb.to
6767

6868
```javascript
6969
[dependencies]
70-
openzeppelin = "3.0.0-alpha.2"
70+
openzeppelin = "{{umbrella_version}}"
7171
```
7272

7373
The previous example would import the entire library. We can also add each package as a separate dependency to
7474
improve the building time by not including modules that won’t be used:
7575

7676
```toml
7777
[dependencies]
78-
openzeppelin_access = "3.0.0-alpha.1"
79-
openzeppelin_token = "3.0.0-alpha.1"
78+
openzeppelin_access = "{{umbrella_version}}"
79+
openzeppelin_token = "{{umbrella_version}}"
8080
openzeppelin_interfaces = "{{openzeppelin_interfaces_version}}"
8181
```
8282

@@ -86,19 +86,19 @@ Here you can find a reference of the versioning of the sub-packages for this umb
8686

8787
```javascript
8888
[dependencies]
89-
openzeppelin_access = "3.0.0-alpha.1"
90-
openzeppelin_token = "3.0.0-alpha.1"
91-
openzeppelin_access = "3.0.0-alpha.1"
92-
openzeppelin_account = "3.0.0-alpha.1"
93-
openzeppelin_finance = "3.0.0-alpha.1"
89+
openzeppelin_access = "{{umbrella_version}}"
90+
openzeppelin_token = "{{umbrella_version}}"
91+
openzeppelin_access = "{{umbrella_version}}"
92+
openzeppelin_account = "{{umbrella_version}}"
93+
openzeppelin_finance = "{{umbrella_version}}"
9494
openzeppelin_interfaces = "{{openzeppelin_interfaces_version}}"
95-
openzeppelin_governance = "3.0.0-alpha.1"
96-
openzeppelin_introspection = "3.0.0-alpha.1"
97-
openzeppelin_merkle_tree = "3.0.0-alpha.1"
98-
openzeppelin_presets = "3.0.0-alpha.1"
99-
openzeppelin_security = "3.0.0-alpha.1"
100-
openzeppelin_token = "3.0.0-alpha.1"
101-
openzeppelin_upgrades = "3.0.0-alpha.1"
95+
openzeppelin_governance = "{{umbrella_version}}"
96+
openzeppelin_introspection = "{{umbrella_version}}"
97+
openzeppelin_merkle_tree = "{{umbrella_version}}"
98+
openzeppelin_presets = "{{umbrella_version}}"
99+
openzeppelin_security = "{{umbrella_version}}"
100+
openzeppelin_token = "{{umbrella_version}}"
101+
openzeppelin_upgrades = "{{umbrella_version}}"
102102
openzeppelin_utils = "{{openzeppelin_utils_version}}"
103103
```
104104

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export const OPENZEPPELIN_INTERFACES_VERSION = "2.1.0-alpha.0";
22
export const OPENZEPPELIN_UTILS_VERSION = "3.1.0-alpha.0";
3-
export const UMBRELLA_VERSION = "3.0.0-alpha.2";
3+
export const UMBRELLA_VERSION = "3.0.0-alpha.1";

src/components/ui/api-reference/api-github-link-header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export function APIGithubLinkHeader({
55
moduleName: string;
66
link: string;
77
}) {
8-
const id = moduleName.toLowerCase().replace(/ /g, "-") + "-toc";
8+
const id = moduleName;
99
return (
1010
<div
1111
style={{ marginTop: "2em" }}

src/navigation/starknet.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,6 @@
178178
}
179179
]
180180
},
181-
{
182-
"type": "page",
183-
"name": "Backwards Compatibility",
184-
"url": "/contracts-cairo/backwards-compatibility"
185-
},
186181
{
187182
"type": "folder",
188183
"name": "API Reference",
@@ -264,6 +259,11 @@
264259
}
265260
]
266261
},
262+
{
263+
"type": "page",
264+
"name": "Backwards Compatibility",
265+
"url": "/contracts-cairo/backwards-compatibility"
266+
},
267267
{
268268
"type": "folder",
269269
"name": "Previous Versions",

0 commit comments

Comments
 (0)