Skip to content

Commit

Permalink
Cairo: Use Contracts for Cairo v0.12.0, add ERC20Votes (#355)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericglau authored May 1, 2024
1 parent 7817c21 commit 83829d1
Show file tree
Hide file tree
Showing 23 changed files with 1,376 additions and 581 deletions.
9 changes: 9 additions & 0 deletions packages/core-cairo/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 0.12.0 (2024-05-01)

- Add `votes` option to ERC20. ([#355](https://github.com/OpenZeppelin/contracts-wizard/pull/355))
- Require `appName` and `appVersion` when `votes` is enabled.
- Sort implemented traits.
- **Breaking changes**:
- Use OpenZeppelin Contracts for Cairo v0.12.0.
- Use Hooks with ERC20.

## 0.11.0 (2024-04-17)

- **Breaking changes**:
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.11.0",
"version": "0.12.0",
"description": "A boilerplate generator to get started with OpenZeppelin Contracts for Cairo",
"license": "MIT",
"repository": "github:OpenZeppelin/contracts-wizard",
Expand Down
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.11.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.12.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.11.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.12.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.11.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.12.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.11.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.12.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.11.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.12.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.11.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.12.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.11.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.12.0␊
#[starknet::contract]␊
mod Foo {␊
Expand Down
Binary file modified packages/core-cairo/src/contract.test.ts.snap
Binary file not shown.
6 changes: 6 additions & 0 deletions packages/core-cairo/src/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ export interface BaseImplementedTrait {
of: string;
tags: string[];
perItemTag?: string;
/**
* Priority for which trait to print first.
* Lower numbers are higher priority, undefined is lowest priority.
*/
priority?: number;
}

export interface ImplementedTrait extends BaseImplementedTrait {
Expand Down Expand Up @@ -165,6 +170,7 @@ export class ContractBuilder implements Contract {
of: baseTrait.of,
tags: [ ...baseTrait.tags ],
functions: [],
priority: baseTrait.priority,
};
this.implementedTraitsMap.set(key, t);
return t;
Expand Down
32 changes: 16 additions & 16 deletions packages/core-cairo/src/custom.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.11.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.12.0␊
#[starknet::contract]␊
mod MyContract {␊
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.11.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.12.0␊
#[starknet::contract]␊
mod MyContract {␊
Expand Down Expand Up @@ -80,7 +80,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.11.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.12.0␊
#[starknet::contract]␊
mod MyContract {␊
Expand Down Expand Up @@ -129,6 +129,14 @@ Generated by [AVA](https://avajs.dev).
fn constructor(ref self: ContractState, owner: ContractAddress) {␊
self.ownable.initializer(owner);␊
}␊
#[abi(embed_v0)]␊
impl UpgradeableImpl of IUpgradeable<ContractState> {␊
fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊
self.ownable.assert_only_owner();␊
self.upgradeable._upgrade(new_class_hash);␊
}␊
}␊
#[generate_trait]␊
#[abi(per_item)]␊
Expand All @@ -145,14 +153,6 @@ Generated by [AVA](https://avajs.dev).
self.pausable._unpause();␊
}␊
}␊
#[abi(embed_v0)]␊
impl UpgradeableImpl of IUpgradeable<ContractState> {␊
fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊
self.ownable.assert_only_owner();␊
self.upgradeable._upgrade(new_class_hash);␊
}␊
}␊
}␊
`

Expand All @@ -161,7 +161,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.11.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.12.0␊
#[starknet::contract]␊
mod MyContract {␊
Expand Down Expand Up @@ -217,7 +217,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.11.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.12.0␊
#[starknet::contract]␊
mod MyContract {␊
Expand All @@ -232,7 +232,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.11.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.12.0␊
#[starknet::contract]␊
mod MyContract {␊
Expand Down Expand Up @@ -288,7 +288,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.11.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.12.0␊
const UPGRADER_ROLE: felt252 = selector!("UPGRADER_ROLE");␊
Expand Down Expand Up @@ -361,7 +361,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.11.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.12.0␊
#[starknet::contract]␊
mod MyContract {␊
Expand Down
Binary file modified packages/core-cairo/src/custom.test.ts.snap
Binary file not shown.
Loading

0 comments on commit 83829d1

Please sign in to comment.