Skip to content

Commit

Permalink
chore: upgrade contract deps
Browse files Browse the repository at this point in the history
  • Loading branch information
Darlington02 committed Apr 16, 2024
1 parent 523fe8e commit ba5e274
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 108 deletions.
54 changes: 4 additions & 50 deletions contracts/Scarb.lock
Original file line number Diff line number Diff line change
@@ -1,66 +1,20 @@
# Code generated by scarb DO NOT EDIT.
version = 1

[[package]]
name = "alexandria_data_structures"
version = "0.2.0"
source = "git+https://github.com/keep-starknet-strange/alexandria.git#11a155f7897294105e2c99a95bf3efeabfd2d014"
dependencies = [
"alexandria_encoding",
]

[[package]]
name = "alexandria_encoding"
version = "0.1.0"
source = "git+https://github.com/keep-starknet-strange/alexandria.git#11a155f7897294105e2c99a95bf3efeabfd2d014"
dependencies = [
"alexandria_math",
"alexandria_numeric",
]

[[package]]
name = "alexandria_math"
version = "0.2.0"
source = "git+https://github.com/keep-starknet-strange/alexandria.git#11a155f7897294105e2c99a95bf3efeabfd2d014"
dependencies = [
"alexandria_data_structures",
]

[[package]]
name = "alexandria_numeric"
version = "0.1.0"
source = "git+https://github.com/keep-starknet-strange/alexandria.git#11a155f7897294105e2c99a95bf3efeabfd2d014"
dependencies = [
"alexandria_math",
]

[[package]]
name = "cairo_lib"
version = "0.2.0"
source = "git+https://github.com/HerodotusDev/cairo-lib.git#a0c0ee4feeb4edb61e7a35d29595ad8647c3d469"

[[package]]
name = "contracts"
version = "0.1.0"
dependencies = [
"alexandria_math",
"cairo_lib",
"openzeppelin",
"pragma_lib",
"snforge_std",
]

[[package]]
name = "openzeppelin"
version = "0.8.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git#441e6ce76ade91817068e4d4c5168dbd3ed20375"

[[package]]
name = "pragma_lib"
version = "1.0.0"
source = "git+https://github.com/astraly-labs/pragma-lib.git#24bb4da111ae7eb00e7cf40d4f1767c86d6447cd"
version = "0.11.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.11.0#a83f36b23f1af6e160288962be4a2701c3ecbcda"

[[package]]
name = "snforge_std"
version = "0.1.0"
source = "git+https://github.com/foundry-rs/starknet-foundry?tag=v0.11.0#5465c41541c44a7804d16318fab45a2f0ccec9e7"
version = "0.20.1"
source = "git+https://github.com/foundry-rs/starknet-foundry?tag=v0.20.1#fea2db8f2b20148cc15ee34b08de12028eb42942"
15 changes: 3 additions & 12 deletions contracts/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,15 @@ name = "contracts"
version = "0.1.0"

[dependencies]
starknet = "2.3.1"

[dependencies.alexandria_math]
git = "https://github.com/keep-starknet-strange/alexandria.git"

[dependencies.cairo_lib]
git = "https://github.com/HerodotusDev/cairo-lib.git"
starknet = "2.6.3"

[dependencies.openzeppelin]
git = "https://github.com/OpenZeppelin/cairo-contracts.git"
tag = "v0.8.0"

[dependencies.pragma_lib]
git = "https://github.com/astraly-labs/pragma-lib.git"
tag = "v0.11.0"

[dependencies.snforge_std]
git = "https://github.com/foundry-rs/starknet-foundry"
tag = "v0.11.0"
tag = "v0.20.1"

[[target.starknet-contract]]
casm = true
Expand Down
8 changes: 4 additions & 4 deletions contracts/src/lib.cairo
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[starknet::interface]
trait IHelloStarknet<TContractState> {
pub trait IHelloStarknet<TContractState> {
fn increase_balance(ref self: TContractState, amount: felt252);
fn get_balance(self: @TContractState) -> felt252;
}
Expand All @@ -8,10 +8,10 @@ trait IHelloStarknet<TContractState> {
mod HelloStarknet {
#[storage]
struct Storage {
balance: felt252,
balance: felt252,
}

#[external(v0)]
#[abi(embed_v0)]
impl HelloStarknetImpl of super::IHelloStarknet<ContractState> {
fn increase_balance(ref self: ContractState, amount: felt252) {
assert(amount != 0, 'Amount cannot be 0');
Expand All @@ -22,4 +22,4 @@ mod HelloStarknet {
self.balance.read()
}
}
}
}
43 changes: 1 addition & 42 deletions contracts/tests/test_contract.cairo
Original file line number Diff line number Diff line change
@@ -1,42 +1 @@
use contracts::IHelloStarknetSafeDispatcher;
use contracts::IHelloStarknetSafeDispatcherTrait;

use snforge_std::{declare, ContractClassTrait};
use starknet::ContractAddress;

fn deploy_contract(name: felt252) -> ContractAddress {
let contract = declare(name);
contract.deploy(@ArrayTrait::new()).unwrap()
}

#[test]
fn test_increase_balance() {
let contract_address = deploy_contract('HelloStarknet');

let safe_dispatcher = IHelloStarknetSafeDispatcher { contract_address };

let balance_before = safe_dispatcher.get_balance().unwrap();
assert(balance_before == 0, 'Invalid balance');

safe_dispatcher.increase_balance(42).unwrap();

let balance_after = safe_dispatcher.get_balance().unwrap();
assert(balance_after == 42, 'Invalid balance');
}

#[test]
fn test_cannot_increase_balance_with_zero_value() {
let contract_address = deploy_contract('HelloStarknet');

let safe_dispatcher = IHelloStarknetSafeDispatcher { contract_address };

let balance_before = safe_dispatcher.get_balance().unwrap();
assert(balance_before == 0, 'Invalid balance');

match safe_dispatcher.increase_balance(0) {
Result::Ok(_) => panic_with_felt252('Should have panicked'),
Result::Err(panic_data) => {
assert(*panic_data.at(0) == 'Amount cannot be 0', *panic_data.at(0));
}
};
}
// contract test in here

0 comments on commit ba5e274

Please sign in to comment.