diff --git a/content/contracts-cairo/4.x/accounts.mdx b/content/contracts-cairo/4.x/accounts.mdx index 2eaabca0..9a89c4f3 100644 --- a/content/contracts-cairo/4.x/accounts.mdx +++ b/content/contracts-cairo/4.x/accounts.mdx @@ -330,24 +330,25 @@ Next, create the account JSON with Starknet Foundry’s [custom account setup](h The flag enables custom account variants. -The following examples use `sncast` [v0.23.0](https://github.com/foundry-rs/starknet-foundry/releases/tag/v0.23.0). +The following examples use `sncast` [v0.63.0](https://github.com/foundry-rs/starknet-foundry/releases/tag/v0.63.0). ```bash $ sncast \ - --url http://127.0.0.1:5050 \ account create \ + --url http://127.0.0.1:5050 \ --name my-custom-account \ + --type oz \ --class-hash 0x123456... ``` -This command will output the precomputed contract address and the recommended `max-fee`. -To counterfactually deploy the account, send funds to the address and then deploy the custom account. +This command will output the precomputed contract address and the estimated deployment fee. +To counterfactually deploy the account, prefund the address and then deploy the custom account. ```bash $ sncast \ - --url http://127.0.0.1:5050 \ account deploy \ + --url http://127.0.0.1:5050 \ --name my-custom-account ``` @@ -356,8 +357,8 @@ Once the account is deployed, set the `--account` flag with the custom account n ```bash $ sncast \ --account my-custom-account \ - --url http://127.0.0.1:5050 \ invoke \ + --url http://127.0.0.1:5050 \ --contract-address 0x123... \ --function "some_function" \ --calldata 1 2 3 @@ -413,10 +414,6 @@ The following examples utilize the [StarknetJS](https://www.starknet-js.com/) li Compile and declare the contract on the target network. Next, precompute the EthAccount contract address using the declared class hash. - -The following examples use unreleased features from StarknetJS (`starknetjs@next`) at commit [d002baea0abc1de3ac6e87a671f3dec3757437b3](https://github.com/starknet-io/starknet.js/commit/d002baea0abc1de3ac6e87a671f3dec3757437b3). - - ```javascript import * as dotenv from 'dotenv'; import { CallData, EthSigner, hash } from 'starknet'; diff --git a/content/contracts-cairo/4.x/api/access.mdx b/content/contracts-cairo/4.x/api/access.mdx index e0872335..10ef0748 100644 --- a/content/contracts-cairo/4.x/api/access.mdx +++ b/content/contracts-cairo/4.x/api/access.mdx @@ -115,7 +115,7 @@ Requirements: #### Events [!toc] [#IAccessControl-Events] @@ -450,7 +450,13 @@ Emitted when a [pending\_default\_admin](#IAccessControlDefaultAdminRules-pendin Emitted when a [default\_admin\_delay](#IAccessControlDefaultAdminRules-default_admin_delay) change is started. Sets `new_delay` as the next delay to be applied between default admins transfers after `effect_schedule` has passed. + + Emitted when a [pending\_default\_admin\_delay](#IAccessControlDefaultAdminRules-pending_default_admin_delay) is reset if its schedule didn’t pass. @@ -764,7 +770,7 @@ The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to grant and r - [`AccessControlImpl`](#AccessControlComponent-Embeddable-Impls-AccessControlImpl) - [`AccessControlCamelImpl`](#AccessControlComponent-Embeddable-Impls-AccessControlCamelImpl) - [`AccessControlWithDelayImpl`](#AccessControlComponent-Embeddable-Impls-AccessControlWithDelayImpl) -- [`SRC5Impl`](./introspection#SRC5Component-Embeddable-Impls) +- [`SRC5Impl`](#AccessControlComponent-Embeddable-Impls-SRC5Impl) Embeddable Implementations @@ -878,7 +884,7 @@ Attempts to grant `role` to `account` with the specified activation delay. Requirements: -- The caller must have \`role’s admin role. +- The caller must have `role`’s admin role. - delay must be greater than 0. - the `role` must not be already effective for `account`. @@ -1083,7 +1089,7 @@ May emit a [RoleRevoked](#IAccessControl-RoleRevoked) event. #### Events [!toc] [#AccessControlComponent-Events] @@ -1146,7 +1152,7 @@ This contract implements the following risk mitigations on top of [AccessControl - [`AccessControlImpl`](#AccessControlDefaultAdminRulesComponent-Embeddable-Impls-AccessControlImpl) - [`AccessControlCamelImpl`](#AccessControlDefaultAdminRulesComponent-Embeddable-Impls-AccessControlCamelImpl) - [`AccessControlWithDelayImpl`](#AccessControlDefaultAdminRulesComponent-Embeddable-Impls-AccessControlWithDelayImpl) -- [`SRC5Impl`](./introspection#SRC5Component-Embeddable-Impls) +- [`SRC5Impl`](#AccessControlDefaultAdminRulesComponent-Embeddable-Impls-SRC5Impl) Embeddable Implementations @@ -1452,7 +1458,7 @@ Attempts to grant `role` to `account` with the specified activation delay. Requirements: -- The caller must have \`role’s admin role. +- The caller must have `role`’s admin role. - delay must be greater than 0. - the `role` must not be already effective for `account`. @@ -1608,7 +1614,7 @@ The account may not be able to act as the role yet, if a delay was set and has n id="AccessControlDefaultAdminRulesComponent-set_role_admin" kind="external" > -Sets `admin_role` as \`role’s admin role. +Sets `admin_role` as `role`’s admin role. Internal function without access restriction. @@ -1684,7 +1690,7 @@ May emit a DefaultAdminTransferCanceled event. > Setter of the tuple for pending delay and its schedule. -May emit a DefaultAdminDelayChangeCanceled event. +May emit a [DefaultAdminDelayChangeCanceled](#AccessControlDefaultAdminRulesComponent-DefaultAdminDelayChangeCanceled) event. + Emitted when a [pending\_default\_admin\_delay](#AccessControlDefaultAdminRulesComponent-pending_default_admin_delay) is reset if its schedule didn’t pass. diff --git a/content/contracts-cairo/4.x/api/account.mdx b/content/contracts-cairo/4.x/api/account.mdx index 70993886..ff365b8f 100644 --- a/content/contracts-cairo/4.x/api/account.mdx +++ b/content/contracts-cairo/4.x/api/account.mdx @@ -144,7 +144,7 @@ Implementing [SRC5Component](./introspection#SRC5Component) is a requirement for - [`PublicKeyImpl`](#AccountComponent-Embeddable-Impls-PublicKeyImpl) - [`SRC6CamelOnlyImpl`](#AccountComponent-Embeddable-Impls-SRC6CamelOnlyImpl) - [`PublicKeyCamelImpl`](#AccountComponent-Embeddable-Impls-PublicKeyCamelImpl) -- [`SRC5Impl`](./introspection#SRC5Component-Embeddable-Impls) +- [`SRC5Impl`](#AccountComponent-Embeddable-Impls-SRC5Impl) Embeddable Implementations @@ -160,7 +160,7 @@ Embeddable Implementations #### DeployableImpl [!toc] [#AccountComponent-Embeddable-Impls-DeployableImpl] -- [`__validate_deploy__(self, hash, signature)`](#AccountComponent-__validate_deploy__) +- [`__validate_deploy__(self, class_hash, contract_address_salt, public_key)`](#AccountComponent-__validate_deploy__) #### PublicKeyImpl [!toc] [#AccountComponent-Embeddable-Impls-PublicKeyImpl] @@ -408,7 +408,7 @@ The `EthPublicKey` type is an alias for `starknet::secp256k1::Secp256k1Point`. - [`PublicKeyImpl`](#EthAccountComponent-Embeddable-Impls-PublicKeyImpl) - [`SRC6CamelOnlyImpl`](#EthAccountComponent-Embeddable-Impls-SRC6CamelOnlyImpl) - [`PublicKeyCamelImpl`](#EthAccountComponent-Embeddable-Impls-PublicKeyCamelImpl) -- [`SRC5Impl`](./introspection#SRC5Component-Embeddable-Impls) +- [`SRC5Impl`](#EthAccountComponent-Embeddable-Impls-SRC5Impl) Embeddable Implementations @@ -424,7 +424,7 @@ Embeddable Implementations #### DeployableImpl [!toc] [#EthAccountComponent-Embeddable-Impls-DeployableImpl] -- [`__validate_deploy__(self, hash, signature)`](#EthAccountComponent-__validate_deploy__) +- [`__validate_deploy__(self, class_hash, contract_address_salt, public_key)`](#EthAccountComponent-__validate_deploy__) #### PublicKeyImpl [!toc] [#EthAccountComponent-Embeddable-Impls-PublicKeyImpl] @@ -747,7 +747,7 @@ Embedded Implementations AccountComponent -- [`AccountMixinImpl`](#AccountComponent-Embeddable-Mixin-Impl) +- [`AccountMixinImpl`](#AccountComponent-Embeddable-Impls-AccountMixinImpl) SRC9Component @@ -810,7 +810,7 @@ Embedded Implementations EthAccountComponent -- [`EthAccountMixinImpl`](#EthAccountComponent-Embeddable-Mixin-Impl) +- [`EthAccountMixinImpl`](#EthAccountComponent-Embeddable-Impls-EthAccountMixinImpl) SRC9Component diff --git a/content/contracts-cairo/4.x/api/erc1155.mdx b/content/contracts-cairo/4.x/api/erc1155.mdx index 9c8347b0..5b8e9d92 100644 --- a/content/contracts-cairo/4.x/api/erc1155.mdx +++ b/content/contracts-cairo/4.x/api/erc1155.mdx @@ -8,7 +8,7 @@ This module provides interfaces, presets, and utilities related to ERC1155 contr For an overview of ERC1155, read our [ERC1155 guide](../erc1155). -## [](#interfaces)Interfaces +## Interfaces [#interfaces] The interfaces documented here are provided by the `openzeppelin_interfaces` package version `{{openzeppelin_interfaces_version}}`. @@ -203,7 +203,7 @@ Functions #### Functions [!toc] [#functions_3] @@ -211,7 +211,7 @@ This function is called whenever an ERC1155 `token_id` token is transferred to t @@ -263,7 +263,7 @@ Returns the aggregate supply across all token IDs. Returns whether the total supply of `token_id` is greater than zero. -## [](#core)Core +## Core [#core] ### `ERC1155Component` [toc] [#ERC1155Component] @@ -307,7 +307,7 @@ Defines `uri(self: @ComponentState, token_id: u256) → ByteArray`, which is use use openzeppelin_token::erc1155::ERC1155TokenURIDefaultImpl; ``` -Returns the component's common base URI for every token type. Clients replace the `\{id\}` substring according to the ERC1155 metadata substitution rules. +Returns the component's common base URI for every token type. Clients replace the `{id}` substring according to the ERC1155 metadata substitution rules. #### Hooks [!toc] [#ERC1155Component-Hooks] @@ -324,7 +324,7 @@ Returns the component's common base URI for every token type. Clients replace th - [`ERC1155Impl`](#ERC1155Component-Embeddable-Impls-ERC1155Impl) - [`ERC1155MetadataURIImpl`](#ERC1155Component-Embeddable-Impls-ERC1155MetadataURIImpl) - [`ERC1155CamelImpl`](#ERC1155Component-Embeddable-Impls-ERC1155CamelImpl) -- [`SRC5Impl`](./introspection#SRC5Component-Embeddable-Impls-SRC5Impl) +- [`SRC5Impl`](./introspection#SRC5Component-SRC5Impl) Embeddable Implementations @@ -488,7 +488,7 @@ Queries if `operator` is an authorized operator for `owner`. This implementation returns the same URI for **all** token types. It relies on the token type ID substitution mechanism [specified in the EIP](https://eips.ethereum.org/EIPS/eip-1155#metadata). -Clients calling this function must replace the `id` substring with the actual token type ID. +Clients calling this function must replace the `{id}` substring with the actual token type ID. Sets a new URI for all token types, by relying on the token type ID substitution mechanism [specified in the EIP](https://eips.ethereum.org/EIPS/eip-1155#metadata). -By this mechanism, any occurrence of the `id` substring in either the URI or any of the values in the JSON file at said URI will be replaced by clients with the token type ID. +By this mechanism, any occurrence of the `{id}` substring in either the URI or any of the values in the JSON file at said URI will be replaced by clients with the token type ID. -For example, the `https://token-cdn-domain/\id\.json` URI would be interpreted by clients as `https://token-cdn-domain/000000000000...000000000000004cce0.json` for token type ID `0x4cce0`. +For example, the `https://token-cdn-domain/{id}.json` URI would be interpreted by clients as `https://token-cdn-domain/000000000000...000000000000004cce0.json` for token type ID `0x4cce0`. Because these URIs cannot be meaningfully represented by the `URI` event, this function emits no events. @@ -726,7 +726,7 @@ Implementing [SRC5Component](./introspection#SRC5Component) is a requirement for - [`ERC1155ReceiverImpl`](#ERC1155ReceiverComponent-Embeddable-Impls-ERC1155ReceiverImpl) - [`ERC1155ReceiverCamelImpl`](#ERC1155ReceiverComponent-Embeddable-Impls-ERC1155ReceiverCamelImpl) -- [`SRC5Impl`](./introspection#SRC5Component-Embeddable-Impls-SRC5Impl) +- [`SRC5Impl`](./introspection#SRC5Component-SRC5Impl) Embeddable Implementations @@ -749,7 +749,7 @@ Internal Functions #### Embeddable functions [!toc] [#embeddable_functions_2] @@ -757,7 +757,7 @@ Returns the `IERC1155Receiver` interface ID. @@ -765,7 +765,7 @@ Returns the `IERC1155Receiver` interface ID. @@ -773,7 +773,7 @@ See [ERC1155ReceiverComponent::on\_erc1155\_received](#ERC1155ReceiverComponent- @@ -945,7 +945,7 @@ Stores `token_uri` as the token-specific suffix for `token_id` and emits the cor Sets the base URI used when a token-specific suffix is present. This function emits no event. -## [](#presets)Presets +## Presets [#presets] ### `ERC1155Upgradeable` [toc] [#ERC1155Upgradeable] @@ -974,11 +974,11 @@ Embedded Implementations ERC1155Component -- [`ERC1155MixinImpl`](#ERC1155Component-Embeddable-Mixin-Impl) +- [`ERC1155MixinImpl`](#ERC1155Component-Embeddable-Impls-ERC1155MixinImpl) OwnableMixinImpl -- [`OwnableMixinImpl`](./access#OwnableComponent-Mixin-Impl) +- [`OwnableMixinImpl`](./access#OwnableComponent-Embeddable-Impls-OwnableMixinImpl) External Functions diff --git a/content/contracts-cairo/4.x/api/erc20.mdx b/content/contracts-cairo/4.x/api/erc20.mdx index 23eea620..6b4f2996 100644 --- a/content/contracts-cairo/4.x/api/erc20.mdx +++ b/content/contracts-cairo/4.x/api/erc20.mdx @@ -6,7 +6,7 @@ This module provides interfaces, presets, and utilities related to ERC20 contrac For an overview of ERC20, read our [ERC20 guide](../erc20). -## [](#interfaces)Interfaces +## Interfaces [#interfaces] The interfaces documented here are provided by the `openzeppelin_interfaces` package version `{{openzeppelin_interfaces_version}}`. @@ -63,7 +63,7 @@ Returns the amount of tokens owned by `account`. id="IERC20-allowance" kind="external" > -Returns the remaining number of tokens that `spender` is allowed to spend on behalf of `owner` through [transfer\_from](#transfer_from). This is zero by default. +Returns the remaining number of tokens that `spender` is allowed to spend on behalf of `owner` through [transfer\_from](#IERC20-transfer_from). This is zero by default. This value changes when [approve](#IERC20-approve) or [transfer\_from](#IERC20-transfer_from) are called. @@ -95,7 +95,7 @@ Emits a [Transfer](#IERC20-Transfer) event. > Sets `amount` as the allowance of `spender` over the caller's tokens. Returns `true` on success, reverts otherwise. -Emits an [Approval](#ERC20-Approval) event. +Emits an [Approval](#IERC20-Approval) event. #### Events [!toc] [#IERC20-Events] @@ -163,7 +163,7 @@ Returns the number of decimals the token uses - e.g. `8` means to divide the tok For example, if `decimals` equals `2`, a balance of `505` tokens should be displayed to a user as `5.05` (`505 / 10 ** 2`). -Tokens usually opt for a value of `18`, imitating the relationship between Ether and Wei. This is the default value returned by this function. To create a custom decimals implementation, see [Customizing decimals](../erc20#customizing_decimals). +Tokens usually opt for a value of `18`, imitating the relationship between Ether and Wei. This is the default value returned by this function. To create a custom decimals implementation, see [Customizing decimals](../erc20#customizing-decimals). This information is only used for *display* purposes: it in no way affects any of the arithmetic of the contract. @@ -866,7 +866,7 @@ Supports the Cairo v0 convention of writing external methods in camelCase as dis @@ -890,7 +890,7 @@ Requirements: - `signature` is a valid signature that can be validated with a call to `owner` account. - `signature` must use the current nonce of the `owner`. -Emits an [Approval](#ERC20-Approval) event. Every successful call increases \`owner's nonce by one. +Emits an [Approval](#ERC20Component-Approval) event. Every successful call increases `owner`'s nonce by one. The interfaces documented here are provided by the `openzeppelin_interfaces` package version `{{openzeppelin_interfaces_version}}`. @@ -72,7 +72,7 @@ Returns the owner address of `token_id`. id="IERC721-safe_transfer_from" kind="external" > -Transfer ownership of `token_id` from `from` to `to`, checking first that `to` is aware of the ERC721 protocol to prevent tokens being locked forever. For information regarding how contracts communicate their awareness of the ERC721 protocol, see [Receiving Tokens](../erc721#receiving_tokens). +Transfer ownership of `token_id` from `from` to `to`, checking first that `to` is aware of the ERC721 protocol to prevent tokens being locked forever. For information regarding how contracts communicate their awareness of the ERC721 protocol, see [Receiving Tokens](../erc721#receiving-tokens). Emits a [Transfer](#IERC721-Transfer) event. @@ -450,7 +450,7 @@ Hooks - [`ERC721MetadataImpl`](#ERC721Component-Embeddable-Impls-ERC721MetadataImpl) - [`ERC721CamelOnlyImpl`](#ERC721Component-Embeddable-Impls-ERC721CamelOnlyImpl) - [`ERC721MetadataCamelOnlyImpl`](#ERC721Component-Embeddable-Impls-ERC721MetadataCamelOnlyImpl) -- [`SRC5Impl`](./introspection#SRC5Component-Embeddable-Impls) +- [`SRC5Impl`](#ERC721Component-Embeddable-Impls-SRC5Impl) Embeddable Implementations @@ -543,7 +543,7 @@ Function executed at the beginning of the [update](#ERC721Component-update) func Function executed at the end of the [update](#ERC721Component-update) function. -#### [](#embeddable_functions)Embeddable functions [!toc] [#embeddable_functions] +#### Embeddable functions [!toc] [#embeddable_functions] -#### [](#internal_functions)Internal functions [!toc] [#internal_functions] +#### Internal functions [!toc] [#internal_functions] Internal function that returns whether `token_id` exists. -Tokens start existing when they are minted ([mint](#ERC721-mint)), and stop existing when they are burned ([burn](#ERC721-burn)). +Tokens start existing when they are minted ([mint](#ERC721Component-mint)), and stop existing when they are burned ([burn](#ERC721Component-burn)). -#### [](#events_2)Events [!toc] [#events_2] +#### Events [!toc] [#events_2] @@ -1058,14 +1058,14 @@ Returns the `IERC721Receiver` interface ID. See [ERC721ReceiverComponent::on\_erc721\_received](#ERC721ReceiverComponent-on_erc721_received). -#### [](#internal_functions_2)Internal functions [!toc] [#internal_functions_2] +#### Internal functions [!toc] [#internal_functions_2] -#### [](#ERC721EnumerableComponent-Internal-functions)Internal functions [!toc] [#ERC721EnumerableComponent-Internal-functions] +#### Internal functions [!toc] [#ERC721EnumerableComponent-Internal-functions] -#### [](#ERC721Upgradeable-external-functions)External functions [!toc] [#ERC721Upgradeable-external-functions] +#### External functions [!toc] [#ERC721Upgradeable-external-functions] The interfaces documented here are provided by the `openzeppelin_interfaces` package version `{{openzeppelin_interfaces_version}}`. @@ -118,7 +118,7 @@ May emit an [AmountReleased](#IVesting-AmountReleased) event. Emitted when vested tokens are released to the beneficiary. -## [](#vesting)Vesting +## Vesting [#vesting] ### `VestingComponent` [toc] [#VestingComponent] @@ -264,7 +264,7 @@ Requirements: id="VestingComponent-resolve_vested_amount" kind="internal" > -Returns the vested amount that's calculated using the [VestingSchedule](#VestingComponent-Vesting-Schedule) trait implementation. +Returns the vested amount that's calculated using the [VestingSchedule](#VestingComponent-Vesting-Schedule-functions) trait implementation. ### `LinearVestingSchedule` [toc] [#LinearVestingSchedule] @@ -280,7 +280,7 @@ 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)Presets +## Presets [#presets] ### `VestingWallet` [toc] [#VestingWallet] @@ -315,7 +315,7 @@ VestingComponent OwnableComponent -- [`OwnableMixinImpl`](./access#OwnableComponent-Mixin-Impl) +- [`OwnableMixinImpl`](./access#OwnableComponent-Embeddable-Impls-OwnableMixinImpl) #### Constructor [!toc] [#VestingWallet-constructor-section] diff --git a/content/contracts-cairo/4.x/api/governance.mdx b/content/contracts-cairo/4.x/api/governance.mdx index 9ffe5c50..4aef5dfe 100644 --- a/content/contracts-cairo/4.x/api/governance.mdx +++ b/content/contracts-cairo/4.x/api/governance.mdx @@ -6,7 +6,7 @@ import { API_SOURCE_VERSION } from "../utils/constants.js"; This crate includes primitives for on-chain governance. -## [](#interfaces)Interfaces +## Interfaces [#interfaces] The interfaces documented here are provided by the `openzeppelin_interfaces` package version `{{openzeppelin_interfaces_version}}`. @@ -53,12 +53,12 @@ Functions - [`propose(calls, description)`](#IGovernor-propose) - [`queue(calls, description_hash)`](#IGovernor-queue) - [`execute(calls, description_hash)`](#IGovernor-execute) -- [`cancel(proposal_id, description_hash)`](#IGovernor-cancel) +- [`cancel(calls, description_hash)`](#IGovernor-cancel) - [`cast_vote(proposal_id, support)`](#IGovernor-cast_vote) - [`cast_vote_with_reason(proposal_id, support, reason)`](#IGovernor-cast_vote_with_reason) - [`cast_vote_with_reason_and_params(proposal_id, support, reason, params)`](#IGovernor-cast_vote_with_reason_and_params) -- [`cast_vote_by_sig(proposal_id, support, reason, signature)`](#IGovernor-cast_vote_by_sig) -- [`cast_vote_with_reason_and_params_by_sig(proposal_id, support, reason, params, signature)`](#IGovernor-cast_vote_with_reason_and_params_by_sig) +- [`cast_vote_by_sig(proposal_id, support, voter, signature)`](#IGovernor-cast_vote_by_sig) +- [`cast_vote_with_reason_and_params_by_sig(proposal_id, support, voter, reason, params, signature)`](#IGovernor-cast_vote_with_reason_and_params_by_sig) - [`nonces(voter)`](#IGovernor-nonces) - [`relay(call)`](#IGovernor-relay) @@ -1117,7 +1117,7 @@ Requirements: @@ -1128,7 +1128,7 @@ Requirements: - The output MUST be formatted like a URL query string, decodable in standard JavaScript. -## [](#governor)Governor +## Governor [#governor] This modular system of Governor components allows the deployment of easily customizable on-chain voting protocols. @@ -1210,12 +1210,12 @@ Embeddable Implementations - [`propose(self, calls, description)`](#GovernorComponent-propose) - [`queue(self, calls, description_hash)`](#GovernorComponent-queue) - [`execute(self, calls, description_hash)`](#GovernorComponent-execute) -- [`cancel(self, proposal_id, description_hash)`](#GovernorComponent-cancel) +- [`cancel(self, calls, description_hash)`](#GovernorComponent-cancel) - [`cast_vote(self, proposal_id, support)`](#GovernorComponent-cast_vote) - [`cast_vote_with_reason(self, proposal_id, support, reason)`](#GovernorComponent-cast_vote_with_reason) - [`cast_vote_with_reason_and_params(self, proposal_id, support, reason, params)`](#GovernorComponent-cast_vote_with_reason_and_params) -- [`cast_vote_by_sig(self, proposal_id, support, reason, signature)`](#GovernorComponent-cast_vote_by_sig) -- [`cast_vote_with_reason_and_params_by_sig(self, proposal_id, support, reason, params, signature)`](#GovernorComponent-cast_vote_with_reason_and_params_by_sig) +- [`cast_vote_by_sig(self, proposal_id, support, voter, signature)`](#GovernorComponent-cast_vote_by_sig) +- [`cast_vote_with_reason_and_params_by_sig(self, proposal_id, support, voter, reason, params, signature)`](#GovernorComponent-cast_vote_with_reason_and_params_by_sig) - [`nonces(self, voter)`](#GovernorComponent-nonces) - [`relay(self, call)`](#GovernorComponent-relay) @@ -1248,7 +1248,7 @@ Internal Implementations Events - [`ProposalCreated(proposal_id, proposer, calls, signatures, vote_start, vote_end, description)`](#GovernorComponent-ProposalCreated) -- [`ProposalQueued(proposal_id)`](#GovernorComponent-ProposalQueued) +- [`ProposalQueued(proposal_id, eta_seconds)`](#GovernorComponent-ProposalQueued) - [`ProposalExecuted(proposal_id)`](#GovernorComponent-ProposalExecuted) - [`ProposalCanceled(proposal_id)`](#GovernorComponent-ProposalCanceled) - [`VoteCast(voter, proposal_id, support, weight, reason)`](#GovernorComponent-VoteCast) @@ -1393,7 +1393,7 @@ When the executor is not the governor itself (i.e. a timelock), it can call func @@ -1402,7 +1402,7 @@ Execution mechanism. Can be used to modify the way operations are executed (for @@ -1414,7 +1414,7 @@ Requirements: @@ -1422,7 +1422,7 @@ Must return whether proposals need to be queued before execution. This usually i @@ -1868,7 +1868,7 @@ When the executor is not the governor itself (i.e. a timelock), it can call func @@ -1876,7 +1876,7 @@ Validates that a proposal is in the expected state. Otherwise it panics. @@ -1912,7 +1912,7 @@ Requirements: @@ -1926,7 +1926,7 @@ Emits a [ProposalCreated](#GovernorComponent-ProposalCreated) event. @@ -2010,9 +2010,9 @@ Emitted when a vote is cast. Emitted when a vote is cast with params. -## [](#governor_extensions)Governor extensions +## Governor extensions [#governor_extensions] -The Governor component can (and must) be extended by implementing the [extensions traits](#GovernorComponent-Extensions-Traits-Traits) to add the desired functionality. This can be achieved by directly implementing the traits on your contract, or by using a set of ready-to-use extensions provided by the library, which are presented below. +The Governor component can (and must) be extended by implementing the [extensions traits](#GovernorComponent-Extensions-Traits) to add the desired functionality. This can be achieved by directly implementing the traits on your contract, or by using a set of ready-to-use extensions provided by the library, which are presented below. ### `GovernorCoreExecutionComponent` [toc] [#GovernorCoreExecutionComponent] @@ -2759,7 +2759,7 @@ Returns the timelock controller address. @@ -2840,7 +2840,7 @@ Emits a [TimelockUpdated](#GovernorTimelockExecutionComponent-TimelockUpdated) e Emitted when the timelock controller is updated. -## [](#multisig)Multisig +## Multisig [#multisig] A Multisig module enhances security and decentralization by requiring multiple signers to approve and execute transactions. Features include configurable quorum, signer management, and self-administration, ensuring collective decision-making and transparency for critical operations. @@ -3369,7 +3369,7 @@ Emitted when a transaction is executed. Emitted when a new transaction is submitted with non-zero salt. -## [](#timelock)Timelock +## Timelock [#timelock] In a governance system, `TimelockControllerComponent` is in charge of introducing a delay between a proposal and its execution. @@ -3390,10 +3390,10 @@ Component that implements [ITimelock](#ITimelock) and enables the implementing c #### TimelockMixinImpl [!toc] [#TimelockControllerComponent-TimelockMixinImpl] -- [`TimelockImpl`](#TimelockControllerComponent-Embeddable-Impls-TimelockImpl) -- [`SRC5Impl`](./introspection#SRC5Component-Embeddable-Impls) -- [`AccessControlImpl`](./access#AccessControlComponent-Embeddable-Impls) -- [`AccessControlCamelImpl`](./access#AccessControlComponent-Embeddable-Impls) +- [`TimelockImpl`](#TimelockControllerComponent-TimelockImpl) +- [`SRC5Impl`](#TimelockControllerComponent-SRC5Impl) +- [`AccessControlImpl`](#TimelockControllerComponent-AccessControlImpl) +- [`AccessControlCamelImpl`](#TimelockControllerComponent-AccessControlCamelImpl) Embeddable Implementations @@ -3429,11 +3429,11 @@ Embeddable Implementations #### AccessControlCamelImpl [!toc] [#TimelockControllerComponent-AccessControlCamelImpl] -- [`hasRole(self, role, account)`](./access#IAccessControl-hasRole) -- [`getRoleAdmin(self, role)`](./access#IAccessControl-getRoleAdmin) -- [`grantRole(self, role, account)`](./access#IAccessControl-grantRole) -- [`revokeRole(self, role, account)`](./access#IAccessControl-revokeRole) -- [`renounceRole(self, role, account)`](./access#IAccessControl-renounceRole) +- [`hasRole(self, role, account)`](./access#AccessControlComponent-hasRole) +- [`getRoleAdmin(self, role)`](./access#AccessControlComponent-getRoleAdmin) +- [`grantRole(self, role, account)`](./access#AccessControlComponent-grantRole) +- [`revokeRole(self, role, account)`](./access#AccessControlComponent-revokeRole) +- [`renounceRole(self, role, account)`](./access#AccessControlComponent-renounceRole) Internal Implementations @@ -3639,7 +3639,7 @@ Emits a [MinDelayChanged](#TimelockControllerComponent-MinDelayChanged) event. #### Internal functions [!toc] [#TimelockControllerComponent-InternalFunctions] @@ -3770,7 +3770,7 @@ Emitted when operation `id` is cancelled. Emitted when the minimum delay for future operations is modified. -## [](#votes)Votes +## Votes [#votes] The `VotesComponent` provides a flexible system for tracking and delegating voting power. This system allows users to delegate their voting power to other addresses, enabling more active participation in governance. @@ -3946,7 +3946,7 @@ Requirements: diff --git a/content/contracts-cairo/4.x/api/introspection.mdx b/content/contracts-cairo/4.x/api/introspection.mdx index 38e16639..448fb55b 100644 --- a/content/contracts-cairo/4.x/api/introspection.mdx +++ b/content/contracts-cairo/4.x/api/introspection.mdx @@ -6,7 +6,7 @@ import { API_SOURCE_VERSION } from "../utils/constants.js"; 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. -## [](#interfaces)Interfaces +## Interfaces [#interfaces] The interfaces documented here are provided by the `openzeppelin_interfaces` package version `{{openzeppelin_interfaces_version}}`. @@ -47,7 +47,7 @@ Checks whether the contract implements the given interface. Check [Computing the Interface ID](../introspection#computing-the-interface-id) for more information on how to compute this ID. -## [](#core)Core +## Core [#core] ### `SRC5Component` [toc] [#SRC5Component] diff --git a/content/contracts-cairo/4.x/api/merkle-tree.mdx b/content/contracts-cairo/4.x/api/merkle-tree.mdx index 41af4b21..046eb129 100644 --- a/content/contracts-cairo/4.x/api/merkle-tree.mdx +++ b/content/contracts-cairo/4.x/api/merkle-tree.mdx @@ -17,9 +17,9 @@ To use it as a standalone package, you can add it in your `Scarb.toml` as follow `openzeppelin_merkle_tree = "{{umbrella_version}}"` -## [](#modules)Modules +## Modules [#modules] -### [](#merkle_proof)`merkle_proof` [toc] [#merkle_proof] +### `merkle_proof` [toc] [#merkle_proof] @@ -42,7 +42,7 @@ Functions - [`verify_multi_proof(proof, proof_flags, root, leaves)`](#merkle_proof-verify_multi_proof) - [`process_multi_proof(proof, proof_flags, leaf)`](#merkle_proof-process_multi_proof) -#### [](#merkle_proof-Functions)Functions [!toc] +#### Functions [!toc] [#merkle_proof-Functions] -### [](#hashes)`hashes` [toc] [#hashes] +### `hashes` [toc] [#hashes] @@ -146,7 +146,7 @@ Impls - [`PedersenCHasher`](#hashes-PedersenCHasher) - [`PoseidonCHasher`](#hashes-PoseidonCHasher) -#### [](#hashes-Traits)Traits [!toc] +#### Traits [!toc] [#hashes-Traits] -#### [](#hashes-Impls)Impls [!toc] +#### Impls [!toc] [#hashes-Impls] @@ -30,7 +30,7 @@ InternalImpl - [`initialize(self)`](#InitializableComponent-initialize) -#### [](#InitializableComponent-Embeddable-Functions)Embeddable functions [!toc] +#### Embeddable functions [!toc] [#InitializableComponent-Embeddable-Functions] -#### [](#InitializableComponent-Internal-Functions)Internal functions [!toc] +#### Internal functions [!toc] [#InitializableComponent-Internal-Functions] -## [](#pausable)Pausable +## Pausable [#pausable] -### [](#PausableComponent)`PausableComponent` [toc] [#PausableComponent] +### `PausableComponent` [toc] [#PausableComponent] @@ -86,7 +86,7 @@ Events - [`Paused(account)`](#PausableComponent-Paused) - [`Unpaused(account)`](#PausableComponent-Unpaused) -#### [](#PausableComponent-Embeddable-Functions)Embeddable functions [!toc] +#### Embeddable functions [!toc] [#PausableComponent-Embeddable-Functions] -#### [](#PausableComponent-Internal-Functions)Internal functions [!toc] +#### Internal functions [!toc] [#PausableComponent-Internal-Functions] -#### [](#PausableComponent-Events)Events [!toc] +#### Events [!toc] [#PausableComponent-Events] -## [](#reentrancyguard)ReentrancyGuard +## ReentrancyGuard [#reentrancyguard] -### [](#ReentrancyGuardComponent)`ReentrancyGuardComponent` [toc] [#ReentrancyGuardComponent] +### `ReentrancyGuardComponent` [toc] [#ReentrancyGuardComponent] @@ -179,7 +179,7 @@ InternalImpl - [`start(self)`](#ReentrancyGuardComponent-start) - [`end(self)`](#ReentrancyGuardComponent-end) -#### [](#ReentrancyGuardComponent-Internal-Functions)Internal functions [!toc] +#### Internal functions [!toc] [#ReentrancyGuardComponent-Internal-Functions] The interfaces documented here are provided by the `openzeppelin_interfaces` package version `{{openzeppelin_interfaces_version}}`. -### [](#IERC2981)`IERC2981` [toc] [#IERC2981] +### `IERC2981` [toc] [#IERC2981] @@ -32,7 +32,7 @@ Functions - [`royalty_info(token_id, sale_price)`](#IERC2981-royalty_info) -#### [](#IERC2981-Functions)Functions [!toc] +#### Functions [!toc] [#IERC2981-Functions] -### [](#IERC2981Info)`IERC2981Info` [toc] [#IERC2981Info] +### `IERC2981Info` [toc] [#IERC2981Info] @@ -57,7 +57,7 @@ Functions - [`default_royalty()`](#IERC2981Info-default_royalty) - [`token_royalty(token_id)`](#IERC2981Info-token_royalty) -#### [](#IERC2981Info-Functions)Functions [!toc] +#### Functions [!toc] [#IERC2981Info-Functions] -### [](#IERC2981Admin)`IERC2981Admin` [toc] [#IERC2981Admin] +### `IERC2981Admin` [toc] [#IERC2981Admin] @@ -104,7 +104,7 @@ Functions - [`set_token_royalty(token_id, receiver, fee_numerator)`](#IERC2981Admin-set_token_royalty) - [`reset_token_royalty(token_id)`](#IERC2981Admin-reset_token_royalty) -#### [](#IERC2981Admin-Functions)Functions [!toc] +#### Functions [!toc] [#IERC2981Admin-Functions] -## [](#erc2981)ERC2981 +## ERC2981 [#erc2981] -### [](#ERC2981Component)`ERC2981Component` [toc] [#ERC2981Component] +### `ERC2981Component` [toc] [#ERC2981Component] @@ -204,7 +204,7 @@ InternalImpl - [`_set_token_royalty(self, token_id, receiver, fee_numerator)`](#ERC2981Component-_set_token_royalty) - [`_reset_token_royalty(self, token_id)`](#ERC2981Component-_reset_token_royalty) -#### [](#ERC2981Component-Immutable-Config)Immutable Config constants [!toc] +#### Immutable Config constants [!toc] [#ERC2981Component-Immutable-Config] -#### [](#ERC2981Component-Embeddable-functions)Embeddable functions [!toc] +#### Embeddable functions [!toc] [#ERC2981Component-Embeddable-functions] -#### [](#ERC2981Component-ERC2981AdminOwnableImpl)ERC2981AdminOwnableImpl [!toc] +#### ERC2981AdminOwnableImpl [!toc] [#ERC2981Component-ERC2981AdminOwnableImpl] Provides admin functions for managing royalty settings that are restricted to be called only by the contract's owner. Requires the contract to implement [OwnableComponent](./access#OwnableComponent). @@ -327,7 +327,7 @@ Requirements: - The caller is the contract owner. -#### [](#ERC2981Component-ERC2981AdminAccessControlImpl)ERC2981AdminAccessControlImpl [!toc] +#### ERC2981AdminAccessControlImpl [!toc] [#ERC2981Component-ERC2981AdminAccessControlImpl] Provides admin functions for managing royalty settings that require `ROYALTY_ADMIN_ROLE` to be granted to the caller. Requires the contract to implement [AccessControlComponent](./access#AccessControlComponent). @@ -391,7 +391,7 @@ Requirements: - The caller must have `ROYALTY_ADMIN_ROLE` role. -#### [](#ERC2981Component-ERC2981AdminAccessControlDefaultAdminRulesImpl)ERC2981AdminAccessControlDefaultAdminRulesImpl [!toc] +#### ERC2981AdminAccessControlDefaultAdminRulesImpl [!toc] [#ERC2981Component-ERC2981AdminAccessControlDefaultAdminRulesImpl] An alternative implementation of [IERC2981Admin](#IERC2981Admin). Provides admin functions for managing royalty settings that require `ROYALTY_ADMIN_ROLE` to be granted to the caller. Requires the contract to implement [AccessControlDefaultAdminRulesComponent](./access#AccessControlDefaultAdminRulesComponent). @@ -449,7 +449,7 @@ Requirements: - The caller must have `ROYALTY_ADMIN_ROLE` role. -#### [](#ERC2981Component-Internal-functions)Internal functions [!toc] +#### Internal functions [!toc] [#ERC2981Component-Internal-functions] -Returns the royalty information that all ids in this contract will default to. +Returns the royalty information specific to a token. If no specific royalty information is set for the token, the default is returned. The returned tuple contains: diff --git a/content/contracts-cairo/4.x/api/udc.mdx b/content/contracts-cairo/4.x/api/udc.mdx index 6650d19b..37833149 100644 --- a/content/contracts-cairo/4.x/api/udc.mdx +++ b/content/contracts-cairo/4.x/api/udc.mdx @@ -6,13 +6,13 @@ import { API_SOURCE_VERSION } from "../utils/constants.js"; Reference of the Universal Deployer Contract (UDC) interface and preset. -## [](#interfaces)Interfaces +## Interfaces [#interfaces] The interfaces documented here are provided by the `openzeppelin_interfaces` package version `{{openzeppelin_interfaces_version}}`. -### [](#IUniversalDeployer)`IUniversalDeployer` [toc] [#IUniversalDeployer] +### `IUniversalDeployer` [toc] [#IUniversalDeployer] @@ -28,7 +28,7 @@ Events - [`ContractDeployed(address, deployer, not_from_zero, class_hash, calldata, salt)`](#IUniversalDeployer-ContractDeployed) -#### [](#IUniversalDeployer-Functions)Functions [!toc] +#### Functions [!toc] [#IUniversalDeployer-Functions] -#### [](#IUniversalDeployer-Events)Events [!toc] +#### Events [!toc] [#IUniversalDeployer-Events] -## [](#presets)Presets +## Presets [#presets] -### [](#UniversalDeployer)`UniversalDeployer` [toc] [#UniversalDeployer] +### `UniversalDeployer` [toc] [#UniversalDeployer] @@ -70,12 +70,12 @@ Embedded Implementations UniversalDeployerImpl -- [`deploy_contract(self, address, deployer, not_from_zero, class_hash, calldata, salt)`](#UniversalDeployer-deploy_contract) +- [`deploy_contract(self, class_hash, salt, not_from_zero, calldata)`](#UniversalDeployer-deploy_contract) -#### [](#UniversalDeployer-External-functions)External functions [!toc] +#### External functions [!toc] [#UniversalDeployer-External-functions] diff --git a/content/contracts-cairo/4.x/api/upgrades.mdx b/content/contracts-cairo/4.x/api/upgrades.mdx index 311aab13..1139b204 100644 --- a/content/contracts-cairo/4.x/api/upgrades.mdx +++ b/content/contracts-cairo/4.x/api/upgrades.mdx @@ -6,13 +6,13 @@ import { API_SOURCE_VERSION } from "../utils/constants.js"; This crate provides interfaces and utilities related to upgradeability. -## [](#interfaces)Interfaces +## Interfaces [#interfaces] The interfaces documented here are provided by the `openzeppelin_interfaces` package version `{{openzeppelin_interfaces_version}}`. -### [](#IUpgradeable)`IUpgradeable` [toc] [#IUpgradeable] +### `IUpgradeable` [toc] [#IUpgradeable] @@ -26,7 +26,7 @@ Functions - [`upgrade(new_class_hash)`](#IUpgradeable-upgrade) -#### [](#IUpgradeable-Functions)Functions [!toc] +#### Functions [!toc] [#IUpgradeable-Functions] -### [](#IUpgradeAndCall)`IUpgradeAndCall` [toc] [#IUpgradeAndCall] +### `IUpgradeAndCall` [toc] [#IUpgradeAndCall] @@ -52,7 +52,7 @@ Functions - [`upgrade_and_call(new_class_hash, selector, calldata)`](#IUpgradeAndCall-upgrade_and_call) -#### [](#IUpgradeAndCall-Functions)Functions [!toc] +#### Functions [!toc] [#IUpgradeAndCall-Functions] -## [](#core)Core +## Core [#core] -### [](#UpgradeableComponent)`UpgradeableComponent` [toc] [#UpgradeableComponent] +### `UpgradeableComponent` [toc] [#UpgradeableComponent] @@ -87,7 +87,7 @@ Events - [`Upgraded(class_hash)`](#UpgradeableComponent-Upgraded) -#### [](#UpgradeableComponent-Internal-Functions)Internal Functions [!toc] +#### Internal Functions [!toc] [#UpgradeableComponent-Internal-Functions] -#### [](#UpgradeableComponent-Events)Events [!toc] +#### Events [!toc] [#UpgradeableComponent-Events] -Here’s an example of how to use the Immutable Component Config pattern with the [ERC2981Component](/contracts-cairo/4.x/api/token_common#erc2981component): +Here’s an example of how to use the Immutable Component Config pattern with the [ERC2981Component](/contracts-cairo/4.x/api/token_common#ERC2981Component): ```rust #[starknet::contract] @@ -393,7 +393,7 @@ on how to use this function, refer to the [validate section of the SRC-107](http Some components include dependencies of other components. Contracts that integrate components with dependencies must also include the component dependency. -For instance, [AccessControlComponent](/contracts-cairo/4.x/api/access#accesscontrolcomponent) depends on [SRC5Component](/contracts-cairo/4.x/api/introspection#src5component). +For instance, [AccessControlComponent](/contracts-cairo/4.x/api/access#AccessControlComponent) depends on [SRC5Component](/contracts-cairo/4.x/api/introspection#SRC5Component). Creating a contract with `AccessControlComponent` should look like this: ```rust @@ -567,7 +567,7 @@ mod ERC20Pausable { The first thing to notice is that the contract imports the interfaces of the implementations that will be customized. These will be used in the next code example. -Next, the contract includes the [ERC20Component](/contracts-cairo/4.x/api/erc20#erc20component) implementations; however, `ERC20Impl` and `ERC20CamelOnlyImpl` are **not** embedded. +Next, the contract includes the [ERC20Component](/contracts-cairo/4.x/api/erc20#ERC20Component) implementations; however, `ERC20Impl` and `ERC20CamelOnlyImpl` are **not** embedded. Instead, we want to expose our custom implementation of an interface. The following example shows the pausable logic integrated into the ERC20 implementations: diff --git a/content/contracts-cairo/4.x/erc20.mdx b/content/contracts-cairo/4.x/erc20.mdx index a1435b88..8359210e 100644 --- a/content/contracts-cairo/4.x/erc20.mdx +++ b/content/contracts-cairo/4.x/erc20.mdx @@ -57,8 +57,9 @@ mod MyToken { } ``` -`MyToken` integrates both the `ERC20Impl` and `ERC20MetadataImpl` with the embed directive which marks the implementations as external in the contract. -While the `ERC20MetadataImpl` is optional, it’s generally recommended to include it because the vast majority of ERC20 tokens provide the metadata methods. +`MyToken` integrates the `ERC20MixinImpl` with the embed directive which marks its implementations as external in the contract. +The mixin bundles the ERC20 and ERC20 Metadata implementations, along with the deprecated `camelCase` entrypoints. +Including the metadata methods is generally recommended because the vast majority of ERC20 tokens provide them. The above example also includes the `ERC20InternalImpl` instance. This allows the contract’s constructor to initialize the contract and create an initial supply of tokens. diff --git a/content/contracts-cairo/4.x/erc4626.mdx b/content/contracts-cairo/4.x/erc4626.mdx index 6be11eaa..c7adbb12 100644 --- a/content/contracts-cairo/4.x/erc4626.mdx +++ b/content/contracts-cairo/4.x/erc4626.mdx @@ -205,7 +205,7 @@ proportional to the deposited/withdrawn amount can be implemented: ```rust #[starknet::contract] -#[with_components(./erc20, ERC4626)] +#[with_components(ERC20, ERC4626)] pub mod ERC4626Fees { use openzeppelin_interfaces::erc20::IERC20Dispatcher; use openzeppelin_token::erc20::extensions::erc4626::ERC4626Component::{Fee, FeeConfigTrait}; diff --git a/content/contracts-cairo/4.x/erc721.mdx b/content/contracts-cairo/4.x/erc721.mdx index a00dbf63..5edc4844 100644 --- a/content/contracts-cairo/4.x/erc721.mdx +++ b/content/contracts-cairo/4.x/erc721.mdx @@ -161,7 +161,7 @@ pub trait IERC721Receiver { ``` Implementing the `IERC721Receiver` interface exposes the [on_erc721_received](/contracts-cairo/4.x/api/erc721#IERC721Receiver-on_erc721_received) method. -When safe methods such as [safe_transfer_from](/contracts-cairo/4.x/api/erc721#IERC721-safe_transfer_from) and [safe_mint](/contracts-cairo/4.x/api/erc721#ERC721-safe_mint) are called, they invoke the recipient contract’s `on_erc721_received` method which **must** return the [IERC721Receiver interface ID](/contracts-cairo/4.x/api/erc721#IERC721Receiver). +When safe methods such as [safe_transfer_from](/contracts-cairo/4.x/api/erc721#IERC721-safe_transfer_from) and [safe_mint](/contracts-cairo/4.x/api/erc721#ERC721Component-safe_mint) are called, they invoke the recipient contract’s `on_erc721_received` method which **must** return the [IERC721Receiver interface ID](/contracts-cairo/4.x/api/erc721#IERC721Receiver). Otherwise, the transaction will fail. diff --git a/content/contracts-cairo/4.x/finance.mdx b/content/contracts-cairo/4.x/finance.mdx index 9e0a9998..1381d7f8 100644 --- a/content/contracts-cairo/4.x/finance.mdx +++ b/content/contracts-cairo/4.x/finance.mdx @@ -26,12 +26,12 @@ for a beneficiary until a specified date. ### Vesting schedule -The [VestingSchedule](/contracts-cairo/4.x/api/finance#VestingComponent-Vesting-Schedule) trait defines the logic for calculating the vested amount based on a given timestamp. This +The [VestingSchedule](/contracts-cairo/4.x/api/finance#VestingComponent-Vesting-Schedule-functions) trait defines the logic for calculating the vested amount based on a given timestamp. This logic is not part of the [VestingComponent](/contracts-cairo/4.x/api/finance#VestingComponent), so any contract implementing the [VestingComponent](/contracts-cairo/4.x/api/finance#VestingComponent) must provide its own -implementation of the [VestingSchedule](/contracts-cairo/4.x/api/finance#VestingComponent-Vesting-Schedule) trait. +implementation of the [VestingSchedule](/contracts-cairo/4.x/api/finance#VestingComponent-Vesting-Schedule-functions) trait. -There’s a ready-made implementation of the [VestingSchedule](/contracts-cairo/4.x/api/finance#VestingComponent-Vesting-Schedule) trait available named [LinearVestingSchedule](/contracts-cairo/4.x/api/finance#LinearVestingSchedule). +There’s a ready-made implementation of the [VestingSchedule](/contracts-cairo/4.x/api/finance#VestingComponent-Vesting-Schedule-functions) trait available named [LinearVestingSchedule](/contracts-cairo/4.x/api/finance#LinearVestingSchedule). 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. @@ -42,7 +42,7 @@ The contract must integrate [VestingComponent](/contracts-cairo/4.x/api/finance# 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 [VestingSchedule](/contracts-cairo/4.x/api/finance#VestingComponent-Vesting-Schedule) trait. This can be achieved either by importing +The implementing contract must provide an implementation of the [VestingSchedule](/contracts-cairo/4.x/api/finance#VestingComponent-Vesting-Schedule-functions) trait. This can be achieved either by importing a ready-made [LinearVestingSchedule](/contracts-cairo/4.x/api/finance#LinearVestingSchedule) implementation or by defining a custom one. Here’s an example of a simple vesting wallet contract with a [LinearVestingSchedule](/contracts-cairo/4.x/api/finance#LinearVestingSchedule), where the vested amount @@ -97,19 +97,19 @@ mod LinearVestingWallet { } ``` -A vesting schedule will often follow a custom formula. In such cases, the [VestingSchedule](/contracts-cairo/4.x/api/finance#VestingComponent-Vesting-Schedule) trait is useful. +A vesting schedule will often follow a custom formula. In such cases, the [VestingSchedule](/contracts-cairo/4.x/api/finance#VestingComponent-Vesting-Schedule-functions) trait is useful. To support a custom vesting schedule, the contract must provide an implementation of the [calculate_vested_amount](/contracts-cairo/4.x/api/finance#VestingComponent-calculate_vested_amount) function based on the desired formula. -When using a custom [VestingSchedule](/contracts-cairo/4.x/api/finance#VestingComponent-Vesting-Schedule) implementation, the [LinearVestingSchedule](/contracts-cairo/4.x/api/finance#LinearVestingSchedule) must be excluded from the imports. +When using a custom [VestingSchedule](/contracts-cairo/4.x/api/finance#VestingComponent-Vesting-Schedule-functions) implementation, the [LinearVestingSchedule](/contracts-cairo/4.x/api/finance#LinearVestingSchedule) must be excluded from the imports. 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 [VestingSchedule](/contracts-cairo/4.x/api/finance#VestingComponent-Vesting-Schedule) implementation, where tokens +Here’s an example of a vesting wallet contract with a custom [VestingSchedule](/contracts-cairo/4.x/api/finance#VestingComponent-Vesting-Schedule-functions) implementation, where tokens are vested in a number of steps. ```rust diff --git a/content/contracts-cairo/4.x/guides/deploy-udc.mdx b/content/contracts-cairo/4.x/guides/deploy-udc.mdx index 7df8732b..392127ed 100644 --- a/content/contracts-cairo/4.x/guides/deploy-udc.mdx +++ b/content/contracts-cairo/4.x/guides/deploy-udc.mdx @@ -41,7 +41,7 @@ If you are using a different compiler version, you need to make sure the class h To avoid potential issues by using a different compiler version, you can directly import the contract class deployed on Starknet mainnet and declare it on your appchain. At -the time of writing, this is not easily achievable with the `sncast` tool, but you can leverage `[starkli](https://book.starkli.rs/declaring-classes)` to do it. +the time of writing, this is not easily achievable with the `sncast` tool, but you can leverage [starkli](https://book.starkli.rs/declaring-classes) to do it. Quick reference: @@ -148,13 +148,13 @@ mod UniversalDeployerBootstrapper { .unwrap_syscall(); } - #[external(v0)] - fn get_udc_address(ref self: ContractState, udc_class_hash: ClassHash) -> ContractAddress { - calculate_contract_address_from_deploy_syscall( - 0, udc_class_hash, array![].span(), Zero::zero(), - ) + #[external(v0)] + fn get_udc_address(ref self: ContractState, udc_class_hash: ClassHash) -> ContractAddress { + calculate_contract_address_from_deploy_syscall( + 0, udc_class_hash, array![].span(), Zero::zero(), + ) + } } - } ``` diff --git a/content/contracts-cairo/4.x/guides/interfaces-and-dispatchers.mdx b/content/contracts-cairo/4.x/guides/interfaces-and-dispatchers.mdx index b6f4a7bb..828d83a0 100644 --- a/content/contracts-cairo/4.x/guides/interfaces-and-dispatchers.mdx +++ b/content/contracts-cairo/4.x/guides/interfaces-and-dispatchers.mdx @@ -131,9 +131,6 @@ The default version of the ERC20 interface trait exposes `snake_case` functions: ```rust #[starknet::interface] pub trait IERC20 { - fn name(self: @TState) -> ByteArray; - fn symbol(self: @TState) -> ByteArray; - fn decimals(self: @TState) -> u8; fn total_supply(self: @TState) -> u256; fn balance_of(self: @TState, account: ContractAddress) -> u256; fn allowance(self: @TState, owner: ContractAddress, spender: ContractAddress) -> u256; @@ -152,9 +149,6 @@ On top of that, the library also offers a `camelCase` version of the same interf ```rust #[starknet::interface] pub trait IERC20Camel { - fn name(self: @TState) -> ByteArray; - fn symbol(self: @TState) -> ByteArray; - fn decimals(self: @TState) -> u8; fn totalSupply(self: @TState) -> u256; fn balanceOf(self: @TState, account: ContractAddress) -> u256; fn allowance(self: @TState, owner: ContractAddress, spender: ContractAddress) -> u256; diff --git a/content/contracts-cairo/4.x/guides/snip12.mdx b/content/contracts-cairo/4.x/guides/snip12.mdx index 2c230e76..5b0730ef 100644 --- a/content/contracts-cairo/4.x/guides/snip12.mdx +++ b/content/contracts-cairo/4.x/guides/snip12.mdx @@ -9,7 +9,7 @@ is then to ensure that the received message was indeed signed by the expected si OpenZeppelin Contracts for Cairo provides a set of utilities to make the implementation of this standard as easy as possible, and in this guide we will walk you through the process of generating the hashes of typed messages -using these utilities for on-chain signature verification. For that, let’s build an example with a custom [ERC20](/contracts-cairo/4.x/api/erc20#ERC20) contract +using these utilities for on-chain signature verification. For that, let’s build an example with a custom [ERC20](/contracts-cairo/4.x/api/erc20#ERC20Component) contract adding an extra `transfer_with_signature` method. diff --git a/content/contracts-cairo/4.x/index.mdx b/content/contracts-cairo/4.x/index.mdx index 07a3255b..f06e06cd 100644 --- a/content/contracts-cairo/4.x/index.mdx +++ b/content/contracts-cairo/4.x/index.mdx @@ -60,7 +60,7 @@ Scarb.toml src The `openzeppelin` package is an umbrella (meta) package that aggregates all library subpackages. The umbrella package, `openzeppelin_interfaces`, `openzeppelin_utils`, and `openzeppelin_testing` use independent version numbers. -See the [Versioning of the sub-packages](/contracts-cairo#versioning-of-the-sub-packages) section for more information. +See the [Versioning of the sub-packages](/contracts-cairo/4.x#versioning-of-the-sub-packages) section for more information. diff --git a/content/contracts-cairo/4.x/macros/with_components.mdx b/content/contracts-cairo/4.x/macros/with_components.mdx index 57fd4884..b2b2f135 100644 --- a/content/contracts-cairo/4.x/macros/with_components.mdx +++ b/content/contracts-cairo/4.x/macros/with_components.mdx @@ -86,9 +86,9 @@ This is how the same contract looks using regular syntax. mod OutsideExecutionAccountUpgradeable { use openzeppelin::account::AccountComponent; use openzeppelin::account::extensions::SRC9Component; + use openzeppelin::interfaces::upgrades::IUpgradeable; use openzeppelin::introspection::src5::SRC5Component; use openzeppelin::upgrades::UpgradeableComponent; - use openzeppelin::upgrades::interface::IUpgradeable; use starknet::ClassHash; component!(path: AccountComponent, storage: account, event: AccountEvent); diff --git a/content/contracts-cairo/4.x/presets.mdx b/content/contracts-cairo/4.x/presets.mdx index 7b3ddd95..85f3a585 100644 --- a/content/contracts-cairo/4.x/presets.mdx +++ b/content/contracts-cairo/4.x/presets.mdx @@ -45,13 +45,13 @@ Simply deploy the preset class hash and add the appropriate constructor argument Deploying the ERC20Upgradeable preset with [starkli](https://book.starkli.rs/introduction), for example, will look like this: ```bash -starkli deploy {ERC20Upgradeable-class-hash} \ +starkli deploy {{ERC20UpgradeableClassHash}} \ \ --network="sepolia" ``` If a class hash has yet to be declared, copy/paste the preset contract code and declare it locally. -Start by [setting up a project](/contracts-cairo#set-up-your-project) and [installing the Contracts for Cairo library](/contracts-cairo#install-the-library). +Start by [setting up a project](/contracts-cairo/4.x#set-up-your-project) and [installing the Contracts for Cairo library](/contracts-cairo/4.x#install-the-library). Copy the target preset contract from the [presets directory](https://github.com/OpenZeppelin/cairo-contracts/tree/{{api_source_version}}/packages/presets/src) and paste it in the new project’s `src/lib.cairo` like this: diff --git a/content/contracts-cairo/4.x/security.mdx b/content/contracts-cairo/4.x/security.mdx index 6530c51c..874dc6f1 100644 --- a/content/contracts-cairo/4.x/security.mdx +++ b/content/contracts-cairo/4.x/security.mdx @@ -72,7 +72,7 @@ The [Pausable](/contracts-cairo/4.x/api/security#PausableComponent) component al This can be useful for scenarios such as preventing trades until the end of an evaluation period or having an emergency switch to freeze all transactions in the event of a large bug. To become pausable, the contract should include `pause` and `unpause` functions (which should be protected). -For methods that should be available only when paused or not, insert calls to `[assert_paused](/contracts-cairo/4.x/api/security#PausableComponent-assert_paused)` and `[assert_not_paused](/contracts-cairo/4.x/api/security#PausableComponent-assert_not_paused)` +For methods that should be available only when paused or not, insert calls to [assert_paused](/contracts-cairo/4.x/api/security#PausableComponent-assert_paused) and [assert_not_paused](/contracts-cairo/4.x/api/security#PausableComponent-assert_not_paused) respectively. ### Usage @@ -165,7 +165,7 @@ A [reentrancy attack](https://gus-tavo-guim.medium.com/reentrancy-attack-on-smar ### Usage Since Cairo does not support modifiers like Solidity, the [ReentrancyGuard](/contracts-cairo/4.x/api/security#ReentrancyGuardComponent) -component exposes two methods `[start](/contracts-cairo/4.x/api/security#ReentrancyGuardComponent-start)` and `[end](/contracts-cairo/4.x/api/security#ReentrancyGuardComponent-end)` to protect functions against reentrancy attacks. +component exposes two methods [start](/contracts-cairo/4.x/api/security#ReentrancyGuardComponent-start) and [end](/contracts-cairo/4.x/api/security#ReentrancyGuardComponent-end) to protect functions against reentrancy attacks. The protected function must call `start` before the first function statement, and `end` before the return statement, as shown below: ```rust diff --git a/content/contracts-cairo/4.x/udc.mdx b/content/contracts-cairo/4.x/udc.mdx index 1b19ea0f..4ade3ac5 100644 --- a/content/contracts-cairo/4.x/udc.mdx +++ b/content/contracts-cairo/4.x/udc.mdx @@ -10,7 +10,7 @@ For details on the motivation and the decision making process, see the [Universa ## UDC contract address -The UDC is deployed at address `0x02ceed65a4bd731034c01113685c831b01c15d7d432f71afb1cf1634b53a2125` on Starknet sepolia and mainnet. +The UDC is deployed at address `{{udc_address}}` on Starknet sepolia and mainnet. ## Interface @@ -33,9 +33,9 @@ Next, call the UDC’s `deploy_contract` method. Here’s an implementation example in Cairo: ```rust -use openzeppelin_utils::interfaces::{IUniversalDeployerDispatcher, IUniversalDeployerDispatcherTrait}; +use openzeppelin_interfaces::deployments::{IUniversalDeployerDispatcher, IUniversalDeployerDispatcherTrait}; -const UDC_ADDRESS: felt252 = 0x04...; +const UDC_ADDRESS: felt252 = {{udc_address}}; fn deploy() -> ContractAddress { let dispatcher = IUniversalDeployerDispatcher { diff --git a/content/contracts-cairo/4.x/upgrades.mdx b/content/contracts-cairo/4.x/upgrades.mdx index e650f40a..928b5062 100644 --- a/content/contracts-cairo/4.x/upgrades.mdx +++ b/content/contracts-cairo/4.x/upgrades.mdx @@ -21,7 +21,7 @@ the class hash needs to be declared. ### `replace_class_syscall` -The `[replace_class](https://docs.starknet.io/build/corelib/core-starknet-syscalls-replace_class_syscall#core-starknet-syscalls-replace-class-syscall)` syscall allows a contract to +The [replace_class](https://docs.starknet.io/build/corelib/core-starknet-syscalls-replace_class_syscall#core-starknet-syscalls-replace-class-syscall) syscall allows a contract to update its source code by replacing its class hash once deployed. ```rust diff --git a/content/contracts-cairo/4.x/utils/constants.js b/content/contracts-cairo/4.x/utils/constants.js index 16b1133b..5ca50118 100644 --- a/content/contracts-cairo/4.x/utils/constants.js +++ b/content/contracts-cairo/4.x/utils/constants.js @@ -5,6 +5,9 @@ export const UMBRELLA_VERSION = "4.0.1"; export const API_SOURCE_VERSION = "v4.0.1"; export const CLASS_HASH_SCARB_VERSION = "2.18.0"; +export const UDC_ADDRESS = + "0x02ceed65a4bd731034c01113685c831b01c15d7d432f71afb1cf1634b53a2125"; + export const CLASS_HASHES = { AccountUpgradeableClassHash: "0x03013bf2edcf93ac575367eee41cd07bb50e809c78925817b61878db29826144", diff --git a/content/contracts-cairo/4.x/utils/replacements.ts b/content/contracts-cairo/4.x/utils/replacements.ts index cb72309e..5592caf0 100644 --- a/content/contracts-cairo/4.x/utils/replacements.ts +++ b/content/contracts-cairo/4.x/utils/replacements.ts @@ -5,6 +5,7 @@ import { OPENZEPPELIN_INTERFACES_VERSION, OPENZEPPELIN_TESTING_VERSION, OPENZEPPELIN_UTILS_VERSION, + UDC_ADDRESS, UMBRELLA_VERSION, } from "./constants"; @@ -17,6 +18,7 @@ export const REPLACEMENTS = { openzeppelin_utils_version: OPENZEPPELIN_UTILS_VERSION, openzeppelin_testing_version: OPENZEPPELIN_TESTING_VERSION, class_hash_scarb_version: CLASS_HASH_SCARB_VERSION, + udc_address: UDC_ADDRESS, ...CLASS_HASHES, }, };