Skip to content

Commit

Permalink
Use Contracts for Cairo v0.10.0 (#344)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericglau authored Mar 12, 2024
1 parent 47d0276 commit d33453b
Show file tree
Hide file tree
Showing 19 changed files with 159 additions and 102 deletions.
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.10.0 (2024-03-12)

- **Breaking changes**:
- Use OpenZeppelin Contracts for Cairo v0.10.0. ([#344](https://github.com/OpenZeppelin/contracts-wizard/pull/344))
- ERC721: Remove token URI parameter from safe mint functions.
- ERC721: Add optional base URI parameter. If not set, this defaults to empty string.
- Use string literals for ByteArray initialization instead of short strings.

## 0.9.2 (2024-02-26)

- Remove code comment for Cairo lang version. ([#337](https://github.com/OpenZeppelin/contracts-wizard/pull/337))
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.9.2",
"version": "0.10.0",
"description": "A boilerplate generator to get started with OpenZeppelin Contracts for Cairo",
"license": "MIT",
"repository": "github:OpenZeppelin/contracts-wizard",
Expand Down
16 changes: 8 additions & 8 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.9.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.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.9.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.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.9.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.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.9.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.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.9.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.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.9.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
#[starknet::contract]␊
mod Foo {␊
Expand Down Expand Up @@ -142,7 +142,7 @@ Generated by [AVA](https://avajs.dev).
#[constructor]␊
fn constructor(ref self: ContractState) {␊
self.foo.initializer('param1');␊
self.foo.initializer("param1");␊
}␊
}␊
`
Expand All @@ -152,7 +152,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.9.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
#[starknet::contract]␊
mod Foo {␊
Expand Down
Binary file modified packages/core-cairo/src/contract.test.ts.snap
Binary file not shown.
14 changes: 7 additions & 7 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.9.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.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.9.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
#[starknet::contract]␊
mod MyContract {␊
Expand Down Expand Up @@ -90,7 +90,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.9.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
#[starknet::contract]␊
mod MyContract {␊
Expand Down Expand Up @@ -148,7 +148,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.9.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
#[starknet::contract]␊
mod MyContract {␊
Expand All @@ -163,7 +163,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.9.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
#[starknet::contract]␊
mod MyContract {␊
Expand Down Expand Up @@ -204,7 +204,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.9.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
#[starknet::contract]␊
mod MyContract {␊
Expand Down Expand Up @@ -256,7 +256,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.9.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
#[starknet::contract]␊
mod MyContract {␊
Expand Down
Binary file modified packages/core-cairo/src/custom.test.ts.snap
Binary file not shown.
44 changes: 22 additions & 22 deletions packages/core-cairo/src/erc20.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.9.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
#[starknet::contract]␊
mod MyToken {␊
Expand Down Expand Up @@ -41,7 +41,7 @@ Generated by [AVA](https://avajs.dev).
#[constructor]␊
fn constructor(ref self: ContractState) {␊
self.erc20.initializer('MyToken', 'MTK');␊
self.erc20.initializer("MyToken", "MTK");␊
}␊
}␊
`
Expand All @@ -51,7 +51,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.9.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
#[starknet::contract]␊
mod MyToken {␊
Expand Down Expand Up @@ -84,7 +84,7 @@ Generated by [AVA](https://avajs.dev).
#[constructor]␊
fn constructor(ref self: ContractState) {␊
self.erc20.initializer('MyToken', 'MTK');␊
self.erc20.initializer("MyToken", "MTK");␊
}␊
#[generate_trait]␊
Expand All @@ -104,7 +104,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.9.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
#[starknet::contract]␊
mod MyToken {␊
Expand Down Expand Up @@ -154,7 +154,7 @@ Generated by [AVA](https://avajs.dev).
#[constructor]␊
fn constructor(ref self: ContractState, owner: ContractAddress) {␊
self.erc20.initializer('MyToken', 'MTK');␊
self.erc20.initializer("MyToken", "MTK");␊
self.ownable.initializer(owner);␊
}␊
Expand Down Expand Up @@ -237,7 +237,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.9.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
const PAUSER_ROLE: felt252 = selector!("PAUSER_ROLE");␊
Expand Down Expand Up @@ -299,7 +299,7 @@ Generated by [AVA](https://avajs.dev).
#[constructor]␊
fn constructor(ref self: ContractState, default_admin: ContractAddress, pauser: ContractAddress) {␊
self.erc20.initializer('MyToken', 'MTK');␊
self.erc20.initializer("MyToken", "MTK");␊
self.accesscontrol.initializer();␊
self.accesscontrol._grant_role(DEFAULT_ADMIN_ROLE, default_admin);␊
Expand Down Expand Up @@ -385,7 +385,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.9.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
#[starknet::contract]␊
mod MyToken {␊
Expand Down Expand Up @@ -436,7 +436,7 @@ Generated by [AVA](https://avajs.dev).
#[constructor]␊
fn constructor(ref self: ContractState, owner: ContractAddress) {␊
self.erc20.initializer('MyToken', 'MTK');␊
self.erc20.initializer("MyToken", "MTK");␊
self.ownable.initializer(owner);␊
}␊
Expand Down Expand Up @@ -526,7 +526,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.9.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
#[starknet::contract]␊
mod MyToken {␊
Expand Down Expand Up @@ -559,7 +559,7 @@ Generated by [AVA](https://avajs.dev).
#[constructor]␊
fn constructor(ref self: ContractState, recipient: ContractAddress) {␊
self.erc20.initializer('MyToken', 'MTK');␊
self.erc20.initializer("MyToken", "MTK");␊
self.erc20._mint(recipient, 1000000000000000000000);␊
}␊
Expand All @@ -571,7 +571,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.9.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
#[starknet::contract]␊
mod MyToken {␊
Expand Down Expand Up @@ -603,7 +603,7 @@ Generated by [AVA](https://avajs.dev).
#[constructor]␊
fn constructor(ref self: ContractState) {␊
self.erc20.initializer('MyToken', 'MTK');␊
self.erc20.initializer("MyToken", "MTK");␊
}␊
}␊
`
Expand All @@ -613,7 +613,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.9.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
#[starknet::contract]␊
mod MyToken {␊
Expand Down Expand Up @@ -657,7 +657,7 @@ Generated by [AVA](https://avajs.dev).
#[constructor]␊
fn constructor(ref self: ContractState, owner: ContractAddress) {␊
self.erc20.initializer('MyToken', 'MTK');␊
self.erc20.initializer("MyToken", "MTK");␊
self.ownable.initializer(owner);␊
}␊
Expand All @@ -678,7 +678,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.9.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
const MINTER_ROLE: felt252 = selector!("MINTER_ROLE");␊
Expand Down Expand Up @@ -734,7 +734,7 @@ Generated by [AVA](https://avajs.dev).
#[constructor]␊
fn constructor(ref self: ContractState, default_admin: ContractAddress, minter: ContractAddress) {␊
self.erc20.initializer('MyToken', 'MTK');␊
self.erc20.initializer("MyToken", "MTK");␊
self.accesscontrol.initializer();␊
self.accesscontrol._grant_role(DEFAULT_ADMIN_ROLE, default_admin);␊
Expand All @@ -758,7 +758,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.9.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
#[starknet::contract]␊
mod MyToken {␊
Expand Down Expand Up @@ -818,7 +818,7 @@ Generated by [AVA](https://avajs.dev).
#[constructor]␊
fn constructor(ref self: ContractState, recipient: ContractAddress, owner: ContractAddress) {␊
self.erc20.initializer('MyToken', 'MTK');␊
self.erc20.initializer("MyToken", "MTK");␊
self.ownable.initializer(owner);␊
self.erc20._mint(recipient, 2000000000000000000000);␊
Expand Down Expand Up @@ -925,7 +925,7 @@ Generated by [AVA](https://avajs.dev).
> Snapshot 1
`// SPDX-License-Identifier: MIT␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.9.0␊
// Compatible with OpenZeppelin Contracts for Cairo ^0.10.0␊
const PAUSER_ROLE: felt252 = selector!("PAUSER_ROLE");␊
const MINTER_ROLE: felt252 = selector!("MINTER_ROLE");␊
Expand Down Expand Up @@ -1006,7 +1006,7 @@ Generated by [AVA](https://avajs.dev).
minter: ContractAddress,␊
upgrader: ContractAddress,␊
) {␊
self.erc20.initializer('MyToken', 'MTK');␊
self.erc20.initializer("MyToken", "MTK");␊
self.accesscontrol.initializer();␊
self.erc20._mint(recipient, 2000000000000000000000);␊
Expand Down
Binary file modified packages/core-cairo/src/erc20.test.ts.snap
Binary file not shown.
4 changes: 2 additions & 2 deletions packages/core-cairo/src/erc20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { defineComponents } from './utils/define-components';
import { defaults as commonDefaults } from './common-options';
import { printContract } from './print';
import { externalTrait } from './external-trait';
import { toShortString } from './utils/convert-strings';
import { toStringLiteral } from './utils/convert-strings';

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

const allOpts = withDefaults(opts);

addBase(c, toShortString(allOpts.name, 'name'), toShortString(allOpts.symbol, 'symbol'));
addBase(c, toStringLiteral(allOpts.name), toStringLiteral(allOpts.symbol));
addERC20ImplAndCamelOnlyImpl(c, allOpts.pausable);

if (allOpts.premint) {
Expand Down
4 changes: 4 additions & 0 deletions packages/core-cairo/src/erc721.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ function testERC721(title: string, opts: Partial<ERC721Options>) {

testERC721('basic', {});

testERC721('base uri', {
baseUri: 'https://gateway.pinata.cloud/ipfs/QmcP9hxrnC1T5ATPmq2saFeAM1ypFX9BnAswCdHB9JCjLA/',
});

testERC721('burnable', {
burnable: true,
});
Expand Down
Loading

0 comments on commit d33453b

Please sign in to comment.