Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/core-cairo/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.17.0 (2024-10-22)

- Add ERC721 votes. ([#399](https://github.com/OpenZeppelin/contracts-wizard/pull/399))

- **Breaking changes**:
- Use OpenZeppelin Contracts for Cairo v0.18.0. ([#399](https://github.com/OpenZeppelin/contracts-wizard/pull/399))
- Use `VotesComponent` for ERC20 votes.

## 0.16.0 (2024-09-26)

- Add ERC721Enumerable. ([#391](https://github.com/OpenZeppelin/contracts-wizard/pull/391))
Expand Down
2 changes: 1 addition & 1 deletion packages/core-cairo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openzeppelin/wizard-cairo",
"version": "0.16.0",
"version": "0.17.0",
"description": "A boilerplate generator to get started with OpenZeppelin Contracts for Cairo",
"license": "MIT",
"repository": "github:OpenZeppelin/contracts-wizard",
Expand Down
48 changes: 24 additions & 24 deletions packages/core-cairo/src/account.test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
#[starknet::contract(account)]␊
mod MyAccount {␊
Expand Down Expand Up @@ -70,7 +70,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
#[starknet::contract(account)]␊
mod MyAccount {␊
Expand Down Expand Up @@ -114,7 +114,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
#[starknet::contract(account)]␊
mod MyAccount {␊
Expand Down Expand Up @@ -175,7 +175,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
#[starknet::contract(account)]␊
mod MyAccount {␊
Expand Down Expand Up @@ -219,7 +219,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
#[starknet::contract(account)]␊
mod MyAccount {␊
Expand Down Expand Up @@ -284,7 +284,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
#[starknet::contract(account)]␊
mod MyAccount {␊
Expand Down Expand Up @@ -332,7 +332,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
#[starknet::contract(account)]␊
mod MyAccount {␊
Expand Down Expand Up @@ -399,7 +399,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
#[starknet::contract(account)]␊
mod MyAccount {␊
Expand Down Expand Up @@ -466,7 +466,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
#[starknet::contract(account)]␊
mod MyAccount {␊
Expand Down Expand Up @@ -535,7 +535,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
#[starknet::contract(account)]␊
mod MyAccount {␊
Expand Down Expand Up @@ -604,7 +604,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
#[starknet::contract(account)]␊
mod MyAccount {␊
Expand Down Expand Up @@ -675,7 +675,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
#[starknet::contract(account)]␊
mod MyAccount {␊
Expand Down Expand Up @@ -746,7 +746,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
#[starknet::contract(account)]␊
mod MyAccount {␊
Expand Down Expand Up @@ -808,7 +808,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
#[starknet::contract(account)]␊
mod MyAccount {␊
Expand Down Expand Up @@ -853,7 +853,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
#[starknet::contract(account)]␊
mod MyAccount {␊
Expand Down Expand Up @@ -915,7 +915,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
#[starknet::contract(account)]␊
mod MyAccount {␊
Expand Down Expand Up @@ -960,7 +960,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
#[starknet::contract(account)]␊
mod MyAccount {␊
Expand Down Expand Up @@ -1026,7 +1026,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
#[starknet::contract(account)]␊
mod MyAccount {␊
Expand Down Expand Up @@ -1075,7 +1075,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
#[starknet::contract(account)]␊
mod MyAccount {␊
Expand Down Expand Up @@ -1143,7 +1143,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
#[starknet::contract(account)]␊
mod MyAccount {␊
Expand Down Expand Up @@ -1211,7 +1211,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
#[starknet::contract(account)]␊
mod MyAccount {␊
Expand Down Expand Up @@ -1281,7 +1281,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
#[starknet::contract(account)]␊
mod MyAccount {␊
Expand Down Expand Up @@ -1351,7 +1351,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
#[starknet::contract(account)]␊
mod MyAccount {␊
Expand Down Expand Up @@ -1423,7 +1423,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
#[starknet::contract(account)]␊
mod MyAccount {␊
Expand Down
Binary file modified packages/core-cairo/src/account.test.ts.snap
Binary file not shown.
78 changes: 76 additions & 2 deletions packages/core-cairo/src/common-components.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import type { ContractBuilder } from "./contract";
import type { BaseImplementedTrait, ContractBuilder } from './contract';
import { defineComponents } from "./utils/define-components";

export const tokenTypes = ['ERC20', 'ERC721'] as const;
export type Token = typeof tokenTypes[number];

const components = defineComponents( {
SRC5Component: {
path: 'openzeppelin::introspection::src5',
Expand All @@ -14,6 +17,41 @@ const components = defineComponents( {
},
impls: [],
},

VotesComponent: {
path: 'openzeppelin::governance::votes',
substorage: {
name: 'votes',
type: 'VotesComponent::Storage',
},
event: {
name: 'VotesEvent',
type: 'VotesComponent::Event',
},
impls: [],
internalImpl: {
name: 'VotesInternalImpl',
value: 'VotesComponent::InternalImpl<ContractState>',
},
},

NoncesComponent: {
path: 'openzeppelin::utils::cryptography::nonces',
substorage: {
name: 'nonces',
type: 'NoncesComponent::Storage',
},
event: {
name: 'NoncesEvent',
type: 'NoncesComponent::Event',
},
impls: [
{
name: 'NoncesImpl',
value: 'NoncesComponent::NoncesImpl<ContractState>',
},
],
},
})

export function addSRC5Component(c: ContractBuilder) {
Expand All @@ -26,4 +64,40 @@ export function addSRC5Component(c: ContractBuilder) {
});
c.addInterfaceFlag('ISRC5');
}
}
}

export function addVotesComponent(c: ContractBuilder, name: string, version: string) {
c.addStandaloneImport('openzeppelin::utils::cryptography::snip12::SNIP12Metadata');
c.addComponent(components.NoncesComponent, [], false);
c.addComponent(components.VotesComponent, [], false);
c.addImplToComponent(components.VotesComponent, {
name: 'VotesImpl',
value: `VotesComponent::VotesImpl<ContractState>`,
});

const SNIP12Metadata: BaseImplementedTrait = {
name: 'SNIP12MetadataImpl',
of: 'SNIP12Metadata',
tags: [],
priority: 0,
};
c.addImplementedTrait(SNIP12Metadata);

c.addFunction(SNIP12Metadata, {
name: 'name',
args: [],
returns: 'felt252',
code: [
`'${name}'`,
],
});

c.addFunction(SNIP12Metadata, {
name: 'version',
args: [],
returns: 'felt252',
code: [
`'${version}'`,
],
});
}
14 changes: 7 additions & 7 deletions packages/core-cairo/src/contract.test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
#[starknet::contract]␊
mod Foo {␊
Expand All @@ -24,7 +24,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
#[starknet::contract]␊
mod Foo {␊
Expand All @@ -44,7 +44,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
#[starknet::contract]␊
mod Foo {␊
Expand All @@ -64,7 +64,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
#[starknet::contract]␊
mod Foo {␊
Expand All @@ -89,7 +89,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
#[starknet::contract]␊
mod Foo {␊
Expand All @@ -114,7 +114,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
#[starknet::contract]␊
mod Foo {␊
Expand Down Expand Up @@ -152,7 +152,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1

`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
#[starknet::contract]␊
mod Foo {␊
Expand Down
Binary file modified packages/core-cairo/src/contract.test.ts.snap
Binary file not shown.
Loading