Skip to content

Commit 779751b

Browse files
authored
Cairo: Remove non-standard increase/decrease from ERC20, avoid external attributes (#324)
1 parent 66d1a23 commit 779751b

24 files changed

+102
-260
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

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

55
Permission is hereby granted, free of charge, to any person obtaining
66
a copy of this software and associated documentation files (the

packages/core-cairo/CHANGELOG.md

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

3+
## 0.9.0 (2024-02-12)
4+
5+
- **Breaking changes**:
6+
- Remove non-standard `safeAllowance` option from ERC20. ([#324](https://github.com/OpenZeppelin/contracts-wizard/pull/324))
7+
- Use `abi(embed_v0)` attribute instead of `external` for impls derived from interfaces.
8+
- Use `abi(per_item)` attribute instead of `external` for impls with generated traits.
9+
310
## 0.8.0 (2023-12-11)
411

512
- **Breaking changes**:

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.8.0",
3+
"version": "0.9.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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ test('contract with function code before', t => {
4949
name: 'External',
5050
of: 'ExternalTrait',
5151
tags: [
52-
'#[generate_trait]',
53-
'#[external(v0)]'
52+
'generate_trait',
53+
'abi(per_item)',
5454
],
55+
perItemTag: 'external(v0)',
5556
};
5657
Foo.addImplementedTrait(trait);
5758
const fn: BaseFunction = {
@@ -72,9 +73,10 @@ test('contract with function code before with semicolons', t => {
7273
name: 'External',
7374
of: 'ExternalTrait',
7475
tags: [
75-
'#[generate_trait]',
76-
'#[external(v0)]'
76+
'generate_trait',
77+
'abi(per_item)',
7778
],
79+
perItemTag: 'external(v0)',
7880
};
7981
Foo.addImplementedTrait(trait);
8082
const fn: BaseFunction = {

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ Generated by [AVA](https://avajs.dev).
6969
}␊
7070
7171
#[generate_trait]␊
72-
#[external(v0)]␊
72+
#[abi(per_item)]␊
7373
impl External of ExternalTrait {␊
74+
#[external(v0)]␊
7475
fn someFunction() {␊
7576
before();␊
7677
someFunction();␊
@@ -92,8 +93,9 @@ Generated by [AVA](https://avajs.dev).
9293
}␊
9394
9495
#[generate_trait]␊
95-
#[external(v0)]␊
96+
#[abi(per_item)]␊
9697
impl External of ExternalTrait {␊
98+
#[external(v0)]␊
9799
fn someFunction() {␊
98100
before();␊
99101
someFunction();␊
10 Bytes
Binary file not shown.

packages/core-cairo/src/contract.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export interface BaseImplementedTrait {
4747
name: string;
4848
of: string;
4949
tags: string[];
50+
perItemTag?: string;
5051
}
5152

5253
export interface ImplementedTrait extends BaseImplementedTrait {
@@ -62,6 +63,7 @@ export interface BaseFunction {
6263

6364
export interface ContractFunction extends BaseFunction {
6465
codeBefore?: string[];
66+
tag?: string;
6567
}
6668

6769
export interface Variable {
@@ -178,6 +180,7 @@ export class ContractBuilder implements Contract {
178180
const contractFn: ContractFunction = {
179181
...fn,
180182
codeBefore: [],
183+
tag: baseTrait.perItemTag,
181184
};
182185
t.functions.push(contractFn);
183186
return contractFn;

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,15 @@ Generated by [AVA](https://avajs.dev).
6666
}␊
6767
6868
#[generate_trait]␊
69-
#[external(v0)]␊
69+
#[abi(per_item)]␊
7070
impl ExternalImpl of ExternalTrait {␊
71+
#[external(v0)]␊
7172
fn pause(ref self: ContractState) {␊
7273
self.ownable.assert_only_owner();␊
7374
self.pausable._pause();␊
7475
}␊
7576
77+
#[external(v0)]␊
7678
fn unpause(ref self: ContractState) {␊
7779
self.ownable.assert_only_owner();␊
7880
self.pausable._unpause();␊
@@ -128,7 +130,7 @@ Generated by [AVA](https://avajs.dev).
128130
self.ownable.initializer(owner);␊
129131
}␊
130132
131-
#[external(v0)]␊
133+
#[abi(embed_v0)]␊
132134
impl UpgradeableImpl of IUpgradeable<ContractState> {␊
133135
fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {␊
134136
self.ownable.assert_only_owner();␊
@@ -291,13 +293,15 @@ Generated by [AVA](https://avajs.dev).
291293
}␊
292294
293295
#[generate_trait]␊
294-
#[external(v0)]␊
296+
#[abi(per_item)]␊
295297
impl ExternalImpl of ExternalTrait {␊
298+
#[external(v0)]␊
296299
fn pause(ref self: ContractState) {␊
297300
self.ownable.assert_only_owner();␊
298301
self.pausable._pause();␊
299302
}␊
300303
304+
#[external(v0)]␊
301305
fn unpause(ref self: ContractState) {␊
302306
self.ownable.assert_only_owner();␊
303307
self.pausable._unpause();␊
16 Bytes
Binary file not shown.

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,12 @@ testERC20('erc20 mintable with roles', {
6868
access: 'roles',
6969
});
7070

71-
testERC20('erc20 safe allowance', {
72-
safeAllowance: true,
73-
});
74-
7571
testERC20('erc20 full upgradeable', {
7672
premint: '2000',
7773
access: 'ownable',
7874
burnable: true,
7975
mintable: true,
8076
pausable: true,
81-
safeAllowance: true,
8277
upgradeable: true,
8378
});
8479

@@ -88,7 +83,6 @@ testERC20('erc20 full upgradeable with roles', {
8883
burnable: true,
8984
mintable: true,
9085
pausable: true,
91-
safeAllowance: true,
9286
upgradeable: true,
9387
});
9488

@@ -104,7 +98,6 @@ testAPIEquivalence('erc20 API full upgradeable', {
10498
burnable: true,
10599
mintable: true,
106100
pausable: true,
107-
safeAllowance: true,
108101
upgradeable: true,
109102
});
110103

0 commit comments

Comments
 (0)