Skip to content

Commit 25c6607

Browse files
committed
chore: add ci && format codebase
1 parent 318f0df commit 25c6607

File tree

8 files changed

+40
-24
lines changed

8 files changed

+40
-24
lines changed

.github/workflows/build.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Build and contracts
2+
on:
3+
push:
4+
merge_group:
5+
pull_request:
6+
jobs:
7+
check:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- uses: software-mansion/setup-scarb@v1
12+
with:
13+
scarb-version: "2.12.2"
14+
- run: scarb fmt --check
15+
- run: scarb lint

Scarb.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ edition = "2024_07"
66
# See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html
77

88
[dependencies]
9-
starknet = "2.11.4"
9+
starknet = "2.12.2"
1010

1111
[dev-dependencies]
12-
snforge_std = "0.48.0"
13-
assert_macros = "2.11.4"
12+
snforge_std = "0.48.1"
13+
assert_macros = "2.12.2"
1414

1515
[[target.starknet-contract]]
1616
sierra = true

src/contracts/HelloStarknet.cairo

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
/// Simple contract for managing balance.
22
#[starknet::contract]
33
pub mod HelloStarknet {
4-
54
use cairo_bootcamp_5::interfaces::IHelloStarknet::IHelloStarknet;
6-
// use starknet::storage::{StoragePointerReadAccess, StoragePathEntry, StoragePointerWriteAccess, Map };
7-
use starknet::storage::{Map, StorageMapReadAccess, StorageMapWriteAccess, StoragePointerReadAccess, StoragePointerWriteAccess };
5+
// use starknet::storage::{StoragePointerReadAccess, StoragePathEntry,
6+
// StoragePointerWriteAccess, Map };
7+
use starknet::storage::{
8+
Map, StorageMapReadAccess, StorageMapWriteAccess, StoragePointerReadAccess,
9+
StoragePointerWriteAccess,
10+
};
811
use starknet::{ContractAddress, get_caller_address};
912

1013
#[storage]
@@ -16,7 +19,7 @@ pub mod HelloStarknet {
1619
#[event]
1720
#[derive(Drop, starknet::Event)]
1821
pub enum Event {
19-
Balance : BalanceIncreased,
22+
Balance: BalanceIncreased,
2023
}
2124

2225
#[derive(Drop, starknet::Event)]
@@ -42,11 +45,11 @@ pub mod HelloStarknet {
4245

4346
// self.balance.write(self.balance.read() + amount);
4447

45-
self.emit(BalanceIncreased{caller, amount});
48+
self.emit(BalanceIncreased { caller, amount });
4649
}
4750

4851
fn get_balance(self: @ContractState) -> felt252 {
4952
self.balance.read()
5053
}
5154
}
52-
}
55+
}

src/contracts/counter.cairo

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub mod Counter {
1313
#[event]
1414
#[derive(Drop, starknet::Event)]
1515
pub enum Event {
16-
CountUpdated : CountUpdated,
16+
CountUpdated: CountUpdated,
1717
}
1818

1919
#[derive(Drop, starknet::Event)]
@@ -48,4 +48,4 @@ pub mod Counter {
4848
self.emit(CountUpdated { old_value, new_value });
4949
}
5050
}
51-
}
51+
}

src/interfaces/ICounter.cairo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ pub trait ICounter<TContractState> {
33
fn get_count(self: @TContractState) -> u32;
44
fn increment(ref self: TContractState);
55
fn decrement(ref self: TContractState);
6-
}
6+
}

src/interfaces/IHelloStarknet.cairo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ pub trait IHelloStarknet<TContractState> {
66
fn increase_balance(ref self: TContractState, amount: felt252);
77
/// Retrieve contract balance.
88
fn get_balance(self: @TContractState) -> felt252;
9-
}
9+
}

src/lib.cairo

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
pub mod interfaces{
2-
pub mod IHelloStarknet;
1+
pub mod interfaces {
32
pub mod ICounter;
3+
pub mod IHelloStarknet;
44
}
55

6-
pub mod contracts{
6+
pub mod contracts {
77
pub mod HelloStarknet;
88
pub mod counter;
99
}

tests/test_contract.cairo

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1+
use cairo_bootcamp_5::interfaces::IHelloStarknet::{
2+
IHelloStarknetDispatcher, IHelloStarknetDispatcherTrait, IHelloStarknetSafeDispatcher,
3+
IHelloStarknetSafeDispatcherTrait,
4+
};
5+
use snforge_std::{ContractClassTrait, DeclareResultTrait, declare};
16
use starknet::ContractAddress;
27

3-
use snforge_std::{declare, ContractClassTrait, DeclareResultTrait};
4-
5-
use cairo_bootcamp_5::interfaces::IHelloStarknet::IHelloStarknetSafeDispatcher;
6-
use cairo_bootcamp_5::interfaces::IHelloStarknet::IHelloStarknetSafeDispatcherTrait;
7-
use cairo_bootcamp_5::interfaces::IHelloStarknet::IHelloStarknetDispatcher;
8-
use cairo_bootcamp_5::interfaces::IHelloStarknet::IHelloStarknetDispatcherTrait;
9-
108
fn deploy_contract(name: ByteArray) -> ContractAddress {
119
let contract = declare(name).unwrap().contract_class();
1210
let (contract_address, _) = contract.deploy(@ArrayTrait::new()).unwrap();
@@ -42,6 +40,6 @@ fn test_cannot_increase_balance_with_zero_value() {
4240
Result::Ok(_) => core::panic_with_felt252('Should have panicked'),
4341
Result::Err(panic_data) => {
4442
assert(*panic_data.at(0) == 'Amount cannot be 0', *panic_data.at(0));
45-
}
43+
},
4644
};
4745
}

0 commit comments

Comments
 (0)