Skip to content

Commit f8fb22f

Browse files
andrew-flemingericglauericnordelo
authored
Bump cairo to v0.18.0 (#399)
Co-authored-by: Eric Lau <[email protected]> Co-authored-by: Eric Nordelo <[email protected]>
1 parent cafb999 commit f8fb22f

25 files changed

+829
-410
lines changed

packages/core-cairo/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## 0.17.0 (2024-10-22)
4+
5+
- Add ERC721 votes. ([#399](https://github.com/OpenZeppelin/contracts-wizard/pull/399))
6+
7+
- **Breaking changes**:
8+
- Use OpenZeppelin Contracts for Cairo v0.18.0. ([#399](https://github.com/OpenZeppelin/contracts-wizard/pull/399))
9+
- Use `VotesComponent` for ERC20 votes.
10+
311
## 0.16.0 (2024-09-26)
412

513
- Add ERC721Enumerable. ([#391](https://github.com/OpenZeppelin/contracts-wizard/pull/391))

packages/core-cairo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openzeppelin/wizard-cairo",
3-
"version": "0.16.0",
3+
"version": "0.17.0",
44
"description": "A boilerplate generator to get started with OpenZeppelin Contracts for Cairo",
55
"license": "MIT",
66
"repository": "github:OpenZeppelin/contracts-wizard",

packages/core-cairo/src/account.test.ts.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Generated by [AVA](https://avajs.dev).
99
> Snapshot 1
1010
1111
`// SPDX-License-Identifier: MIT␊
12-
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
12+
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
1313
1414
#[starknet::contract(account)]␊
1515
mod MyAccount {␊
@@ -70,7 +70,7 @@ Generated by [AVA](https://avajs.dev).
7070
> Snapshot 1
7171
7272
`// SPDX-License-Identifier: MIT␊
73-
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
73+
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
7474
7575
#[starknet::contract(account)]␊
7676
mod MyAccount {␊
@@ -114,7 +114,7 @@ Generated by [AVA](https://avajs.dev).
114114
> Snapshot 1
115115
116116
`// SPDX-License-Identifier: MIT␊
117-
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
117+
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
118118
119119
#[starknet::contract(account)]␊
120120
mod MyAccount {␊
@@ -175,7 +175,7 @@ Generated by [AVA](https://avajs.dev).
175175
> Snapshot 1
176176
177177
`// SPDX-License-Identifier: MIT␊
178-
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
178+
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
179179
180180
#[starknet::contract(account)]␊
181181
mod MyAccount {␊
@@ -219,7 +219,7 @@ Generated by [AVA](https://avajs.dev).
219219
> Snapshot 1
220220
221221
`// SPDX-License-Identifier: MIT␊
222-
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
222+
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
223223
224224
#[starknet::contract(account)]␊
225225
mod MyAccount {␊
@@ -284,7 +284,7 @@ Generated by [AVA](https://avajs.dev).
284284
> Snapshot 1
285285
286286
`// SPDX-License-Identifier: MIT␊
287-
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
287+
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
288288
289289
#[starknet::contract(account)]␊
290290
mod MyAccount {␊
@@ -332,7 +332,7 @@ Generated by [AVA](https://avajs.dev).
332332
> Snapshot 1
333333
334334
`// SPDX-License-Identifier: MIT␊
335-
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
335+
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
336336
337337
#[starknet::contract(account)]␊
338338
mod MyAccount {␊
@@ -399,7 +399,7 @@ Generated by [AVA](https://avajs.dev).
399399
> Snapshot 1
400400
401401
`// SPDX-License-Identifier: MIT␊
402-
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
402+
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
403403
404404
#[starknet::contract(account)]␊
405405
mod MyAccount {␊
@@ -466,7 +466,7 @@ Generated by [AVA](https://avajs.dev).
466466
> Snapshot 1
467467
468468
`// SPDX-License-Identifier: MIT␊
469-
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
469+
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
470470
471471
#[starknet::contract(account)]␊
472472
mod MyAccount {␊
@@ -535,7 +535,7 @@ Generated by [AVA](https://avajs.dev).
535535
> Snapshot 1
536536
537537
`// SPDX-License-Identifier: MIT␊
538-
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
538+
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
539539
540540
#[starknet::contract(account)]␊
541541
mod MyAccount {␊
@@ -604,7 +604,7 @@ Generated by [AVA](https://avajs.dev).
604604
> Snapshot 1
605605
606606
`// SPDX-License-Identifier: MIT␊
607-
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
607+
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
608608
609609
#[starknet::contract(account)]␊
610610
mod MyAccount {␊
@@ -675,7 +675,7 @@ Generated by [AVA](https://avajs.dev).
675675
> Snapshot 1
676676
677677
`// SPDX-License-Identifier: MIT␊
678-
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
678+
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
679679
680680
#[starknet::contract(account)]␊
681681
mod MyAccount {␊
@@ -746,7 +746,7 @@ Generated by [AVA](https://avajs.dev).
746746
> Snapshot 1
747747
748748
`// SPDX-License-Identifier: MIT␊
749-
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
749+
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
750750
751751
#[starknet::contract(account)]␊
752752
mod MyAccount {␊
@@ -808,7 +808,7 @@ Generated by [AVA](https://avajs.dev).
808808
> Snapshot 1
809809
810810
`// SPDX-License-Identifier: MIT␊
811-
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
811+
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
812812
813813
#[starknet::contract(account)]␊
814814
mod MyAccount {␊
@@ -853,7 +853,7 @@ Generated by [AVA](https://avajs.dev).
853853
> Snapshot 1
854854
855855
`// SPDX-License-Identifier: MIT␊
856-
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
856+
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
857857
858858
#[starknet::contract(account)]␊
859859
mod MyAccount {␊
@@ -915,7 +915,7 @@ Generated by [AVA](https://avajs.dev).
915915
> Snapshot 1
916916
917917
`// SPDX-License-Identifier: MIT␊
918-
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
918+
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
919919
920920
#[starknet::contract(account)]␊
921921
mod MyAccount {␊
@@ -960,7 +960,7 @@ Generated by [AVA](https://avajs.dev).
960960
> Snapshot 1
961961
962962
`// SPDX-License-Identifier: MIT␊
963-
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
963+
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
964964
965965
#[starknet::contract(account)]␊
966966
mod MyAccount {␊
@@ -1026,7 +1026,7 @@ Generated by [AVA](https://avajs.dev).
10261026
> Snapshot 1
10271027
10281028
`// SPDX-License-Identifier: MIT␊
1029-
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
1029+
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
10301030
10311031
#[starknet::contract(account)]␊
10321032
mod MyAccount {␊
@@ -1075,7 +1075,7 @@ Generated by [AVA](https://avajs.dev).
10751075
> Snapshot 1
10761076
10771077
`// SPDX-License-Identifier: MIT␊
1078-
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
1078+
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
10791079
10801080
#[starknet::contract(account)]␊
10811081
mod MyAccount {␊
@@ -1143,7 +1143,7 @@ Generated by [AVA](https://avajs.dev).
11431143
> Snapshot 1
11441144
11451145
`// SPDX-License-Identifier: MIT␊
1146-
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
1146+
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
11471147
11481148
#[starknet::contract(account)]␊
11491149
mod MyAccount {␊
@@ -1211,7 +1211,7 @@ Generated by [AVA](https://avajs.dev).
12111211
> Snapshot 1
12121212
12131213
`// SPDX-License-Identifier: MIT␊
1214-
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
1214+
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
12151215
12161216
#[starknet::contract(account)]␊
12171217
mod MyAccount {␊
@@ -1281,7 +1281,7 @@ Generated by [AVA](https://avajs.dev).
12811281
> Snapshot 1
12821282
12831283
`// SPDX-License-Identifier: MIT␊
1284-
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
1284+
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
12851285
12861286
#[starknet::contract(account)]␊
12871287
mod MyAccount {␊
@@ -1351,7 +1351,7 @@ Generated by [AVA](https://avajs.dev).
13511351
> Snapshot 1
13521352
13531353
`// SPDX-License-Identifier: MIT␊
1354-
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
1354+
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
13551355
13561356
#[starknet::contract(account)]␊
13571357
mod MyAccount {␊
@@ -1423,7 +1423,7 @@ Generated by [AVA](https://avajs.dev).
14231423
> Snapshot 1
14241424
14251425
`// SPDX-License-Identifier: MIT␊
1426-
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
1426+
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
14271427
14281428
#[starknet::contract(account)]␊
14291429
mod MyAccount {␊
0 Bytes
Binary file not shown.

packages/core-cairo/src/common-components.ts

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
import type { ContractBuilder } from "./contract";
1+
import type { BaseImplementedTrait, ContractBuilder } from './contract';
22
import { defineComponents } from "./utils/define-components";
33

4+
export const tokenTypes = ['ERC20', 'ERC721'] as const;
5+
export type Token = typeof tokenTypes[number];
6+
47
const components = defineComponents( {
58
SRC5Component: {
69
path: 'openzeppelin::introspection::src5',
@@ -14,6 +17,41 @@ const components = defineComponents( {
1417
},
1518
impls: [],
1619
},
20+
21+
VotesComponent: {
22+
path: 'openzeppelin::governance::votes',
23+
substorage: {
24+
name: 'votes',
25+
type: 'VotesComponent::Storage',
26+
},
27+
event: {
28+
name: 'VotesEvent',
29+
type: 'VotesComponent::Event',
30+
},
31+
impls: [],
32+
internalImpl: {
33+
name: 'VotesInternalImpl',
34+
value: 'VotesComponent::InternalImpl<ContractState>',
35+
},
36+
},
37+
38+
NoncesComponent: {
39+
path: 'openzeppelin::utils::cryptography::nonces',
40+
substorage: {
41+
name: 'nonces',
42+
type: 'NoncesComponent::Storage',
43+
},
44+
event: {
45+
name: 'NoncesEvent',
46+
type: 'NoncesComponent::Event',
47+
},
48+
impls: [
49+
{
50+
name: 'NoncesImpl',
51+
value: 'NoncesComponent::NoncesImpl<ContractState>',
52+
},
53+
],
54+
},
1755
})
1856

1957
export function addSRC5Component(c: ContractBuilder) {
@@ -26,4 +64,40 @@ export function addSRC5Component(c: ContractBuilder) {
2664
});
2765
c.addInterfaceFlag('ISRC5');
2866
}
29-
}
67+
}
68+
69+
export function addVotesComponent(c: ContractBuilder, name: string, version: string) {
70+
c.addStandaloneImport('openzeppelin::utils::cryptography::snip12::SNIP12Metadata');
71+
c.addComponent(components.NoncesComponent, [], false);
72+
c.addComponent(components.VotesComponent, [], false);
73+
c.addImplToComponent(components.VotesComponent, {
74+
name: 'VotesImpl',
75+
value: `VotesComponent::VotesImpl<ContractState>`,
76+
});
77+
78+
const SNIP12Metadata: BaseImplementedTrait = {
79+
name: 'SNIP12MetadataImpl',
80+
of: 'SNIP12Metadata',
81+
tags: [],
82+
priority: 0,
83+
};
84+
c.addImplementedTrait(SNIP12Metadata);
85+
86+
c.addFunction(SNIP12Metadata, {
87+
name: 'name',
88+
args: [],
89+
returns: 'felt252',
90+
code: [
91+
`'${name}'`,
92+
],
93+
});
94+
95+
c.addFunction(SNIP12Metadata, {
96+
name: 'version',
97+
args: [],
98+
returns: 'felt252',
99+
code: [
100+
`'${version}'`,
101+
],
102+
});
103+
}

packages/core-cairo/src/contract.test.ts.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Generated by [AVA](https://avajs.dev).
99
> Snapshot 1
1010
1111
`// SPDX-License-Identifier: MIT␊
12-
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
12+
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
1313
1414
#[starknet::contract]␊
1515
mod Foo {␊
@@ -24,7 +24,7 @@ Generated by [AVA](https://avajs.dev).
2424
> Snapshot 1
2525
2626
`// SPDX-License-Identifier: MIT␊
27-
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
27+
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
2828
2929
#[starknet::contract]␊
3030
mod Foo {␊
@@ -44,7 +44,7 @@ Generated by [AVA](https://avajs.dev).
4444
> Snapshot 1
4545
4646
`// SPDX-License-Identifier: MIT␊
47-
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
47+
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
4848
4949
#[starknet::contract]␊
5050
mod Foo {␊
@@ -64,7 +64,7 @@ Generated by [AVA](https://avajs.dev).
6464
> Snapshot 1
6565
6666
`// SPDX-License-Identifier: MIT␊
67-
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
67+
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
6868
6969
#[starknet::contract]␊
7070
mod Foo {␊
@@ -89,7 +89,7 @@ Generated by [AVA](https://avajs.dev).
8989
> Snapshot 1
9090
9191
`// SPDX-License-Identifier: MIT␊
92-
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
92+
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
9393
9494
#[starknet::contract]␊
9595
mod Foo {␊
@@ -114,7 +114,7 @@ Generated by [AVA](https://avajs.dev).
114114
> Snapshot 1
115115
116116
`// SPDX-License-Identifier: MIT␊
117-
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
117+
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
118118
119119
#[starknet::contract]␊
120120
mod Foo {␊
@@ -152,7 +152,7 @@ Generated by [AVA](https://avajs.dev).
152152
> Snapshot 1
153153
154154
`// SPDX-License-Identifier: MIT␊
155-
// Compatible with OpenZeppelin Contracts for Cairo ^0.17.0␊
155+
// Compatible with OpenZeppelin Contracts for Cairo ^0.18.0␊
156156
157157
#[starknet::contract]␊
158158
mod Foo {␊
-1 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)