Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #17 from ptisserand/feat/upgrade-to-cairo-2.8.4
Browse files Browse the repository at this point in the history
feat: upgrade to cairo 2.8.4
  • Loading branch information
EjembiEmmanuel authored Oct 24, 2024
2 parents 3ade390 + 36f8a4f commit 787a47d
Show file tree
Hide file tree
Showing 9 changed files with 168 additions and 30 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/contract.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CI Contracts

on:
push:
branches: [main, dev]
paths:
- "onchain/**"
pull_request:
branches: [main, dev]
workflow_dispatch:

jobs:
test-starknet-contracts:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: software-mansion/setup-scarb@v1
with:
tool-versions: onchain/.tool-versions
# starknet foundry setup require rust
- name: Set Up Stable Rust Toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- name: Install universal sierra compiler
shell: bash
run: |
curl -L https://raw.githubusercontent.com/software-mansion/universal-sierra-compiler/master/scripts/install.sh | sh
echo "/root/.local/bin" >> ${GITHUB_PATH}
- uses: foundry-rs/setup-snfoundry@v3
with:
tool-versions: onchain/.tool-versions
- run: scarb build
working-directory: onchain
- run: snforge test
working-directory: onchain
2 changes: 2 additions & 0 deletions onchain/.tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
scarb 2.8.4
starknet-foundry 0.32.0
116 changes: 112 additions & 4 deletions onchain/Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,108 @@ version = 1

[[package]]
name = "openzeppelin"
version = "0.13.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.13.0#978b4e75209da355667d8954d2450e32bd71fe49"
version = "0.18.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.18.0#2f37306b490e63c0afa9e33ad192ba428141b487"
dependencies = [
"openzeppelin_access",
"openzeppelin_account",
"openzeppelin_finance",
"openzeppelin_governance",
"openzeppelin_introspection",
"openzeppelin_merkle_tree",
"openzeppelin_presets",
"openzeppelin_security",
"openzeppelin_token",
"openzeppelin_upgrades",
"openzeppelin_utils",
]

[[package]]
name = "openzeppelin_access"
version = "0.18.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.18.0#2f37306b490e63c0afa9e33ad192ba428141b487"
dependencies = [
"openzeppelin_introspection",
"openzeppelin_utils",
]

[[package]]
name = "openzeppelin_account"
version = "0.18.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.18.0#2f37306b490e63c0afa9e33ad192ba428141b487"
dependencies = [
"openzeppelin_introspection",
"openzeppelin_utils",
]

[[package]]
name = "openzeppelin_finance"
version = "0.18.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.18.0#2f37306b490e63c0afa9e33ad192ba428141b487"
dependencies = [
"openzeppelin_access",
"openzeppelin_token",
]

[[package]]
name = "openzeppelin_governance"
version = "0.18.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.18.0#2f37306b490e63c0afa9e33ad192ba428141b487"
dependencies = [
"openzeppelin_access",
"openzeppelin_account",
"openzeppelin_introspection",
"openzeppelin_token",
]

[[package]]
name = "openzeppelin_introspection"
version = "0.18.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.18.0#2f37306b490e63c0afa9e33ad192ba428141b487"

[[package]]
name = "openzeppelin_merkle_tree"
version = "0.18.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.18.0#2f37306b490e63c0afa9e33ad192ba428141b487"

[[package]]
name = "openzeppelin_presets"
version = "0.18.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.18.0#2f37306b490e63c0afa9e33ad192ba428141b487"
dependencies = [
"openzeppelin_access",
"openzeppelin_account",
"openzeppelin_finance",
"openzeppelin_introspection",
"openzeppelin_token",
"openzeppelin_upgrades",
"openzeppelin_utils",
]

[[package]]
name = "openzeppelin_security"
version = "0.18.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.18.0#2f37306b490e63c0afa9e33ad192ba428141b487"

[[package]]
name = "openzeppelin_token"
version = "0.18.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.18.0#2f37306b490e63c0afa9e33ad192ba428141b487"
dependencies = [
"openzeppelin_account",
"openzeppelin_introspection",
"openzeppelin_utils",
]

[[package]]
name = "openzeppelin_upgrades"
version = "0.18.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.18.0#2f37306b490e63c0afa9e33ad192ba428141b487"

[[package]]
name = "openzeppelin_utils"
version = "0.18.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.18.0#2f37306b490e63c0afa9e33ad192ba428141b487"

[[package]]
name = "scanguard"
Expand All @@ -14,7 +114,15 @@ dependencies = [
"snforge_std",
]

