diff --git a/.github/workflows/typos.yaml b/.github/workflows/typos.yaml index 961283630..7360d7686 100644 --- a/.github/workflows/typos.yaml +++ b/.github/workflows/typos.yaml @@ -10,4 +10,4 @@ jobs: uses: actions/checkout@v4 - name: Check for typos - uses: crate-ci/typos@8e6a4285bcbde632c5d79900a7779746e8b7ea3f + uses: crate-ci/typos@f12cee1d8f3c79282a98ecb41d235aef17dfa8fd diff --git a/CHANGELOG.md b/CHANGELOG.md index 36638c27c..0312236cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Changed + +- Bump scarb to v2.8.3 (#1166) + +## 0.17.0 (2024-09-23) + ### Added - `into_base_16_string_no_padding` function to the test helpers (#1137) @@ -24,6 +30,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `execute_calls` function from account utils (#1150) - calls param type changed from `Array` to `Span` +### Deprecated + +- DualCase dispatchers + ## 0.16.0 (2024-08-30) ### Added diff --git a/README.md b/README.md index 8dd36e303..6e4d27302 100644 --- a/README.md +++ b/README.md @@ -43,14 +43,14 @@ Edit `scarb.toml` and add: ```toml [dependencies] -openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.16.0" } +openzeppelin = "0.17.0" ``` -The previous example would import the entire library. we can also add each package as a separated dependency to improve the time for building by not including modules that won't be used: +The previous example would import the entire library. We can also add each package as a separate dependency to improve the building time by not including modules that won't be used: ```toml [dependencies] -openzeppelin_token = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.16.0" } +openzeppelin_token = "0.17.0" ``` Build the project to download it: @@ -72,8 +72,7 @@ For example, this is how to write an ERC20-compliant contract: ```cairo #[starknet::contract] mod MyToken { - // If only the token package was added as a dependency, use `openzeppelin_token::` instead - use openzeppelin::token::erc20::{ERC20Component, ERC20HooksEmptyImpl}; + use openzeppelin_token::erc20::{ERC20Component, ERC20HooksEmptyImpl}; use starknet::ContractAddress; component!(path: ERC20Component, storage: erc20, event: ERC20Event); @@ -113,22 +112,13 @@ mod MyToken { ### Unsupported -[`DualCase` dispatchers](https://docs.openzeppelin.com/contracts-cairo/0.16.0/interfaces#dualcase_dispatchers) rely on Sierra's ability to catch a revert to resume execution. Currently, Starknet live chains (testnets and mainnet) don't implement that behavior. Starknet's testing framework does support it. +[`DualCase` dispatchers](https://docs.openzeppelin.com/contracts-cairo/0.17.0/interfaces#dualcase_dispatchers) rely on Sierra's ability to catch a revert to resume execution. Currently, Starknet live chains (testnets and mainnet) don't implement that behavior. Starknet's testing framework does support it. ## Learn - +Check out the [full documentation site](https://docs.openzeppelin.com/contracts-cairo)! ### Cairo diff --git a/Scarb.lock b/Scarb.lock index 579ba42fc..a67000d04 100644 --- a/Scarb.lock +++ b/Scarb.lock @@ -3,7 +3,7 @@ version = 1 [[package]] name = "openzeppelin" -version = "0.16.0" +version = "0.17.0" dependencies = [ "openzeppelin_access", "openzeppelin_account", @@ -23,7 +23,7 @@ dependencies = [ [[package]] name = "openzeppelin_access" -version = "0.16.0" +version = "0.17.0" dependencies = [ "openzeppelin_introspection", "openzeppelin_test_common", @@ -34,7 +34,7 @@ dependencies = [ [[package]] name = "openzeppelin_account" -version = "0.16.0" +version = "0.17.0" dependencies = [ "openzeppelin_introspection", "openzeppelin_test_common", @@ -45,7 +45,7 @@ dependencies = [ [[package]] name = "openzeppelin_finance" -version = "0.16.0" +version = "0.17.0" dependencies = [ "openzeppelin_access", "openzeppelin_test_common", @@ -56,7 +56,7 @@ dependencies = [ [[package]] name = "openzeppelin_governance" -version = "0.16.0" +version = "0.17.0" dependencies = [ "openzeppelin_access", "openzeppelin_introspection", @@ -66,21 +66,21 @@ dependencies = [ [[package]] name = "openzeppelin_introspection" -version = "0.16.0" +version = "0.17.0" dependencies = [ "snforge_std", ] [[package]] name = "openzeppelin_merkle_tree" -version = "0.16.0" +version = "0.17.0" dependencies = [ "snforge_std", ] [[package]] name = "openzeppelin_presets" -version = "0.16.0" +version = "0.17.0" dependencies = [ "openzeppelin_access", "openzeppelin_account", @@ -95,7 +95,7 @@ dependencies = [ [[package]] name = "openzeppelin_security" -version = "0.16.0" +version = "0.17.0" dependencies = [ "openzeppelin_testing", "snforge_std", @@ -103,7 +103,7 @@ dependencies = [ [[package]] name = "openzeppelin_test_common" -version = "0.16.0" +version = "0.17.0" dependencies = [ "openzeppelin_access", "openzeppelin_account", @@ -117,14 +117,14 @@ dependencies = [ [[package]] name = "openzeppelin_testing" -version = "0.16.0" +version = "0.17.0" dependencies = [ "snforge_std", ] [[package]] name = "openzeppelin_token" -version = "0.16.0" +version = "0.17.0" dependencies = [ "openzeppelin_account", "openzeppelin_governance", @@ -136,7 +136,7 @@ dependencies = [ [[package]] name = "openzeppelin_upgrades" -version = "0.16.0" +version = "0.17.0" dependencies = [ "openzeppelin_test_common", "openzeppelin_testing", @@ -145,7 +145,7 @@ dependencies = [ [[package]] name = "openzeppelin_utils" -version = "0.16.0" +version = "0.17.0" dependencies = [ "openzeppelin_testing", "snforge_std", diff --git a/Scarb.toml b/Scarb.toml index 528b45ba1..7fb7c15a4 100644 --- a/Scarb.toml +++ b/Scarb.toml @@ -22,10 +22,10 @@ version.workspace = true keywords.workspace = true [workspace.package] -version = "0.16.0" +version = "0.17.0" edition = "2024_07" cairo-version = "2.8.2" -scarb-version = "2.8.2" +scarb-version = "2.8.3" authors = ["OpenZeppelin Community "] description = "OpenZeppelin Contracts written in Cairo for Starknet, a decentralized ZK Rollup" documentation = "https://docs.openzeppelin.com/contracts-cairo" diff --git a/docs/antora.yml b/docs/antora.yml index 4fa5518a0..0272f3629 100644 --- a/docs/antora.yml +++ b/docs/antora.yml @@ -1,8 +1,8 @@ name: contracts-cairo title: Contracts for Cairo -version: 0.16.0 +version: 0.17.0 nav: - modules/ROOT/nav.adoc asciidoc: attributes: - page-sidebar-collapse-default: 'Access,Accounts,Governance,Introspection,Security,ERC20,ERC721,ERC1155,Upgrades,Universal Deployer Contract' + page-sidebar-collapse-default: 'Access,Accounts,Finance,Governance,Introspection,Security,ERC20,ERC721,ERC1155,Upgrades,Universal Deployer Contract' diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc index b005c159f..906112a0e 100644 --- a/docs/modules/ROOT/nav.adoc +++ b/docs/modules/ROOT/nav.adoc @@ -17,6 +17,9 @@ ** xref:accounts.adoc[Accounts] *** xref:/api/account.adoc[API Reference] +** xref:finance.adoc[Finance] +*** xref:/api/finance.adoc[API Reference] + ** xref:governance.adoc[Governance] *** xref:/api/governance.adoc[API Reference] diff --git a/docs/modules/ROOT/pages/access.adoc b/docs/modules/ROOT/pages/access.adoc index dbd987a1e..752c7ffc9 100644 --- a/docs/modules/ROOT/pages/access.adoc +++ b/docs/modules/ROOT/pages/access.adoc @@ -26,7 +26,7 @@ xref:/api/access.adoc#OwnableComponent-initializer[`initializer`] like this: ---- #[starknet::contract] mod MyContract { - use openzeppelin::access::ownable::OwnableComponent; + use openzeppelin_access::ownable::OwnableComponent; use starknet::ContractAddress; component!(path: OwnableComponent, storage: ownable, event: OwnableEvent); @@ -174,9 +174,9 @@ const MINTER_ROLE: felt252 = selector!("MINTER_ROLE"); #[starknet::contract] mod MyContract { - use openzeppelin::access::accesscontrol::AccessControlComponent; - use openzeppelin::introspection::src5::SRC5Component; - use openzeppelin::token::erc20::{ERC20Component, ERC20HooksEmptyImpl}; + use openzeppelin_access::accesscontrol::AccessControlComponent; + use openzeppelin_introspection::src5::SRC5Component; + use openzeppelin_token::erc20::{ERC20Component, ERC20HooksEmptyImpl}; use starknet::ContractAddress; use super::MINTER_ROLE; @@ -265,9 +265,9 @@ const BURNER_ROLE: felt252 = selector!("BURNER_ROLE"); #[starknet::contract] mod MyContract { - use openzeppelin::access::accesscontrol::AccessControlComponent; - use openzeppelin::introspection::src5::SRC5Component; - use openzeppelin::token::erc20::{ERC20Component, ERC20HooksEmptyImpl}; + use openzeppelin_access::accesscontrol::AccessControlComponent; + use openzeppelin_introspection::src5::SRC5Component; + use openzeppelin_token::erc20::{ERC20Component, ERC20HooksEmptyImpl}; use starknet::ContractAddress; use super::{MINTER_ROLE, BURNER_ROLE}; @@ -376,7 +376,7 @@ This mechanism can be used to create complex permissioning structures resembling provides an easy way to manage simpler applications. `AccessControl` includes a special role with the role identifier of `0`, called `DEFAULT_ADMIN_ROLE`, which acts as the *default admin role for all roles*. An account with this role will be able to manage any other role, unless -xref:api/access.adoc#AccessControlComponent-_set_role_admin[`_set_role_admin`] is used to select a new admin role. +xref:api/access.adoc#AccessControlComponent-set_role_admin[`set_role_admin`] is used to select a new admin role. Let's take a look at the ERC20 token example, this time taking advantage of the default admin role: @@ -387,10 +387,10 @@ const BURNER_ROLE: felt252 = selector!("BURNER_ROLE"); #[starknet::contract] mod MyContract { - use openzeppelin::access::accesscontrol::AccessControlComponent; - use openzeppelin::access::accesscontrol::DEFAULT_ADMIN_ROLE; - use openzeppelin::introspection::src5::SRC5Component; - use openzeppelin::token::erc20::{ERC20Component, ERC20HooksEmptyImpl}; + use openzeppelin_access::accesscontrol::AccessControlComponent; + use openzeppelin_access::accesscontrol::DEFAULT_ADMIN_ROLE; + use openzeppelin_introspection::src5::SRC5Component; + use openzeppelin_token::erc20::{ERC20Component, ERC20HooksEmptyImpl}; use starknet::ContractAddress; use super::{MINTER_ROLE, BURNER_ROLE}; diff --git a/docs/modules/ROOT/pages/accounts.adoc b/docs/modules/ROOT/pages/accounts.adoc index 12ffd0dae..077591d95 100644 --- a/docs/modules/ROOT/pages/accounts.adoc +++ b/docs/modules/ROOT/pages/accounts.adoc @@ -112,8 +112,8 @@ Constructing an account contract requires integrating both {account-component} a ---- #[starknet::contract(account)] mod MyAccount { - use openzeppelin::account::AccountComponent; - use openzeppelin::introspection::src5::SRC5Component; + use openzeppelin_account::AccountComponent; + use openzeppelin_introspection::src5::SRC5Component; component!(path: AccountComponent, storage: account, event: AccountEvent); component!(path: SRC5Component, storage: src5, event: SRC5Event); @@ -202,9 +202,9 @@ Here’s an example of a basic contract: ---- #[starknet::contract(account)] mod MyEthAccount { - use openzeppelin::account::EthAccountComponent; - use openzeppelin::account::interface::EthPublicKey; - use openzeppelin::introspection::src5::SRC5Component; + use openzeppelin_account::EthAccountComponent; + use openzeppelin_account::interface::EthPublicKey; + use openzeppelin_introspection::src5::SRC5Component; use starknet::ClassHash; component!(path: EthAccountComponent, storage: eth_account, event: EthAccountEvent); @@ -303,8 +303,8 @@ First, let's take the example account we created before and deploy it: ```[,cairo] #[starknet::contract(account)] mod MyAccount { - use openzeppelin::account::AccountComponent; - use openzeppelin::introspection::src5::SRC5Component; + use openzeppelin_account::AccountComponent; + use openzeppelin_introspection::src5::SRC5Component; component!(path: AccountComponent, storage: account, event: AccountEvent); component!(path: SRC5Component, storage: src5, event: SRC5Event); @@ -386,9 +386,9 @@ First, let's take the example account we created before and deploy it: ```[,cairo] #[starknet::contract(account)] mod MyEthAccount { - use openzeppelin::account::EthAccountComponent; - use openzeppelin::account::interface::EthPublicKey; - use openzeppelin::introspection::src5::SRC5Component; + use openzeppelin_account::EthAccountComponent; + use openzeppelin_account::interface::EthPublicKey; + use openzeppelin_introspection::src5::SRC5Component; component!(path: EthAccountComponent, storage: eth_account, event: EthAccountEvent); component!(path: SRC5Component, storage: src5, event: SRC5Event); diff --git a/docs/modules/ROOT/pages/api/access.adoc b/docs/modules/ROOT/pages/api/access.adoc index 4d403341a..41e518bff 100644 --- a/docs/modules/ROOT/pages/api/access.adoc +++ b/docs/modules/ROOT/pages/api/access.adoc @@ -20,10 +20,10 @@ assigned each to multiple accounts. [.contract] [[OwnableComponent]] -=== `++OwnableComponent++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/access/src/ownable/ownable.cairo[{github-icon},role=heading-link] +=== `++OwnableComponent++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/access/src/ownable/ownable.cairo[{github-icon},role=heading-link] ```cairo -use openzeppelin::access::ownable::OwnableComponent; +use openzeppelin_access::ownable::OwnableComponent; ``` `Ownable` provides a basic access control mechanism where an account @@ -255,7 +255,7 @@ Emitted when the ownership is transferred. [.contract] [[IAccessControl]] -=== `++IAccessControl++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/access/src/accesscontrol/interface.cairo[{github-icon},role=heading-link] +=== `++IAccessControl++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/access/src/accesscontrol/interface.cairo[{github-icon},role=heading-link] :grant_role: xref:#IAccessControl-grant_role[grant_role] :revoke_role: xref:#IAccessControl-revoke_role[revoke_role] @@ -264,7 +264,7 @@ Emitted when the ownership is transferred. :RoleAdminChanged: xref:#IAccessControl-RoleAdminChanged[RoleAdminChanged] ```cairo -use openzeppelin::access::accesscontrol::interface::IAccessControl; +use openzeppelin_access::accesscontrol::interface::IAccessControl; ``` External interface of AccessControl. @@ -388,14 +388,14 @@ Emitted when `account` is revoked `role`. [.contract] [[AccessControlComponent]] -=== `++AccessControlComponent++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/access/src/accesscontrol/accesscontrol.cairo[{github-icon},role=heading-link] +=== `++AccessControlComponent++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/access/src/accesscontrol/accesscontrol.cairo[{github-icon},role=heading-link] :assert_only_role: xref:#AccessControlComponent-assert_only_role :grant_role: xref:#AccessControlComponent-grant_role[grant_role] :revoke_role: xref:#AccessControlComponent-revoke_role[revoke_role] ```cairo -use openzeppelin::access::accesscontrol::AccessControlComponent; +use openzeppelin_access::accesscontrol::AccessControlComponent; ``` Component that allows contracts to implement role-based access control mechanisms. diff --git a/docs/modules/ROOT/pages/api/account.adoc b/docs/modules/ROOT/pages/api/account.adoc index dbe63843b..3f289d98a 100644 --- a/docs/modules/ROOT/pages/api/account.adoc +++ b/docs/modules/ROOT/pages/api/account.adoc @@ -14,10 +14,10 @@ include::../utils/_common.adoc[] [.contract] [[ISRC6]] -=== `++ISRC6++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/account/src/interface.cairo[{github-icon},role=heading-link] +=== `++ISRC6++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/account/src/interface.cairo[{github-icon},role=heading-link] ```cairo -use openzeppelin::account::interface::ISRC6; +use openzeppelin_account::interface::ISRC6; ``` Interface of the SRC6 Standard Account as defined in the {snip6}. @@ -67,14 +67,14 @@ Returns the short string `'VALID'` if valid, otherwise it reverts. [.contract] [[AccountComponent]] -=== `++AccountComponent++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/account/src/account.cairo[{github-icon},role=heading-link] +=== `++AccountComponent++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/account/src/account.cairo[{github-icon},role=heading-link] :OwnerAdded: xref:AccountComponent-OwnerAdded[OwnerAdded] :OwnerRemoved: xref:AccountComponent-OwnerRemoved[OwnerRemoved] :starknet-curve: https://docs.starknet.io/documentation/architecture_and_concepts/Cryptography/stark-curve/[Starknet curve] ```cairo -use openzeppelin::account::AccountComponent; +use openzeppelin_account::AccountComponent; ``` Account component implementing xref:ISRC6[`ISRC6`] for signatures over the {starknet-curve}. @@ -317,14 +317,14 @@ Emitted when a `public_key` is removed. [.contract] [[EthAccountComponent]] -=== `++EthAccountComponent++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/account/src/eth_account.cairo[{github-icon},role=heading-link] +=== `++EthAccountComponent++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/account/src/eth_account.cairo[{github-icon},role=heading-link] :OwnerAdded: xref:EthAccountComponent-OwnerAdded[OwnerAdded] :OwnerRemoved: xref:EthAccountComponent-OwnerRemoved[OwnerRemoved] :secp256k1-curve: https://en.bitcoin.it/wiki/Secp256k1[Secp256k1 curve] ```cairo -use openzeppelin::account::eth_account::EthAccountComponent; +use openzeppelin_account::eth_account::EthAccountComponent; ``` Account component implementing xref:ISRC6[`ISRC6`] for signatures over the {secp256k1-curve}. @@ -572,10 +572,10 @@ Emitted when a `public_key` is removed. [.contract] [[ISRC9_V2]] -=== `++ISRC9_V2++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/account/src/extensions/src9/interface.cairo[{github-icon},role=heading-link] +=== `++ISRC9_V2++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/account/src/extensions/src9/interface.cairo[{github-icon},role=heading-link] ```cairo -use openzeppelin::account::extensions::src9::ISRC9_V2; +use openzeppelin_account::extensions::src9::ISRC9_V2; ``` Interface of the SRC9 Standard as defined in the {snip9}. @@ -622,10 +622,10 @@ Get the status of a given nonce. `true` if the nonce is available to use. [.contract] [[SRC9Component]] -=== `++SRC9Component++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/account/src/extensions/src9/src9.cairo[{github-icon},role=heading-link] +=== `++SRC9Component++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/account/src/extensions/src9/src9.cairo[{github-icon},role=heading-link] ```cairo -use openzeppelin::account::extensions::SRC9Component; +use openzeppelin_account::extensions::SRC9Component; ``` OutsideExecution component implementing xref:ISRC9_V2[`ISRC9_V2`]. @@ -698,10 +698,10 @@ Initializes the account by registering the `ISRC9_V2` interface Id. [.contract] [[AccountUpgradeable]] -=== `++AccountUpgradeable++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/presets/src/account.cairo[{github-icon},role=heading-link] +=== `++AccountUpgradeable++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/presets/src/account.cairo[{github-icon},role=heading-link] ```cairo -use openzeppelin::presets::AccountUpgradeable; +use openzeppelin_presets::AccountUpgradeable; ``` Upgradeable account contract leveraging xref:#AccountComponent[AccountComponent]. @@ -759,10 +759,10 @@ Requirements: [.contract] [[EthAccountUpgradeable]] -=== `++EthAccountUpgradeable++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/presets/src/eth_account.cairo[{github-icon},role=heading-link] +=== `++EthAccountUpgradeable++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/presets/src/eth_account.cairo[{github-icon},role=heading-link] ```cairo -use openzeppelin::presets::EthAccountUpgradeable; +use openzeppelin_presets::EthAccountUpgradeable; ``` Upgradeable account contract leveraging xref:#EthAccountComponent[EthAccountComponent]. diff --git a/docs/modules/ROOT/pages/api/erc1155.adoc b/docs/modules/ROOT/pages/api/erc1155.adoc index ff1cf0921..5c3afac71 100644 --- a/docs/modules/ROOT/pages/api/erc1155.adoc +++ b/docs/modules/ROOT/pages/api/erc1155.adoc @@ -16,11 +16,11 @@ TIP: For an overview of ERC1155, read our xref:erc1155.adoc[ERC1155 guide]. [.contract] [[IERC1155]] -=== `++IERC1155++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/token/src/erc1155/interface.cairo[{github-icon},role=heading-link] +=== `++IERC1155++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/token/src/erc1155/interface.cairo[{github-icon},role=heading-link] [.hljs-theme-dark] ```cairo -use openzeppelin::token::erc1155::interface::IERC1155; +use openzeppelin_token::erc1155::interface::IERC1155; ``` Interface of the IERC1155 standard as defined in {eip1155}. @@ -126,11 +126,11 @@ Emitted when the token URI is updated to `value` for the `id` token. [.contract] [[IERC1155MetadataURI]] -=== `++IERC1155MetadataURI++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/token/src/erc1155/interface.cairo[{github-icon},role=heading-link] +=== `++IERC1155MetadataURI++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/token/src/erc1155/interface.cairo[{github-icon},role=heading-link] [.hljs-theme-dark] ```cairo -use openzeppelin::token::erc1155::interface::IERC1155MetadataURI; +use openzeppelin_token::erc1155::interface::IERC1155MetadataURI; ``` Interface for the optional metadata function in {eip1155-metadata}[EIP1155]. @@ -156,11 +156,11 @@ Returns the Uniform Resource Identifier (URI) for the `token_id` token. [.contract] [[ERC1155Component]] -=== `++ERC1155Component++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/token/src/erc1155/erc1155.cairo[{github-icon},role=heading-link] +=== `++ERC1155Component++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/token/src/erc1155/erc1155.cairo[{github-icon},role=heading-link] [.hljs-theme-dark] ```cairo -use openzeppelin::token::erc1155::ERC1155Component; +use openzeppelin_token::erc1155::ERC1155Component; ``` ERC1155 component implementing <> and <>. @@ -246,7 +246,7 @@ Hooks are functions which implementations can extend the functionality of the co using ERC1155Component is expected to provide an implementation of the ERC1155HooksTrait. For basic token contracts, an empty implementation with no logic must be provided. -TIP: You can use `openzeppelin::token::erc1155::ERC1155HooksEmptyImpl` which is already available as part of the library +TIP: You can use `openzeppelin_token::erc1155::ERC1155HooksEmptyImpl` which is already available as part of the library for this purpose. [.contract-item] @@ -543,11 +543,11 @@ See <>. [.contract] [[IERC1155Receiver]] -=== `++IERC1155Receiver++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/token/src/erc1155/interface.cairo[{github-icon},role=heading-link] +=== `++IERC1155Receiver++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/token/src/erc1155/interface.cairo[{github-icon},role=heading-link] [.hljs-theme-dark] ```cairo -use openzeppelin::token::erc1155::interface::IERC1155Receiver; +use openzeppelin_token::erc1155::interface::IERC1155Receiver; ``` Interface for contracts that support receiving token transfers from `ERC1155` contracts. @@ -583,11 +583,11 @@ via <> by [.contract] [[ERC1155ReceiverComponent]] -=== `++ERC1155ReceiverComponent++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/token/src/erc1155/erc1155_receiver.cairo[{github-icon},role=heading-link] +=== `++ERC1155ReceiverComponent++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/token/src/erc1155/erc1155_receiver.cairo[{github-icon},role=heading-link] [.hljs-theme-dark] ```cairo -use openzeppelin::token::erc1155::ERC1155ReceiverComponent; +use openzeppelin_token::erc1155::ERC1155ReceiverComponent; ``` ERC1155Receiver component implementing <>. @@ -660,10 +660,10 @@ Registers the `IERC1155Receiver` interface ID as supported through introspection [.contract] [[ERC1155Upgradeable]] -=== `++ERC1155Upgradeable++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/presets/src/erc1155.cairo[{github-icon},role=heading-link] +=== `++ERC1155Upgradeable++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/presets/src/erc1155.cairo[{github-icon},role=heading-link] ```cairo -use openzeppelin::presets::ERC1155; +use openzeppelin_presets::ERC1155; ``` Upgradeable ERC1155 contract leveraging xref:#ERC1155Component[ERC1155Component]. diff --git a/docs/modules/ROOT/pages/api/erc20.adoc b/docs/modules/ROOT/pages/api/erc20.adoc index d53aea12c..ba4328868 100644 --- a/docs/modules/ROOT/pages/api/erc20.adoc +++ b/docs/modules/ROOT/pages/api/erc20.adoc @@ -16,11 +16,11 @@ TIP: For an overview of ERC20, read our {erc20-guide}. [.contract] [[IERC20]] -=== `++IERC20++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/token/src/erc20/interface.cairo[{github-icon},role=heading-link] +=== `++IERC20++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/token/src/erc20/interface.cairo[{github-icon},role=heading-link] [.hljs-theme-dark] ```cairo -use openzeppelin::token::erc20::interface::IERC20; +use openzeppelin_token::erc20::interface::IERC20; ``` Interface of the IERC20 standard as defined in {eip20}. @@ -114,11 +114,11 @@ Emitted when the allowance of a `spender` for an `owner` is set. [.contract] [[IERC20Metadata]] -=== `++IERC20Metadata++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/token/src/erc20/interface.cairo#L19[{github-icon},role=heading-link] +=== `++IERC20Metadata++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/token/src/erc20/interface.cairo#L19[{github-icon},role=heading-link] [.hljs-theme-dark] ```cairo -use openzeppelin::token::erc20::interface::IERC20Metadata; +use openzeppelin_token::erc20::interface::IERC20Metadata; ``` Interface for the optional metadata functions in {eip20}. @@ -162,11 +162,11 @@ NOTE: This information is only used for _display_ purposes: it in no way affects [.contract] [[ERC20Component]] -=== `++ERC20Component++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/token/src/erc20/erc20.cairo[{github-icon},role=heading-link] +=== `++ERC20Component++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/token/src/erc20/erc20.cairo[{github-icon},role=heading-link] [.hljs-theme-dark] ```cairo -use openzeppelin::token::erc20::ERC20Component; +use openzeppelin_token::erc20::ERC20Component; ``` ERC20 component extending <> and <>. @@ -242,7 +242,7 @@ Hooks are functions which implementations can extend the functionality of the co using ERC20Component is expected to provide an implementation of the ERC20HooksTrait. For basic token contracts, an empty implementation with no logic must be provided. -TIP: You can use `openzeppelin::token::erc20::ERC20HooksEmptyImpl` which is already available as part of the library +TIP: You can use `openzeppelin_token::erc20::ERC20HooksEmptyImpl` which is already available as part of the library for this purpose. [.contract-item] @@ -460,10 +460,10 @@ See <>. [.contract] [[ERC20VotesComponent]] -=== `++ERC20VotesComponent++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/token/src/erc20/extensions/erc20_votes.cairo[{github-icon},role=heading-link] +=== `++ERC20VotesComponent++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/token/src/erc20/extensions/erc20_votes.cairo[{github-icon},role=heading-link] ```cairo -use openzeppelin::token::extensions::ERC20VotesComponent; +use openzeppelin_token::extensions::ERC20VotesComponent; ``` :DelegateChanged: xref:ERC20VotesComponent-DelegateChanged[DelegateChanged] @@ -654,10 +654,10 @@ Emitted when `delegate` votes are updated from `previous_votes` to `new_votes`. [.contract] [[ERC20Upgradeable]] -=== `++ERC20Upgradeable++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/presets/src/erc20.cairo[{github-icon},role=heading-link] +=== `++ERC20Upgradeable++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/presets/src/erc20.cairo[{github-icon},role=heading-link] ```cairo -use openzeppelin::presets::ERC20Upgradeable; +use openzeppelin_presets::ERC20Upgradeable; ``` Upgradeable ERC20 contract leveraging xref:#ERC20Component[ERC20Component] with a fixed-supply mechanism for token distribution. diff --git a/docs/modules/ROOT/pages/api/erc721.adoc b/docs/modules/ROOT/pages/api/erc721.adoc index f5c78b5b1..0126a2979 100644 --- a/docs/modules/ROOT/pages/api/erc721.adoc +++ b/docs/modules/ROOT/pages/api/erc721.adoc @@ -16,11 +16,11 @@ TIP: For an overview of ERC721, read our xref:erc721.adoc[ERC721 guide]. [.contract] [[IERC721]] -=== `++IERC721++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/token/src/erc721/interface.cairo#L13-L31[{github-icon},role=heading-link] +=== `++IERC721++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/token/src/erc721/interface.cairo#L13-L31[{github-icon},role=heading-link] [.hljs-theme-dark] ```cairo -use openzeppelin::token::erc721::interface::IERC721; +use openzeppelin_token::erc721::interface::IERC721; ``` Interface of the IERC721 standard as defined in {eip721}. @@ -135,11 +135,11 @@ Emitted when `token_id` token is transferred from `from` to `to`. [.contract] [[IERC721Metadata]] -=== `++IERC721Metadata++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/token/src/erc721/interface.cairo#L54-L59[{github-icon},role=heading-link] +=== `++IERC721Metadata++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/token/src/erc721/interface.cairo#L54-L59[{github-icon},role=heading-link] [.hljs-theme-dark] ```cairo -use openzeppelin::token::erc721::interface::IERC721Metadata; +use openzeppelin_token::erc721::interface::IERC721Metadata; ``` Interface for the optional metadata functions in {eip721}. @@ -181,11 +181,11 @@ If the URI is not set for `token_id`, the return value will be an empty `ByteArr [.contract] [[ERC721Component]] -=== `++ERC721Component++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/token/src/erc721/erc721.cairo#L7[{github-icon},role=heading-link] +=== `++ERC721Component++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/token/src/erc721/erc721.cairo#L7[{github-icon},role=heading-link] [.hljs-theme-dark] ```cairo -use openzeppelin::token::erc721::ERC721Component; +use openzeppelin_token::erc721::ERC721Component; ``` ERC721 component implementing <> and <>. @@ -292,7 +292,7 @@ Hooks are functions which implementations can extend the functionality of the co using ERC721Component is expected to provide an implementation of the ERC721HooksTrait. For basic token contracts, an empty implementation with no logic must be provided. -TIP: You can use `openzeppelin::token::erc721::ERC721HooksEmptyImpl` which is already available as part of the library +TIP: You can use `openzeppelin_token::erc721::ERC721HooksEmptyImpl` which is already available as part of the library for this purpose. [.contract-item] @@ -693,11 +693,11 @@ See <>. [.contract] [[IERC721Receiver]] -=== `++IERC721Receiver++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/token/src/erc721/interface.cairo#L70-L79[{github-icon},role=heading-link] +=== `++IERC721Receiver++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/token/src/erc721/interface.cairo#L70-L79[{github-icon},role=heading-link] [.hljs-theme-dark] ```cairo -use openzeppelin::token::erc721::interface::IERC721Receiver; +use openzeppelin_token::erc721::interface::IERC721Receiver; ``` Interface for contracts that support receiving `safe_transfer_from` transfers. @@ -724,11 +724,11 @@ Whenever an IERC721 `token_id` token is transferred to this non-account contract [.contract] [[ERC721ReceiverComponent]] -=== `++ERC721ReceiverComponent++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/token/src/erc721/erc721_receiver.cairo[{github-icon},role=heading-link] +=== `++ERC721ReceiverComponent++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/token/src/erc721/erc721_receiver.cairo[{github-icon},role=heading-link] [.hljs-theme-dark] ```cairo -use openzeppelin::token::erc721::ERC721ReceiverComponent; +use openzeppelin_token::erc721::ERC721ReceiverComponent; ``` ERC721Receiver component implementing <>. @@ -790,7 +790,7 @@ Registers the `IERC721Receiver` interface ID as supported through introspection. [.contract] [[IERC721Enumerable]] -=== `++IERC721Enumerable++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/token/src/erc721/extensions/erc721_enumerable/interface.cairo[{github-icon},role=heading-link] +=== `++IERC721Enumerable++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/token/src/erc721/extensions/erc721_enumerable/interface.cairo[{github-icon},role=heading-link] Interface for the optional enumerable functions in {eip721}. @@ -832,10 +832,10 @@ Use along with xref:#IERC721-balance_of[IERC721::balance_of] to enumerate all of [.contract] [[ERC721EnumerableComponent]] -=== `++ERC721EnumerableComponent++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/token/src/erc721/extensions/erc721_enumerable.cairo[{github-icon},role=heading-link] +=== `++ERC721EnumerableComponent++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/token/src/erc721/extensions/erc721_enumerable.cairo[{github-icon},role=heading-link] ```cairo -use openzeppelin::token::erc721::extensions::ERC721EnumerableComponent; +use openzeppelin_token::erc721::extensions::ERC721EnumerableComponent; ``` Extension of ERC721 as defined in the EIP that adds enumerability of all the token ids in the contract as well as all token ids owned by each account. @@ -975,10 +975,10 @@ This has 0(1) time complexity but alters the indexed order by swapping `token_id [.contract] [[ERC721Upgradeable]] -=== `++ERC721Upgradeable++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/presets/src/erc721.cairo[{github-icon},role=heading-link] +=== `++ERC721Upgradeable++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/presets/src/erc721.cairo[{github-icon},role=heading-link] ```cairo -use openzeppelin::presets::ERC721Upgradeable; +use openzeppelin_presets::ERC721Upgradeable; ``` Upgradeable ERC721 contract leveraging xref:#ERC721Component[ERC721Component]. diff --git a/docs/modules/ROOT/pages/api/finance.adoc b/docs/modules/ROOT/pages/api/finance.adoc new file mode 100755 index 000000000..60479e47f --- /dev/null +++ b/docs/modules/ROOT/pages/api/finance.adoc @@ -0,0 +1,302 @@ +:github-icon: pass:[] +:vesting-component: xref:VestingComponent[VestingComponent] +:ownable-component: xref:api/access.adoc#OwnableComponent[OwnableComponent] +:vesting-schedule: xref:api/finance.adoc#VestingComponent-Vesting-Schedule[VestingSchedule] +:AmountReleased: xref:IVesting-AmountReleased[AmountReleased] + += Finance + +This crate includes primitives for financial systems. + +== Vesting + +[.contract] +[[IVesting]] +=== `++IVesting++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/finance/src/vesting/interface.cairo[{github-icon},role=heading-link] + +[.hljs-theme-dark] +```cairo +use openzeppelin_finance::vesting::interface::IVesting; +``` + +Common interface for contracts implementing the vesting functionality. + +[.contract-index] +.Functions +-- +* xref:#IVesting-start[`++start()++`] +* xref:#IVesting-cliff[`++cliff()++`] +* xref:#IVesting-duration[`++duration()++`] +* xref:#IVesting-end[`++end()++`] +* xref:#IVesting-released[`++released(token)++`] +* xref:#IVesting-releasable[`++releasable(token)++`] +* xref:#IVesting-vested_amount[`++vested_amount(token, timestamp)++`] +* xref:#IVesting-release[`++release(token)++`] +-- + +[.contract-index] +.Events +-- +* xref:#IVesting-AmountReleased[`++AmountReleased(token, amount)++`] +-- + +[#IVesting-Functions] +==== Functions + +[.contract-item] +[[IVesting-start]] +==== `[.contract-item-name]#++start++#++() → u64++` [.item-kind]#external# + +Returns the timestamp marking the beginning of the vesting period. + +[.contract-item] +[[IVesting-cliff]] +==== `[.contract-item-name]#++cliff++#++() → u64++` [.item-kind]#external# + +Returns the timestamp marking the end of the cliff period. + +[.contract-item] +[[IVesting-duration]] +==== `[.contract-item-name]#++duration++#++() → u64++` [.item-kind]#external# + +Returns the total duration of the vesting period. + +[.contract-item] +[[IVesting-end]] +==== `[.contract-item-name]#++end++#++() → u64++` [.item-kind]#external# + +Returns the timestamp marking the end of the vesting period. + +[.contract-item] +[[IVesting-released]] +==== `[.contract-item-name]#++released++#++(token: ContractAddress) → u256++` [.item-kind]#external# + +Returns the already released amount for a given `token`. + +[.contract-item] +[[IVesting-releasable]] +==== `[.contract-item-name]#++releasable++#++(token: ContractAddress) → u256++` [.item-kind]#external# + +Returns the amount of a given `token` that can be released at the time of the call. + +[.contract-item] +[[IVesting-vested_amount]] +==== `[.contract-item-name]#++vested_amount++#++(token: ContractAddress, timestamp: u64) → u256++` [.item-kind]#external# + +Returns the total vested amount of a specified `token` at a given `timestamp`. + +[.contract-item] +[[IVesting-release]] +==== `[.contract-item-name]#++release++#++(token: ContractAddress) → u256++` [.item-kind]#external# + +Releases the amount of a given `token` that has already vested and returns that amount. + +Emits {AmountReleased} event. + +[#IVesting-Events] +==== Events + +[.contract-item] +[[IVesting-AmountReleased]] +==== `[.contract-item-name]#++AmountReleased++#++(token: ContractAddress, amount: u256)++` [.item-kind]#event# + +Emitted when vested tokens are released to the beneficiary. + +[.contract] +[[VestingComponent]] +=== `++VestingComponent++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/finance/src/vesting/vesting.cairo[{github-icon},role=heading-link] + +[.hljs-theme-dark] +```cairo +use openzeppelin_finance::vesting::VestingComponent; +``` + +Vesting component implementing the xref:IVesting[`IVesting`] interface. + +[.contract-index] +.Vesting Schedule Trait +-- +.functions +* xref:#VestingComponent-calculate_vested_amount[`++calculate_vested_amount(self, token, total_allocation, +timestamp, start, duration, cliff)++`] +-- + +[.contract-index#VestingComponent-Embeddable-Impls] +.Embeddable Implementations +-- +[.sub-index#VestingComponent-Embeddable-Impls-VestingImpl] +.VestingImpl +* xref:#VestingComponent-start[`++start(self)++`] +* xref:#VestingComponent-cliff[`++cliff(self)++`] +* xref:#VestingComponent-duration[`++duration(self)++`] +* xref:#VestingComponent-end[`++end(self)++`] +* xref:#VestingComponent-released[`++released(self, token)++`] +* xref:#VestingComponent-releasable[`++releasable(self, token)++`] +* xref:#VestingComponent-vested_amount[`++vested_amount(self, token, timestamp)++`] +* xref:#VestingComponent-release[`++release(self, token)++`] +-- + +[.contract-index] +.Internal implementations +-- +.InternalImpl +* xref:#VestingComponent-initializer[`++initializer(self, start, duration, cliff_duration)++`] +* xref:#VestingComponent-resolve_vested_amount[`++resolve_vested_amount(self, token, timestamp)++`] +-- + +[#VestingComponent-Vesting-Schedule] +==== VestingSchedule trait + +A trait that defines the logic for calculating the vested amount based on a given timestamp. + +NOTE: You can read more about the trait's purpose and how to use it xref:finance.adoc#vesting_schedule[here]. + +[.contract-item] +[[VestingComponent-calculate_vested_amount]] +==== `[.contract-item-name]#++calculate_vested_amount++#++(self: @ContractState, token: ContractAddress, total_allocation: u256, timestamp: u64, start: u64, duration: u64, cliff: u64) → u256++` [.item-kind]#internal# + +Calculates and returns the vested amount at a given `timestamp` based on the core vesting parameters. + +[#VestingComponent-Functions] +==== Functions + +[.contract-item] +[[VestingComponent-start]] +==== `[.contract-item-name]#++start++#++(self: @ContractState) → u64++` [.item-kind]#external# + +Returns the timestamp marking the beginning of the vesting period. + +[.contract-item] +[[VestingComponent-cliff]] +==== `[.contract-item-name]#++cliff++#++(self: @ContractState) → u64++` [.item-kind]#external# + +Returns the timestamp marking the end of the cliff period. + +[.contract-item] +[[VestingComponent-duration]] +==== `[.contract-item-name]#++duration++#++(self: @ContractState) → u64++` [.item-kind]#external# + +Returns the total duration of the vesting period. + +[.contract-item] +[[VestingComponent-end]] +==== `[.contract-item-name]#++end++#++(self: @ContractState) → u64++` [.item-kind]#external# + +Returns the timestamp marking the end of the vesting period. + +[.contract-item] +[[VestingComponent-released]] +==== `[.contract-item-name]#++released++#++(self: @ContractState, token: ContractAddress) → u256++` [.item-kind]#external# + +Returns the already released amount for a given `token`. + +[.contract-item] +[[VestingComponent-releasable]] +==== `[.contract-item-name]#++releasable++#++(self: @ContractState, token: ContractAddress) → u256++` [.item-kind]#external# + +Returns the amount of a given `token` that can be released at the time of the call. + +[.contract-item] +[[VestingComponent-vested_amount]] +==== `[.contract-item-name]#++vested_amount++#++(self: @ContractState, token: ContractAddress, timestamp: u64) → u256++` [.item-kind]#external# + +Returns the total vested amount of a specified `token` at a given `timestamp`. + +[.contract-item] +[[VestingComponent-release]] +==== `[.contract-item-name]#++release++#++(ref self: ContractState, token: ContractAddress) → u256++` [.item-kind]#external# + +Releases the amount of a given `token` that has already vested and returns that amount. + +Requirements: + +- `transfer` call to the `token` must return `true` indicating a successful transfer. + +Emits {AmountReleased} event. + +[#VestingComponent-Internal-Functions] +==== Internal functions + +[.contract-item] +[[VestingComponent-initializer]] +==== `[.contract-item-name]#++initializer++#++(ref self: ContractState, start: u64, duration: u64, cliff_duration: u64)++` [.item-kind]#internal# + +Initializes the component by setting the vesting `start`, `duration` and `cliff_duration`. To prevent +reinitialization, this should only be used inside of a contract's constructor. + +Requirements: + +- `cliff_duration` must be less than or equal to `duration`. + +[.contract-item] +[[VestingComponent-resolve_vested_amount]] +==== `[.contract-item-name]#++resolve_vested_amount++#++(self: @ContractState, token: ContractAddress, timestamp: u64) → u256++` [.item-kind]#internal# + +Returns the vested amount that's calculated using the {vesting-schedule} trait implementation. + +[.contract] +[[LinearVestingSchedule]] +=== `++LinearVestingSchedule++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/finance/src/vesting/vesting.cairo[{github-icon},role=heading-link] + +[.hljs-theme-dark] +```cairo +use openzeppelin_finance::vesting::LinearVestingSchedule; +``` + +Defines the logic for calculating the vested amount, incorporating a cliff period. +It returns 0 before the cliff ends. After the cliff period, the vested amount returned +is directly proportional to the time passed since the start of the vesting schedule. + +== Presets + +[.contract] +[[VestingWallet]] +=== `++VestingWallet++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/presets/src/vesting.cairo[{github-icon},role=heading-link] + +```cairo +use openzeppelin::presets::VestingWallet; +``` + +A non-upgradable contract leveraging {vesting-component} and {ownable-component}. + +NOTE: The contract is intentionally designed to be non-upgradable to ensure that neither the vesting initiator +nor the vesting beneficiary can modify the vesting schedule without the consent of the other party. + +include::../utils/_class_hashes.adoc[] + +[.contract-index] +.{presets-page} +-- +{VestingWallet-class-hash} +-- + +[.contract-index] +.Constructor +-- +* xref:#VestingWallet-constructor[`++constructor(self, beneficiary, start, duration, cliff_duration)++`] +-- + +[.contract-index] +.Embedded Implementations +-- +.VestingComponent + +* xref:#VestingComponent-Embeddable-Impls-VestingImpl[`++VestingImpl++`] + +.OwnableComponent + +* xref:/api/access.adoc#OwnableComponent-Mixin-Impl[`++OwnableMixinImpl++`] +-- + +[#VestingWallet-constructor-section] +==== Constructor + +[.contract-item] +[[VestingWallet-constructor]] +==== `[.contract-item-name]#++constructor++#++(ref self: ContractState, beneficiary: ContractAddress, start: u64, duration: u64, cliff_duration: u64)++` [.item-kind]#constructor# + +Initializes the vesting component by setting the vesting `start`, `duration` and `cliff_duration`. Assigns `beneficiary` as the contract owner and the vesting beneficiary. + +Requirements: + +- `cliff_duration` must be less than or equal to `duration`. diff --git a/docs/modules/ROOT/pages/api/governance.adoc b/docs/modules/ROOT/pages/api/governance.adoc index f11a3de41..9e5f083b1 100644 --- a/docs/modules/ROOT/pages/api/governance.adoc +++ b/docs/modules/ROOT/pages/api/governance.adoc @@ -16,11 +16,11 @@ In a governance system, `TimelockControllerComponent` is in charge of introducin [.contract] [[ITimelock]] -=== `++ITimelock++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/governance/src/timelock/interface.cairo[{github-icon},role=heading-link] +=== `++ITimelock++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/governance/src/timelock/interface.cairo[{github-icon},role=heading-link] [.hljs-theme-dark] ```cairo -use openzeppelin::governance::timelock::interface::ITimelock; +use openzeppelin_governance::timelock::interface::ITimelock; ``` [.contract-index] @@ -240,13 +240,13 @@ Emitted when the minimum delay for future operations is modified. [.contract] [[TimelockControllerComponent]] -=== `++TimelockControllerComponent++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/governance/src/timelock/timelock_controller.cairo[{github-icon},role=heading-link] +=== `++TimelockControllerComponent++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/governance/src/timelock/timelock_controller.cairo[{github-icon},role=heading-link] include::../utils/_common.adoc[] [.hljs-theme-dark] ```cairo -use openzeppelin::governance::timelock::TimelockControllerComponent; +use openzeppelin_governance::timelock::TimelockControllerComponent; ``` [.contract-index#TimelockControllerComponent-Embeddable-Mixin-Impl] @@ -600,11 +600,11 @@ Emitted when the minimum delay for future operations is modified. [.contract] [[IVotes]] -=== `++IVotes++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/governance/src/utils/interfaces/votes.cairo[{github-icon},role=heading-link] +=== `++IVotes++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/governance/src/utils/interfaces/votes.cairo[{github-icon},role=heading-link] [.hljs-theme-dark] ```cairo -use openzeppelin::governance::utils::interfaces::IVotes; +use openzeppelin_governance::utils::interfaces::IVotes; ``` Common interface for Votes-enabled contracts. For an implementation example see diff --git a/docs/modules/ROOT/pages/api/introspection.adoc b/docs/modules/ROOT/pages/api/introspection.adoc index ffa4681ef..5ff7f0ea5 100644 --- a/docs/modules/ROOT/pages/api/introspection.adoc +++ b/docs/modules/ROOT/pages/api/introspection.adoc @@ -10,10 +10,10 @@ This crate handles https://en.wikipedia.org/wiki/Type_introspection[type introsp [.contract] [[ISRC5]] -=== `++ISRC5++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/introspection/src/interface.cairo#L7[{github-icon},role=heading-link] +=== `++ISRC5++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/introspection/src/interface.cairo#L7[{github-icon},role=heading-link] ```cairo -use openzeppelin::introspection::interface::ISRC5; +use openzeppelin_introspection::interface::ISRC5; ``` Interface of the SRC5 Introspection Standard as defined in {snip5}. @@ -44,10 +44,10 @@ on how to compute this ID. [.contract] [[SRC5Component]] -=== `++SRC5Component++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/introspection/src/src5.cairo[{github-icon},role=heading-link] +=== `++SRC5Component++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/introspection/src/src5.cairo[{github-icon},role=heading-link] ```cairo -use openzeppelin::introspection::src5::SRC5Component; +use openzeppelin_introspection::src5::SRC5Component; ``` SRC5 component extending xref:ISRC5[`ISRC5`]. diff --git a/docs/modules/ROOT/pages/api/merkle-tree.adoc b/docs/modules/ROOT/pages/api/merkle-tree.adoc index 9a634c7d9..d9aef334f 100644 --- a/docs/modules/ROOT/pages/api/merkle-tree.adoc +++ b/docs/modules/ROOT/pages/api/merkle-tree.adoc @@ -23,14 +23,14 @@ NOTE: `openzeppelin_merkle_tree` doesn't have dependencies outside of `corelib`, ==== To use it as a standalone package, you can add it in your `Scarb.toml` as follows: -`openzeppelin_merkle_tree = { git = "https://github.com/openzeppelin/cairo-contracts.git", tag = "v0.X.X" }` +`openzeppelin_merkle_tree = "0.17.0"` ==== == Modules [.contract] [[merkle_proof]] -=== `++merkle_proof++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/merkle_tree/src/merkle_proof.cairo[{github-icon},role=heading-link] +=== `++merkle_proof++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/merkle_tree/src/merkle_proof.cairo[{github-icon},role=heading-link] ```cairo use openzeppelin_merkle_tree::merkle_proof; @@ -144,7 +144,7 @@ NOTE: This function expects a `CommutativeHasher` implementation. See xref:#hash [.contract] [[hashes]] -=== `++hashes++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/merkle_tree/src/hashes.cairo[{github-icon},role=heading-link] +=== `++hashes++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/merkle_tree/src/hashes.cairo[{github-icon},role=heading-link] ```cairo use openzeppelin_merkle_tree::hashes; diff --git a/docs/modules/ROOT/pages/api/security.adoc b/docs/modules/ROOT/pages/api/security.adoc index d86431e1c..7d7a621d2 100644 --- a/docs/modules/ROOT/pages/api/security.adoc +++ b/docs/modules/ROOT/pages/api/security.adoc @@ -8,10 +8,10 @@ This crate provides components to handle common security-related tasks. [.contract] [[InitializableComponent]] -=== `++InitializableComponent++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/security/src/initializable.cairo[{github-icon},role=heading-link] +=== `++InitializableComponent++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/security/src/initializable.cairo[{github-icon},role=heading-link] ```cairo -use openzeppelin::security::InitializableComponent; +use openzeppelin_security::InitializableComponent; ``` Component enabling one-time initialization for contracts. @@ -58,13 +58,13 @@ Requirements: [.contract] [[PausableComponent]] -=== `++PausableComponent++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/security/src/pausable.cairo[{github-icon},role=heading-link] +=== `++PausableComponent++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/security/src/pausable.cairo[{github-icon},role=heading-link] :Paused: xref:PausableComponent-Paused[Paused] :Unpaused: xref:PausableComponent-Unpaused[Unpaused] ```cairo -use openzeppelin::security::PausableComponent; +use openzeppelin_security::PausableComponent; ``` Component to implement an emergency stop mechanism. @@ -163,10 +163,10 @@ Emitted when the contract is unpaused by `account`. [.contract] [[ReentrancyGuardComponent]] -=== `++ReentrancyGuardComponent++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/security/src/reentrancyguard.cairo[{github-icon},role=heading-link] +=== `++ReentrancyGuardComponent++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/security/src/reentrancyguard.cairo[{github-icon},role=heading-link] ```cairo -use openzeppelin::security::ReentrancyGuardComponent; +use openzeppelin_security::ReentrancyGuardComponent; ``` Component to help prevent reentrant calls. diff --git a/docs/modules/ROOT/pages/api/testing.adoc b/docs/modules/ROOT/pages/api/testing.adoc index eb7442d56..8e2447648 100644 --- a/docs/modules/ROOT/pages/api/testing.adoc +++ b/docs/modules/ROOT/pages/api/testing.adoc @@ -15,7 +15,7 @@ be added as a separate dependency in `Scarb.toml`: ``` [dev-dependencies] -openzeppelin_testing = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.16.0" } +openzeppelin_testing = "0.17.0" ``` == Test Utilities diff --git a/docs/modules/ROOT/pages/api/token_common.adoc b/docs/modules/ROOT/pages/api/token_common.adoc index 0c8993be0..0b57b096c 100644 --- a/docs/modules/ROOT/pages/api/token_common.adoc +++ b/docs/modules/ROOT/pages/api/token_common.adoc @@ -12,11 +12,11 @@ This module provides extensions and utilities that are common to multiple token [.contract] [[IERC2981]] -=== `++IERC2981++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/token/src/common/erc2981/interface.cairo[{github-icon},role=heading-link] +=== `++IERC2981++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/token/src/common/erc2981/interface.cairo[{github-icon},role=heading-link] [.hljs-theme-dark] ```cairo -use openzeppelin::token::common::erc2981::IERC2981; +use openzeppelin_token::common::erc2981::IERC2981; ``` [.contract-index] @@ -46,10 +46,10 @@ unit of exchange. [.contract] [[ERC2981Component]] -=== `++ERC2981Component++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/token/src/common/erc2981/erc2981.cairo[{github-icon},role=heading-link] +=== `++ERC2981Component++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/token/src/common/erc2981/erc2981.cairo[{github-icon},role=heading-link] ```cairo -use openzeppelin::token::common::erc2981::ERC2981Component; +use openzeppelin_token::common::erc2981::ERC2981Component; ``` ERC2981 component extending <>. diff --git a/docs/modules/ROOT/pages/api/udc.adoc b/docs/modules/ROOT/pages/api/udc.adoc index dca90f48b..06bd59471 100644 --- a/docs/modules/ROOT/pages/api/udc.adoc +++ b/docs/modules/ROOT/pages/api/udc.adoc @@ -8,10 +8,10 @@ Reference of the Universal Deployer Contract (UDC) interface and preset. [.contract] [[IUniversalDeployer]] -=== `++IUniversalDeployer++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/utils/src/deployments/interface.cairo[{github-icon},role=heading-link] +=== `++IUniversalDeployer++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/utils/src/deployments/interface.cairo[{github-icon},role=heading-link] ```cairo -use openzeppelin::utils::interfaces::IUniversalDeployer; +use openzeppelin_utils::interfaces::IUniversalDeployer; ``` [.contract-index] @@ -51,10 +51,10 @@ Emitted when `deployer` deploys a contract through the Universal Deployer Contra [.contract] [[UniversalDeployer]] -=== `++UniversalDeployer++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/presets/src/universal_deployer.cairo[{github-icon},role=heading-link] +=== `++UniversalDeployer++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/presets/src/universal_deployer.cairo[{github-icon},role=heading-link] ```cairo -use openzeppelin::presets::UniversalDeployer; +use openzeppelin_presets::UniversalDeployer; ``` The standard Universal Deployer Contract. diff --git a/docs/modules/ROOT/pages/api/upgrades.adoc b/docs/modules/ROOT/pages/api/upgrades.adoc index 1b27d6da8..9ac417087 100644 --- a/docs/modules/ROOT/pages/api/upgrades.adoc +++ b/docs/modules/ROOT/pages/api/upgrades.adoc @@ -9,12 +9,12 @@ This crate provides interfaces and utilities related to upgradeability. [.contract] [[IUpgradeable]] -=== `++IUpgradeable++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/upgrades/src/interface.cairo[{github-icon},role=heading-link] +=== `++IUpgradeable++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/upgrades/src/interface.cairo[{github-icon},role=heading-link] :Upgraded: xref:UpgradeableComponent-Upgraded[Upgraded] ```cairo -use openzeppelin::upgrades::interface::IUpgradeable; +use openzeppelin_upgrades::interface::IUpgradeable; ``` Interface of an upgradeable contract. @@ -38,10 +38,10 @@ NOTE: This function is usually protected by an xref:access.adoc[Access Control] [.contract] [[UpgradeableComponent]] -=== `++UpgradeableComponent++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/upgrades/src/upgradeable.cairo[{github-icon},role=heading-link] +=== `++UpgradeableComponent++` link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/upgrades/src/upgradeable.cairo[{github-icon},role=heading-link] ```cairo -use openzeppelin::upgrades::upgradeable::UpgradeableComponent; +use openzeppelin_upgrades::upgradeable::UpgradeableComponent; ``` Upgradeable component. diff --git a/docs/modules/ROOT/pages/api/utilities.adoc b/docs/modules/ROOT/pages/api/utilities.adoc index 494e8bddd..32a69935f 100644 --- a/docs/modules/ROOT/pages/api/utilities.adoc +++ b/docs/modules/ROOT/pages/api/utilities.adoc @@ -11,7 +11,7 @@ This crate provides miscellaneous components and libraries containing utility fu === `++utils++` ```cairo -use openzeppelin::utils; +use openzeppelin_utils; ``` Module containing core utilities of the library. @@ -74,8 +74,8 @@ casting and unwrapping the result multiple times. Usage example: ```cairo -use openzeppelin::utils::selectors; -use openzeppelin::utils::UnwrapAndCast; +use openzeppelin_utils::selectors; +use openzeppelin_utils::UnwrapAndCast; fn call_and_cast_to_bool(target: ContractAddress, args: Span) -> bool { try_selector_with_fallback( @@ -99,31 +99,31 @@ Note that it can be automatically casted to any type implementing the `Serde` tr [[utils-cryptography]] ==== `[.contract-item-name]#++cryptography++#` [.item-kind]#module# -See xref:#cryptography[`openzeppelin::utils::cryptography`]. +See xref:#cryptography[`openzeppelin_utils::cryptography`]. [.contract-item] [[utils-deployments]] ==== `[.contract-item-name]#++deployments++#` [.item-kind]#module# -See xref:#deployments[`openzeppelin::utils::deployments`]. +See xref:#deployments[`openzeppelin_utils::deployments`]. [.contract-item] [[utils-math]] ==== `[.contract-item-name]#++math++#` [.item-kind]#module# -See xref:#math[`openzeppelin::utils::math`]. +See xref:#math[`openzeppelin_utils::math`]. [.contract-item] [[utils-selectors]] ==== `[.contract-item-name]#++selectors++#` [.item-kind]#module# -See xref:#selectors[`openzeppelin::utils::selectors`]. +See xref:#selectors[`openzeppelin_utils::selectors`]. [.contract-item] [[utils-serde]] ==== `[.contract-item-name]#++serde++#` [.item-kind]#module# -See xref:#serde[`openzeppelin::utils::serde`]. +See xref:#serde[`openzeppelin_utils::serde`]. [.contract] [[cryptography]] @@ -132,7 +132,7 @@ See xref:#serde[`openzeppelin::utils::serde`]. :snip12: https://github.com/starknet-io/SNIPs/blob/main/SNIPS/snip-12.md[SNIP12] ```cairo -use openzeppelin::utils::cryptography; +use openzeppelin_utils::cryptography; ``` Module containing utilities related to cryptography. @@ -152,13 +152,13 @@ Module containing utilities related to cryptography. [[cryptography-nonces]] ==== `[.contract-item-name]#++nonces++#` [.item-kind]#module# -See xref:#NoncesComponent[`openzeppelin::utils::cryptography::nonces::NoncesComponent`]. +See xref:#NoncesComponent[`openzeppelin_utils::cryptography::nonces::NoncesComponent`]. [.contract-item] [[cryptography-snip12]] ==== `[.contract-item-name]#++snip12++#` [.item-kind]#module# -See xref:#snip12[`openzeppelin::utils::cryptography::snip12`]. +See xref:#snip12[`openzeppelin_utils::cryptography::snip12`]. [.contract] [[deployments]] @@ -167,7 +167,7 @@ See xref:#snip12[`openzeppelin::utils::cryptography::snip12`]. :udc-doc: xref:/udc.adoc[Universal Deployer Contract] ```cairo -use openzeppelin::utils::deployments; +use openzeppelin_utils::deployments; ``` Module containing utility functions for calculating contract addresses through {deploy_syscall} and the {udc-doc} (UDC). @@ -227,7 +227,7 @@ Origin-dependent deployments hash `salt` with `caller_address` (member of {deplo === `++math++` ```cairo -use openzeppelin::utils::math; +use openzeppelin_utils::math; ``` Module containing math utilities. @@ -255,10 +255,10 @@ NOTE: `T` is a generic value matching different numeric implementations. === `++selectors++` ```cairo -use openzeppelin::utils::selectors; +use openzeppelin_utils::selectors; ``` -:selectors: https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/utils/src/selectors.cairo[selectors.cairo] +:selectors: https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/utils/src/selectors.cairo[selectors.cairo] Module containing constants matching multiple selectors used through the library. To see the full list of selectors, see {selectors}. @@ -268,7 +268,7 @@ To see the full list of selectors, see {selectors}. === `++serde++` ```cairo -use openzeppelin::utils::serde; +use openzeppelin_utils::serde; ``` Module containing utilities related to serialization and deserialization of Cairo data structures. @@ -293,7 +293,7 @@ implementing the `Serde` trait to a `felt252` buffer. Usage example: ```cairo -use openzeppelin::utils::serde::SerializedAppend; +use openzeppelin_utils::serde::SerializedAppend; use starknet::ContractAddress; fn to_calldata(recipient: ContractAddress, amount: u256) -> Array { @@ -314,7 +314,7 @@ that implements the `Serde` trait. === `++NoncesComponent++` ```cairo -use openzeppelin::utils::cryptography::nonces::NoncesComponent; +use openzeppelin_utils::cryptography::nonces::NoncesComponent; ``` This component provides a simple mechanism for handling incremental @@ -371,7 +371,7 @@ Same as `use_nonce` but checking that `nonce` is the next valid one for `owner`. === `++snip12++` ```cairo -use openzeppelin::utils::snip12; +use openzeppelin_utils::snip12; ``` Supports on-chain generation of message hashes compliant with {snip12}. diff --git a/docs/modules/ROOT/pages/components.adoc b/docs/modules/ROOT/pages/components.adoc index f48a3b875..07a1ab92e 100644 --- a/docs/modules/ROOT/pages/components.adoc +++ b/docs/modules/ROOT/pages/components.adoc @@ -25,7 +25,7 @@ The contract should first import the component and declare it with the `componen #[starknet::contract] mod MyContract { // Import the component - use openzeppelin::security::InitializableComponent; + use openzeppelin_security::InitializableComponent; // Declare the component component!(path: InitializableComponent, storage: initializable, event: InitializableEvent); @@ -40,7 +40,7 @@ Note that even if the component doesn't define any events, the compiler will sti ---- #[starknet::contract] mod MyContract { - use openzeppelin::security::InitializableComponent; + use openzeppelin_security::InitializableComponent; component!(path: InitializableComponent, storage: initializable, event: InitializableEvent); @@ -79,7 +79,7 @@ Integrating an implementation looks like this: [,cairo] ---- mod MyContract { - use openzeppelin::security::InitializableComponent; + use openzeppelin_security::InitializableComponent; component!(path: InitializableComponent, storage: initializable, event: InitializableEvent); @@ -99,7 +99,7 @@ A function on the contract level can expose it like this: ---- #[starknet::contract] mod MyContract { - use openzeppelin::security::InitializableComponent; + use openzeppelin_security::InitializableComponent; component!(path: InitializableComponent, storage: initializable, event: InitializableEvent); @@ -202,8 +202,8 @@ Here's a full example of an account contract that embeds the `AccountMixinImpl`: ---- #[starknet::contract] mod Account { - use openzeppelin::account::AccountComponent; - use openzeppelin::introspection::src5::SRC5Component; + use openzeppelin_account::AccountComponent; + use openzeppelin_introspection::src5::SRC5Component; component!(path: AccountComponent, storage: account, event: AccountEvent); component!(path: SRC5Component, storage: src5, event: SRC5Event); @@ -254,7 +254,7 @@ Let's look at how a contract would integrate {ownable-component}: ---- #[starknet::contract] mod MyContract { - use openzeppelin::access::ownable::OwnableComponent; + use openzeppelin_access::ownable::OwnableComponent; use starknet::ContractAddress; component!(path: OwnableComponent, storage: ownable, event: OwnableEvent); @@ -301,8 +301,8 @@ Here's an example of how to use the Immutable Component Config pattern with the ---- #[starknet::contract] mod MyContract { - use openzeppelin::introspection::src5::SRC5Component; - use openzeppelin::token::common::erc2981::ERC2981Component; + use openzeppelin_introspection::src5::SRC5Component; + use openzeppelin_token::common::erc2981::ERC2981Component; use starknet::contract_address_const; component!(path: ERC2981Component, storage: erc2981, event: ERC2981Event); @@ -359,9 +359,9 @@ In the following example, the `DefaultConfig` trait is used to define the `FEE_D ---- #[starknet::contract] mod MyContract { - use openzeppelin::introspection::src5::SRC5Component; + use openzeppelin_introspection::src5::SRC5Component; // Bring the DefaultConfig trait into scope - use openzeppelin::token::common::erc2981::{ERC2981Component, DefaultConfig}; + use openzeppelin_token::common::erc2981::{ERC2981Component, DefaultConfig}; use starknet::contract_address_const; component!(path: ERC2981Component, storage: erc2981, event: ERC2981Event); @@ -417,8 +417,8 @@ Creating a contract with `AccessControlComponent` should look like this: ---- #[starknet::contract] mod MyContract { - use openzeppelin::access::accesscontrol::AccessControlComponent; - use openzeppelin::introspection::src5::SRC5Component; + use openzeppelin_access::accesscontrol::AccessControlComponent; + use openzeppelin_introspection::src5::SRC5Component; component!(path: AccessControlComponent, storage: accesscontrol, event: AccessControlEvent); component!(path: SRC5Component, storage: src5, event: SRC5Event); @@ -481,9 +481,9 @@ The following snippet leverages the `before_update` hook to include this behavio ---- #[starknet::contract] mod MyToken { - use openzeppelin::security::pausable::PausableComponent::InternalTrait; - use openzeppelin::security::pausable::PausableComponent; - use openzeppelin::token::erc20::ERC20Component; + use openzeppelin_security::pausable::PausableComponent::InternalTrait; + use openzeppelin_security::pausable::PausableComponent; + use openzeppelin_token::erc20::ERC20Component; use starknet::ContractAddress; component!(path: ERC20Component, storage: erc20, event: ERC20Event); @@ -535,8 +535,8 @@ The using contract just needs to bring the implementation into scope like this: ---- #[starknet::contract] mod MyToken { - use openzeppelin::token::erc20::ERC20Component; - use openzeppelin::token::erc20::ERC20HooksEmptyImpl; + use openzeppelin_token::erc20::ERC20Component; + use openzeppelin_token::erc20::ERC20HooksEmptyImpl; (...) } @@ -558,10 +558,10 @@ Here's the setup: ---- #[starknet::contract] mod ERC20Pausable { - use openzeppelin::security::pausable::PausableComponent; - use openzeppelin::token::erc20::{ERC20Component, ERC20HooksEmptyImpl}; + use openzeppelin_security::pausable::PausableComponent; + use openzeppelin_token::erc20::{ERC20Component, ERC20HooksEmptyImpl}; // Import the ERC20 interfaces to create custom implementations - use openzeppelin::token::erc20::interface::{IERC20, IERC20CamelOnly}; + use openzeppelin_token::erc20::interface::{IERC20, IERC20CamelOnly}; use starknet::ContractAddress; component!(path: PausableComponent, storage: pausable, event: PausableEvent); @@ -662,7 +662,7 @@ To do so, use the same syntax as calling an implementation method except replace ---- #[starknet::contract] mod MyContract { - use openzeppelin::security::InitializableComponent; + use openzeppelin_security::InitializableComponent; component!(path: InitializableComponent, storage: initializable, event: InitializableEvent); diff --git a/docs/modules/ROOT/pages/erc1155.adoc b/docs/modules/ROOT/pages/erc1155.adoc index 78cdc322b..87f593660 100644 --- a/docs/modules/ROOT/pages/erc1155.adoc +++ b/docs/modules/ROOT/pages/erc1155.adoc @@ -34,8 +34,8 @@ Here's an example of a basic contract: ---- #[starknet::contract] mod MyERC1155 { - use openzeppelin::introspection::src5::SRC5Component; - use openzeppelin::token::erc1155::{ERC1155Component, ERC1155HooksEmptyImpl}; + use openzeppelin_introspection::src5::SRC5Component; + use openzeppelin_token::erc1155::{ERC1155Component, ERC1155HooksEmptyImpl}; use starknet::ContractAddress; component!(path: ERC1155Component, storage: erc1155, event: ERC1155Event); @@ -227,8 +227,8 @@ Here's an example of a simple token receiver contract: ---- #[starknet::contract] mod MyTokenReceiver { - use openzeppelin::introspection::src5::SRC5Component; - use openzeppelin::token::erc1155::ERC1155ReceiverComponent; + use openzeppelin_introspection::src5::SRC5Component; + use openzeppelin_token::erc1155::ERC1155ReceiverComponent; use starknet::ContractAddress; component!(path: ERC1155ReceiverComponent, storage: erc1155_receiver, event: ERC1155ReceiverEvent); diff --git a/docs/modules/ROOT/pages/erc20.adoc b/docs/modules/ROOT/pages/erc20.adoc index 67d100db9..b73124f12 100644 --- a/docs/modules/ROOT/pages/erc20.adoc +++ b/docs/modules/ROOT/pages/erc20.adoc @@ -23,7 +23,7 @@ Here's what that looks like: ---- #[starknet::contract] mod MyToken { - use openzeppelin::token::erc20::{ERC20Component, ERC20HooksEmptyImpl}; + use openzeppelin_token::erc20::{ERC20Component, ERC20HooksEmptyImpl}; use starknet::ContractAddress; component!(path: ERC20Component, storage: erc20, event: ERC20Event); @@ -170,7 +170,7 @@ TIP: Note that we are not using the MixinImpl in this case, since we need to cus ---- #[starknet::contract] mod MyToken { - use openzeppelin::token::erc20::{ERC20Component, ERC20HooksEmptyImpl}; + use openzeppelin_token::erc20::{ERC20Component, ERC20HooksEmptyImpl}; use starknet::ContractAddress; component!(path: ERC20Component, storage: erc20, event: ERC20Event); diff --git a/docs/modules/ROOT/pages/erc721.adoc b/docs/modules/ROOT/pages/erc721.adoc index 33c250ebf..b4166ae12 100644 --- a/docs/modules/ROOT/pages/erc721.adoc +++ b/docs/modules/ROOT/pages/erc721.adoc @@ -18,8 +18,8 @@ Here's an example of a basic contract: ---- #[starknet::contract] mod MyNFT { - use openzeppelin::introspection::src5::SRC5Component; - use openzeppelin::token::erc721::{ERC721Component, ERC721HooksEmptyImpl}; + use openzeppelin_introspection::src5::SRC5Component; + use openzeppelin_token::erc721::{ERC721Component, ERC721HooksEmptyImpl}; use starknet::ContractAddress; component!(path: ERC721Component, storage: erc721, event: ERC721Event); @@ -195,8 +195,8 @@ Here's an example of a simple token receiver contract: ---- #[starknet::contract] mod MyTokenReceiver { - use openzeppelin::introspection::src5::SRC5Component; - use openzeppelin::token::erc721::ERC721ReceiverComponent; + use openzeppelin_introspection::src5::SRC5Component; + use openzeppelin_token::erc721::ERC721ReceiverComponent; use starknet::ContractAddress; component!(path: ERC721ReceiverComponent, storage: erc721_receiver, event: ERC721ReceiverEvent); diff --git a/docs/modules/ROOT/pages/finance.adoc b/docs/modules/ROOT/pages/finance.adoc new file mode 100644 index 000000000..593cf9077 --- /dev/null +++ b/docs/modules/ROOT/pages/finance.adoc @@ -0,0 +1,216 @@ += Finance + +:vesting-component: xref:api/finance.adoc#VestingComponent[VestingComponent] +:vesting-schedule: xref:api/finance.adoc#VestingComponent-Vesting-Schedule[VestingSchedule] +:ownable-component: xref:api/access.adoc#OwnableComponent[OwnableComponent] +:linear-vesting-schedule: xref:api/finance.adoc#LinearVestingSchedule[LinearVestingSchedule] +:calculate_vested_amount: xref:api/finance.adoc#VestingComponent-calculate_vested_amount[calculate_vested_amount] + +This module includes primitives for financial systems. + +[[vesting_component]] +== Vesting component + +The {vesting-component} manages the gradual release of ERC-20 tokens to a designated beneficiary based on a predefined vesting schedule. +The implementing contract must implement the {ownable-component}, where the contract owner is regarded as the vesting beneficiary. +This structure allows ownership rights of both the contract and the vested tokens to be assigned and transferred. + +NOTE: Any assets transferred to this contract will follow the vesting schedule as if they were locked from the beginning of the vesting period. +As a result, if the vesting has already started, a portion of the newly transferred tokens may become immediately releasable. + +NOTE: By setting the duration to 0, it's possible to configure this contract to behave like an asset timelock that holds tokens +for a beneficiary until a specified date. + +[[vesting_schedule]] +=== Vesting schedule + +The {vesting-schedule} trait defines the logic for calculating the vested amount based on a given timestamp. This +logic is not part of the {vesting-component}, so any contract implementing the {vesting-component} must provide its own +implementation of the {vesting-schedule} trait. + +NOTE: There's a ready-made implementation of the {vesting-schedule} trait available named {linear-vesting-schedule}. +It incorporates a cliff period by returning 0 vested amount until the cliff ends. After the cliff, the vested amount +is calculated as directly proportional to the time elapsed since the beginning of the vesting schedule. + +=== Usage + +The contract must integrate {vesting-component} and {ownable-component} as dependencies. The contract's constructor +should initialize both components. Core vesting parameters, such as `beneficiary`, `start`, `duration` +and `cliff_duration`, are passed as arguments to the constructor and set at the time of deployment. + +The implementing contract must provide an implementation of the {vesting-schedule} trait. This can be achieved either by importing +a ready-made {linear-vesting-schedule} implementation or by defining a custom one. + +Here’s an example of a simple vesting wallet contract with a {linear-vesting-schedule}, where the vested amount +is calculated as being directly proportional to the time elapsed since the start of the vesting period. + +[,cairo] +---- +#[starknet::contract] +mod LinearVestingWallet { + use openzeppelin_access::ownable::OwnableComponent; + use openzeppelin_finance::vesting::{VestingComponent, LinearVestingSchedule}; + use starknet::ContractAddress; + + component!(path: OwnableComponent, storage: ownable, event: OwnableEvent); + component!(path: VestingComponent, storage: vesting, event: VestingEvent); + + #[abi(embed_v0)] + impl OwnableMixinImpl = OwnableComponent::OwnableMixinImpl; + impl OwnableInternalImpl = OwnableComponent::InternalImpl; + + #[abi(embed_v0)] + impl VestingImpl = VestingComponent::VestingImpl; + impl VestingInternalImpl = VestingComponent::InternalImpl; + + #[storage] + struct Storage { + #[substorage(v0)] + ownable: OwnableComponent::Storage, + #[substorage(v0)] + vesting: VestingComponent::Storage + } + + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + #[flat] + OwnableEvent: OwnableComponent::Event, + #[flat] + VestingEvent: VestingComponent::Event + } + + #[constructor] + fn constructor( + ref self: ContractState, + beneficiary: ContractAddress, + start: u64, + duration: u64, + cliff_duration: u64 + ) { + self.ownable.initializer(beneficiary); + self.vesting.initializer(start, duration, cliff_duration); + } +} +---- + +A vesting schedule will often follow a custom formula. In such cases, the {vesting-schedule} trait is useful. +To support a custom vesting schedule, the contract must provide an implementation of the +{calculate_vested_amount} function based on the desired formula. + +NOTE: When using a custom {vesting-schedule} implementation, the {linear-vesting-schedule} must be excluded from the imports. + +NOTE: If there are additional parameters required for calculations, which are stored in the contract's storage, you can access them using `self.get_contract()`. + +Here’s an example of a vesting wallet contract with a custom {vesting-schedule} implementation, where tokens +are vested in a number of steps. + +[,cairo] +---- +#[starknet::contract] +mod StepsVestingWallet { + use openzeppelin_access::ownable::OwnableComponent; + use openzeppelin_finance::vesting::VestingComponent::VestingScheduleTrait; + use openzeppelin_finance::vesting::VestingComponent; + use starknet::ContractAddress; + use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess}; + + component!(path: OwnableComponent, storage: ownable, event: OwnableEvent); + component!(path: VestingComponent, storage: vesting, event: VestingEvent); + + #[abi(embed_v0)] + impl OwnableMixinImpl = OwnableComponent::OwnableMixinImpl; + impl OwnableInternalImpl = OwnableComponent::InternalImpl; + + #[abi(embed_v0)] + impl VestingImpl = VestingComponent::VestingImpl; + impl VestingInternalImpl = VestingComponent::InternalImpl; + + #[storage] + struct Storage { + total_steps: u64, + #[substorage(v0)] + ownable: OwnableComponent::Storage, + #[substorage(v0)] + vesting: VestingComponent::Storage + } + + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + #[flat] + OwnableEvent: OwnableComponent::Event, + #[flat] + VestingEvent: VestingComponent::Event + } + + #[constructor] + fn constructor( + ref self: ContractState, + total_steps: u64, + beneficiary: ContractAddress, + start: u64, + duration: u64, + cliff: u64, + ) { + self.total_steps.write(total_steps); + self.ownable.initializer(beneficiary); + self.vesting.initializer(start, duration, cliff); + } + + impl VestingSchedule of VestingScheduleTrait { + fn calculate_vested_amount( + self: @VestingComponent::ComponentState, + token: ContractAddress, + total_allocation: u256, + timestamp: u64, + start: u64, + duration: u64, + cliff: u64, + ) -> u256 { + if timestamp < cliff { + 0 + } else if timestamp >= start + duration { + total_allocation + } else { + let total_steps = self.get_contract().total_steps.read(); + let vested_per_step = total_allocation / total_steps.into(); + let step_duration = duration / total_steps; + let current_step = (timestamp - start) / step_duration; + let vested_amount = vested_per_step * current_step.into(); + vested_amount + } + } + } +} +---- + +=== Interface + +Here is the full interface of a standard contract implementing the vesting functionality: + +[,cairo] +---- +#[starknet::interface] +pub trait VestingABI { + // IVesting + fn start(self: @TState) -> u64; + fn cliff(self: @TState) -> u64; + fn duration(self: @TState) -> u64; + fn end(self: @TState) -> u64; + fn released(self: @TState, token: ContractAddress) -> u256; + fn releasable(self: @TState, token: ContractAddress) -> u256; + fn vested_amount(self: @TState, token: ContractAddress, timestamp: u64) -> u256; + fn release(ref self: TState, token: ContractAddress) -> u256; + + // IOwnable + fn owner(self: @TState) -> ContractAddress; + fn transfer_ownership(ref self: TState, new_owner: ContractAddress); + fn renounce_ownership(ref self: TState); + + // IOwnableCamelOnly + fn transferOwnership(ref self: TState, newOwner: ContractAddress); + fn renounceOwnership(ref self: TState); +} +---- + diff --git a/docs/modules/ROOT/pages/governance.adoc b/docs/modules/ROOT/pages/governance.adoc index 58f4d8503..0678b3ba8 100644 --- a/docs/modules/ROOT/pages/governance.adoc +++ b/docs/modules/ROOT/pages/governance.adoc @@ -95,9 +95,9 @@ Here's an example of a simple timelock contract: ---- #[starknet::contract] mod TimelockControllerContract { - use openzeppelin::access::accesscontrol::AccessControlComponent; - use openzeppelin::governance::timelock::TimelockControllerComponent; - use openzeppelin::introspection::src5::SRC5Component; + use openzeppelin_access::accesscontrol::AccessControlComponent; + use openzeppelin_governance::timelock::TimelockControllerComponent; + use openzeppelin_introspection::src5::SRC5Component; use starknet::ContractAddress; component!(path: AccessControlComponent, storage: access_control, event: AccessControlEvent); diff --git a/docs/modules/ROOT/pages/guides/erc20-supply.adoc b/docs/modules/ROOT/pages/guides/erc20-supply.adoc index a1c86340e..71543e19d 100644 --- a/docs/modules/ROOT/pages/guides/erc20-supply.adoc +++ b/docs/modules/ROOT/pages/guides/erc20-supply.adoc @@ -15,7 +15,7 @@ We can achieve this by setting the token supply in the constructor which will ex ---- #[starknet::contract] mod MyToken { - use openzeppelin::token::erc20::{ERC20Component, ERC20HooksEmptyImpl}; + use openzeppelin_token::erc20::{ERC20Component, ERC20HooksEmptyImpl}; use starknet::ContractAddress; component!(path: ERC20Component, storage: erc20, event: ERC20Event); @@ -69,7 +69,7 @@ Let's make a few changes to the almighty `MyToken` contract and create a minting ---- #[starknet::contract] mod MyToken { - use openzeppelin::token::erc20::{ERC20Component, ERC20HooksEmptyImpl}; + use openzeppelin_token::erc20::{ERC20Component, ERC20HooksEmptyImpl}; use starknet::ContractAddress; component!(path: ERC20Component, storage: erc20, event: ERC20Event); diff --git a/docs/modules/ROOT/pages/guides/snip12.adoc b/docs/modules/ROOT/pages/guides/snip12.adoc index 190c66456..c9e51790c 100644 --- a/docs/modules/ROOT/pages/guides/snip12.adoc +++ b/docs/modules/ROOT/pages/guides/snip12.adoc @@ -26,7 +26,7 @@ Note that some declarations are omitted for brevity. The full example will be av ---- #[starknet::contract] mod CustomERC20 { - use openzeppelin::token::erc20::{ERC20Component, ERC20HooksEmptyImpl}; + use openzeppelin_token::erc20::{ERC20Component, ERC20HooksEmptyImpl}; use starknet::ContractAddress; component!(path: ERC20Component, storage: erc20, event: ERC20Event); @@ -117,12 +117,12 @@ NOTE: In practice it's better to compute the type hash off-chain and hardcode it === 3. Implement the `StructHash` trait for the struct. -You can import the trait from: `openzeppelin::utils::snip12::StructHash`. And this implementation +You can import the trait from: `openzeppelin_utils::snip12::StructHash`. And this implementation is nothing more than the encoding of the message as defined in the {snip}. [,cairo] ---- -use openzeppelin::utils::snip12::StructHash; +use openzeppelin_utils::snip12::StructHash; use core::hash::HashStateExTrait; use hash::{HashStateTrait, Hash}; @@ -155,7 +155,7 @@ because the `chain_id` is obtained on-chain, and the `revision` is hardcoded to [,cairo] ---- -use openzeppelin::utils::snip12::SNIP12Metadata; +use openzeppelin_utils::snip12::SNIP12Metadata; impl SNIP12MetadataImpl of SNIP12Metadata { fn name() -> felt252 { 'DAPP_NAME' } @@ -169,7 +169,7 @@ the trait is not bounded to the ContractState, like this: [,cairo] ---- -use openzeppelin::utils::snip12::SNIP12Metadata; +use openzeppelin_utils::snip12::SNIP12Metadata; impl SNIP12MetadataImpl of SNIP12Metadata { fn name() -> felt252 { @@ -190,7 +190,7 @@ using the `get_message_hash` function. The implementation is already available a [,cairo] ---- -use openzeppelin::utils::snip12::{SNIP12Metadata, StructHash, OffchainMessageHashImpl}; +use openzeppelin_utils::snip12::{SNIP12Metadata, StructHash, OffchainMessageHashImpl}; use core::hash::HashStateExTrait; use hash::{HashStateTrait, Hash}; @@ -251,7 +251,7 @@ and the {nonces}[`NoncesComponent`] to handle nonces to prevent replay attacks. [,cairo] ---- -use openzeppelin::utils::snip12::{SNIP12Metadata, StructHash, OffchainMessageHashImpl}; +use openzeppelin_utils::snip12::{SNIP12Metadata, StructHash, OffchainMessageHashImpl}; use core::hash::HashStateExTrait; use hash::{HashStateTrait, Hash}; @@ -278,9 +278,9 @@ impl StructHashImpl of StructHash { #[starknet::contract] mod CustomERC20 { - use openzeppelin::account::dual_account::{DualCaseAccount, DualCaseAccountTrait}; - use openzeppelin::token::erc20::{ERC20Component, ERC20HooksEmptyImpl}; - use openzeppelin::utils::cryptography::nonces::NoncesComponent; + use openzeppelin_account::dual_account::{DualCaseAccount, DualCaseAccountTrait}; + use openzeppelin_token::erc20::{ERC20Component, ERC20HooksEmptyImpl}; + use openzeppelin_utils::cryptography::nonces::NoncesComponent; use starknet::ContractAddress; use super::{Message, OffchainMessageHashImpl, SNIP12Metadata}; diff --git a/docs/modules/ROOT/pages/guides/src5-migration.adoc b/docs/modules/ROOT/pages/guides/src5-migration.adoc index 5f97d5ee3..b12eb5239 100644 --- a/docs/modules/ROOT/pages/guides/src5-migration.adoc +++ b/docs/modules/ROOT/pages/guides/src5-migration.adoc @@ -36,8 +36,8 @@ Here's the setup: ---- #[starknet::contract] mod MigratingContract { - use openzeppelin::introspection::src5::SRC5Component; - use openzeppelin::security::initializable::InitializableComponent; + use openzeppelin_introspection::src5::SRC5Component; + use openzeppelin_security::initializable::InitializableComponent; component!(path: SRC5Component, storage: src5, event: SRC5Event); component!(path: InitializableComponent, storage: initializable, event: InitializableEvent); @@ -84,7 +84,7 @@ The contract should implement an `InternalImpl` and add a function to register t ---- #[starknet::contract] mod MigratingContract { - use openzeppelin::token::erc721::interface::{IERC721_ID, IERC721_METADATA_ID}; + use openzeppelin_token::erc721::interface::{IERC721_ID, IERC721_METADATA_ID}; (...) diff --git a/docs/modules/ROOT/pages/index.adoc b/docs/modules/ROOT/pages/index.adoc index a71e80392..9e6f5ecbb 100644 --- a/docs/modules/ROOT/pages/index.adoc +++ b/docs/modules/ROOT/pages/index.adoc @@ -21,8 +21,8 @@ before proceeding, and run the following command to check that the installation ---- $ scarb --version -scarb 2.8.0 (09590f5fc 2024-08-27) -cairo: 2.8.0 (https://crates.io/crates/cairo-lang-compiler/2.8.0) +scarb 2.8.2 (a37b4cbfc 2024-09-09) +cairo: 2.8.2 (https://crates.io/crates/cairo-lang-compiler/2.8.2) sierra: 1.6.0 ---- @@ -58,7 +58,7 @@ Install the library by declaring it as a dependency in the project's `Scarb.toml [,text] ---- [dependencies] -openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.16.0" } +openzeppelin = "0.17.0" ---- WARNING: Make sure the tag matches the target release. @@ -72,7 +72,7 @@ Copy the code into `src/lib.cairo`. ---- #[starknet::contract] mod MyERC20Token { - use openzeppelin::token::erc20::{ERC20Component, ERC20HooksEmptyImpl}; + use openzeppelin_token::erc20::{ERC20Component, ERC20HooksEmptyImpl}; use starknet::ContractAddress; component!(path: ERC20Component, storage: erc20, event: ERC20Event); diff --git a/docs/modules/ROOT/pages/interfaces.adoc b/docs/modules/ROOT/pages/interfaces.adoc index d6e6a7fc8..c01486d9f 100644 --- a/docs/modules/ROOT/pages/interfaces.adoc +++ b/docs/modules/ROOT/pages/interfaces.adoc @@ -7,13 +7,13 @@ This section describes the interfaces OpenZeppelin Contracts for Cairo offer, an Interfaces can be found in the module tree under the `interface` submodule, such as `token::erc20::interface`. For example: ```cairo -use openzeppelin::token::erc20::interface::IERC20; +use openzeppelin_token::erc20::interface::IERC20; ``` or ```cairo -use openzeppelin::token::erc20::dual20::DualCaseERC20; +use openzeppelin_token::erc20::dual20::DualCaseERC20; ``` NOTE: For simplicity, we'll use ERC20 as example but the same concepts apply to other modules. @@ -152,6 +152,8 @@ pub trait IERC20Camel { == `DualCase` dispatchers +WARNING: `DualCase` dispatchers are deprecated, and they will be removed from the library soon. + WARNING: `DualCase` dispatchers won't work on live chains (`mainnet` or testnets) until they implement panic handling in their runtime. Dispatchers work fine in testing environments. In order to ease this transition, OpenZeppelin Contracts for Cairo offer what we call `DualCase` dispatchers such as `DualCaseERC721` or `DualCaseAccount`. diff --git a/docs/modules/ROOT/pages/introspection.adoc b/docs/modules/ROOT/pages/introspection.adoc index d4c9a4170..18a4f0bff 100644 --- a/docs/modules/ROOT/pages/introspection.adoc +++ b/docs/modules/ROOT/pages/introspection.adoc @@ -26,7 +26,7 @@ Here is an example contract: ---- #[starknet::contract] mod MyContract { - use openzeppelin::introspection::src5::SRC5Component; + use openzeppelin_introspection::src5::SRC5Component; component!(path: SRC5Component, storage: src5, event: SRC5Event); @@ -82,8 +82,8 @@ For a contract to declare its support for a given interface, we recommend using ---- #[starknet::contract] mod MyContract { - use openzeppelin::account::interface; - use openzeppelin::introspection::src5::SRC5Component; + use openzeppelin_account::interface; + use openzeppelin_introspection::src5::SRC5Component; component!(path: SRC5Component, storage: src5, event: SRC5Event); @@ -122,9 +122,9 @@ Use the `supports_interface` function to query a contract's support for a given ---- #[starknet::contract] mod MyContract { - use openzeppelin::account::interface; - use openzeppelin::introspection::interface::ISRC5DispatcherTrait; - use openzeppelin::introspection::interface::ISRC5Dispatcher; + use openzeppelin_account::interface; + use openzeppelin_introspection::interface::ISRC5DispatcherTrait; + use openzeppelin_introspection::interface::ISRC5Dispatcher; use starknet::ContractAddress; #[storage] diff --git a/docs/modules/ROOT/pages/presets.adoc b/docs/modules/ROOT/pages/presets.adoc index 3958b66ce..90f154313 100644 --- a/docs/modules/ROOT/pages/presets.adoc +++ b/docs/modules/ROOT/pages/presets.adoc @@ -4,6 +4,7 @@ :erc1155-upgradeable: xref:/api/erc1155.adoc#ERC1155Upgradeable[ERC1155Upgradeable] :eth-account-upgradeable: xref:/api/account.adoc#EthAccountUpgradeable[EthAccountUpgradeable] :udc: xref:/api/udc.adoc#UniversalDeployer[UniversalDeployer] +:vesting-wallet: xref:/api/finance.adoc#VestingWallet[VestingWallet] :sierra-class-hashes: https://docs.starknet.io/documentation/architecture_and_concepts/Smart_Contracts/class-hash[Sierra class hashes] :starkli: https://book.starkli.rs/introduction[starkli] :wizard: https://wizard.openzeppelin.com[Wizard for Cairo] @@ -45,6 +46,9 @@ NOTE: Class hashes were computed using {class-hash-cairo-version}. | `{udc}` | `{UniversalDeployer-class-hash}` + +| `{vesting-wallet}` +| `{VestingWallet-class-hash}` |=== TIP: {starkli} class-hash command can be used to compute the class hash from a Sierra artifact. @@ -53,7 +57,7 @@ TIP: {starkli} class-hash command can be used to compute the class hash from a S :setup_project: xref:index.adoc#set_up_your_project[setting up a project] :install_lib: xref:index.adoc#install the_library[installing the Contracts for Cairo library] -:presets_dir: link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/presets/src[presets directory] +:presets_dir: link:https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/presets/src[presets directory] These preset contracts are ready-to-deploy which means they should already be declared on the Sepolia network. Simply deploy the preset class hash and add the appropriate constructor arguments. @@ -76,10 +80,10 @@ Copy the target preset contract from the {presets_dir} and paste it in the new p #[starknet::contract] mod ERC20Upgradeable { - use openzeppelin::access::ownable::OwnableComponent; - use openzeppelin::token::erc20::{ERC20Component, ERC20HooksEmptyImpl}; - use openzeppelin::upgrades::UpgradeableComponent; - use openzeppelin::upgrades::interface::IUpgradeable; + use openzeppelin_access::ownable::OwnableComponent; + use openzeppelin_token::erc20::{ERC20Component, ERC20HooksEmptyImpl}; + use openzeppelin_upgrades::UpgradeableComponent; + use openzeppelin_upgrades::interface::IUpgradeable; use starknet::{ContractAddress, ClassHash}; component!(path: OwnableComponent, storage: ownable, event: OwnableEvent); diff --git a/docs/modules/ROOT/pages/security.adoc b/docs/modules/ROOT/pages/security.adoc index 9ccfe9c1a..b3d44c1ae 100644 --- a/docs/modules/ROOT/pages/security.adoc +++ b/docs/modules/ROOT/pages/security.adoc @@ -1,6 +1,6 @@ = Security -The following documentation provides context, reasoning, and examples of modules found under `openzeppelin::security`. +The following documentation provides context, reasoning, and examples of modules found under `openzeppelin_security`. CAUTION: Expect these modules to evolve. @@ -18,7 +18,7 @@ You can use the component in your contracts like this: ---- #[starknet::contract] mod MyInitializableContract { - use openzeppelin::security::InitializableComponent; + use openzeppelin_security::InitializableComponent; component!(path: InitializableComponent, storage: initializable, event: InitializableEvent); @@ -82,8 +82,8 @@ For example (using the xref:api/access.adoc#OwnableComponent[Ownable] component ---- #[starknet::contract] mod MyPausableContract { - use openzeppelin::access::ownable::OwnableComponent; - use openzeppelin::security::PausableComponent; + use openzeppelin_access::ownable::OwnableComponent; + use openzeppelin_security::PausableComponent; use starknet::ContractAddress; component!(path: OwnableComponent, storage: ownable, event: OwnableEvent); @@ -176,7 +176,7 @@ The protected function must call `start` before the first function statement, an ---- #[starknet::contract] mod MyReentrancyContract { - use openzeppelin::security::ReentrancyGuardComponent; + use openzeppelin_security::ReentrancyGuardComponent; component!( path: ReentrancyGuardComponent, storage: reentrancy_guard, event: ReentrancyGuardEvent diff --git a/docs/modules/ROOT/pages/udc.adoc b/docs/modules/ROOT/pages/udc.adoc index fd30ce729..823ee7c96 100644 --- a/docs/modules/ROOT/pages/udc.adoc +++ b/docs/modules/ROOT/pages/udc.adoc @@ -41,7 +41,7 @@ Here's an implementation example in Cairo: [,cairo] ---- -use openzeppelin::utils::interfaces::{IUniversalDeployerDispatcher, IUniversalDeployerDispatcherTrait}; +use openzeppelin_utils::interfaces::{IUniversalDeployerDispatcher, IUniversalDeployerDispatcherTrait}; const UDC_ADDRESS: felt252 = 0x04a64cd09a853868621d94cae9952b106f2c36a3f81260f85de6696c6b050221; diff --git a/docs/modules/ROOT/pages/upgrades.adoc b/docs/modules/ROOT/pages/upgrades.adoc index 171117df5..b981d9aa0 100644 --- a/docs/modules/ROOT/pages/upgrades.adoc +++ b/docs/modules/ROOT/pages/upgrades.adoc @@ -1,7 +1,7 @@ :contract_classes: https://docs.starknet.io/documentation/architecture_and_concepts/Smart_Contracts/contract-classes/[Contract Classes] :class_hash: https://docs.starknet.io/documentation/architecture_and_concepts/Smart_Contracts/class-hash/[class hash] :replace_class_syscall: https://docs.starknet.io/documentation/architecture_and_concepts/Smart_Contracts/system-calls-cairo1/#replace_class[replace_class] -:upgradeable: https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.16.0/packages/upgrades/src/upgradeable.cairo[Upgradeable] +:upgradeable: https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.17.0/packages/upgrades/src/upgradeable.cairo[Upgradeable] :ownable: xref:access.adoc#ownership_and_ownable[Ownable] :i_upgradeable: xref:api/upgrades.adoc#IUpgradeable[IUpgradeable] :library_calls: https://docs.starknet.io/documentation/architecture_and_concepts/Smart_Contracts/system-calls-cairo1/#library_call[library calls] @@ -51,9 +51,9 @@ NOTE: We will be using the following module to implement the {i_upgradeable} int ---- #[starknet::contract] mod UpgradeableContract { - use openzeppelin::access::ownable::OwnableComponent; - use openzeppelin::upgrades::UpgradeableComponent; - use openzeppelin::upgrades::interface::IUpgradeable; + use openzeppelin_access::ownable::OwnableComponent; + use openzeppelin_upgrades::UpgradeableComponent; + use openzeppelin_upgrades::interface::IUpgradeable; use starknet::ClassHash; use starknet::ContractAddress; diff --git a/docs/modules/ROOT/pages/utils/_class_hashes.adoc b/docs/modules/ROOT/pages/utils/_class_hashes.adoc index 07acf954d..369b18d47 100644 --- a/docs/modules/ROOT/pages/utils/_class_hashes.adoc +++ b/docs/modules/ROOT/pages/utils/_class_hashes.adoc @@ -1,13 +1,14 @@ // Version -:class-hash-cairo-version: https://crates.io/crates/cairo-lang-compiler/2.8.0[cairo 2.8.0] +:class-hash-cairo-version: https://crates.io/crates/cairo-lang-compiler/2.8.2[cairo 2.8.2] // Class Hashes -:ERC20Upgradeable-class-hash: 0x041f57a27f2fba3477c38e6559a09bf5b7bb3244ec1ca3cbea4ca5918d253137 -:ERC721Upgradeable-class-hash: 0x025b0f8fea29627735c3d11552b040ff15ca82c1f977d985165150f59ab689a4 -:ERC1155Upgradeable-class-hash: 0x065306fa7eb4d2ffb04a0186378b64ef8f83786b43f9e04798230c65df98619d -:AccountUpgradeable-class-hash: 0x0358a1635f95aaaa840ec3b47219a354d5dfe6b01f0bca38ae6b2ff397490348 -:EthAccountUpgradeable-class-hash: 0x039d1c6f335e7b92ee4dfaee4cc5324b4cbbfdc48bebcc81e7b45042b35dc592 -:UniversalDeployer-class-hash: 0x03b73428ba2f1dac3319da1fdb4ed3db047f148c8f78fe5bd7f34b41bb9aa50c +:ERC20Upgradeable-class-hash: 0x073d71c37e20c569186445d2c497d2195b4c0be9a255d72dbad86662fcc63ae6 +:ERC721Upgradeable-class-hash: 0x0080896d748e41d74501743b310b302f99ee69cff91b93b5ba8488431b42ea5b +:ERC1155Upgradeable-class-hash: 0x0704e79532206d47e9b453bd5784ba21bd946a49227f7478a89ca7ffb72ad36e +:AccountUpgradeable-class-hash: 0x06d4b80c0f3c3ea9e98252403a83f8a6bacf7f7362e9ac0a8824854dca31f8a8 +:EthAccountUpgradeable-class-hash: 0x06cc43e9a4a0036cd09d8a997c61df18d7e4fa9459c907a4664b4e56b679d187 +:UniversalDeployer-class-hash: 0x042b05f5d6e6359415b3da6902e8be480e695db0990826e107f1f45fabd03a78 +:VestingWallet-class-hash: 0x07e018b5ddc3fe3452060aad622545a6b30564049998ceab9f0783c12926eab6 // Presets page :presets-page: xref:presets.adoc[Sierra class hash] diff --git a/docs/modules/ROOT/pages/wizard.adoc b/docs/modules/ROOT/pages/wizard.adoc index 83261a0d3..df85de98b 100644 --- a/docs/modules/ROOT/pages/wizard.adoc +++ b/docs/modules/ROOT/pages/wizard.adoc @@ -10,5 +10,5 @@ NOTE: We strongly recommend checking the xref:components.adoc[Components] sectio ++++ - + ++++ diff --git a/packages/access/README.md b/packages/access/README.md index 748b00ad0..3efaee70f 100644 --- a/packages/access/README.md +++ b/packages/access/README.md @@ -1,20 +1,20 @@ ## Access Control -> **NOTE:** This document is better viewed at https://docs.openzeppelin.com/contracts-cairo/api/access +> **NOTE:** This document is better viewed at [https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/access](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/access) This crate provides ways to restrict who can access the functions of a contract or when they can do it. -- `Ownable` is a simple mechanism with a single "owner" role that can be assigned to a single contract (usually an account). This mechanism -can be useful in simple scenarios, but fine grained access needs are likely to outgrow it. +- `Ownable` is a simple mechanism with a single "owner" role that can be assigned to a single contract (usually an +account). This mechanism can be useful in simple scenarios, but fine grained access needs are likely to outgrow it. - `AccessControl` provides a general role based access control mechanism. Multiple hierarchical roles can be created and assigned each to multiple accounts. ### Interfaces -- `IAccessControl` +- [`IAccessControl`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/access#IAccessControl) ### Components -- `OwnableComponent` -- `AccessControlComponent` +- [`OwnableComponent`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/access#OwnableComponent) +- [`AccessControlComponent`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/access#AccessControlComponent) diff --git a/packages/access/src/accesscontrol/accesscontrol.cairo b/packages/access/src/accesscontrol/accesscontrol.cairo index 857242726..d634918a3 100644 --- a/packages/access/src/accesscontrol/accesscontrol.cairo +++ b/packages/access/src/accesscontrol/accesscontrol.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (access/accesscontrol/accesscontrol.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (access/accesscontrol/accesscontrol.cairo) /// # AccessControl Component /// diff --git a/packages/access/src/accesscontrol/interface.cairo b/packages/access/src/accesscontrol/interface.cairo index 407616e8b..a7c6a4e95 100644 --- a/packages/access/src/accesscontrol/interface.cairo +++ b/packages/access/src/accesscontrol/interface.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (access/accesscontrol/interface.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (access/accesscontrol/interface.cairo) use starknet::ContractAddress; diff --git a/packages/access/src/ownable/interface.cairo b/packages/access/src/ownable/interface.cairo index e36456852..e3b888089 100644 --- a/packages/access/src/ownable/interface.cairo +++ b/packages/access/src/ownable/interface.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (access/ownable/interface.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (access/ownable/interface.cairo) use starknet::ContractAddress; diff --git a/packages/access/src/ownable/ownable.cairo b/packages/access/src/ownable/ownable.cairo index 050a0bc9b..1d9164e12 100644 --- a/packages/access/src/ownable/ownable.cairo +++ b/packages/access/src/ownable/ownable.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (access/ownable/ownable.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (access/ownable/ownable.cairo) /// # Ownable Component /// diff --git a/packages/account/README.md b/packages/account/README.md index 2d30148b3..54eae9778 100644 --- a/packages/account/README.md +++ b/packages/account/README.md @@ -1,6 +1,6 @@ ## Account -> **NOTE:** This document is better viewed at https://docs.openzeppelin.com/contracts-cairo/api/account +> **NOTE:** This document is better viewed at [https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/account](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/account) This crate provides components to implement account contracts that can be used for interacting with the network. @@ -12,11 +12,11 @@ This crate provides components to implement account contracts that can be used f ### Interfaces -- `ISRC6` -- `ISRC9_V2` +- [`ISRC6`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/account#ISRC6) +- [`ISRC9_V2`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/account#ISRC9_V2) ### Components -- `AccountComponent` -- `EthAccountComponent` -- `SRC9Component` +- [`AccountComponent`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/account#AccountComponent) +- [`EthAccountComponent`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/account#EthAccountComponent) +- [`SRC9Component`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/account#SRC9Component) diff --git a/packages/account/src/account.cairo b/packages/account/src/account.cairo index 37022a049..9914e3eed 100644 --- a/packages/account/src/account.cairo +++ b/packages/account/src/account.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (account/account.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (account/account.cairo) /// # Account Component /// diff --git a/packages/account/src/eth_account.cairo b/packages/account/src/eth_account.cairo index e56ce634b..a2baa0fb1 100644 --- a/packages/account/src/eth_account.cairo +++ b/packages/account/src/eth_account.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (account/eth_account.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (account/eth_account.cairo) /// # EthAccount Component /// diff --git a/packages/account/src/extensions/src9/interface.cairo b/packages/account/src/extensions/src9/interface.cairo index 53990778d..bd3c0be0b 100644 --- a/packages/account/src/extensions/src9/interface.cairo +++ b/packages/account/src/extensions/src9/interface.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (account/extensions/src9/interface.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (account/extensions/src9/interface.cairo) use starknet::ContractAddress; use starknet::account::Call; diff --git a/packages/account/src/extensions/src9/snip12_utils.cairo b/packages/account/src/extensions/src9/snip12_utils.cairo index 31597814c..b2d81132c 100644 --- a/packages/account/src/extensions/src9/snip12_utils.cairo +++ b/packages/account/src/extensions/src9/snip12_utils.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (account/extensions/src9/snip12_utils.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (account/extensions/src9/snip12_utils.cairo) use core::hash::{HashStateTrait, HashStateExTrait}; use core::poseidon::{PoseidonTrait, poseidon_hash_span}; diff --git a/packages/account/src/extensions/src9/src9.cairo b/packages/account/src/extensions/src9/src9.cairo index 6f00b1952..468e1475f 100644 --- a/packages/account/src/extensions/src9/src9.cairo +++ b/packages/account/src/extensions/src9/src9.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (account/extensions/src9/src9.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (account/extensions/src9/src9.cairo) /// # SRC9 Component (Outside Execution) /// diff --git a/packages/account/src/interface.cairo b/packages/account/src/interface.cairo index 76c29f57e..cb93569db 100644 --- a/packages/account/src/interface.cairo +++ b/packages/account/src/interface.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (account/interface.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (account/interface.cairo) use starknet::account::Call; diff --git a/packages/account/src/utils.cairo b/packages/account/src/utils.cairo index d50192882..b4dfcd5c4 100644 --- a/packages/account/src/utils.cairo +++ b/packages/account/src/utils.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (account/utils.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (account/utils.cairo) pub mod secp256k1; pub mod signature; diff --git a/packages/account/src/utils/secp256k1.cairo b/packages/account/src/utils/secp256k1.cairo index 9462aa971..49f0efd84 100644 --- a/packages/account/src/utils/secp256k1.cairo +++ b/packages/account/src/utils/secp256k1.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (account/utils/secp256k1.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (account/utils/secp256k1.cairo) use core::fmt::{Formatter, Error}; use starknet::SyscallResultTrait; diff --git a/packages/account/src/utils/signature.cairo b/packages/account/src/utils/signature.cairo index 70e3eedc6..b8b8affb8 100644 --- a/packages/account/src/utils/signature.cairo +++ b/packages/account/src/utils/signature.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (account/utils/signature.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (account/utils/signature.cairo) use core::ecdsa::check_ecdsa_signature; use crate::interface::EthPublicKey; diff --git a/packages/finance/README.md b/packages/finance/README.md index bf885125d..091813f25 100644 --- a/packages/finance/README.md +++ b/packages/finance/README.md @@ -1,5 +1,7 @@ ## Finance +> **NOTE:** Documentation will soon be added to [https://docs.openzeppelin.com/contracts-cairo](https://docs.openzeppelin.com/contracts-cairo) + This crate includes primitives for financial systems. ### Interfaces diff --git a/packages/finance/src/vesting/interface.cairo b/packages/finance/src/vesting/interface.cairo index ee3a7b95f..19d086a61 100644 --- a/packages/finance/src/vesting/interface.cairo +++ b/packages/finance/src/vesting/interface.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (finance/vesting/interface.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (finance/vesting/interface.cairo) use starknet::ContractAddress; diff --git a/packages/finance/src/vesting/vesting.cairo b/packages/finance/src/vesting/vesting.cairo index 843b3394e..4f8b893c9 100644 --- a/packages/finance/src/vesting/vesting.cairo +++ b/packages/finance/src/vesting/vesting.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (finance/vesting/vesting.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (finance/vesting/vesting.cairo) use starknet::ContractAddress; @@ -132,6 +132,11 @@ pub mod VestingComponent { /// Releases the amount of a given `token` that has already vested. /// + /// + /// Requirements: + /// + /// - `transfer` call to the `token` must return `true` indicating a successful transfer. + /// /// Emits an `AmountReleased` event. fn release(ref self: ComponentState, token: ContractAddress) -> u256 { let amount = self.releasable(token); @@ -152,9 +157,15 @@ pub mod VestingComponent { +HasComponent, impl VestingSchedule: VestingScheduleTrait > of InternalTrait { - /// Initializes the component by setting the vesting start, duration and cliff. + /// Initializes the component by setting the vesting `start`, `duration` and + /// `cliff_duration`. /// To prevent reinitialization, this should only be used inside of a contract's /// constructor. + /// + /// Requirements: + /// + /// - `cliff_duration` must be less than or equal to `duration`. + /// fn initializer( ref self: ComponentState, start: u64, duration: u64, cliff_duration: u64 ) { diff --git a/packages/governance/README.md b/packages/governance/README.md index 7689e67b7..89296ae46 100644 --- a/packages/governance/README.md +++ b/packages/governance/README.md @@ -1,14 +1,14 @@ ## Governance -> **NOTE:** This document is better viewed at https://docs.openzeppelin.com/contracts-cairo/api/governance +> **NOTE:** This document is better viewed at [https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/governance](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/governance) This crate includes primitives for on-chain governance. ### Interfaces -- `ITimelock` -- `IVotes` +- [`ITimelock`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/governance#ITimelock) +- [`IVotes`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/governance#IVotes) ### Components -- `TimelockControllerComponent` +- [`TimelockControllerComponent`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/governance#TimelockControllerComponent) diff --git a/packages/governance/src/timelock/interface.cairo b/packages/governance/src/timelock/interface.cairo index 4d2f5d2c9..4523c344c 100644 --- a/packages/governance/src/timelock/interface.cairo +++ b/packages/governance/src/timelock/interface.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (governance/timelock/interface.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (governance/timelock/interface.cairo) use crate::timelock::OperationState; use starknet::ContractAddress; diff --git a/packages/governance/src/timelock/timelock_controller.cairo b/packages/governance/src/timelock/timelock_controller.cairo index eddd5609b..af7adf464 100644 --- a/packages/governance/src/timelock/timelock_controller.cairo +++ b/packages/governance/src/timelock/timelock_controller.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (governance/timelock/timelock_controller.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (governance/timelock/timelock_controller.cairo) /// # TimelockController Component /// diff --git a/packages/governance/src/timelock/utils/call_impls.cairo b/packages/governance/src/timelock/utils/call_impls.cairo index 29d0fafa5..302308e61 100644 --- a/packages/governance/src/timelock/utils/call_impls.cairo +++ b/packages/governance/src/timelock/utils/call_impls.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (governance/timelock/utils/call_impls.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (governance/timelock/utils/call_impls.cairo) use core::hash::{HashStateTrait, HashStateExTrait, Hash}; use starknet::account::Call; diff --git a/packages/introspection/README.md b/packages/introspection/README.md index 8e4e65c0e..6d4183e90 100644 --- a/packages/introspection/README.md +++ b/packages/introspection/README.md @@ -1,14 +1,13 @@ ## Introspection -> **NOTE:** This document is better viewed at https://docs.openzeppelin.com/contracts-cairo/api/introspection +> **NOTE:** This document is better viewed at [https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/introspection](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/introspection) This crate handles [type introspection](https://en.wikipedia.org/wiki/Type_introspection) of contracts. In other words, it examines which functions can be called on a given contract. This is referred to as the contract's interface. -examining which functions can be called on them. This is usually referred to as a contract’s interface. ### Interfaces -- `ISRC5` +- [`ISRC5`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/introspection#ISRC5) ### Components -- `SRC5Component` +- [`SRC5Component`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/introspection#SRC5Component) diff --git a/packages/introspection/src/interface.cairo b/packages/introspection/src/interface.cairo index c7da02b12..317693dd5 100644 --- a/packages/introspection/src/interface.cairo +++ b/packages/introspection/src/interface.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (introspection/interface.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (introspection/interface.cairo) pub const ISRC5_ID: felt252 = 0x3f918d17e5ee77373b56385708f855659a07f75997f365cf87748628532a055; diff --git a/packages/introspection/src/src5.cairo b/packages/introspection/src/src5.cairo index dcea6381d..451f716bc 100644 --- a/packages/introspection/src/src5.cairo +++ b/packages/introspection/src/src5.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (introspection/src5.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (introspection/src5.cairo) /// # SRC5 Component /// diff --git a/packages/merkle_tree/README.md b/packages/merkle_tree/README.md index 0abe18575..43d6eca3b 100644 --- a/packages/merkle_tree/README.md +++ b/packages/merkle_tree/README.md @@ -1,6 +1,6 @@ ## Merkle Tree -> **NOTE:** This document is better viewed at https://docs.openzeppelin.com/contracts-cairo/api/introspection +> **NOTE:** This document is better viewed at [https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/merkle-tree](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/merkle-tree) This crate provides a set of utilities for verifying Merkle Tree proofs on-chain. The tree and the proofs can be generated using this [JavaScript library](https://github.com/ericnordelo/strk-merkle-tree) both for Pedersen and Poseidon diff --git a/packages/merkle_tree/Scarb.toml b/packages/merkle_tree/Scarb.toml index 9a3784569..f9b50d14f 100644 --- a/packages/merkle_tree/Scarb.toml +++ b/packages/merkle_tree/Scarb.toml @@ -1,4 +1,3 @@ - [package] name = "openzeppelin_merkle_tree" readme = "README.md" diff --git a/packages/merkle_tree/src/hashes.cairo b/packages/merkle_tree/src/hashes.cairo index 51c5e3593..e6d456d22 100644 --- a/packages/merkle_tree/src/hashes.cairo +++ b/packages/merkle_tree/src/hashes.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (merkle_tree/hashes.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (merkle_tree/hashes.cairo) use core::hash::HashStateTrait; use core::pedersen::PedersenTrait; diff --git a/packages/merkle_tree/src/merkle_proof.cairo b/packages/merkle_tree/src/merkle_proof.cairo index 9f4194896..97bec3f0b 100644 --- a/packages/merkle_tree/src/merkle_proof.cairo +++ b/packages/merkle_tree/src/merkle_proof.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (merkle_tree/merkle_proof.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (merkle_tree/merkle_proof.cairo) /// These functions deal with verification of Merkle Tree proofs. /// diff --git a/packages/presets/README.md b/packages/presets/README.md index 9f0db31cd..a86a5285b 100644 --- a/packages/presets/README.md +++ b/packages/presets/README.md @@ -1,6 +1,6 @@ ## Presets -> **NOTE:** This document is better viewed at https://docs.openzeppelin.com/contracts-cairo/presets +> **NOTE:** This document is better viewed at [https://docs.openzeppelin.com/contracts-cairo/0.17.0/presets](https://docs.openzeppelin.com/contracts-cairo/0.17.0/presets) Presets are ready-to-deploy contracts provided by the library. Since presets are intended to be very simple and as generic as possible, there’s no support for custom or complex contracts such as `ERC20Pausable` or `ERC721Mintable`. @@ -10,9 +10,9 @@ For contract customization and combination of modules you can use ### Presets -- `AccountUpgradeable` -- `ERC20Upgradeable` -- `ERC721Upgradeable` -- `ERC1155Upgradeable` -- `EthAccountUpgradeable` -- `UniversalDeployer` +- [`AccountUpgradeable`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/account#AccountUpgradeable) +- [`ERC20Upgradeable`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/erc20#ERC20Upgradeable) +- [`ERC721Upgradeable`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/erc721#ERC721Upgradeable) +- [`ERC1155Upgradeable`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/erc1155#ERC1155Upgradeable) +- [`EthAccountUpgradeable`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/account#EthAccountUpgradeable) +- [`UniversalDeployer`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/udc#UniversalDeployer) diff --git a/packages/presets/src/account.cairo b/packages/presets/src/account.cairo index 25fbaa96f..08a61129e 100644 --- a/packages/presets/src/account.cairo +++ b/packages/presets/src/account.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (presets/account.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (presets/account.cairo) /// # Account Preset /// diff --git a/packages/presets/src/erc1155.cairo b/packages/presets/src/erc1155.cairo index 1fd81732c..18f7a1b74 100644 --- a/packages/presets/src/erc1155.cairo +++ b/packages/presets/src/erc1155.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (presets/erc1155.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (presets/erc1155.cairo) /// # ERC1155Upgradeable Preset /// diff --git a/packages/presets/src/erc20.cairo b/packages/presets/src/erc20.cairo index 2e539522a..f65bfcec1 100644 --- a/packages/presets/src/erc20.cairo +++ b/packages/presets/src/erc20.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (presets/erc20.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (presets/erc20.cairo) /// # ERC20 Preset /// diff --git a/packages/presets/src/erc721.cairo b/packages/presets/src/erc721.cairo index cf6e5e99b..efd67a940 100644 --- a/packages/presets/src/erc721.cairo +++ b/packages/presets/src/erc721.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (presets/erc721.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (presets/erc721.cairo) /// # ERC721 Preset /// diff --git a/packages/presets/src/eth_account.cairo b/packages/presets/src/eth_account.cairo index f11020c45..d10305bfc 100644 --- a/packages/presets/src/eth_account.cairo +++ b/packages/presets/src/eth_account.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (presets/eth_account.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (presets/eth_account.cairo) /// # EthAccount Preset /// diff --git a/packages/presets/src/interfaces.cairo b/packages/presets/src/interfaces.cairo index d825525b3..15e1b2fd6 100644 --- a/packages/presets/src/interfaces.cairo +++ b/packages/presets/src/interfaces.cairo @@ -3,6 +3,7 @@ pub mod erc1155; pub mod erc20; pub mod erc721; pub mod eth_account; +pub mod vesting; pub use account::AccountUpgradeableABI; pub use account::{AccountUpgradeableABIDispatcher, AccountUpgradeableABIDispatcherTrait}; @@ -14,3 +15,5 @@ pub use erc721::ERC721UpgradeableABI; pub use erc721::{ERC721UpgradeableABIDispatcher, ERC721UpgradeableABIDispatcherTrait}; pub use eth_account::EthAccountUpgradeableABI; pub use eth_account::{EthAccountUpgradeableABIDispatcher, EthAccountUpgradeableABIDispatcherTrait}; +pub use vesting::VestingWalletABI; +pub use vesting::{VestingWalletABIDispatcher, VestingWalletABIDispatcherTrait}; diff --git a/packages/presets/src/interfaces/vesting.cairo b/packages/presets/src/interfaces/vesting.cairo new file mode 100644 index 000000000..716781be9 --- /dev/null +++ b/packages/presets/src/interfaces/vesting.cairo @@ -0,0 +1,23 @@ +use starknet::ContractAddress; + +#[starknet::interface] +pub trait VestingWalletABI { + // IVesting + fn start(self: @TState) -> u64; + fn cliff(self: @TState) -> u64; + fn duration(self: @TState) -> u64; + fn end(self: @TState) -> u64; + fn released(self: @TState, token: ContractAddress) -> u256; + fn releasable(self: @TState, token: ContractAddress) -> u256; + fn vested_amount(self: @TState, token: ContractAddress, timestamp: u64) -> u256; + fn release(ref self: TState, token: ContractAddress) -> u256; + + // IOwnable + fn owner(self: @TState) -> ContractAddress; + fn transfer_ownership(ref self: TState, new_owner: ContractAddress); + fn renounce_ownership(ref self: TState); + + // IOwnableCamelOnly + fn transferOwnership(ref self: TState, newOwner: ContractAddress); + fn renounceOwnership(ref self: TState); +} diff --git a/packages/presets/src/tests/test_vesting.cairo b/packages/presets/src/tests/test_vesting.cairo index 657c87df7..0cbc9763a 100644 --- a/packages/presets/src/tests/test_vesting.cairo +++ b/packages/presets/src/tests/test_vesting.cairo @@ -1,10 +1,11 @@ -use openzeppelin_access::ownable::interface::{IOwnableDispatcher, IOwnableDispatcherTrait}; +use core::num::traits::Zero; +use crate::interfaces::{VestingWalletABIDispatcher, VestingWalletABIDispatcherTrait}; use openzeppelin_finance::vesting::VestingComponent::InternalImpl; -use openzeppelin_finance::vesting::interface::{IVestingDispatcher, IVestingDispatcherTrait}; use openzeppelin_test_common::erc20::deploy_erc20; +use openzeppelin_test_common::ownable::OwnableSpyHelpers; use openzeppelin_test_common::vesting::VestingSpyHelpers; use openzeppelin_testing as utils; -use openzeppelin_testing::constants::{OWNER, OTHER}; +use openzeppelin_testing::constants::{OWNER, OTHER, ZERO}; use openzeppelin_token::erc20::interface::{IERC20Dispatcher, IERC20DispatcherTrait}; use openzeppelin_utils::serde::SerializedAppend; use snforge_std::{spy_events, start_cheat_caller_address, start_cheat_block_timestamp_global}; @@ -29,7 +30,7 @@ fn TEST_DATA() -> TestData { } } -fn setup(data: TestData) -> (IVestingDispatcher, ContractAddress) { +fn setup(data: TestData) -> (VestingWalletABIDispatcher, ContractAddress) { let mut calldata = array![]; calldata.append_serde(data.beneficiary); calldata.append_serde(data.start); @@ -37,12 +38,12 @@ fn setup(data: TestData) -> (IVestingDispatcher, ContractAddress) { calldata.append_serde(data.cliff_duration); let contract_address = utils::declare_and_deploy("VestingWallet", calldata); let token = deploy_erc20(contract_address, data.total_allocation); - let vesting = IVestingDispatcher { contract_address }; + let vesting = VestingWalletABIDispatcher { contract_address }; (vesting, token.contract_address) } // -// Tests +// IVesting // #[test] @@ -54,8 +55,7 @@ fn test_state_after_init() { assert_eq!(vesting.duration(), data.duration); assert_eq!(vesting.cliff(), data.start + data.cliff_duration); assert_eq!(vesting.end(), data.start + data.duration); - let beneficiary = IOwnableDispatcher { contract_address: vesting.contract_address }.owner(); - assert_eq!(beneficiary, data.beneficiary); + assert_eq!(vesting.owner(), data.beneficiary); } #[test] @@ -199,7 +199,6 @@ fn test_release_multiple_calls() { fn test_release_after_ownership_transferred() { let data = TEST_DATA(); let (vesting, token) = setup(data); - let ownable_vesting = IOwnableDispatcher { contract_address: vesting.contract_address }; let token_dispatcher = IERC20Dispatcher { contract_address: token }; // 1. Release to initial owner @@ -213,7 +212,7 @@ fn test_release_after_ownership_transferred() { // 2. Transfer ownership let new_owner = OTHER(); start_cheat_caller_address(vesting.contract_address, data.beneficiary); - ownable_vesting.transfer_ownership(new_owner); + vesting.transfer_ownership(new_owner); // 3. Release to new owner let release_amount_2 = data.total_allocation - release_amount_1; @@ -223,3 +222,135 @@ fn test_release_after_ownership_transferred() { assert_eq!(token_dispatcher.balance_of(data.beneficiary), release_amount_1); assert_eq!(token_dispatcher.balance_of(new_owner), release_amount_2); } + +// +// transfer_ownership & transferOwnership +// + +#[test] +fn test_transfer_ownership() { + let (vesting, _) = setup(TEST_DATA()); + let mut spy = spy_events(); + start_cheat_caller_address(vesting.contract_address, OWNER()); + vesting.transfer_ownership(OTHER()); + + spy.assert_event_ownership_transferred(vesting.contract_address, OWNER(), OTHER()); + assert_eq!(vesting.owner(), OTHER()); +} + +#[test] +#[should_panic(expected: 'New owner is the zero address')] +fn test_transfer_ownership_to_zero() { + let (vesting, _) = setup(TEST_DATA()); + start_cheat_caller_address(vesting.contract_address, OWNER()); + vesting.transfer_ownership(ZERO()); +} + +#[test] +#[should_panic(expected: 'Caller is the zero address')] +fn test_transfer_ownership_from_zero() { + let (vesting, _) = setup(TEST_DATA()); + start_cheat_caller_address(vesting.contract_address, ZERO()); + vesting.transfer_ownership(OTHER()); +} + +#[test] +#[should_panic(expected: 'Caller is not the owner')] +fn test_transfer_ownership_from_nonowner() { + let (vesting, _) = setup(TEST_DATA()); + start_cheat_caller_address(vesting.contract_address, OTHER()); + vesting.transfer_ownership(OTHER()); +} + +#[test] +fn test_transferOwnership() { + let (vesting, _) = setup(TEST_DATA()); + let mut spy = spy_events(); + start_cheat_caller_address(vesting.contract_address, OWNER()); + vesting.transferOwnership(OTHER()); + + spy.assert_event_ownership_transferred(vesting.contract_address, OWNER(), OTHER()); + assert_eq!(vesting.owner(), OTHER()); +} + +#[test] +#[should_panic(expected: 'New owner is the zero address')] +fn test_transferOwnership_to_zero() { + let (vesting, _) = setup(TEST_DATA()); + start_cheat_caller_address(vesting.contract_address, OWNER()); + vesting.transferOwnership(ZERO()); +} + +#[test] +#[should_panic(expected: 'Caller is the zero address')] +fn test_transferOwnership_from_zero() { + let (vesting, _) = setup(TEST_DATA()); + start_cheat_caller_address(vesting.contract_address, ZERO()); + vesting.transferOwnership(OTHER()); +} + +#[test] +#[should_panic(expected: 'Caller is not the owner')] +fn test_transferOwnership_from_nonowner() { + let (vesting, _) = setup(TEST_DATA()); + start_cheat_caller_address(vesting.contract_address, OTHER()); + vesting.transferOwnership(OTHER()); +} + +// +// renounce_ownership & renounceOwnership +// + +#[test] +fn test_renounce_ownership() { + let (vesting, _) = setup(TEST_DATA()); + let mut spy = spy_events(); + start_cheat_caller_address(vesting.contract_address, OWNER()); + vesting.renounce_ownership(); + + spy.assert_event_ownership_transferred(vesting.contract_address, OWNER(), ZERO()); + assert!(vesting.owner().is_zero()); +} + +#[test] +#[should_panic(expected: 'Caller is the zero address')] +fn test_renounce_ownership_from_zero_address() { + let (vesting, _) = setup(TEST_DATA()); + start_cheat_caller_address(vesting.contract_address, ZERO()); + vesting.renounce_ownership(); +} + +#[test] +#[should_panic(expected: 'Caller is not the owner')] +fn test_renounce_ownership_from_nonowner() { + let (vesting, _) = setup(TEST_DATA()); + start_cheat_caller_address(vesting.contract_address, OTHER()); + vesting.renounce_ownership(); +} + +#[test] +fn test_renounceOwnership() { + let (vesting, _) = setup(TEST_DATA()); + let mut spy = spy_events(); + start_cheat_caller_address(vesting.contract_address, OWNER()); + vesting.renounceOwnership(); + + spy.assert_event_ownership_transferred(vesting.contract_address, OWNER(), ZERO()); + assert!(vesting.owner().is_zero()); +} + +#[test] +#[should_panic(expected: 'Caller is the zero address')] +fn test_renounceOwnership_from_zero_address() { + let (vesting, _) = setup(TEST_DATA()); + start_cheat_caller_address(vesting.contract_address, ZERO()); + vesting.renounceOwnership(); +} + +#[test] +#[should_panic(expected: 'Caller is not the owner')] +fn test_renounceOwnership_from_nonowner() { + let (vesting, _) = setup(TEST_DATA()); + start_cheat_caller_address(vesting.contract_address, OTHER()); + vesting.renounceOwnership(); +} diff --git a/packages/presets/src/universal_deployer.cairo b/packages/presets/src/universal_deployer.cairo index 9acf3535a..2c2f25752 100644 --- a/packages/presets/src/universal_deployer.cairo +++ b/packages/presets/src/universal_deployer.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (presets/universal_deployer.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (presets/universal_deployer.cairo) /// # UniversalDeployerContract Preset /// diff --git a/packages/presets/src/vesting.cairo b/packages/presets/src/vesting.cairo index 0c5199430..8d7b42ac2 100644 --- a/packages/presets/src/vesting.cairo +++ b/packages/presets/src/vesting.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (presets/vesting.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (presets/vesting.cairo) #[starknet::contract] pub mod VestingWallet { @@ -21,11 +21,11 @@ pub mod VestingWallet { impl VestingInternalImpl = VestingComponent::InternalImpl; #[storage] - struct Storage { + pub struct Storage { #[substorage(v0)] - ownable: OwnableComponent::Storage, + pub ownable: OwnableComponent::Storage, #[substorage(v0)] - vesting: VestingComponent::Storage + pub vesting: VestingComponent::Storage } #[event] @@ -37,11 +37,22 @@ pub mod VestingWallet { VestingEvent: VestingComponent::Event } + /// Initializes the vesting component by setting the vesting `start`, `duration` and + /// `cliff_duration`. + /// Assigns `beneficiary` as the contract owner and the vesting beneficiary. + /// + /// Requirements: + /// + /// - `cliff_duration` must be less than or equal to `duration`. #[constructor] fn constructor( - ref self: ContractState, beneficiary: ContractAddress, start: u64, duration: u64, cliff: u64 + ref self: ContractState, + beneficiary: ContractAddress, + start: u64, + duration: u64, + cliff_duration: u64 ) { self.ownable.initializer(beneficiary); - self.vesting.initializer(start, duration, cliff); + self.vesting.initializer(start, duration, cliff_duration); } } diff --git a/packages/security/README.md b/packages/security/README.md index 5433803f8..0845748ff 100644 --- a/packages/security/README.md +++ b/packages/security/README.md @@ -1,11 +1,11 @@ ## Security -> **NOTE:** This document is better viewed at https://docs.openzeppelin.com/contracts-cairo/api/security +> **NOTE:** This document is better viewed at [https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/security](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/security) This crate provides components to handle common security-related tasks such as pausing a contract. ### Components -- `InitializableComponent` -- `PausableComponent` -- `ReentrancyGuardComponent` +- [`InitializableComponent`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/security#InitializableComponent) +- [`PausableComponent`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/security#PausableComponent) +- [`ReentrancyGuardComponent`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/security#ReentrancyGuardComponent) diff --git a/packages/security/src/initializable.cairo b/packages/security/src/initializable.cairo index fb64ffeee..cbf13fdd1 100644 --- a/packages/security/src/initializable.cairo +++ b/packages/security/src/initializable.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (security/initializable.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (security/initializable.cairo) /// # Initializable Component /// diff --git a/packages/security/src/pausable.cairo b/packages/security/src/pausable.cairo index 25e014cc9..5f88cf164 100644 --- a/packages/security/src/pausable.cairo +++ b/packages/security/src/pausable.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (security/pausable.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (security/pausable.cairo) /// # Pausable Component /// diff --git a/packages/security/src/reentrancyguard.cairo b/packages/security/src/reentrancyguard.cairo index 6165fb00b..c6e3616a8 100644 --- a/packages/security/src/reentrancyguard.cairo +++ b/packages/security/src/reentrancyguard.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (security/reentrancyguard.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (security/reentrancyguard.cairo) /// # ReentrancyGuard Component /// diff --git a/packages/testing/README.md b/packages/testing/README.md index 109a60131..4d268349d 100644 --- a/packages/testing/README.md +++ b/packages/testing/README.md @@ -1,13 +1,13 @@ ## Testing -> **NOTE:** This document is better viewed at https://docs.openzeppelin.com/contracts-cairo/api/testing +> **NOTE:** This document is better viewed at [https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/testing](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/testing) This crate provides various helper functions for declaring, deploying, and testing smart contracts using the `snforge` toolchain from Starknet Foundry. ### Modules -- `common` -- `deployment` -- `events` -- `signing` +- [`common`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/testing#testing-common) +- [`deployment`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/testing#testing-deployment) +- [`events`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/testing#testing-events) +- [`signing`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/testing#testing-signing) diff --git a/packages/token/README.md b/packages/token/README.md index 35b7a316c..33982f342 100644 --- a/packages/token/README.md +++ b/packages/token/README.md @@ -5,58 +5,58 @@ standards. ### ERC20 -> **NOTE:** This document is better viewed at https://docs.openzeppelin.com/contracts-cairo/api/erc20 +> **NOTE:** This document is better viewed at [https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/erc20](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/erc20) #### Interfaces -- `IERC20` -- `IERC20Metadata` +- [`IERC20`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/erc20#IERC20) +- [`IERC20Metadata`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/erc20#IERC20Metadata) #### Components -- `ERC20Component` -- `ERC20VotesComponent` +- [`ERC20Component`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/erc20#ERC20Component) +- [`ERC20VotesComponent`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/erc20#ERC20VotesComponent) ### ERC721 -> **NOTE:** This document is better viewed at https://docs.openzeppelin.com/contracts-cairo/api/erc721 +> **NOTE:** This document is better viewed at [https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/erc721](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/erc721) #### Interfaces -- `IERC721` -- `IERC721Metadata` -- `IERC721Receiver` -- `IERC721Enumerable` +- [`IERC721`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/erc721#IERC721) +- [`IERC721Metadata`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/erc721#IERC721Metadata) +- [`IERC721Receiver`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/erc721#IERC721Receiver) +- [`IERC721Enumerable`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/erc721#IERC721Enumerable) #### Components -- `ERC721Component` -- `ERC721ReceiverComponent` -- `ERC721EnumerableComponent` +- [`ERC721Component`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/erc721#ERC721Component) +- [`ERC721ReceiverComponent`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/erc721#ERC721ReceiverComponent) +- [`ERC721EnumerableComponent`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/erc721#ERC721EnumerableComponent) ### ERC1155 -> **NOTE:** This document is better viewed at https://docs.openzeppelin.com/contracts-cairo/api/erc1155 +> **NOTE:** This document is better viewed at [https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/erc1155](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/erc1155) #### Interfaces -- `IERC1155` -- `IERC1155MetadataURI` -- `IERC1155Receiver` +- [`IERC1155`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/erc1155#IERC1155) +- [`IERC1155MetadataURI`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/erc1155#IERC1155MetadataURI) +- [`IERC1155Receiver`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/erc1155#IERC1155Receiver) #### Components -- `ERC1155Component` -- `ERC1155ReceiverComponent` +- [`ERC1155Component`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/erc1155#ERC1155Component) +- [`ERC1155ReceiverComponent`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/erc1155#ERC1155ReceiverComponent) ### Common -> **NOTE:** This document is better viewed at https://docs.openzeppelin.com/contracts-cairo/api/token_common +> **NOTE:** This document is better viewed at [https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/token_common](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/token_common) #### Interfaces -- `IERC2981` +- [`IERC2981`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/token_common#IERC2981) #### Components -- `ERC2981Component` +- [`ERC2981Component`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/token_common#ERC2981Component) diff --git a/packages/token/src/common/erc2981/erc2981.cairo b/packages/token/src/common/erc2981/erc2981.cairo index 64766df89..42ef33c36 100644 --- a/packages/token/src/common/erc2981/erc2981.cairo +++ b/packages/token/src/common/erc2981/erc2981.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (token/common/erc2981/erc2981.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (token/common/erc2981/erc2981.cairo) /// # ERC2981 Component /// diff --git a/packages/token/src/common/erc2981/interface.cairo b/packages/token/src/common/erc2981/interface.cairo index cc5ba0e69..20181e6e5 100644 --- a/packages/token/src/common/erc2981/interface.cairo +++ b/packages/token/src/common/erc2981/interface.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (token/common/erc2981/interface.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (token/common/erc2981/interface.cairo) use starknet::ContractAddress; diff --git a/packages/token/src/erc1155/dual1155.cairo b/packages/token/src/erc1155/dual1155.cairo index a2e77f3c1..95da3bfa2 100644 --- a/packages/token/src/erc1155/dual1155.cairo +++ b/packages/token/src/erc1155/dual1155.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (token/erc1155/dual1155.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (token/erc1155/dual1155.cairo) use openzeppelin_utils::UnwrapAndCast; use openzeppelin_utils::selectors; diff --git a/packages/token/src/erc1155/dual1155_receiver.cairo b/packages/token/src/erc1155/dual1155_receiver.cairo index 1d8f8d508..d123224e5 100644 --- a/packages/token/src/erc1155/dual1155_receiver.cairo +++ b/packages/token/src/erc1155/dual1155_receiver.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (token/erc1155/dual1155_receiver.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (token/erc1155/dual1155_receiver.cairo) use openzeppelin_utils::UnwrapAndCast; use openzeppelin_utils::selectors; diff --git a/packages/token/src/erc1155/erc1155.cairo b/packages/token/src/erc1155/erc1155.cairo index 7c495d3f0..30128dd42 100644 --- a/packages/token/src/erc1155/erc1155.cairo +++ b/packages/token/src/erc1155/erc1155.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (token/erc1155/erc1155.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (token/erc1155/erc1155.cairo) /// # ERC1155 Component /// diff --git a/packages/token/src/erc1155/erc1155_receiver.cairo b/packages/token/src/erc1155/erc1155_receiver.cairo index 0172f2c36..92e9acba4 100644 --- a/packages/token/src/erc1155/erc1155_receiver.cairo +++ b/packages/token/src/erc1155/erc1155_receiver.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (token/erc1155/erc1155_receiver.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (token/erc1155/erc1155_receiver.cairo) /// # ERC1155Receiver Component /// diff --git a/packages/token/src/erc1155/interface.cairo b/packages/token/src/erc1155/interface.cairo index 73405fac6..f42586429 100644 --- a/packages/token/src/erc1155/interface.cairo +++ b/packages/token/src/erc1155/interface.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (token/erc1155/interface.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (token/erc1155/interface.cairo) use starknet::ContractAddress; diff --git a/packages/token/src/erc20/dual20.cairo b/packages/token/src/erc20/dual20.cairo index f7bfbab93..20cefb030 100644 --- a/packages/token/src/erc20/dual20.cairo +++ b/packages/token/src/erc20/dual20.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (token/erc20/dual20.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (token/erc20/dual20.cairo) use openzeppelin_utils::UnwrapAndCast; use openzeppelin_utils::selectors; diff --git a/packages/token/src/erc20/erc20.cairo b/packages/token/src/erc20/erc20.cairo index 8515c41a3..baf76b0a5 100644 --- a/packages/token/src/erc20/erc20.cairo +++ b/packages/token/src/erc20/erc20.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (token/erc20/erc20.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (token/erc20/erc20.cairo) /// # ERC20 Component /// @@ -8,7 +8,7 @@ /// component is agnostic regarding how tokens are created, which means that developers /// must create their own token distribution mechanism. /// See [the documentation] -/// (https://docs.openzeppelin.com/contracts-cairo/0.16.0/guides/erc20-supply) +/// (https://docs.openzeppelin.com/contracts-cairo/0.17.0/guides/erc20-supply) /// for examples. #[starknet::component] pub mod ERC20Component { diff --git a/packages/token/src/erc20/extensions/erc20_votes.cairo b/packages/token/src/erc20/extensions/erc20_votes.cairo index a80901b62..b1dfa1fcb 100644 --- a/packages/token/src/erc20/extensions/erc20_votes.cairo +++ b/packages/token/src/erc20/extensions/erc20_votes.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (token/erc20/extensions/erc20_votes.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (token/erc20/extensions/erc20_votes.cairo) use core::hash::{HashStateTrait, HashStateExTrait}; use core::poseidon::PoseidonTrait; diff --git a/packages/token/src/erc20/interface.cairo b/packages/token/src/erc20/interface.cairo index 53f6c69aa..811eb62fc 100644 --- a/packages/token/src/erc20/interface.cairo +++ b/packages/token/src/erc20/interface.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (token/erc20/interface.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (token/erc20/interface.cairo) use starknet::ContractAddress; diff --git a/packages/token/src/erc721/dual721.cairo b/packages/token/src/erc721/dual721.cairo index 61c09d212..7932cd559 100644 --- a/packages/token/src/erc721/dual721.cairo +++ b/packages/token/src/erc721/dual721.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (token/erc721/dual721.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (token/erc721/dual721.cairo) use openzeppelin_utils::UnwrapAndCast; use openzeppelin_utils::selectors; diff --git a/packages/token/src/erc721/dual721_receiver.cairo b/packages/token/src/erc721/dual721_receiver.cairo index a9a067f64..1e616c5b6 100644 --- a/packages/token/src/erc721/dual721_receiver.cairo +++ b/packages/token/src/erc721/dual721_receiver.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (token/erc721/dual721_receiver.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (token/erc721/dual721_receiver.cairo) use openzeppelin_utils::UnwrapAndCast; use openzeppelin_utils::selectors; diff --git a/packages/token/src/erc721/erc721.cairo b/packages/token/src/erc721/erc721.cairo index 353e84f93..d19a82cbd 100644 --- a/packages/token/src/erc721/erc721.cairo +++ b/packages/token/src/erc721/erc721.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (token/erc721/erc721.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (token/erc721/erc721.cairo) /// # ERC721 Component /// diff --git a/packages/token/src/erc721/erc721_receiver.cairo b/packages/token/src/erc721/erc721_receiver.cairo index a1c6d16ed..740dc701f 100644 --- a/packages/token/src/erc721/erc721_receiver.cairo +++ b/packages/token/src/erc721/erc721_receiver.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (token/erc721/erc721_receiver.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (token/erc721/erc721_receiver.cairo) /// # ERC721Receiver Component /// diff --git a/packages/token/src/erc721/extensions/erc721_enumerable/erc721_enumerable.cairo b/packages/token/src/erc721/extensions/erc721_enumerable/erc721_enumerable.cairo index 058a79ada..2b0629810 100644 --- a/packages/token/src/erc721/extensions/erc721_enumerable/erc721_enumerable.cairo +++ b/packages/token/src/erc721/extensions/erc721_enumerable/erc721_enumerable.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 +// OpenZeppelin Contracts for Cairo v0.17.0 // (token/erc721/extensions/erc721_enumerable/erc721_enumerable.cairo) /// # ERC721Enumerable Component diff --git a/packages/token/src/erc721/extensions/erc721_enumerable/interface.cairo b/packages/token/src/erc721/extensions/erc721_enumerable/interface.cairo index 0d56f32e6..29073b61b 100644 --- a/packages/token/src/erc721/extensions/erc721_enumerable/interface.cairo +++ b/packages/token/src/erc721/extensions/erc721_enumerable/interface.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 +// OpenZeppelin Contracts for Cairo v0.17.0 // (token/erc721/extensions/erc721_enumerable/interface.cairo) use starknet::ContractAddress; diff --git a/packages/token/src/erc721/interface.cairo b/packages/token/src/erc721/interface.cairo index 5f81898cd..e5f292e28 100644 --- a/packages/token/src/erc721/interface.cairo +++ b/packages/token/src/erc721/interface.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (token/erc721/interface.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (token/erc721/interface.cairo) use starknet::ContractAddress; diff --git a/packages/upgrades/README.md b/packages/upgrades/README.md index 18f4f4fbe..f48cb4762 100644 --- a/packages/upgrades/README.md +++ b/packages/upgrades/README.md @@ -1,13 +1,13 @@ ## Upgrades -> **NOTE:** This document is better viewed at https://docs.openzeppelin.com/contracts-cairo/api/upgrades +> **NOTE:** This document is better viewed at [https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/upgrades](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/upgrades) This crate provides an interface and component used for upgradeability. ### Interfaces -- `IUpgradeable` +- [`IUpgradeable`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/upgrades#IUpgradeable) ### Components -- `UpgradeableComponent` +- [`UpgradeableComponent`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/upgrades#UpgradeableComponent) diff --git a/packages/upgrades/src/interface.cairo b/packages/upgrades/src/interface.cairo index 566b8ec8a..63892423b 100644 --- a/packages/upgrades/src/interface.cairo +++ b/packages/upgrades/src/interface.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (upgrades/interface.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (upgrades/interface.cairo) use starknet::ClassHash; diff --git a/packages/upgrades/src/upgradeable.cairo b/packages/upgrades/src/upgradeable.cairo index 6729d7917..2879130da 100644 --- a/packages/upgrades/src/upgradeable.cairo +++ b/packages/upgrades/src/upgradeable.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (upgrades/upgradeable.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (upgrades/upgradeable.cairo) /// # Upgradeable Component /// diff --git a/packages/utils/README.md b/packages/utils/README.md index f904f11cd..bb6cdc520 100644 --- a/packages/utils/README.md +++ b/packages/utils/README.md @@ -1,19 +1,19 @@ -## Upgrades +## Utils -> **NOTE:** This document is better viewed at https://docs.openzeppelin.com/contracts-cairo/api/utilities +> **NOTE:** This document is better viewed at [https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/utilities](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/utilities) This crate provides components and libraries containing miscellaneous utilities. ### Core utilities -- `utils` -- `cryptography` -- `deployments` -- `math` -- `selectors` -- `serde` +- [`utils`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/utilities#utils) +- [`cryptography`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/utilities#cryptography) +- [`deployments`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/utilities#deployments) +- [`math`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/utilities#math) +- [`selectors`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/utilities#selectors) +- [`serde`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/utilities#serde) ### Cryptography -- `NoncesComponent` -- `snip12` +- [`NoncesComponent`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/utilities#NoncesComponent) +- [`snip12`](https://docs.openzeppelin.com/contracts-cairo/0.17.0/api/utilities#snip12) diff --git a/packages/utils/src/cryptography/interface.cairo b/packages/utils/src/cryptography/interface.cairo index caace02ef..cb7c314f6 100644 --- a/packages/utils/src/cryptography/interface.cairo +++ b/packages/utils/src/cryptography/interface.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (utils/cryptography/interface.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (utils/cryptography/interface.cairo) use starknet::ContractAddress; diff --git a/packages/utils/src/cryptography/nonces.cairo b/packages/utils/src/cryptography/nonces.cairo index 2473c3f33..c4f97f724 100644 --- a/packages/utils/src/cryptography/nonces.cairo +++ b/packages/utils/src/cryptography/nonces.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (utils/cryptography/nonces.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (utils/cryptography/nonces.cairo) /// # Nonces Component /// diff --git a/packages/utils/src/cryptography/snip12.cairo b/packages/utils/src/cryptography/snip12.cairo index f227c62dc..39f460fa3 100644 --- a/packages/utils/src/cryptography/snip12.cairo +++ b/packages/utils/src/cryptography/snip12.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (utils/cryptography/snip12.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (utils/cryptography/snip12.cairo) use core::hash::{HashStateTrait, HashStateExTrait}; use core::poseidon::PoseidonTrait; diff --git a/packages/utils/src/deployments.cairo b/packages/utils/src/deployments.cairo index 3876d5188..9954c4f51 100644 --- a/packages/utils/src/deployments.cairo +++ b/packages/utils/src/deployments.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (utils/deployments.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (utils/deployments.cairo) pub mod interface; diff --git a/packages/utils/src/deployments/interface.cairo b/packages/utils/src/deployments/interface.cairo index 542cf5914..da8c8cf1d 100644 --- a/packages/utils/src/deployments/interface.cairo +++ b/packages/utils/src/deployments/interface.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (utils/deployments/interface.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (utils/deployments/interface.cairo) use starknet::{ClassHash, ContractAddress}; diff --git a/packages/utils/src/lib.cairo b/packages/utils/src/lib.cairo index c5bba5098..074486181 100644 --- a/packages/utils/src/lib.cairo +++ b/packages/utils/src/lib.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (utils/lib.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (utils/lib.cairo) pub mod cryptography; pub mod deployments; diff --git a/packages/utils/src/math.cairo b/packages/utils/src/math.cairo index 5c99f6498..a21e245d7 100644 --- a/packages/utils/src/math.cairo +++ b/packages/utils/src/math.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (utils/math.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (utils/math.cairo) use core::traits::{Into, BitAnd, BitXor}; diff --git a/packages/utils/src/selectors.cairo b/packages/utils/src/selectors.cairo index 32f8a964c..90281206e 100644 --- a/packages/utils/src/selectors.cairo +++ b/packages/utils/src/selectors.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (utils/selectors.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (utils/selectors.cairo) // // AccessControl diff --git a/packages/utils/src/serde.cairo b/packages/utils/src/serde.cairo index b59936339..872adcbdf 100644 --- a/packages/utils/src/serde.cairo +++ b/packages/utils/src/serde.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (utils/serde.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (utils/serde.cairo) pub trait SerializedAppend { fn append_serde(ref self: Array, value: T); diff --git a/packages/utils/src/structs/checkpoint.cairo b/packages/utils/src/structs/checkpoint.cairo index abb6bca4b..f4e2e1b55 100644 --- a/packages/utils/src/structs/checkpoint.cairo +++ b/packages/utils/src/structs/checkpoint.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (utils/structs/checkpoint.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (utils/structs/checkpoint.cairo) use core::num::traits::Sqrt; use crate::math; diff --git a/packages/utils/src/structs/storage_array.cairo b/packages/utils/src/structs/storage_array.cairo index a53ec4822..ee960cb8a 100644 --- a/packages/utils/src/structs/storage_array.cairo +++ b/packages/utils/src/structs/storage_array.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (utils/structs/storage_array.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (utils/structs/storage_array.cairo) use core::hash::{HashStateExTrait, HashStateTrait}; use core::poseidon::PoseidonTrait; diff --git a/packages/utils/src/unwrap_and_cast.cairo b/packages/utils/src/unwrap_and_cast.cairo index 25a5b208f..a21d36004 100644 --- a/packages/utils/src/unwrap_and_cast.cairo +++ b/packages/utils/src/unwrap_and_cast.cairo @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// OpenZeppelin Contracts for Cairo v0.16.0 (utils/unwrap_and_cast.cairo) +// OpenZeppelin Contracts for Cairo v0.17.0 (utils/unwrap_and_cast.cairo) use starknet::SyscallResult; use starknet::SyscallResultTrait;