diff --git a/packages/core-cairo/CHANGELOG.md b/packages/core-cairo/CHANGELOG.md index 19f093ab..77c8eb58 100644 --- a/packages/core-cairo/CHANGELOG.md +++ b/packages/core-cairo/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 0.14.0 (2024-06-20) + +- **Breaking changes**: + - Use OpenZeppelin Contracts for Cairo v0.14.0. ([#369](https://github.com/OpenZeppelin/contracts-wizard/pull/369)) + - Fix compile error with ERC1155 Burnable. + ## 0.13.0 (2024-05-22) - **Breaking changes**: diff --git a/packages/core-cairo/package.json b/packages/core-cairo/package.json index 58fcb89f..263dd14f 100644 --- a/packages/core-cairo/package.json +++ b/packages/core-cairo/package.json @@ -1,6 +1,6 @@ { "name": "@openzeppelin/wizard-cairo", - "version": "0.13.0", + "version": "0.14.0", "description": "A boilerplate generator to get started with OpenZeppelin Contracts for Cairo", "license": "MIT", "repository": "github:OpenZeppelin/contracts-wizard", diff --git a/packages/core-cairo/src/add-pausable.ts b/packages/core-cairo/src/add-pausable.ts index 7dec045f..a98fe91f 100644 --- a/packages/core-cairo/src/add-pausable.ts +++ b/packages/core-cairo/src/add-pausable.ts @@ -44,7 +44,7 @@ const functions = defineFunctions({ getSelfArg(), ], code: [ - 'self.pausable._pause()' + 'self.pausable.pause()' ] }, unpause: { @@ -52,7 +52,7 @@ const functions = defineFunctions({ getSelfArg(), ], code: [ - 'self.pausable._unpause()' + 'self.pausable.unpause()' ] }, }); diff --git a/packages/core-cairo/src/contract.test.ts.md b/packages/core-cairo/src/contract.test.ts.md index 30ca51d4..0e2bedd5 100644 --- a/packages/core-cairo/src/contract.test.ts.md +++ b/packages/core-cairo/src/contract.test.ts.md @@ -9,7 +9,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod Foo {␊ @@ -24,7 +24,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod Foo {␊ @@ -44,7 +44,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod Foo {␊ @@ -64,7 +64,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod Foo {␊ @@ -89,7 +89,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod Foo {␊ @@ -114,7 +114,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod Foo {␊ @@ -152,7 +152,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod Foo {␊ diff --git a/packages/core-cairo/src/contract.test.ts.snap b/packages/core-cairo/src/contract.test.ts.snap index 0201cf73..1090b140 100644 Binary files a/packages/core-cairo/src/contract.test.ts.snap and b/packages/core-cairo/src/contract.test.ts.snap differ diff --git a/packages/core-cairo/src/contract.ts b/packages/core-cairo/src/contract.ts index 194dfca4..0875221e 100644 --- a/packages/core-cairo/src/contract.ts +++ b/packages/core-cairo/src/contract.ts @@ -131,7 +131,7 @@ export class ContractBuilder implements Contract { const key = component.name; const present = this.componentsMap.has(key); if (!present) { - const initializer = initializable ? { params } : undefined; + const initializer = initializable ? { params } : undefined; const cp: Component = { initializer, ...component, impls: [ ...component.impls ] }; // spread impls to deep copy from original component this.componentsMap.set(key, cp); } diff --git a/packages/core-cairo/src/custom.test.ts.md b/packages/core-cairo/src/custom.test.ts.md index c391f504..0b2e82c6 100644 --- a/packages/core-cairo/src/custom.test.ts.md +++ b/packages/core-cairo/src/custom.test.ts.md @@ -9,7 +9,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyContract {␊ @@ -24,7 +24,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyContract {␊ @@ -69,7 +69,7 @@ Generated by [AVA](https://avajs.dev). impl UpgradeableImpl of IUpgradeable {␊ fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊ self.ownable.assert_only_owner();␊ - self.upgradeable._upgrade(new_class_hash);␊ + self.upgradeable.upgrade(new_class_hash);␊ }␊ }␊ }␊ @@ -80,7 +80,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyContract {␊ @@ -134,7 +134,7 @@ Generated by [AVA](https://avajs.dev). impl UpgradeableImpl of IUpgradeable {␊ fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊ self.ownable.assert_only_owner();␊ - self.upgradeable._upgrade(new_class_hash);␊ + self.upgradeable.upgrade(new_class_hash);␊ }␊ }␊ ␊ @@ -144,13 +144,13 @@ Generated by [AVA](https://avajs.dev). #[external(v0)]␊ fn pause(ref self: ContractState) {␊ self.ownable.assert_only_owner();␊ - self.pausable._pause();␊ + self.pausable.pause();␊ }␊ ␊ #[external(v0)]␊ fn unpause(ref self: ContractState) {␊ self.ownable.assert_only_owner();␊ - self.pausable._unpause();␊ + self.pausable.unpause();␊ }␊ }␊ }␊ @@ -161,7 +161,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyContract {␊ @@ -206,7 +206,7 @@ Generated by [AVA](https://avajs.dev). impl UpgradeableImpl of IUpgradeable {␊ fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊ self.ownable.assert_only_owner();␊ - self.upgradeable._upgrade(new_class_hash);␊ + self.upgradeable.upgrade(new_class_hash);␊ }␊ }␊ }␊ @@ -217,7 +217,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyContract {␊ @@ -232,7 +232,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyContract {␊ @@ -277,7 +277,7 @@ Generated by [AVA](https://avajs.dev). impl UpgradeableImpl of IUpgradeable {␊ fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊ self.ownable.assert_only_owner();␊ - self.upgradeable._upgrade(new_class_hash);␊ + self.upgradeable.upgrade(new_class_hash);␊ }␊ }␊ }␊ @@ -288,7 +288,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ const UPGRADER_ROLE: felt252 = selector!("UPGRADER_ROLE");␊ ␊ @@ -350,7 +350,7 @@ Generated by [AVA](https://avajs.dev). impl UpgradeableImpl of IUpgradeable {␊ fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊ self.accesscontrol.assert_only_role(UPGRADER_ROLE);␊ - self.upgradeable._upgrade(new_class_hash);␊ + self.upgradeable.upgrade(new_class_hash);␊ }␊ }␊ }␊ @@ -361,7 +361,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyContract {␊ @@ -408,13 +408,13 @@ Generated by [AVA](https://avajs.dev). #[external(v0)]␊ fn pause(ref self: ContractState) {␊ self.ownable.assert_only_owner();␊ - self.pausable._pause();␊ + self.pausable.pause();␊ }␊ ␊ #[external(v0)]␊ fn unpause(ref self: ContractState) {␊ self.ownable.assert_only_owner();␊ - self.pausable._unpause();␊ + self.pausable.unpause();␊ }␊ }␊ }␊ diff --git a/packages/core-cairo/src/custom.test.ts.snap b/packages/core-cairo/src/custom.test.ts.snap index 5da6f997..382d56da 100644 Binary files a/packages/core-cairo/src/custom.test.ts.snap and b/packages/core-cairo/src/custom.test.ts.snap differ diff --git a/packages/core-cairo/src/erc1155.test.ts.md b/packages/core-cairo/src/erc1155.test.ts.md index 341e6a26..bfa4646e 100644 --- a/packages/core-cairo/src/erc1155.test.ts.md +++ b/packages/core-cairo/src/erc1155.test.ts.md @@ -9,7 +9,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyToken {␊ @@ -64,7 +64,7 @@ Generated by [AVA](https://avajs.dev). #[external(v0)]␊ fn set_base_uri(ref self: ContractState, base_uri: ByteArray) {␊ self.ownable.assert_only_owner();␊ - self.erc1155.set_base_uri(base_uri);␊ + self.erc1155._set_base_uri(base_uri);␊ }␊ ␊ #[external(v0)]␊ @@ -80,7 +80,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyToken {␊ @@ -142,7 +142,7 @@ Generated by [AVA](https://avajs.dev). impl UpgradeableImpl of IUpgradeable {␊ fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊ self.ownable.assert_only_owner();␊ - self.upgradeable._upgrade(new_class_hash);␊ + self.upgradeable.upgrade(new_class_hash);␊ }␊ }␊ ␊ @@ -152,7 +152,7 @@ Generated by [AVA](https://avajs.dev). #[external(v0)]␊ fn set_base_uri(ref self: ContractState, base_uri: ByteArray) {␊ self.ownable.assert_only_owner();␊ - self.erc1155.set_base_uri(base_uri);␊ + self.erc1155._set_base_uri(base_uri);␊ }␊ ␊ #[external(v0)]␊ @@ -168,7 +168,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ const URI_SETTER_ROLE: felt252 = selector!("URI_SETTER_ROLE");␊ const UPGRADER_ROLE: felt252 = selector!("UPGRADER_ROLE");␊ @@ -246,7 +246,7 @@ Generated by [AVA](https://avajs.dev). impl UpgradeableImpl of IUpgradeable {␊ fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊ self.accesscontrol.assert_only_role(UPGRADER_ROLE);␊ - self.upgradeable._upgrade(new_class_hash);␊ + self.upgradeable.upgrade(new_class_hash);␊ }␊ }␊ ␊ @@ -256,7 +256,7 @@ Generated by [AVA](https://avajs.dev). #[external(v0)]␊ fn set_base_uri(ref self: ContractState, base_uri: ByteArray) {␊ self.accesscontrol.assert_only_role(URI_SETTER_ROLE);␊ - self.erc1155.set_base_uri(base_uri);␊ + self.erc1155._set_base_uri(base_uri);␊ }␊ ␊ #[external(v0)]␊ @@ -272,7 +272,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyToken {␊ @@ -334,7 +334,7 @@ Generated by [AVA](https://avajs.dev). impl UpgradeableImpl of IUpgradeable {␊ fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊ self.ownable.assert_only_owner();␊ - self.upgradeable._upgrade(new_class_hash);␊ + self.upgradeable.upgrade(new_class_hash);␊ }␊ }␊ }␊ @@ -345,7 +345,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyToken {␊ @@ -408,7 +408,7 @@ Generated by [AVA](https://avajs.dev). impl UpgradeableImpl of IUpgradeable {␊ fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊ self.ownable.assert_only_owner();␊ - self.upgradeable._upgrade(new_class_hash);␊ + self.upgradeable.upgrade(new_class_hash);␊ }␊ }␊ ␊ @@ -451,7 +451,7 @@ Generated by [AVA](https://avajs.dev). #[external(v0)]␊ fn set_base_uri(ref self: ContractState, base_uri: ByteArray) {␊ self.ownable.assert_only_owner();␊ - self.erc1155.set_base_uri(base_uri);␊ + self.erc1155._set_base_uri(base_uri);␊ }␊ ␊ #[external(v0)]␊ @@ -467,7 +467,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyToken {␊ @@ -559,7 +559,7 @@ Generated by [AVA](https://avajs.dev). impl UpgradeableImpl of IUpgradeable {␊ fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊ self.ownable.assert_only_owner();␊ - self.upgradeable._upgrade(new_class_hash);␊ + self.upgradeable.upgrade(new_class_hash);␊ }␊ }␊ ␊ @@ -569,19 +569,19 @@ Generated by [AVA](https://avajs.dev). #[external(v0)]␊ fn pause(ref self: ContractState) {␊ self.ownable.assert_only_owner();␊ - self.pausable._pause();␊ + self.pausable.pause();␊ }␊ ␊ #[external(v0)]␊ fn unpause(ref self: ContractState) {␊ self.ownable.assert_only_owner();␊ - self.pausable._unpause();␊ + self.pausable.unpause();␊ }␊ ␊ #[external(v0)]␊ fn set_base_uri(ref self: ContractState, base_uri: ByteArray) {␊ self.ownable.assert_only_owner();␊ - self.erc1155.set_base_uri(base_uri);␊ + self.erc1155._set_base_uri(base_uri);␊ }␊ ␊ #[external(v0)]␊ @@ -597,7 +597,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyToken {␊ @@ -659,7 +659,7 @@ Generated by [AVA](https://avajs.dev). impl UpgradeableImpl of IUpgradeable {␊ fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊ self.ownable.assert_only_owner();␊ - self.upgradeable._upgrade(new_class_hash);␊ + self.upgradeable.upgrade(new_class_hash);␊ }␊ }␊ ␊ @@ -704,7 +704,7 @@ Generated by [AVA](https://avajs.dev). #[external(v0)]␊ fn set_base_uri(ref self: ContractState, base_uri: ByteArray) {␊ self.ownable.assert_only_owner();␊ - self.erc1155.set_base_uri(base_uri);␊ + self.erc1155._set_base_uri(base_uri);␊ }␊ ␊ #[external(v0)]␊ @@ -720,7 +720,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ const MINTER_ROLE: felt252 = selector!("MINTER_ROLE");␊ const URI_SETTER_ROLE: felt252 = selector!("URI_SETTER_ROLE");␊ @@ -801,7 +801,7 @@ Generated by [AVA](https://avajs.dev). impl UpgradeableImpl of IUpgradeable {␊ fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊ self.accesscontrol.assert_only_role(UPGRADER_ROLE);␊ - self.upgradeable._upgrade(new_class_hash);␊ + self.upgradeable.upgrade(new_class_hash);␊ }␊ }␊ ␊ @@ -846,7 +846,7 @@ Generated by [AVA](https://avajs.dev). #[external(v0)]␊ fn set_base_uri(ref self: ContractState, base_uri: ByteArray) {␊ self.accesscontrol.assert_only_role(URI_SETTER_ROLE);␊ - self.erc1155.set_base_uri(base_uri);␊ + self.erc1155._set_base_uri(base_uri);␊ }␊ ␊ #[external(v0)]␊ @@ -862,7 +862,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ const PAUSER_ROLE: felt252 = selector!("PAUSER_ROLE");␊ const MINTER_ROLE: felt252 = selector!("MINTER_ROLE");␊ @@ -967,13 +967,13 @@ Generated by [AVA](https://avajs.dev). #[external(v0)]␊ fn pause(ref self: ContractState) {␊ self.accesscontrol.assert_only_role(PAUSER_ROLE);␊ - self.pausable._pause();␊ + self.pausable.pause();␊ }␊ ␊ #[external(v0)]␊ fn unpause(ref self: ContractState) {␊ self.accesscontrol.assert_only_role(PAUSER_ROLE);␊ - self.pausable._unpause();␊ + self.pausable.unpause();␊ }␊ ␊ #[external(v0)]␊ @@ -1047,7 +1047,7 @@ Generated by [AVA](https://avajs.dev). #[external(v0)]␊ fn set_base_uri(ref self: ContractState, base_uri: ByteArray) {␊ self.accesscontrol.assert_only_role(URI_SETTER_ROLE);␊ - self.erc1155.set_base_uri(base_uri);␊ + self.erc1155._set_base_uri(base_uri);␊ }␊ ␊ #[external(v0)]␊ @@ -1063,7 +1063,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ const PAUSER_ROLE: felt252 = selector!("PAUSER_ROLE");␊ const MINTER_ROLE: felt252 = selector!("MINTER_ROLE");␊ @@ -1178,7 +1178,7 @@ Generated by [AVA](https://avajs.dev). impl UpgradeableImpl of IUpgradeable {␊ fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊ self.accesscontrol.assert_only_role(UPGRADER_ROLE);␊ - self.upgradeable._upgrade(new_class_hash);␊ + self.upgradeable.upgrade(new_class_hash);␊ }␊ }␊ ␊ @@ -1188,13 +1188,13 @@ Generated by [AVA](https://avajs.dev). #[external(v0)]␊ fn pause(ref self: ContractState) {␊ self.accesscontrol.assert_only_role(PAUSER_ROLE);␊ - self.pausable._pause();␊ + self.pausable.pause();␊ }␊ ␊ #[external(v0)]␊ fn unpause(ref self: ContractState) {␊ self.accesscontrol.assert_only_role(PAUSER_ROLE);␊ - self.pausable._unpause();␊ + self.pausable.unpause();␊ }␊ ␊ #[external(v0)]␊ @@ -1268,7 +1268,7 @@ Generated by [AVA](https://avajs.dev). #[external(v0)]␊ fn set_base_uri(ref self: ContractState, base_uri: ByteArray) {␊ self.accesscontrol.assert_only_role(URI_SETTER_ROLE);␊ - self.erc1155.set_base_uri(base_uri);␊ + self.erc1155._set_base_uri(base_uri);␊ }␊ ␊ #[external(v0)]␊ diff --git a/packages/core-cairo/src/erc1155.test.ts.snap b/packages/core-cairo/src/erc1155.test.ts.snap index 3df4d9cd..4a857a71 100644 Binary files a/packages/core-cairo/src/erc1155.test.ts.snap and b/packages/core-cairo/src/erc1155.test.ts.snap differ diff --git a/packages/core-cairo/src/erc1155.ts b/packages/core-cairo/src/erc1155.ts index 529f4a35..db32cd63 100644 --- a/packages/core-cairo/src/erc1155.ts +++ b/packages/core-cairo/src/erc1155.ts @@ -145,6 +145,7 @@ function addBase(c: ContractBuilder, baseUri: string) { } function addBurnable(c: ContractBuilder) { + c.addStandaloneImport('starknet::ContractAddress'); c.addStandaloneImport('starknet::get_caller_address'); c.addFunction(externalTrait, functions.burn); c.addFunction(externalTrait, functions.batch_burn); @@ -270,7 +271,7 @@ const functions = defineFunctions({ { name: 'base_uri', type: 'ByteArray' }, ], code: [ - 'self.erc1155.set_base_uri(base_uri);' + 'self.erc1155._set_base_uri(base_uri);' ] }, setBaseUri: { diff --git a/packages/core-cairo/src/erc20.test.ts b/packages/core-cairo/src/erc20.test.ts index 929f1591..69f4cdd3 100644 --- a/packages/core-cairo/src/erc20.test.ts +++ b/packages/core-cairo/src/erc20.test.ts @@ -171,7 +171,7 @@ test('erc20 API isAccessControlRequired', async t => { t.is(erc20.isAccessControlRequired({ mintable: true }), true); t.is(erc20.isAccessControlRequired({ pausable: true }), true); t.is(erc20.isAccessControlRequired({ upgradeable: true }), true); -}); +}); test('erc20 getInitialSupply', async t => { t.is(getInitialSupply('1000', 18), '1000000000000000000000'); diff --git a/packages/core-cairo/src/erc20.test.ts.md b/packages/core-cairo/src/erc20.test.ts.md index cf5fb11f..7e507ab2 100644 --- a/packages/core-cairo/src/erc20.test.ts.md +++ b/packages/core-cairo/src/erc20.test.ts.md @@ -9,7 +9,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyToken {␊ @@ -48,7 +48,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyToken {␊ @@ -104,7 +104,7 @@ Generated by [AVA](https://avajs.dev). impl UpgradeableImpl of IUpgradeable {␊ fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊ self.ownable.assert_only_owner();␊ - self.upgradeable._upgrade(new_class_hash);␊ + self.upgradeable.upgrade(new_class_hash);␊ }␊ }␊ }␊ @@ -115,7 +115,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyToken {␊ @@ -172,7 +172,7 @@ Generated by [AVA](https://avajs.dev). impl UpgradeableImpl of IUpgradeable {␊ fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊ self.ownable.assert_only_owner();␊ - self.upgradeable._upgrade(new_class_hash);␊ + self.upgradeable.upgrade(new_class_hash);␊ }␊ }␊ ␊ @@ -181,7 +181,7 @@ Generated by [AVA](https://avajs.dev). impl ExternalImpl of ExternalTrait {␊ #[external(v0)]␊ fn burn(ref self: ContractState, value: u256) {␊ - self.erc20._burn(get_caller_address(), value);␊ + self.erc20.burn(get_caller_address(), value);␊ }␊ }␊ }␊ @@ -192,7 +192,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyToken {␊ @@ -276,7 +276,7 @@ Generated by [AVA](https://avajs.dev). impl UpgradeableImpl of IUpgradeable {␊ fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊ self.ownable.assert_only_owner();␊ - self.upgradeable._upgrade(new_class_hash);␊ + self.upgradeable.upgrade(new_class_hash);␊ }␊ }␊ ␊ @@ -286,13 +286,13 @@ Generated by [AVA](https://avajs.dev). #[external(v0)]␊ fn pause(ref self: ContractState) {␊ self.ownable.assert_only_owner();␊ - self.pausable._pause();␊ + self.pausable.pause();␊ }␊ ␊ #[external(v0)]␊ fn unpause(ref self: ContractState) {␊ self.ownable.assert_only_owner();␊ - self.pausable._unpause();␊ + self.pausable.unpause();␊ }␊ }␊ }␊ @@ -303,7 +303,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ const PAUSER_ROLE: felt252 = selector!("PAUSER_ROLE");␊ const UPGRADER_ROLE: felt252 = selector!("UPGRADER_ROLE");␊ @@ -407,7 +407,7 @@ Generated by [AVA](https://avajs.dev). impl UpgradeableImpl of IUpgradeable {␊ fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊ self.accesscontrol.assert_only_role(UPGRADER_ROLE);␊ - self.upgradeable._upgrade(new_class_hash);␊ + self.upgradeable.upgrade(new_class_hash);␊ }␊ }␊ ␊ @@ -417,13 +417,13 @@ Generated by [AVA](https://avajs.dev). #[external(v0)]␊ fn pause(ref self: ContractState) {␊ self.accesscontrol.assert_only_role(PAUSER_ROLE);␊ - self.pausable._pause();␊ + self.pausable.pause();␊ }␊ ␊ #[external(v0)]␊ fn unpause(ref self: ContractState) {␊ self.accesscontrol.assert_only_role(PAUSER_ROLE);␊ - self.pausable._unpause();␊ + self.pausable.unpause();␊ }␊ }␊ }␊ @@ -434,7 +434,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyToken {␊ @@ -519,7 +519,7 @@ Generated by [AVA](https://avajs.dev). impl UpgradeableImpl of IUpgradeable {␊ fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊ self.ownable.assert_only_owner();␊ - self.upgradeable._upgrade(new_class_hash);␊ + self.upgradeable.upgrade(new_class_hash);␊ }␊ }␊ ␊ @@ -529,18 +529,18 @@ Generated by [AVA](https://avajs.dev). #[external(v0)]␊ fn pause(ref self: ContractState) {␊ self.ownable.assert_only_owner();␊ - self.pausable._pause();␊ + self.pausable.pause();␊ }␊ ␊ #[external(v0)]␊ fn unpause(ref self: ContractState) {␊ self.ownable.assert_only_owner();␊ - self.pausable._unpause();␊ + self.pausable.unpause();␊ }␊ ␊ #[external(v0)]␊ fn burn(ref self: ContractState, value: u256) {␊ - self.erc20._burn(get_caller_address(), value);␊ + self.erc20.burn(get_caller_address(), value);␊ }␊ }␊ }␊ @@ -551,7 +551,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyToken {␊ @@ -602,14 +602,14 @@ Generated by [AVA](https://avajs.dev). self.erc20.initializer("MyToken", "MTK");␊ self.ownable.initializer(owner);␊ ␊ - self.erc20._mint(recipient, 1000000000000000000000);␊ + self.erc20.mint(recipient, 1000000000000000000000);␊ }␊ ␊ #[abi(embed_v0)]␊ impl UpgradeableImpl of IUpgradeable {␊ fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊ self.ownable.assert_only_owner();␊ - self.upgradeable._upgrade(new_class_hash);␊ + self.upgradeable.upgrade(new_class_hash);␊ }␊ }␊ }␊ @@ -620,7 +620,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyToken {␊ @@ -676,7 +676,7 @@ Generated by [AVA](https://avajs.dev). impl UpgradeableImpl of IUpgradeable {␊ fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊ self.ownable.assert_only_owner();␊ - self.upgradeable._upgrade(new_class_hash);␊ + self.upgradeable.upgrade(new_class_hash);␊ }␊ }␊ }␊ @@ -687,7 +687,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyToken {␊ @@ -743,7 +743,7 @@ Generated by [AVA](https://avajs.dev). impl UpgradeableImpl of IUpgradeable {␊ fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊ self.ownable.assert_only_owner();␊ - self.upgradeable._upgrade(new_class_hash);␊ + self.upgradeable.upgrade(new_class_hash);␊ }␊ }␊ ␊ @@ -753,7 +753,7 @@ Generated by [AVA](https://avajs.dev). #[external(v0)]␊ fn mint(ref self: ContractState, recipient: ContractAddress, amount: u256) {␊ self.ownable.assert_only_owner();␊ - self.erc20._mint(recipient, amount);␊ + self.erc20.mint(recipient, amount);␊ }␊ }␊ }␊ @@ -764,7 +764,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ const MINTER_ROLE: felt252 = selector!("MINTER_ROLE");␊ const UPGRADER_ROLE: felt252 = selector!("UPGRADER_ROLE");␊ @@ -840,7 +840,7 @@ Generated by [AVA](https://avajs.dev). impl UpgradeableImpl of IUpgradeable {␊ fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊ self.accesscontrol.assert_only_role(UPGRADER_ROLE);␊ - self.upgradeable._upgrade(new_class_hash);␊ + self.upgradeable.upgrade(new_class_hash);␊ }␊ }␊ ␊ @@ -850,7 +850,7 @@ Generated by [AVA](https://avajs.dev). #[external(v0)]␊ fn mint(ref self: ContractState, recipient: ContractAddress, amount: u256) {␊ self.accesscontrol.assert_only_role(MINTER_ROLE);␊ - self.erc20._mint(recipient, amount);␊ + self.erc20.mint(recipient, amount);␊ }␊ }␊ }␊ @@ -861,7 +861,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyToken {␊ @@ -964,7 +964,7 @@ Generated by [AVA](https://avajs.dev). impl UpgradeableImpl of IUpgradeable {␊ fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊ self.ownable.assert_only_owner();␊ - self.upgradeable._upgrade(new_class_hash);␊ + self.upgradeable.upgrade(new_class_hash);␊ }␊ }␊ }␊ @@ -975,7 +975,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyToken {␊ @@ -1078,7 +1078,7 @@ Generated by [AVA](https://avajs.dev). impl UpgradeableImpl of IUpgradeable {␊ fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊ self.ownable.assert_only_owner();␊ - self.upgradeable._upgrade(new_class_hash);␊ + self.upgradeable.upgrade(new_class_hash);␊ }␊ }␊ }␊ @@ -1089,7 +1089,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyToken {␊ @@ -1176,7 +1176,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyToken {␊ @@ -1245,7 +1245,7 @@ Generated by [AVA](https://avajs.dev). self.erc20.initializer("MyToken", "MTK");␊ self.ownable.initializer(owner);␊ ␊ - self.erc20._mint(recipient, 2000000000000000000000);␊ + self.erc20.mint(recipient, 2000000000000000000000);␊ }␊ ␊ impl SNIP12MetadataImpl of SNIP12Metadata {␊ @@ -1286,24 +1286,24 @@ Generated by [AVA](https://avajs.dev). #[external(v0)]␊ fn pause(ref self: ContractState) {␊ self.ownable.assert_only_owner();␊ - self.pausable._pause();␊ + self.pausable.pause();␊ }␊ ␊ #[external(v0)]␊ fn unpause(ref self: ContractState) {␊ self.ownable.assert_only_owner();␊ - self.pausable._unpause();␊ + self.pausable.unpause();␊ }␊ ␊ #[external(v0)]␊ fn burn(ref self: ContractState, value: u256) {␊ - self.erc20._burn(get_caller_address(), value);␊ + self.erc20.burn(get_caller_address(), value);␊ }␊ ␊ #[external(v0)]␊ fn mint(ref self: ContractState, recipient: ContractAddress, amount: u256) {␊ self.ownable.assert_only_owner();␊ - self.erc20._mint(recipient, amount);␊ + self.erc20.mint(recipient, amount);␊ }␊ }␊ }␊ @@ -1314,7 +1314,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyToken {␊ @@ -1392,7 +1392,7 @@ Generated by [AVA](https://avajs.dev). self.erc20.initializer("MyToken", "MTK");␊ self.ownable.initializer(owner);␊ ␊ - self.erc20._mint(recipient, 2000000000000000000000);␊ + self.erc20.mint(recipient, 2000000000000000000000);␊ }␊ ␊ impl SNIP12MetadataImpl of SNIP12Metadata {␊ @@ -1431,7 +1431,7 @@ Generated by [AVA](https://avajs.dev). impl UpgradeableImpl of IUpgradeable {␊ fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊ self.ownable.assert_only_owner();␊ - self.upgradeable._upgrade(new_class_hash);␊ + self.upgradeable.upgrade(new_class_hash);␊ }␊ }␊ ␊ @@ -1441,24 +1441,24 @@ Generated by [AVA](https://avajs.dev). #[external(v0)]␊ fn pause(ref self: ContractState) {␊ self.ownable.assert_only_owner();␊ - self.pausable._pause();␊ + self.pausable.pause();␊ }␊ ␊ #[external(v0)]␊ fn unpause(ref self: ContractState) {␊ self.ownable.assert_only_owner();␊ - self.pausable._unpause();␊ + self.pausable.unpause();␊ }␊ ␊ #[external(v0)]␊ fn burn(ref self: ContractState, value: u256) {␊ - self.erc20._burn(get_caller_address(), value);␊ + self.erc20.burn(get_caller_address(), value);␊ }␊ ␊ #[external(v0)]␊ fn mint(ref self: ContractState, recipient: ContractAddress, amount: u256) {␊ self.ownable.assert_only_owner();␊ - self.erc20._mint(recipient, amount);␊ + self.erc20.mint(recipient, amount);␊ }␊ }␊ }␊ @@ -1469,7 +1469,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ const PAUSER_ROLE: felt252 = selector!("PAUSER_ROLE");␊ const MINTER_ROLE: felt252 = selector!("MINTER_ROLE");␊ @@ -1566,7 +1566,7 @@ Generated by [AVA](https://avajs.dev). self.erc20.initializer("MyToken", "MTK");␊ self.accesscontrol.initializer();␊ ␊ - self.erc20._mint(recipient, 2000000000000000000000);␊ + self.erc20.mint(recipient, 2000000000000000000000);␊ self.accesscontrol._grant_role(DEFAULT_ADMIN_ROLE, default_admin);␊ self.accesscontrol._grant_role(PAUSER_ROLE, pauser);␊ self.accesscontrol._grant_role(MINTER_ROLE, minter);␊ @@ -1609,7 +1609,7 @@ Generated by [AVA](https://avajs.dev). impl UpgradeableImpl of IUpgradeable {␊ fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊ self.accesscontrol.assert_only_role(UPGRADER_ROLE);␊ - self.upgradeable._upgrade(new_class_hash);␊ + self.upgradeable.upgrade(new_class_hash);␊ }␊ }␊ ␊ @@ -1619,24 +1619,24 @@ Generated by [AVA](https://avajs.dev). #[external(v0)]␊ fn pause(ref self: ContractState) {␊ self.accesscontrol.assert_only_role(PAUSER_ROLE);␊ - self.pausable._pause();␊ + self.pausable.pause();␊ }␊ ␊ #[external(v0)]␊ fn unpause(ref self: ContractState) {␊ self.accesscontrol.assert_only_role(PAUSER_ROLE);␊ - self.pausable._unpause();␊ + self.pausable.unpause();␊ }␊ ␊ #[external(v0)]␊ fn burn(ref self: ContractState, value: u256) {␊ - self.erc20._burn(get_caller_address(), value);␊ + self.erc20.burn(get_caller_address(), value);␊ }␊ ␊ #[external(v0)]␊ fn mint(ref self: ContractState, recipient: ContractAddress, amount: u256) {␊ self.accesscontrol.assert_only_role(MINTER_ROLE);␊ - self.erc20._mint(recipient, amount);␊ + self.erc20.mint(recipient, amount);␊ }␊ }␊ }␊ diff --git a/packages/core-cairo/src/erc20.test.ts.snap b/packages/core-cairo/src/erc20.test.ts.snap index 5211ab23..ea1745be 100644 Binary files a/packages/core-cairo/src/erc20.test.ts.snap and b/packages/core-cairo/src/erc20.test.ts.snap differ diff --git a/packages/core-cairo/src/erc20.ts b/packages/core-cairo/src/erc20.ts index 76e49e5f..075f99e0 100644 --- a/packages/core-cairo/src/erc20.ts +++ b/packages/core-cairo/src/erc20.ts @@ -194,7 +194,7 @@ function addPremint(c: ContractBuilder, amount: string) { c.addStandaloneImport('starknet::ContractAddress'); c.addConstructorArgument({ name:'recipient', type:'ContractAddress' }); - c.addConstructorCode(`self.erc20._mint(recipient, ${premintAbsolute})`); + c.addConstructorCode(`self.erc20.mint(recipient, ${premintAbsolute})`); } } @@ -338,7 +338,7 @@ const functions = defineFunctions({ { name: 'value', type: 'u256' } ], code: [ - 'self.erc20._burn(get_caller_address(), value);' + 'self.erc20.burn(get_caller_address(), value);' ] }, mint: { @@ -348,7 +348,7 @@ const functions = defineFunctions({ { name: 'amount', type: 'u256' } ], code: [ - 'self.erc20._mint(recipient, amount);' + 'self.erc20.mint(recipient, amount);' ] }, }); diff --git a/packages/core-cairo/src/erc721.test.ts.md b/packages/core-cairo/src/erc721.test.ts.md index 2c7eb15a..37413e94 100644 --- a/packages/core-cairo/src/erc721.test.ts.md +++ b/packages/core-cairo/src/erc721.test.ts.md @@ -9,7 +9,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyToken {␊ @@ -54,7 +54,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyToken {␊ @@ -116,7 +116,7 @@ Generated by [AVA](https://avajs.dev). impl UpgradeableImpl of IUpgradeable {␊ fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊ self.ownable.assert_only_owner();␊ - self.upgradeable._upgrade(new_class_hash);␊ + self.upgradeable.upgrade(new_class_hash);␊ }␊ }␊ }␊ @@ -127,7 +127,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyToken {␊ @@ -189,7 +189,7 @@ Generated by [AVA](https://avajs.dev). impl UpgradeableImpl of IUpgradeable {␊ fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊ self.ownable.assert_only_owner();␊ - self.upgradeable._upgrade(new_class_hash);␊ + self.upgradeable.upgrade(new_class_hash);␊ }␊ }␊ }␊ @@ -200,10 +200,11 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyToken {␊ + use core::num::traits::Zero;␊ use openzeppelin::access::ownable::OwnableComponent;␊ use openzeppelin::introspection::src5::SRC5Component;␊ use openzeppelin::token::erc721::ERC721Component;␊ @@ -263,7 +264,7 @@ Generated by [AVA](https://avajs.dev). impl UpgradeableImpl of IUpgradeable {␊ fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊ self.ownable.assert_only_owner();␊ - self.upgradeable._upgrade(new_class_hash);␊ + self.upgradeable.upgrade(new_class_hash);␊ }␊ }␊ ␊ @@ -272,7 +273,7 @@ Generated by [AVA](https://avajs.dev). impl ExternalImpl of ExternalTrait {␊ #[external(v0)]␊ fn burn(ref self: ContractState, token_id: u256) {␊ - self.erc721._update(Zeroable::zero(), token_id, get_caller_address());␊ + self.erc721.update(Zero::zero(), token_id, get_caller_address());␊ }␊ }␊ }␊ @@ -283,7 +284,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyToken {␊ @@ -373,7 +374,7 @@ Generated by [AVA](https://avajs.dev). impl UpgradeableImpl of IUpgradeable {␊ fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊ self.ownable.assert_only_owner();␊ - self.upgradeable._upgrade(new_class_hash);␊ + self.upgradeable.upgrade(new_class_hash);␊ }␊ }␊ ␊ @@ -383,13 +384,13 @@ Generated by [AVA](https://avajs.dev). #[external(v0)]␊ fn pause(ref self: ContractState) {␊ self.ownable.assert_only_owner();␊ - self.pausable._pause();␊ + self.pausable.pause();␊ }␊ ␊ #[external(v0)]␊ fn unpause(ref self: ContractState) {␊ self.ownable.assert_only_owner();␊ - self.pausable._unpause();␊ + self.pausable.unpause();␊ }␊ }␊ }␊ @@ -400,7 +401,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyToken {␊ @@ -462,7 +463,7 @@ Generated by [AVA](https://avajs.dev). impl UpgradeableImpl of IUpgradeable {␊ fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊ self.ownable.assert_only_owner();␊ - self.upgradeable._upgrade(new_class_hash);␊ + self.upgradeable.upgrade(new_class_hash);␊ }␊ }␊ ␊ @@ -477,7 +478,7 @@ Generated by [AVA](https://avajs.dev). data: Span,␊ ) {␊ self.ownable.assert_only_owner();␊ - self.erc721._safe_mint(recipient, token_id, data);␊ + self.erc721.safe_mint(recipient, token_id, data);␊ }␊ ␊ #[external(v0)]␊ @@ -498,7 +499,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ const MINTER_ROLE: felt252 = selector!("MINTER_ROLE");␊ const UPGRADER_ROLE: felt252 = selector!("UPGRADER_ROLE");␊ @@ -576,7 +577,7 @@ Generated by [AVA](https://avajs.dev). impl UpgradeableImpl of IUpgradeable {␊ fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊ self.accesscontrol.assert_only_role(UPGRADER_ROLE);␊ - self.upgradeable._upgrade(new_class_hash);␊ + self.upgradeable.upgrade(new_class_hash);␊ }␊ }␊ ␊ @@ -591,7 +592,7 @@ Generated by [AVA](https://avajs.dev). data: Span,␊ ) {␊ self.accesscontrol.assert_only_role(MINTER_ROLE);␊ - self.erc721._safe_mint(recipient, token_id, data);␊ + self.erc721.safe_mint(recipient, token_id, data);␊ }␊ ␊ #[external(v0)]␊ @@ -612,10 +613,11 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyToken {␊ + use core::num::traits::Zero;␊ use openzeppelin::access::ownable::OwnableComponent;␊ use openzeppelin::introspection::src5::SRC5Component;␊ use openzeppelin::security::pausable::PausableComponent;␊ @@ -696,18 +698,18 @@ Generated by [AVA](https://avajs.dev). #[external(v0)]␊ fn pause(ref self: ContractState) {␊ self.ownable.assert_only_owner();␊ - self.pausable._pause();␊ + self.pausable.pause();␊ }␊ ␊ #[external(v0)]␊ fn unpause(ref self: ContractState) {␊ self.ownable.assert_only_owner();␊ - self.pausable._unpause();␊ + self.pausable.unpause();␊ }␊ ␊ #[external(v0)]␊ fn burn(ref self: ContractState, token_id: u256) {␊ - self.erc721._update(Zeroable::zero(), token_id, get_caller_address());␊ + self.erc721.update(Zero::zero(), token_id, get_caller_address());␊ }␊ ␊ #[external(v0)]␊ @@ -718,7 +720,7 @@ Generated by [AVA](https://avajs.dev). data: Span,␊ ) {␊ self.ownable.assert_only_owner();␊ - self.erc721._safe_mint(recipient, token_id, data);␊ + self.erc721.safe_mint(recipient, token_id, data);␊ }␊ ␊ #[external(v0)]␊ @@ -739,10 +741,11 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `// SPDX-License-Identifier: MIT␊ - // Compatible with OpenZeppelin Contracts for Cairo ^0.13.0␊ + // Compatible with OpenZeppelin Contracts for Cairo ^0.14.0␊ ␊ #[starknet::contract]␊ mod MyToken {␊ + use core::num::traits::Zero;␊ use openzeppelin::access::ownable::OwnableComponent;␊ use openzeppelin::introspection::src5::SRC5Component;␊ use openzeppelin::security::pausable::PausableComponent;␊ @@ -830,7 +833,7 @@ Generated by [AVA](https://avajs.dev). impl UpgradeableImpl of IUpgradeable {␊ fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊ self.ownable.assert_only_owner();␊ - self.upgradeable._upgrade(new_class_hash);␊ + self.upgradeable.upgrade(new_class_hash);␊ }␊ }␊ ␊ @@ -840,18 +843,18 @@ Generated by [AVA](https://avajs.dev). #[external(v0)]␊ fn pause(ref self: ContractState) {␊ self.ownable.assert_only_owner();␊ - self.pausable._pause();␊ + self.pausable.pause();␊ }␊ ␊ #[external(v0)]␊ fn unpause(ref self: ContractState) {␊ self.ownable.assert_only_owner();␊ - self.pausable._unpause();␊ + self.pausable.unpause();␊ }␊ ␊ #[external(v0)]␊ fn burn(ref self: ContractState, token_id: u256) {␊ - self.erc721._update(Zeroable::zero(), token_id, get_caller_address());␊ + self.erc721.update(Zero::zero(), token_id, get_caller_address());␊ }␊ ␊ #[external(v0)]␊ @@ -862,7 +865,7 @@ Generated by [AVA](https://avajs.dev). data: Span,␊ ) {␊ self.ownable.assert_only_owner();␊ - self.erc721._safe_mint(recipient, token_id, data);␊ + self.erc721.safe_mint(recipient, token_id, data);␊ }␊ ␊ #[external(v0)]␊ diff --git a/packages/core-cairo/src/erc721.test.ts.snap b/packages/core-cairo/src/erc721.test.ts.snap index f4485c90..ba6bf848 100644 Binary files a/packages/core-cairo/src/erc721.test.ts.snap and b/packages/core-cairo/src/erc721.test.ts.snap differ diff --git a/packages/core-cairo/src/erc721.ts b/packages/core-cairo/src/erc721.ts index a309a4a8..3e762d7f 100644 --- a/packages/core-cairo/src/erc721.ts +++ b/packages/core-cairo/src/erc721.ts @@ -139,7 +139,9 @@ function addBase(c: ContractBuilder, name: string, symbol: string, baseUri: stri } function addBurnable(c: ContractBuilder) { + c.addStandaloneImport('core::num::traits::Zero'); c.addStandaloneImport('starknet::get_caller_address'); + c.addFunction(externalTrait, functions.burn); } @@ -177,7 +179,7 @@ const functions = defineFunctions({ { name: 'token_id', type: 'u256' } ], code: [ - 'self.erc721._update(Zeroable::zero(), token_id, get_caller_address());', + 'self.erc721.update(Zero::zero(), token_id, get_caller_address());', ] }, safe_mint: { @@ -188,7 +190,7 @@ const functions = defineFunctions({ { name: 'data', type: 'Span' }, ], code: [ - 'self.erc721._safe_mint(recipient, token_id, data);', + 'self.erc721.safe_mint(recipient, token_id, data);', ] }, safeMint: { diff --git a/packages/core-cairo/src/set-upgradeable.ts b/packages/core-cairo/src/set-upgradeable.ts index 1cc89b18..1f2c70ed 100644 --- a/packages/core-cairo/src/set-upgradeable.ts +++ b/packages/core-cairo/src/set-upgradeable.ts @@ -57,7 +57,7 @@ const functions = defineFunctions({ { name: 'new_class_hash', type: 'ClassHash' }, ], code: [ - 'self.upgradeable._upgrade(new_class_hash)' + 'self.upgradeable.upgrade(new_class_hash)' ] }, }); diff --git a/packages/core-cairo/src/utils/version.ts b/packages/core-cairo/src/utils/version.ts index b79eeb5b..42e87513 100644 --- a/packages/core-cairo/src/utils/version.ts +++ b/packages/core-cairo/src/utils/version.ts @@ -1,17 +1,17 @@ /** * The actual latest version to use in links. */ -export const contractsVersion = '0.13.0'; +export const contractsVersion = '0.14.0'; export const contractsVersionTag = `v${contractsVersion}`; /** * Cairo compiler versions. */ -export const edition = '2023_01'; +export const edition = '2023_11'; export const cairoVersion = '2.6.4'; export const scarbVersion = '2.6.5'; /** * Semantic version string representing of the minimum compatible version of Contracts to display in output. */ -export const compatibleContractsSemver = '^0.13.0'; +export const compatibleContractsSemver = '^0.14.0'; diff --git a/packages/core-cairo/test_project/Scarb.lock b/packages/core-cairo/test_project/Scarb.lock index 2189644e..27888156 100644 --- a/packages/core-cairo/test_project/Scarb.lock +++ b/packages/core-cairo/test_project/Scarb.lock @@ -3,8 +3,8 @@ version = 1 [[package]] name = "openzeppelin" -version = "0.13.0" -source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.13.0#978b4e75209da355667d8954d2450e32bd71fe49" +version = "0.14.0" +source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.14.0#f091c4f51ddeb10297db984acae965328c5a4e5b" [[package]] name = "test_project" diff --git a/packages/core-cairo/test_project/Scarb.toml b/packages/core-cairo/test_project/Scarb.toml index 915f2ad6..98fdcd7b 100644 --- a/packages/core-cairo/test_project/Scarb.toml +++ b/packages/core-cairo/test_project/Scarb.toml @@ -1,13 +1,13 @@ [package] name = "test_project" version = "0.1.0" -edition = "2023_01" +edition = "2023_11" cairo-version = "2.6.4" scarb-version = "2.6.5" [dependencies] starknet = "2.6.4" -openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.13.0" } +openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.14.0" } [lib]