Skip to content

Commit d33453b

Browse files
authored
Use Contracts for Cairo v0.10.0 (#344)
1 parent 47d0276 commit d33453b

19 files changed

+159
-102
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.10.0 (2024-03-12)
4+
5+
- **Breaking changes**:
6+
- Use OpenZeppelin Contracts for Cairo v0.10.0. ([#344](https://github.com/OpenZeppelin/contracts-wizard/pull/344))
7+
- ERC721: Remove token URI parameter from safe mint functions.
8+
- ERC721: Add optional base URI parameter. If not set, this defaults to empty string.
9+
- Use string literals for ByteArray initialization instead of short strings.
10+
311
## 0.9.2 (2024-02-26)
412

513
- Remove code comment for Cairo lang version. ([#337](https://github.com/OpenZeppelin/contracts-wizard/pull/337))

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.9.2",
3+
"version": "0.10.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/contract.test.ts.md

Lines changed: 8 additions & 8 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.9.0␊
12+
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.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.9.0␊
27+
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.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.9.0␊
47+
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.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.9.0␊
67+
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.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.9.0␊
92+
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.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.9.0␊
117+
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
118118
119119
#[starknet::contract]␊
120120
mod Foo {␊
@@ -142,7 +142,7 @@ Generated by [AVA](https://avajs.dev).
142142
143143
#[constructor]␊
144144
fn constructor(ref self: ContractState) {␊
145-
self.foo.initializer('param1');␊
145+
self.foo.initializer("param1");␊
146146
}␊
147147
}␊
148148
`
@@ -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.9.0␊
155+
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
156156
157157
#[starknet::contract]␊
158158
mod Foo {␊
1 Byte
Binary file not shown.

packages/core-cairo/src/custom.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.9.0␊
12+
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
1313
1414
#[starknet::contract]␊
1515
mod MyContract {␊
@@ -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.9.0␊
27+
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
2828
2929
#[starknet::contract]␊
3030
mod MyContract {␊
@@ -90,7 +90,7 @@ Generated by [AVA](https://avajs.dev).
9090
> Snapshot 1
9191
9292
`// SPDX-License-Identifier: MIT␊
93-
// Compatible with OpenZeppelin Contracts for Cairo ^0.9.0␊
93+
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
9494
9595
#[starknet::contract]␊
9696
mod MyContract {␊
@@ -148,7 +148,7 @@ Generated by [AVA](https://avajs.dev).
148148
> Snapshot 1
149149
150150
`// SPDX-License-Identifier: MIT␊
151-
// Compatible with OpenZeppelin Contracts for Cairo ^0.9.0␊
151+
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
152152
153153
#[starknet::contract]␊
154154
mod MyContract {␊
@@ -163,7 +163,7 @@ Generated by [AVA](https://avajs.dev).
163163
> Snapshot 1
164164
165165
`// SPDX-License-Identifier: MIT␊
166-
// Compatible with OpenZeppelin Contracts for Cairo ^0.9.0␊
166+
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
167167
168168
#[starknet::contract]␊
169169
mod MyContract {␊
@@ -204,7 +204,7 @@ Generated by [AVA](https://avajs.dev).
204204
> Snapshot 1
205205
206206
`// SPDX-License-Identifier: MIT␊
207-
// Compatible with OpenZeppelin Contracts for Cairo ^0.9.0␊
207+
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
208208
209209
#[starknet::contract]␊
210210
mod MyContract {␊
@@ -256,7 +256,7 @@ Generated by [AVA](https://avajs.dev).
256256
> Snapshot 1
257257
258258
`// SPDX-License-Identifier: MIT␊
259-
// Compatible with OpenZeppelin Contracts for Cairo ^0.9.0␊
259+
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
260260
261261
#[starknet::contract]␊
262262
mod MyContract {␊
1 Byte
Binary file not shown.

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

Lines changed: 22 additions & 22 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.9.0␊
12+
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
1313
1414
#[starknet::contract]␊
1515
mod MyToken {␊
@@ -41,7 +41,7 @@ Generated by [AVA](https://avajs.dev).
4141
4242
#[constructor]␊
4343
fn constructor(ref self: ContractState) {␊
44-
self.erc20.initializer('MyToken', 'MTK');␊
44+
self.erc20.initializer("MyToken", "MTK");␊
4545
}␊
4646
}␊
4747
`
@@ -51,7 +51,7 @@ Generated by [AVA](https://avajs.dev).
5151
> Snapshot 1
5252
5353
`// SPDX-License-Identifier: MIT␊
54-
// Compatible with OpenZeppelin Contracts for Cairo ^0.9.0␊
54+
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
5555
5656
#[starknet::contract]␊
5757
mod MyToken {␊
@@ -84,7 +84,7 @@ Generated by [AVA](https://avajs.dev).
8484
8585
#[constructor]␊
8686
fn constructor(ref self: ContractState) {␊
87-
self.erc20.initializer('MyToken', 'MTK');␊
87+
self.erc20.initializer("MyToken", "MTK");␊
8888
}␊
8989
9090
#[generate_trait]␊
@@ -104,7 +104,7 @@ Generated by [AVA](https://avajs.dev).
104104
> Snapshot 1
105105
106106
`// SPDX-License-Identifier: MIT␊
107-
// Compatible with OpenZeppelin Contracts for Cairo ^0.9.0␊
107+
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
108108
109109
#[starknet::contract]␊
110110
mod MyToken {␊
@@ -154,7 +154,7 @@ Generated by [AVA](https://avajs.dev).
154154
155155
#[constructor]␊
156156
fn constructor(ref self: ContractState, owner: ContractAddress) {␊
157-
self.erc20.initializer('MyToken', 'MTK');␊
157+
self.erc20.initializer("MyToken", "MTK");␊
158158
self.ownable.initializer(owner);␊
159159
}␊
160160
@@ -237,7 +237,7 @@ Generated by [AVA](https://avajs.dev).
237237
> Snapshot 1
238238
239239
`// SPDX-License-Identifier: MIT␊
240-
// Compatible with OpenZeppelin Contracts for Cairo ^0.9.0␊
240+
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
241241
242242
const PAUSER_ROLE: felt252 = selector!("PAUSER_ROLE");␊
243243
@@ -299,7 +299,7 @@ Generated by [AVA](https://avajs.dev).
299299
300300
#[constructor]␊
301301
fn constructor(ref self: ContractState, default_admin: ContractAddress, pauser: ContractAddress) {␊
302-
self.erc20.initializer('MyToken', 'MTK');␊
302+
self.erc20.initializer("MyToken", "MTK");␊
303303
self.accesscontrol.initializer();␊
304304
305305
self.accesscontrol._grant_role(DEFAULT_ADMIN_ROLE, default_admin);␊
@@ -385,7 +385,7 @@ Generated by [AVA](https://avajs.dev).
385385
> Snapshot 1
386386
387387
`// SPDX-License-Identifier: MIT␊
388-
// Compatible with OpenZeppelin Contracts for Cairo ^0.9.0␊
388+
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
389389
390390
#[starknet::contract]␊
391391
mod MyToken {␊
@@ -436,7 +436,7 @@ Generated by [AVA](https://avajs.dev).
436436
437437
#[constructor]␊
438438
fn constructor(ref self: ContractState, owner: ContractAddress) {␊
439-
self.erc20.initializer('MyToken', 'MTK');␊
439+
self.erc20.initializer("MyToken", "MTK");␊
440440
self.ownable.initializer(owner);␊
441441
}␊
442442
@@ -526,7 +526,7 @@ Generated by [AVA](https://avajs.dev).
526526
> Snapshot 1
527527
528528
`// SPDX-License-Identifier: MIT␊
529-
// Compatible with OpenZeppelin Contracts for Cairo ^0.9.0␊
529+
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
530530
531531
#[starknet::contract]␊
532532
mod MyToken {␊
@@ -559,7 +559,7 @@ Generated by [AVA](https://avajs.dev).
559559
560560
#[constructor]␊
561561
fn constructor(ref self: ContractState, recipient: ContractAddress) {␊
562-
self.erc20.initializer('MyToken', 'MTK');␊
562+
self.erc20.initializer("MyToken", "MTK");␊
563563
564564
self.erc20._mint(recipient, 1000000000000000000000);␊
565565
}␊
@@ -571,7 +571,7 @@ Generated by [AVA](https://avajs.dev).
571571
> Snapshot 1
572572
573573
`// SPDX-License-Identifier: MIT␊
574-
// Compatible with OpenZeppelin Contracts for Cairo ^0.9.0␊
574+
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
575575
576576
#[starknet::contract]␊
577577
mod MyToken {␊
@@ -603,7 +603,7 @@ Generated by [AVA](https://avajs.dev).
603603
604604
#[constructor]␊
605605
fn constructor(ref self: ContractState) {␊
606-
self.erc20.initializer('MyToken', 'MTK');␊
606+
self.erc20.initializer("MyToken", "MTK");␊
607607
}␊
608608
}␊
609609
`
@@ -613,7 +613,7 @@ Generated by [AVA](https://avajs.dev).
613613
> Snapshot 1
614614
615615
`// SPDX-License-Identifier: MIT␊
616-
// Compatible with OpenZeppelin Contracts for Cairo ^0.9.0␊
616+
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
617617
618618
#[starknet::contract]␊
619619
mod MyToken {␊
@@ -657,7 +657,7 @@ Generated by [AVA](https://avajs.dev).
657657
658658
#[constructor]␊
659659
fn constructor(ref self: ContractState, owner: ContractAddress) {␊
660-
self.erc20.initializer('MyToken', 'MTK');␊
660+
self.erc20.initializer("MyToken", "MTK");␊
661661
self.ownable.initializer(owner);␊
662662
}␊
663663
@@ -678,7 +678,7 @@ Generated by [AVA](https://avajs.dev).
678678
> Snapshot 1
679679
680680
`// SPDX-License-Identifier: MIT␊
681-
// Compatible with OpenZeppelin Contracts for Cairo ^0.9.0␊
681+
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
682682
683683
const MINTER_ROLE: felt252 = selector!("MINTER_ROLE");␊
684684
@@ -734,7 +734,7 @@ Generated by [AVA](https://avajs.dev).
734734
735735
#[constructor]␊
736736
fn constructor(ref self: ContractState, default_admin: ContractAddress, minter: ContractAddress) {␊
737-
self.erc20.initializer('MyToken', 'MTK');␊
737+
self.erc20.initializer("MyToken", "MTK");␊
738738
self.accesscontrol.initializer();␊
739739
740740
self.accesscontrol._grant_role(DEFAULT_ADMIN_ROLE, default_admin);␊
@@ -758,7 +758,7 @@ Generated by [AVA](https://avajs.dev).
758758
> Snapshot 1
759759
760760
`// SPDX-License-Identifier: MIT␊
761-
// Compatible with OpenZeppelin Contracts for Cairo ^0.9.0␊
761+
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
762762
763763
#[starknet::contract]␊
764764
mod MyToken {␊
@@ -818,7 +818,7 @@ Generated by [AVA](https://avajs.dev).
818818
819819
#[constructor]␊
820820
fn constructor(ref self: ContractState, recipient: ContractAddress, owner: ContractAddress) {␊
821-
self.erc20.initializer('MyToken', 'MTK');␊
821+
self.erc20.initializer("MyToken", "MTK");␊
822822
self.ownable.initializer(owner);␊
823823
824824
self.erc20._mint(recipient, 2000000000000000000000);␊
@@ -925,7 +925,7 @@ Generated by [AVA](https://avajs.dev).
925925
> Snapshot 1
926926
927927
`// SPDX-License-Identifier: MIT␊
928-
// Compatible with OpenZeppelin Contracts for Cairo ^0.9.0␊
928+
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
929929
930930
const PAUSER_ROLE: felt252 = selector!("PAUSER_ROLE");␊
931931
const MINTER_ROLE: felt252 = selector!("MINTER_ROLE");␊
@@ -1006,7 +1006,7 @@ Generated by [AVA](https://avajs.dev).
10061006
minter: ContractAddress,␊
10071007
upgrader: ContractAddress,␊
10081008
) {␊
1009-
self.erc20.initializer('MyToken', 'MTK');␊
1009+
self.erc20.initializer("MyToken", "MTK");␊
10101010
self.accesscontrol.initializer();␊
10111011
10121012
self.erc20._mint(recipient, 2000000000000000000000);␊
-1 Bytes
Binary file not shown.

packages/core-cairo/src/erc20.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { defineComponents } from './utils/define-components';
1010
import { defaults as commonDefaults } from './common-options';
1111
import { printContract } from './print';
1212
import { externalTrait } from './external-trait';
13-
import { toShortString } from './utils/convert-strings';
13+
import { toStringLiteral } from './utils/convert-strings';
1414

1515
export const defaults: Required<ERC20Options> = {
1616
name: 'MyToken',
@@ -57,7 +57,7 @@ export function buildERC20(opts: ERC20Options): Contract {
5757

5858
const allOpts = withDefaults(opts);
5959

60-
addBase(c, toShortString(allOpts.name, 'name'), toShortString(allOpts.symbol, 'symbol'));
60+
addBase(c, toStringLiteral(allOpts.name), toStringLiteral(allOpts.symbol));
6161
addERC20ImplAndCamelOnlyImpl(c, allOpts.pausable);
6262

6363
if (allOpts.premint) {

packages/core-cairo/src/erc721.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ function testERC721(title: string, opts: Partial<ERC721Options>) {
3131

3232
testERC721('basic', {});
3333

34+
testERC721('base uri', {
35+
baseUri: 'https://gateway.pinata.cloud/ipfs/QmcP9hxrnC1T5ATPmq2saFeAM1ypFX9BnAswCdHB9JCjLA/',
36+
});
37+
3438
testERC721('burnable', {
3539
burnable: true,
3640
});

0 commit comments

Comments
 (0)