diff --git a/Scarb.lock b/Scarb.lock index 0bc093c..68ab755 100644 --- a/Scarb.lock +++ b/Scarb.lock @@ -2,7 +2,7 @@ version = 1 [[package]] -name = "class_character" +name = "class_character_v2" version = "0.1.0" dependencies = [ "snforge_std", diff --git a/Scarb.toml b/Scarb.toml index 0b558de..b929f53 100644 --- a/Scarb.toml +++ b/Scarb.toml @@ -1,5 +1,5 @@ [package] -name = "class_character" +name = "class_character_v2" version = "0.1.0" edition = "2023_10" @@ -12,7 +12,9 @@ starknet = "2.4.0" [[target.starknet-contract]] sierra = true casm = true -[tool.sncast.cohort_test_deploy] -account = "cohort_test_deploy" -accounts-file = "your_accounts_file_goes_here" # add the path to account file path (the json file) -url = "your_rpc_url" \ No newline at end of file + +[tool.sncast.test_1] +account = "test_1" +accounts-file = "/Users/mac/.starknet_accounts/starknet_open_zeppelin_accounts.json" +url = "https://starknet-goerli.infura.io/v3/14d4909928f148238ba1da4db2886e77" + diff --git a/src/class_character_v2.cairo b/src/class_character_v2.cairo index 92cb43a..6d1b507 100644 --- a/src/class_character_v2.cairo +++ b/src/class_character_v2.cairo @@ -1,5 +1,6 @@ #[starknet::contract] mod ClassCharacterV2 { + use core::zeroable::Zeroable; use core::starknet::event::EventEmitter; use starknet::{ContractAddress, get_caller_address}; @@ -54,9 +55,13 @@ mod ClassCharacterV2 { ) { let owner = self.owner.read(); let caller = get_caller_address(); + assert(owner == caller, 'caller not owner'); + + assert(!student_account.is_zero(), 'is zero address'); assert(_name != '', 'name cannot be empty'); assert(_age != 0, 'age cannot be zero'); + assert(student_account != owner, 'not owner'); let student_instance = Student { name: _name, age: _age,