Skip to content
16 changes: 12 additions & 4 deletions packages/core-cairo/src/erc1155.test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,9 @@ Generated by [AVA](https://avajs.dev).
#[external(v0)]␊
fn burn(ref self: ContractState, account: ContractAddress, token_id: u256, value: u256) {␊
let caller = get_caller_address();␊
assert(self.erc1155.is_approved_for_all(account, caller), ERC1155Component::Errors::UNAUTHORIZED);␊
if account != caller {␊
assert(self.erc1155.is_approved_for_all(account, caller), ERC1155Component::Errors::UNAUTHORIZED);␊
}␊
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

self.erc1155.burn(account, token_id, value);␊
}␊
Expand All @@ -273,7 +275,9 @@ Generated by [AVA](https://avajs.dev).
values: Span<u256>,␊
) {␊
let caller = get_caller_address();␊
assert(self.erc1155.is_approved_for_all(account, caller), ERC1155Component::Errors::UNAUTHORIZED);␊
if account != caller {␊
assert(self.erc1155.is_approved_for_all(account, caller), ERC1155Component::Errors::UNAUTHORIZED);␊
}␊
self.erc1155.batch_burn(account, token_ids, values);␊
}␊
Expand Down Expand Up @@ -907,7 +911,9 @@ Generated by [AVA](https://avajs.dev).
fn burn(ref self: ContractState, account: ContractAddress, token_id: u256, value: u256) {␊
self.pausable.assert_not_paused();␊
let caller = get_caller_address();␊
assert(self.erc1155.is_approved_for_all(account, caller), ERC1155Component::Errors::UNAUTHORIZED);␊
if account != caller {␊
assert(self.erc1155.is_approved_for_all(account, caller), ERC1155Component::Errors::UNAUTHORIZED);␊
}␊
self.erc1155.burn(account, token_id, value);␊
}␊
Expand All @@ -920,7 +926,9 @@ Generated by [AVA](https://avajs.dev).
) {␊
self.pausable.assert_not_paused();␊
let caller = get_caller_address();␊
assert(self.erc1155.is_approved_for_all(account, caller), ERC1155Component::Errors::UNAUTHORIZED);␊
if account != caller {␊
assert(self.erc1155.is_approved_for_all(account, caller), ERC1155Component::Errors::UNAUTHORIZED);␊
}␊
self.erc1155.batch_burn(account, token_ids, values);␊
}␊
Expand Down
Binary file modified packages/core-cairo/src/erc1155.test.ts.snap
Binary file not shown.
8 changes: 6 additions & 2 deletions packages/core-cairo/src/erc1155.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ const functions = defineFunctions({
],
code: [
'let caller = get_caller_address();',
'assert(self.erc1155.is_approved_for_all(account, caller), ERC1155Component::Errors::UNAUTHORIZED)',
'if account != caller {',
' assert(self.erc1155.is_approved_for_all(account, caller), ERC1155Component::Errors::UNAUTHORIZED)',
'}',
'self.erc1155.burn(account, token_id, value);'
]
},
Expand All @@ -217,7 +219,9 @@ const functions = defineFunctions({
],
code: [
'let caller = get_caller_address();',
'assert(self.erc1155.is_approved_for_all(account, caller), ERC1155Component::Errors::UNAUTHORIZED)',
'if account != caller {',
' assert(self.erc1155.is_approved_for_all(account, caller), ERC1155Component::Errors::UNAUTHORIZED)',
'}',
'self.erc1155.batch_burn(account, token_ids, values);'
]
},
Expand Down
4 changes: 2 additions & 2 deletions packages/core-cairo/src/print.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ function printFunction(fn: ContractFunction) {
for (let i = 0; i < codeLines.length; i++) {
const line = codeLines[i];
const shouldEndWithSemicolon = i < codeLines.length - 1 || fn.returns === undefined;
if (line !== undefined) {
if (shouldEndWithSemicolon && !line.endsWith(';')) {
if (line !== undefined && line.length > 0) {
if (shouldEndWithSemicolon && !['{', '}', ';'].includes(line.charAt(line.length - 1))) {
codeLines[i] += ';';
} else if (!shouldEndWithSemicolon && line.endsWith(';')) {
codeLines[i] = line.slice(0, line.length - 1);
Expand Down