Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2021-2023 zOS Global Limited and contributors
Copyright (c) 2021-2024 zOS Global Limited and contributors

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
7 changes: 7 additions & 0 deletions packages/core-cairo/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 0.9.0 (2024-02-12)

- **Breaking changes**:
- Remove non-standard `safeAllowance` option from ERC20. ([#324](https://github.com/OpenZeppelin/contracts-wizard/pull/324))
- Use `abi(embed_v0)` attribute instead of `external` for impls derived from interfaces.
- Use `abi(per_item)` attribute instead of `external` for impls with generated traits.

## 0.8.0 (2023-12-11)

- **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.8.0",
"version": "0.9.0",
"description": "A boilerplate generator to get started with OpenZeppelin Contracts for Cairo",
"license": "MIT",
"repository": "github:OpenZeppelin/contracts-wizard",
Expand Down
10 changes: 6 additions & 4 deletions packages/core-cairo/src/contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ test('contract with function code before', t => {
name: 'External',
of: 'ExternalTrait',
tags: [
'#[generate_trait]',
'#[external(v0)]'
'generate_trait',
'abi(per_item)',
],
perItemTag: 'external(v0)',
};
Foo.addImplementedTrait(trait);
const fn: BaseFunction = {
Expand All @@ -72,9 +73,10 @@ test('contract with function code before with semicolons', t => {
name: 'External',
of: 'ExternalTrait',
tags: [
'#[generate_trait]',
'#[external(v0)]'
'generate_trait',
'abi(per_item)',
],
perItemTag: 'external(v0)',
};
Foo.addImplementedTrait(trait);
const fn: BaseFunction = {
Expand Down
6 changes: 4 additions & 2 deletions packages/core-cairo/src/contract.test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ Generated by [AVA](https://avajs.dev).
}␊
#[generate_trait]␊
#[external(v0)]␊
#[abi(per_item)]␊
impl External of ExternalTrait {␊
#[external(v0)]␊
fn someFunction() {␊
before();␊
someFunction();␊
Expand All @@ -92,8 +93,9 @@ Generated by [AVA](https://avajs.dev).
}␊
#[generate_trait]␊
#[external(v0)]␊
#[abi(per_item)]␊
impl External of ExternalTrait {␊
#[external(v0)]␊
fn someFunction() {␊
before();␊
someFunction();␊
Expand Down
Binary file modified packages/core-cairo/src/contract.test.ts.snap
Binary file not shown.
3 changes: 3 additions & 0 deletions packages/core-cairo/src/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export interface BaseImplementedTrait {
name: string;
of: string;
tags: string[];
perItemTag?: string;
}

export interface ImplementedTrait extends BaseImplementedTrait {
Expand All @@ -62,6 +63,7 @@ export interface BaseFunction {

export interface ContractFunction extends BaseFunction {
codeBefore?: string[];
tag?: string;
}

export interface Variable {
Expand Down Expand Up @@ -178,6 +180,7 @@ export class ContractBuilder implements Contract {
const contractFn: ContractFunction = {
...fn,
codeBefore: [],
tag: baseTrait.perItemTag,
};
t.functions.push(contractFn);
return contractFn;
Expand Down
10 changes: 7 additions & 3 deletions packages/core-cairo/src/custom.test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,15 @@ Generated by [AVA](https://avajs.dev).
}␊
#[generate_trait]␊
#[external(v0)]␊
#[abi(per_item)]␊
impl ExternalImpl of ExternalTrait {␊
#[external(v0)]␊
fn pause(ref self: ContractState) {␊
self.ownable.assert_only_owner();␊
self.pausable._pause();␊
}␊
#[external(v0)]␊
fn unpause(ref self: ContractState) {␊
self.ownable.assert_only_owner();␊
self.pausable._unpause();␊
Expand Down Expand Up @@ -128,7 +130,7 @@ Generated by [AVA](https://avajs.dev).
self.ownable.initializer(owner);␊
}␊
#[external(v0)]␊
#[abi(embed_v0)]␊
impl UpgradeableImpl of IUpgradeable<ContractState> {␊
fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊
self.ownable.assert_only_owner();␊
Expand Down Expand Up @@ -291,13 +293,15 @@ Generated by [AVA](https://avajs.dev).
}␊
#[generate_trait]␊
#[external(v0)]␊
#[abi(per_item)]␊
impl ExternalImpl of ExternalTrait {␊
#[external(v0)]␊
fn pause(ref self: ContractState) {␊
self.ownable.assert_only_owner();␊
self.pausable._pause();␊
}␊
#[external(v0)]␊
fn unpause(ref self: ContractState) {␊
self.ownable.assert_only_owner();␊
self.pausable._unpause();␊
Expand Down
Binary file modified packages/core-cairo/src/custom.test.ts.snap
Binary file not shown.
7 changes: 0 additions & 7 deletions packages/core-cairo/src/erc20.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,12 @@ testERC20('erc20 mintable with roles', {
access: 'roles',
});

testERC20('erc20 safe allowance', {
safeAllowance: true,
});

testERC20('erc20 full upgradeable', {
premint: '2000',
access: 'ownable',
burnable: true,
mintable: true,
pausable: true,
safeAllowance: true,
upgradeable: true,
});

Expand All @@ -88,7 +83,6 @@ testERC20('erc20 full upgradeable with roles', {
burnable: true,
mintable: true,
pausable: true,
safeAllowance: true,
upgradeable: true,
});

Expand All @@ -104,7 +98,6 @@ testAPIEquivalence('erc20 API full upgradeable', {
burnable: true,
mintable: true,
pausable: true,
safeAllowance: true,
upgradeable: true,
});

Expand Down
Loading