Skip to content

Commit

Permalink
Merge branch 'main' into release-v0.14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-fleming committed Jun 14, 2024
2 parents dc6e36f + 7d91709 commit f091c4f
Show file tree
Hide file tree
Showing 15 changed files with 53 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Extract current versions
run: |
CURRENT_VERSION=$(grep '^version = ' Scarb.toml | sed 's/version = "\(.*\)"/\1/')
SCARB_VERSION=$(grep 'cairo-version = ' Scarb.toml | sed 's/cairo-version = "\(.*\)"/\1/')
SCARB_VERSION=$(grep 'scarb-version = ' Scarb.toml | sed 's/scarb-version = "\(.*\)"/\1/')
echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
echo "SCARB_VERSION=$SCARB_VERSION" >> $GITHUB_ENV
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v3
- name: Extract scarb version
run: |
SCARB_VERSION=$(grep 'cairo-version = ' Scarb.toml | sed 's/cairo-version = "\(.*\)"/\1/')
SCARB_VERSION=$(grep 'scarb-version = ' Scarb.toml | sed 's/scarb-version = "\(.*\)"/\1/')
echo "SCARB_VERSION=$SCARB_VERSION" >> $GITHUB_ENV
- uses: software-mansion/setup-scarb@v1
with:
Expand Down
5 changes: 3 additions & 2 deletions Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
name = "openzeppelin"
version = "0.14.0"
edition = "2023_11"
cairo-version = "2.6.3"
cairo-version = "2.6.4"
scarb-version = "2.6.5"
authors = ["OpenZeppelin Community <[email protected]>"]
description = "OpenZeppelin Contracts written in Cairo for StarkNet, a decentralized ZK Rollup"
documentation = "https://docs.openzeppelin.com/contracts-cairo"
Expand All @@ -12,7 +13,7 @@ license-file = "LICENSE"
keywords = ["openzeppelin", "starknet", "cairo", "contracts", "security", "standards"]

[dependencies]
starknet = "2.6.3"
starknet = "2.6.4"

[lib]

Expand Down
9 changes: 6 additions & 3 deletions docs/modules/ROOT/pages/access.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ This is the full interface of the `OwnableMixinImpl` implementation:

