Skip to content

Commit

Permalink
chore: update to Cairo v2.2.0 (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
julio4 authored Aug 31, 2023
1 parent 3e9bbe3 commit 761b32e
Show file tree
Hide file tree
Showing 35 changed files with 28 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/verify-cairo-programs/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ runs:
- name: Install scarb
uses: software-mansion/setup-scarb@v1
with:
scarb-version: "0.6.2"
scarb-version: "0.7.0"

- name: Run build script
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/verify_cairo_programs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Install scarb
uses: software-mansion/setup-scarb@v1
with:
scarb-version: "0.6.2"
scarb-version: "0.7.0"

- name: Run build script
run: |
Expand Down
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
scarb 0.6.2
scarb 0.7.0
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ name = "calling_other_contracts"
version = "0.1.0"

[dependencies]
starknet = ">=2.1.0"
starknet = ">=2.2.0"

[[target.starknet-contract]]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
mod Callee {
#[storage]
struct Storage {
value: u128,
value: u128,
}

#[external(v0)]
Expand Down
2 changes: 1 addition & 1 deletion listings/ch00-introduction/constructor/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ name = "constructor"
version = "0.1.0"

[dependencies]
starknet = ">=2.1.0"
starknet = ">=2.2.0"

[[target.starknet-contract]]
2 changes: 1 addition & 1 deletion listings/ch00-introduction/constructor/src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mod ExampleConstructor {

#[storage]
struct Storage {
names: LegacyMap::<ContractAddress, felt252>,
names: LegacyMap::<ContractAddress, felt252>,
}

// The constructor is decorated with a `#[constructor]` attribute.
Expand Down
2 changes: 1 addition & 1 deletion listings/ch00-introduction/counter/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ name = "counter"
version = "0.1.0"

[dependencies]
starknet = ">=2.1.0"
starknet = ">=2.2.0"

[[target.starknet-contract]]
2 changes: 1 addition & 1 deletion listings/ch00-introduction/custom_type_serde/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ name = "custom_type_serde"
version = "0.1.0"

[dependencies]
starknet = ">=2.1.0"
starknet = ">=2.2.0"

[[target.starknet-contract]]
2 changes: 1 addition & 1 deletion listings/ch00-introduction/errors/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ name = "errors"
version = "0.1.0"

[dependencies]
starknet = ">=2.1.0"
starknet = ">=2.2.0"

[[target.starknet-contract]]
1 change: 0 additions & 1 deletion listings/ch00-introduction/errors/src/custom_errors.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ mod Errors {
const NOT_NULL: felt252 = 'must not be null';
}


#[starknet::contract]
mod CustomErrorsExample {
use super::Errors;
Expand Down
2 changes: 1 addition & 1 deletion listings/ch00-introduction/errors/src/vault_errors.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mod VaultErrorsExample {

#[storage]
struct Storage {
balance: u256,
balance: u256,
}

#[generate_trait]
Expand Down
2 changes: 1 addition & 1 deletion listings/ch00-introduction/events/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ name = "counter"
version = "0.1.0"

[dependencies]
starknet = ">=2.1.0"
starknet = ">=2.2.0"

[[target.starknet-contract]]
2 changes: 1 addition & 1 deletion listings/ch00-introduction/interfaces_traits/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ name = "interfaces_traits"
version = "0.1.0"

[dependencies]
starknet = ">=2.1.0"
starknet = ">=2.2.0"

[[target.starknet-contract]]
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ mod explicit_interface_contract_tests {
};
use debug::PrintTrait;
use starknet::{deploy_syscall, ContractAddress};
use option::OptionTrait;
use array::ArrayTrait;
use traits::{Into, TryInto};
use starknet::class_hash::Felt252TryIntoClassHash;
use result::ResultTrait;

#[test]
#[available_gas(2000000000)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,8 @@ mod implicit_internal_contract_tests {
IImplicitInternalContract, ImplicitInternalContract, IImplicitInternalContractDispatcher,
IImplicitInternalContractDispatcherTrait
};
use debug::PrintTrait;
use starknet::{deploy_syscall, ContractAddress};
use option::OptionTrait;
use array::ArrayTrait;
use traits::{Into, TryInto};
use starknet::class_hash::Felt252TryIntoClassHash;
use result::ResultTrait;

#[test]
#[available_gas(2000000000)]
Expand Down
2 changes: 1 addition & 1 deletion listings/ch00-introduction/mappings/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ name = "maps"
version = "0.1.0"

[dependencies]
starknet = ">=2.1.0"
starknet = ">=2.2.0"

[[target.starknet-contract]]
5 changes: 0 additions & 5 deletions listings/ch00-introduction/mappings/src/test_mappings.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,8 @@ trait IMapContract<TContractState> {
mod tests {
use maps::mappings::MapContract;
use super::{IMapContract, IMapContractDispatcher, IMapContractDispatcherTrait};
use debug::PrintTrait;
use starknet::{deploy_syscall, ContractAddress};
use option::OptionTrait;
use array::ArrayTrait;
use traits::{Into, TryInto};
use starknet::class_hash::Felt252TryIntoClassHash;
use result::ResultTrait;

#[test]
#[available_gas(2000000000)]
Expand Down
2 changes: 1 addition & 1 deletion listings/ch00-introduction/storing_custom_types/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ name = "storing_custom_types"
version = "0.1.0"

[dependencies]
starknet = ">=2.1.0"
starknet = ">=2.2.0"

[[target.starknet-contract]]
2 changes: 1 addition & 1 deletion listings/ch00-introduction/testing/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ name = "tests"
version = "0.1.0"

[dependencies]
starknet = ">=2.1.0"
starknet = ">=2.2.0"

[[target.starknet-contract]]
9 changes: 0 additions & 9 deletions listings/ch00-introduction/testing/src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,9 @@ mod simple_contract_tests {
contract_address_const
};

// Use debug print trait to be able to print result if needed.
use debug::PrintTrait;

// Use starknet test utils to fake the transaction context.
use starknet::testing::{set_caller_address, set_contract_address};

use serde::Serde;
use option::OptionTrait;
use array::ArrayTrait;
use traits::{Into, TryInto};
use result::ResultTrait;

// Deploy the contract and return its dispatcher.
fn deploy(initial_value: u32) -> ISimpleContractDispatcher {
// Set up constructor arguments.
Expand Down
2 changes: 1 addition & 1 deletion listings/ch00-introduction/variables/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ name = "variables"
version = "0.1.0"

[dependencies]
starknet = ">=2.1.0"
starknet = ">=2.2.0"

[[target.starknet-contract]]
2 changes: 1 addition & 1 deletion listings/ch00-introduction/visibility/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ name = "visibility"
version = "0.1.0"

[dependencies]
starknet = ">=2.1.0"
starknet = ">=2.2.0"

[[target.starknet-contract]]
2 changes: 1 addition & 1 deletion listings/ch01-advanced-concepts/storing_arrays/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ name = "storing_arrays"
version = "0.1.0"

[dependencies]
starknet = ">=2.1.0"
starknet = ">=2.2.0"

[[target.starknet-contract]]
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
use traits::{Into, TryInto};
use result::ResultTrait;
use option::OptionTrait;
use array::ArrayTrait;
use array::SpanTrait;
use starknet::{
StorageBaseAddress, Store, SyscallResult, storage_read_syscall, storage_write_syscall,
storage_address_from_base_and_offset
};
use debug::PrintTrait;

// ANCHOR: StorageAccessImpl
impl StoreFelt252Array of Store<Array<felt252>> {
Expand Down Expand Up @@ -59,7 +53,7 @@ impl StoreFelt252Array of Store<Array<felt252>> {
loop {
match value.pop_front() {
Option::Some(element) => {
Store::<felt252>::write_at_offset(address_domain, base, offset, element)?;
Store::<felt252>::write_at_offset(address_domain, base, offset, element);
offset += Store::<felt252>::size();
},
Option::None(_) => {
Expand Down Expand Up @@ -109,14 +103,8 @@ trait IStoreArrayContract<TContractState> {
mod tests {
use super::StoreArrayContract;
use super::{IStoreArrayContractDispatcher, IStoreArrayContractDispatcherTrait};
use debug::PrintTrait;
use starknet::deploy_syscall;
use option::OptionTrait;
use array::ArrayTrait;
use traits::{Into, TryInto};
use starknet::class_hash::Felt252TryIntoClassHash;
use result::ResultTrait;
use array::SpanTrait;

#[test]
#[available_gas(20000000)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ name = "src"
version = "0.1.0"

[dependencies]
starknet = ">=2.1.0"
starknet = ">=2.2.0"

[[target.starknet-contract]]
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#[starknet::contract]
mod PetRegistry {
use poseidon::poseidon_hash_span;
use serde::Serde;
use array::ArrayTrait;

#[storage]
struct Storage {
registration_time: LegacyMap::<felt252, u64>,
registration_time: LegacyMap::<felt252, u64>,
}

#[derive(Copy, Drop, Serde)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@
mod tests {
use src::contract::PetRegistry;
use PetRegistry::Pet;
use debug::PrintTrait;
use starknet::deploy_syscall;
use option::OptionTrait;
use array::ArrayTrait;
use traits::{Into, TryInto};
use starknet::class_hash::Felt252TryIntoClassHash;
use result::ResultTrait;
use array::SpanTrait;

#[starknet::interface]
trait IPetRegistry<TContractState> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ name = "write_to_any_slot"
version = "0.1.0"

[dependencies]
starknet = ">=2.1.0"
starknet = ">=2.2.0"

[[target.starknet-contract]]
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,8 @@ mod tests {
use super::WriteToAnySlot::{get_address_from_name};
use super::WriteToAnySlot;
use super::{IWriteToAnySlotDispatcher, IWriteToAnySlotDispatcherTrait};
use debug::PrintTrait;
use starknet::deploy_syscall;
use option::OptionTrait;
use array::ArrayTrait;
use traits::{Into, TryInto};
use starknet::class_hash::Felt252TryIntoClassHash;
use result::ResultTrait;

#[test]
#[available_gas(2000000000)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#[starknet::contract]
mod WriteToAnySlot {
use starknet::syscalls::{storage_read_syscall, storage_write_syscall};
use array::ArrayTrait;
use option::OptionTrait;
use traits::{Into, TryInto};
use starknet::SyscallResultTrait;
use poseidon::poseidon_hash_span;
use starknet::storage_access::Felt252TryIntoStorageAddress;
use starknet::StorageAddress;
Expand Down
2 changes: 1 addition & 1 deletion listings/ch02-applications/simple_vault/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ name = "simple_vault"
version = "0.1.0"

[dependencies]
starknet = ">=2.1.0"
starknet = ">=2.2.0"

[[target.starknet-contract]]
2 changes: 1 addition & 1 deletion listings/ch02-applications/upgradeable_contract/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ name = "upgradeable_contract"
version = "0.1.0"

[dependencies]
starknet = ">=2.1.0"
starknet = ">=2.2.0"

[[target.starknet-contract]]
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#[starknet::contract]
mod UpgradeableContract_V0 {
use starknet::class_hash::ClassHash;
use zeroable::Zeroable;
use result::ResultTrait;
use starknet::SyscallResult;
use starknet::SyscallResultTrait;

#[storage]
struct Storage {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#[starknet::contract]
mod UpgradeableContract_V1 {
use starknet::class_hash::ClassHash;
use zeroable::Zeroable;
use result::ResultTrait;
use starknet::SyscallResult;
use starknet::SyscallResultTrait;

#[storage]
struct Storage {}
Expand Down

0 comments on commit 761b32e

Please sign in to comment.