[[package]]
name = "snforge_scarb_plugin"
version = "0.32.0"
source = "git+https://github.com/foundry-rs/starknet-foundry.git?tag=v0.32.0#3817c903b640201c72e743b9bbe70a97149828a2"

[[package]]
name = "snforge_std"
version = "0.25.0"
source = "git+https://github.com/foundry-rs/starknet-foundry.git?tag=v0.25.0#5b366e24821e530fea97f11b211d220e8493fbea"
version = "0.32.0"
source = "git+https://github.com/foundry-rs/starknet-foundry.git?tag=v0.32.0#3817c903b640201c72e743b9bbe70a97149828a2"
dependencies = [
"snforge_scarb_plugin",
]
10 changes: 5 additions & 5 deletions onchain/Scarb.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[package]
name = "scanguard"
version = "0.1.0"
edition = "2023_11"
cairo-version = "2.6.3"
edition = "2024_07"
cairo-version = "2.8.4"

# See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html

[dependencies]
starknet = "2.6.3"
openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.13.0" }
starknet = "2.8.4"
openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.18.0" }

[dev-dependencies]
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry.git", tag = "v0.25.0" }
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry.git", tag = "v0.32.0" }

[scripts]
test = "snforge test"
Expand Down
2 changes: 1 addition & 1 deletion onchain/src/base.cairo
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pub mod types;
pub mod errors;
pub mod errors;
3 changes: 0 additions & 3 deletions onchain/src/base/types.cairo
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
use core::serde::Serde;
use core::option::OptionTrait;

#[derive(Drop, Serde, starknet::Store, Clone)]
pub struct ProductParams {
pub product_id: felt252,
Expand Down
3 changes: 1 addition & 2 deletions onchain/src/interfaces/IProduct.cairo
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use starknet::{ContractAddress};
use scanguard::base::types::{ProductParams};
use scanguard::base::types::ProductParams;

#[starknet::interface]
pub trait IProducts<TContractState> {
Expand Down
15 changes: 5 additions & 10 deletions onchain/src/product/product.cairo
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
use starknet::{ContractAddress};

#[starknet::contract]
pub mod Product {
use core::clone::Clone;
use core::option::OptionTrait;
use core::num::traits::zero::Zero;
use core::traits::{TryInto, Into};
use core::byte_array::ByteArrayTrait;
use starknet::{ContractAddress, get_caller_address};
use core::starknet::storage::{Map, StorageMapReadAccess, StorageMapWriteAccess};
use starknet::ContractAddress;
use scanguard::interfaces::IProduct::IProducts;
use scanguard::base::types::{ProductParams};
use scanguard::base::errors::Errors::{ZERO_ADDRESS_CALLER, ZERO_ADDRESS_OWNER, NOT_OWNER};
use scanguard::base::types::ProductParams;
use scanguard::base::errors::Errors::ZERO_ADDRESS_CALLER;
use openzeppelin::access::ownable::OwnableComponent;

component!(path: OwnableComponent, storage: ownable, event: OwnableEvent);
Expand All @@ -25,7 +20,7 @@ pub mod Product {
struct Storage {
#[substorage(v0)]
ownable: OwnableComponent::Storage,
products: LegacyMap::<felt252, ByteArray>,
products: Map::<felt252, ByteArray>,
}

#[event]
Expand Down
10 changes: 5 additions & 5 deletions onchain/tests/test_product.cairo
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use core::option::OptionTrait;
use core::traits::{TryInto, Into};
use core::traits::TryInto;
use core::starknet::SyscallResultTrait;
use openzeppelin::access::ownable::interface::{IOwnableDispatcher, IOwnableDispatcherTrait};
use starknet::{ContractAddress, class_hash::ClassHash, contract_address_const};
use starknet::ContractAddress;
use snforge_std::{
declare, ContractClassTrait, start_cheat_caller_address, stop_cheat_caller_address
declare, ContractClassTrait, DeclareResultTrait, start_cheat_caller_address,
stop_cheat_caller_address
};
use scanguard::interfaces::IProduct::{IProductsDispatcher, IProductsDispatcherTrait};
use scanguard::base::types::{ProductParams};


const ZERO_ADDR: felt252 = 0x0;
Expand All @@ -16,7 +16,7 @@ const USER_ONE_ADDR: felt252 = 0x2;

fn __setup__(owner: felt252) -> ContractAddress {
// deploy Prodct contract
let product_contract = declare("Product").unwrap();
let product_contract = declare("Product").unwrap().contract_class();
let mut product_constructor_calldata = array![owner];
let (product_contract_address, _) = product_contract
.deploy(@product_constructor_calldata)
Expand Down

0 comments on commit 787a47d

Please sign in to comment.