[,cairo]
----
trait OwnableABI {
#[starknet::interface]
pub trait OwnableABI {
// IOwnable
fn owner() -> ContractAddress;
fn transfer_ownership(new_owner: ContractAddress);
Expand Down Expand Up @@ -124,7 +125,8 @@ This is the full interface of the two step `OwnableTwoStepMixinImpl` implementat

[,cairo]
----
trait OwnableTwoStepABI {
#[starknet::interface]
pub trait OwnableTwoStepABI {
// IOwnableTwoStep
fn owner() -> ContractAddress;
fn pending_owner() -> ContractAddress;
Expand Down Expand Up @@ -491,7 +493,8 @@ This is the full interface of the `AccessControlMixinImpl` implementation:

[,cairo]
----
trait AccessControlABI {
#[starknet::interface]
pub trait AccessControlABI {
// IAccessControl
fn has_role(role: felt252, account: ContractAddress) -> bool;
fn get_role_admin(role: felt252) -> felt252;
Expand Down
15 changes: 11 additions & 4 deletions docs/modules/ROOT/pages/accounts.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ struct Call {
}
/// Standard Account Interface
trait ISRC6 {
#[starknet::interface]
pub trait ISRC6 {
/// Executes a transaction through the account.
fn __execute__(calls: Array<Call>) -> Array<Span<felt252>>;
Expand All @@ -48,6 +49,9 @@ trait ISRC6 {
}
----

WARNING: The `calldata` member of the `Call` struct in the accounts has been updated to `Span<felt252>` for optimization
purposes, but the interface Id remains the same for backwards compatibility. This inconsistency will be fixed in future releases.

{snip-6}[SNIP-6] adds the `is_valid_signature` method. This method is not used by the protocol, but it's useful for
DApps to verify the validity of signatures, supporting features like Sign In with Starknet.

Expand All @@ -59,7 +63,8 @@ a mechanism for detecting whether a contract is an account or not through intros
[,cairo]
----
/// Standard Interface Detection
trait ISRC5 {
#[starknet::interface]
pub trait ISRC5 {
/// Queries if a contract implements a given interface.
fn supports_interface(interface_id: felt252) -> bool;
}
Expand Down Expand Up @@ -148,7 +153,8 @@ This is the full interface of the `AccountMixinImpl` implementation:

[,cairo]
----
trait AccountABI {
#[starknet::interface]
pub trait AccountABI {
// ISRC6
fn __execute__(calls: Array<Call>) -> Array<Span<felt252>>;
fn __validate__(calls: Array<Call>) -> felt252;
Expand Down Expand Up @@ -241,7 +247,8 @@ This is the full interface of the `EthAccountMixinImpl` implementation:

[,cairo]
----
trait EthAccountABI {
#[starknet::interface]
pub trait EthAccountABI {
// ISRC6
fn __execute__(calls: Array<Call>) -> Array<Span<felt252>>;
fn __validate__(calls: Array<Call>) -> felt252;
Expand Down
4 changes: 2 additions & 2 deletions docs/modules/ROOT/pages/components.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ mod ERC20Pausable {
(...)
// Custom ERC20 implementation
#[external(v0)]
#[abi(embed_v0)]
impl CustomERC20Impl of IERC20<ContractState> {
fn transfer(
ref self: ContractState, recipient: ContractAddress, amount: u256
Expand All @@ -422,7 +422,7 @@ mod ERC20Pausable {
}
// Custom ERC20CamelOnly implementation
#[external(v0)]
#[abi(embed_v0)]
impl CustomERC20CamelOnlyImpl of IERC20CamelOnly<ContractState> {
fn totalSupply(self: @ContractState) -> u256 {
self.erc20.total_supply()
Expand Down
6 changes: 4 additions & 2 deletions docs/modules/ROOT/pages/erc1155.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ To support older token deployments, as mentioned in {dual-interfaces}, the compo

[,cairo]
----
trait ERC1155ABI {
#[starknet::interface]
pub trait ERC1155ABI {
// IERC1155
fn balance_of(account: ContractAddress, token_id: u256) -> u256;
fn balance_of_batch(
Expand Down Expand Up @@ -189,7 +190,8 @@ The recipient contract must also implement the {src5} interface which supports i

[,cairo]
----
trait IERC1155Receiver {
#[starknet::interface]
pub trait IERC1155Receiver {
fn on_erc1155_received(
operator: ContractAddress,
from: ContractAddress,
Expand Down
7 changes: 4 additions & 3 deletions docs/modules/ROOT/pages/erc20.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ To support older token deployments, as mentioned in {dual-interfaces}, the compo

[,cairo]
----
trait ERC20ABI {
#[starknet::interface]
pub trait ERC20ABI {
// IERC20
fn total_supply() -> u256;
fn balance_of(account: ContractAddress) -> u256;
Expand Down Expand Up @@ -147,7 +148,7 @@ For example:

[,cairo]
----
#[external(v0)]
#[abi(embed_v0)]
impl ERC20MetadataImpl of interface::IERC20Metadata<ContractState> {
fn decimals(self: @ContractState) -> u8 {
// Change the `3` below to the desired number of decimals
Expand Down Expand Up @@ -213,7 +214,7 @@ mod MyToken {
self.erc20.mint(recipient, initial_supply);
}
#[external(v0)]
#[abi(embed_v0)]
impl ERC20MetadataImpl of interface::IERC20Metadata<ContractState> {
fn name(self: @ContractState) -> ByteArray {
self.erc20.name()
Expand Down
6 changes: 4 additions & 2 deletions docs/modules/ROOT/pages/erc721.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ To support older token deployments, as mentioned in {dual-interfaces}, the compo

[,cairo]
----
trait ERC721ABI {
#[starknet::interface]
pub trait ERC721ABI {
// IERC721
fn balance_of(account: ContractAddress) -> u256;
fn owner_of(token_id: u256) -> ContractAddress;
Expand Down Expand Up @@ -167,7 +168,8 @@ The recipient contract must also implement the {src5} interface which, as descri

[,cairo]
----
trait IERC721Receiver {
#[starknet::interface]
pub trait IERC721Receiver {
fn on_erc721_received(
operator: ContractAddress,
from: ContractAddress,
Expand Down
4 changes: 2 additions & 2 deletions docs/modules/ROOT/pages/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ before proceeding, and run the following command to check that the installation
----
$ scarb --version
scarb 2.6.3 (e6f921dfd 2024-03-13)
cairo: 2.6.3 (https://crates.io/crates/cairo-lang-compiler/2.6.3)
scarb 2.6.5 (d49f54394 2024-06-11)
cairo: 2.6.4 (https://crates.io/crates/cairo-lang-compiler/2.6.4)
sierra: 1.5.0
----

Expand Down
12 changes: 6 additions & 6 deletions docs/modules/ROOT/pages/interfaces.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ This includes only the functions defined in the interface, and is the standard w

```cairo
#[starknet::interface]
trait IERC20<TState> {
pub trait IERC20<TState> {
fn total_supply(self: @TState) -> u256;
fn balance_of(self: @TState, account: ContractAddress) -> u256;
fn allowance(self: @TState, owner: ContractAddress, spender: ContractAddress) -> u256;
Expand All @@ -46,7 +46,7 @@ They describe a contract's complete interface. This is useful to interface with

```cairo
#[starknet::interface]
trait ERC20ABI<TState> {
pub trait ERC20ABI<TState> {
// IERC20
fn total_supply(self: @TState) -> u256;
fn balance_of(self: @TState, account: ContractAddress) -> u256;
Expand Down Expand Up @@ -76,11 +76,11 @@ This is a utility trait to interface with contracts whose interface is unknown.

```cairo
#[derive(Copy, Drop)]
struct DualCaseERC20 {
pub struct DualCaseERC20 {
contract_address: ContractAddress
}

trait DualCaseERC20Trait {
pub trait DualCaseERC20Trait {
fn name(self: @DualCaseERC20) -> ByteArray;
fn symbol(self: @DualCaseERC20) -> ByteArray;
fn decimals(self: @DualCaseERC20) -> u8;
Expand Down Expand Up @@ -114,7 +114,7 @@ The default version of the ERC20 interface trait exposes `snake_case` functions:

```cairo
#[starknet::interface]
trait IERC20<TState> {
pub trait IERC20<TState> {
fn name(self: @TState) -> ByteArray;
fn symbol(self: @TState) -> ByteArray;
fn decimals(self: @TState) -> u8;
Expand All @@ -135,7 +135,7 @@ On top of that, we also offer a `camelCase` version of the same interface:

```cairo
#[starknet::interface]
trait IERC20Camel<TState> {
pub trait IERC20Camel<TState> {
fn name(self: @TState) -> ByteArray;
fn symbol(self: @TState) -> ByteArray;
fn decimals(self: @TState) -> u8;
Expand Down
3 changes: 2 additions & 1 deletion docs/modules/ROOT/pages/introspection.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ mod MyContract {

[,cairo]
----
trait ISRC5 {
#[starknet::interface]
pub trait ISRC5 {
/// Query if a contract implements an interface.
/// Receives the interface identifier as specified in SRC-5.
/// Returns `true` if the contract implements `interface_id`, `false` otherwise.
Expand Down
6 changes: 4 additions & 2 deletions docs/modules/ROOT/pages/security.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ The component provides the following external functions as part of the `Initiali

[,cairo]
----
trait InitializableABI {
#[starknet::interface]
pub trait InitializableABI {
fn is_initialized() -> bool;
}
----
Expand Down Expand Up @@ -152,7 +153,8 @@ The component provides the following external functions as part of the `Pausable

[,cairo]
----
trait PausableABI {
#[starknet::interface]
pub trait PausableABI {
fn is_paused() -> bool;
}
----
Expand Down
3 changes: 2 additions & 1 deletion docs/modules/ROOT/pages/udc.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ The UDC address is deployed at address `0x04a64cd09a853868621d94cae9952b106f2c36

[,cairo]
----
trait IUniversalDeployer {
#[starknet::interface]
pub trait IUniversalDeployer {
fn deploy_contract(
class_hash: ClassHash,
salt: felt252,
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/upgrades.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ mod UpgradeableContract {
self.ownable.initializer(owner);
}
#[external(v0)]
#[abi(embed_v0)]
impl UpgradeableImpl of IUpgradeable<ContractState> {
fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {
// This function can only be called by the owner
Expand Down

0 comments on commit f091c4f

Please sign in to comment.