From f83559e666d80f39ce3baea8828db492fedfc820 Mon Sep 17 00:00:00 2001 From: Kashapov Shamil Date: Mon, 12 Aug 2024 06:42:34 +0300 Subject: [PATCH] fix cairo compatibility --- cairo/lack-of-error-message.cairo | 2 +- cairo/view-fn-mutable-state.cairo | 6 +++--- cairo/view-fn-writes.cairo | 23 +++++++---------------- cairo/zero-division.cairo | 2 +- 4 files changed, 12 insertions(+), 21 deletions(-) diff --git a/cairo/lack-of-error-message.cairo b/cairo/lack-of-error-message.cairo index 376e479..4442fb9 100644 --- a/cairo/lack-of-error-message.cairo +++ b/cairo/lack-of-error-message.cairo @@ -1,6 +1,6 @@ use starknet::ContractAddress; -#[contract] +#[starknet::contract] mod TestContract { fn test1() { let a = 1; diff --git a/cairo/view-fn-mutable-state.cairo b/cairo/view-fn-mutable-state.cairo index 139c97e..5e7ce21 100644 --- a/cairo/view-fn-mutable-state.cairo +++ b/cairo/view-fn-mutable-state.cairo @@ -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] diff --git a/cairo/view-fn-writes.cairo b/cairo/view-fn-writes.cairo index af93b82..7be5434 100644 --- a/cairo/view-fn-writes.cairo +++ b/cairo/view-fn-writes.cairo @@ -1,9 +1,3 @@ -#[starknet::interface] -trait ISimpleStorage { - fn set(ref self: TContractState, x: u128); - fn get(self: @TContractState) -> u128; -} - #[starknet::contract] mod SimpleStorage { #[storage] @@ -11,16 +5,13 @@ mod SimpleStorage { stored_data: u128 } - #[abi(embed_v0)] - impl SimpleStorage of super::ISimpleStorage { - // 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); } } \ No newline at end of file diff --git a/cairo/zero-division.cairo b/cairo/zero-division.cairo index 2a0c683..d8d9faf 100644 --- a/cairo/zero-division.cairo +++ b/cairo/zero-division.cairo @@ -1,6 +1,6 @@ use starknet::ContractAddress; -#[contract] +#[starknet::contract] mod TestContract { fn test1(x: uint256) -> uint256 { // ruleid: zero-division