Skip to content

Commit

Permalink
Merge pull request #1 from amegakure-starknet/bump-cairo-2.5.0
Browse files Browse the repository at this point in the history
bump cairo 2.5.0
  • Loading branch information
dubzn authored Jan 27, 2024
2 parents ccc10d4 + 3538b11 commit a670101
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build
on: [push, pull_request]

env:
SCARB_VERSION: 2.4.0
SCARB_VERSION: 2.5.0

jobs:
check:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Format
on: [push, pull_request]

env:
SCARB_VERSION: 2.4.0
SCARB_VERSION: 2.5.0

jobs:
check:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Test
on: [push, pull_request]

env:
SCARB_VERSION: 2.4.0
SCARB_VERSION: 2.5.0

jobs:
check:
Expand All @@ -15,6 +15,6 @@ jobs:
scarb-version: ${{ env.SCARB_VERSION }}
- uses: foundry-rs/setup-snfoundry@v2
with:
starknet-foundry-version: 0.14.0
starknet-foundry-version: 0.16.0
- name: Run cairo tests
run: snforge test
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
scarb 2.4.0
starknet-foundry 0.14.0
scarb 2.5.0
starknet-foundry 0.16.0
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ asdf plugin add scarb
Install:

```bash
asdf install scarb 2.4.0
asdf global scarb 2.4.0
asdf install scarb 2.5.0
asdf global scarb 2.5.0
```

### Starknet Foundry
Expand All @@ -34,7 +34,8 @@ asdf plugin add starknet-foundry
Install:

```bash
asdf install starknet-foundry 0.14.0
asdf install starknet-foundry 0.16.0
asdf global starknet-foundry 0.16.0
```

## 🛠️ Build
Expand Down
10 changes: 2 additions & 8 deletions Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,10 @@ version = 1
name = "cairo_template"
version = "0.1.0"
dependencies = [
"openzeppelin",
"snforge_std",
]

[[package]]
name = "openzeppelin"
version = "0.8.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.8.0#c23e8e96de60e6e3159b1ff8591a1187269c0eb7"

[[package]]
name = "snforge_std"
version = "0.14.0"
source = "git+https://github.com/foundry-rs/starknet-foundry?tag=v0.14.0#e8cbecee4e31ed428c76d5173eaa90c8df796fe3"
version = "0.16.0"
source = "git+https://github.com/foundry-rs/starknet-foundry?tag=v0.16.0#f58e0ab42b6095b7d0cb841ede595aecbc9cb45d"
5 changes: 2 additions & 3 deletions Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ version = "0.1.0"
# See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html

[dependencies]
starknet = "2.4.0"
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry", tag = "v0.14.0" }
openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.8.0" }
starknet = "2.5.0"
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry", tag = "v0.16.0" }

[[target.starknet-contract]]
casm = true
2 changes: 1 addition & 1 deletion src/hello_starknet.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mod HelloStarknet {
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 Down
17 changes: 10 additions & 7 deletions src/tests/test_hello_starknet.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ use starknet::ContractAddress;

use snforge_std::{declare, ContractClassTrait};

use cairo_template::hello_starknet::{
IHelloStarknetSafeDispatcher, IHelloStarknetSafeDispatcherTrait
};
use cairo_template::hello_starknet::IHelloStarknetSafeDispatcher;
use cairo_template::hello_starknet::IHelloStarknetSafeDispatcherTrait;
use cairo_template::hello_starknet::IHelloStarknetDispatcher;
use cairo_template::hello_starknet::IHelloStarknetDispatcherTrait;

fn deploy_contract(name: felt252) -> ContractAddress {
let contract = declare(name);
Expand All @@ -15,14 +16,14 @@ fn deploy_contract(name: felt252) -> ContractAddress {
fn test_increase_balance() {
let contract_address = deploy_contract('HelloStarknet');

let safe_dispatcher = IHelloStarknetSafeDispatcher { contract_address };
let dispatcher = IHelloStarknetDispatcher { contract_address };

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

safe_dispatcher.increase_balance(42).unwrap();
dispatcher.increase_balance(42);

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

Expand All @@ -32,9 +33,11 @@ fn test_cannot_increase_balance_with_zero_value() {

let safe_dispatcher = IHelloStarknetSafeDispatcher { contract_address };

#[feature("safe_dispatcher")]
let balance_before = safe_dispatcher.get_balance().unwrap();
assert(balance_before == 0, 'Invalid balance');

#[feature("safe_dispatcher")]
match safe_dispatcher.increase_balance(0) {
Result::Ok(_) => panic_with_felt252('Should have panicked'),
Result::Err(panic_data) => {
Expand Down

0 comments on commit a670101

Please sign in to comment.