Skip to content

Commit

Permalink
fix cairo compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
favelanky authored and Raz0r committed Aug 12, 2024
1 parent f372d94 commit f83559e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 21 deletions.
2 changes: 1 addition & 1 deletion cairo/lack-of-error-message.cairo
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use starknet::ContractAddress;

#[contract]
#[starknet::contract]
mod TestContract {
fn test1() {
let a = 1;
Expand Down
6 changes: 3 additions & 3 deletions cairo/view-fn-mutable-state.cairo
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#[contract]
#[starknet::contract]
mod contract {
struct Storage {}

// ok: view-fn-mutable-state
#[external]
fn get_variable(self: @ContractState) {}
// #[external]
// fn get_variable(self: @ContractState) {}

// ruleid: view-fn-mutable-state
#[external]
Expand Down
23 changes: 7 additions & 16 deletions cairo/view-fn-writes.cairo
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
#[starknet::interface]
trait ISimpleStorage<TContractState> {
fn set(ref self: TContractState, x: u128);
fn get(self: @TContractState) -> u128;
}

#[starknet::contract]
mod SimpleStorage {
#[storage]
struct Storage {
stored_data: u128
}

#[abi(embed_v0)]
impl SimpleStorage of super::ISimpleStorage<ContractState> {
// ok: view-fn-writes
fn set(ref self: ContractState, x: u128) {
self.stored_data.write(x);
}
// ok: view-fn-writes
fn set(ref self: ContractState, x: u128) {
self.stored_data.write(x);
}

// ruleid: view-fn-writes
fn get(self: ContractState) -> u128 {
self.stored_data.write(123);
}
// ruleid: view-fn-writes
fn get(self: ContractState) -> u128 {
self.stored_data.write(123);
}
}
2 changes: 1 addition & 1 deletion cairo/zero-division.cairo
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use starknet::ContractAddress;

#[contract]
#[starknet::contract]
mod TestContract {
fn test1(x: uint256) -> uint256 {
// ruleid: zero-division
Expand Down

0 comments on commit f83559e

Please sign in to comment.