Skip to content

Commit

Permalink
bump: Update cairo syntax (#580)
Browse files Browse the repository at this point in the history
* bump(update_cairo_syntax): Updated external to #[abi(embed_v0)]

* bump(update_cairo_syntax): Anonymous generic impl

* bump(update_cairo_syntax): Embedding impls

* bump(update_cairo_syntax): Alexandria update
  • Loading branch information
akhercha authored Nov 5, 2023
1 parent 0a109aa commit 0c9ad1a
Show file tree
Hide file tree
Showing 38 changed files with 57 additions and 62 deletions.
10 changes: 5 additions & 5 deletions Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,36 @@ version = 1
[[package]]
name = "alexandria_data_structures"
version = "0.1.0"
source = "git+https://github.com/keep-starknet-strange/alexandria.git?rev=ae1d514#ae1d5149ff601a7ac5b39edc867d33ebd83d7f4f"
source = "git+https://github.com/keep-starknet-strange/alexandria.git?tag=cairo-v2.3.0-rc0#ae1d5149ff601a7ac5b39edc867d33ebd83d7f4f"
dependencies = [
"alexandria_encoding",
]

[[package]]
name = "alexandria_encoding"
version = "0.1.0"
source = "git+https://github.com/keep-starknet-strange/alexandria.git?rev=ae1d514#ae1d5149ff601a7ac5b39edc867d33ebd83d7f4f"
source = "git+https://github.com/keep-starknet-strange/alexandria.git?tag=cairo-v2.3.0-rc0#ae1d5149ff601a7ac5b39edc867d33ebd83d7f4f"
dependencies = [
"alexandria_math",
]

[[package]]
name = "alexandria_math"
version = "0.2.0"
source = "git+https://github.com/keep-starknet-strange/alexandria.git?rev=ae1d514#ae1d5149ff601a7ac5b39edc867d33ebd83d7f4f"
source = "git+https://github.com/keep-starknet-strange/alexandria.git?tag=cairo-v2.3.0-rc0#ae1d5149ff601a7ac5b39edc867d33ebd83d7f4f"
dependencies = [
"alexandria_data_structures",
]

[[package]]
name = "alexandria_sorting"
version = "0.1.0"
source = "git+https://github.com/keep-starknet-strange/alexandria.git?rev=ae1d514#ae1d5149ff601a7ac5b39edc867d33ebd83d7f4f"
source = "git+https://github.com/keep-starknet-strange/alexandria.git?tag=cairo-v2.3.0-rc0#ae1d5149ff601a7ac5b39edc867d33ebd83d7f4f"

[[package]]
name = "alexandria_storage"
version = "0.2.0"
source = "git+https://github.com/keep-starknet-strange/alexandria.git?rev=ae1d514#ae1d5149ff601a7ac5b39edc867d33ebd83d7f4f"
source = "git+https://github.com/keep-starknet-strange/alexandria.git?tag=cairo-v2.3.0-rc0#ae1d5149ff601a7ac5b39edc867d33ebd83d7f4f"

[[package]]
name = "satoru"
Expand Down
8 changes: 4 additions & 4 deletions Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ sierra-replace-ids = true

[dependencies]
starknet = ">=2.3.1"
alexandria_data_structures = { git = "https://github.com/keep-starknet-strange/alexandria.git", rev = "ae1d514" }
alexandria_math = { git = "https://github.com/keep-starknet-strange/alexandria.git", rev = "ae1d514" }
alexandria_storage = { git = "https://github.com/keep-starknet-strange/alexandria.git", rev = "ae1d514" }
alexandria_sorting = { git = "https://github.com/keep-starknet-strange/alexandria.git", rev = "ae1d514" }
alexandria_data_structures = { git = "https://github.com/keep-starknet-strange/alexandria.git", tag = "cairo-v2.3.0-rc0" }
alexandria_math = { git = "https://github.com/keep-starknet-strange/alexandria.git", tag = "cairo-v2.3.0-rc0" }
alexandria_storage = { git = "https://github.com/keep-starknet-strange/alexandria.git", tag = "cairo-v2.3.0-rc0" }
alexandria_sorting = { git = "https://github.com/keep-starknet-strange/alexandria.git", tag = "cairo-v2.3.0-rc0" }
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry.git", tag = "v0.9.1" }


Expand Down
2 changes: 1 addition & 1 deletion src/bank/bank.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ mod Bank {
// *************************************************************************
// EXTERNAL FUNCTIONS
// *************************************************************************
#[external(v0)]
#[abi(embed_v0)]
impl BankImpl of super::IBank<ContractState> {
fn initialize(
ref self: ContractState,
Expand Down
2 changes: 1 addition & 1 deletion src/bank/strict_bank.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ mod StrictBank {
// *************************************************************************
// EXTERNAL FUNCTIONS
// *************************************************************************
#[external(v0)]
#[abi(embed_v0)]
impl StrictBank of super::IStrictBank<ContractState> {
fn initialize(
ref self: ContractState,
Expand Down
4 changes: 2 additions & 2 deletions src/callback/mocks.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ mod CallbackMock {
}


#[external(v0)]
#[abi(embed_v0)]
impl ICallbackMockImpl of super::ICallbackMock<ContractState> {
fn get_counter(self: @ContractState) -> u32 {
self.counter.read()
}
}

#[external(v0)]
#[abi(embed_v0)]
impl IDepositCallbackReceiverImpl of IDepositCallbackReceiver<ContractState> {
fn after_deposit_execution(
ref self: ContractState, key: felt252, deposit: Deposit, log_data: Array<felt252>,
Expand Down
2 changes: 1 addition & 1 deletion src/chain/chain.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ mod Chain {
// *************************************************************************
// EXTERNAL FUNCTIONS
// *************************************************************************
#[external(v0)]
#[abi(embed_v0)]
impl Chain of super::IChain<ContractState> {
fn get_block_number(self: @ContractState) -> u64 {
starknet::info::get_block_number()
Expand Down
2 changes: 1 addition & 1 deletion src/config/config.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ mod Config {
// *************************************************************************
// EXTERNAL FUNCTIONS
// *************************************************************************
#[external(v0)]
#[abi(embed_v0)]
impl ConfigImpl of super::IConfig<ContractState> {
fn set_bool(
ref self: ContractState, base_key: felt252, data: Array<felt252>, value: bool,
Expand Down
2 changes: 1 addition & 1 deletion src/config/timelock.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ mod Timelock {
// *************************************************************************
// EXTERNAL FUNCTIONS
// *************************************************************************
#[external(v0)]
#[abi(embed_v0)]
impl TimelockImpl of super::ITimelock<ContractState> {}
}
2 changes: 1 addition & 1 deletion src/data/data_store.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ mod DataStore {
// *************************************************************************
// EXTERNAL FUNCTIONS
// *************************************************************************
#[external(v0)]
#[abi(embed_v0)]
impl DataStore of super::IDataStore<ContractState> {
// *************************************************************************
// Felt252 related functions.
Expand Down
2 changes: 1 addition & 1 deletion src/deposit/deposit_vault.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ mod DepositVault {
// *************************************************************************
// EXTERNAL FUNCTIONS
// *************************************************************************
#[external(v0)]
#[abi(embed_v0)]
impl DepositVaultImpl of super::IDepositVault<ContractState> {
fn initialize(
ref self: ContractState,
Expand Down
2 changes: 1 addition & 1 deletion src/event/event_emitter.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -1549,7 +1549,7 @@ mod EventEmitter {
// *************************************************************************
// EXTERNAL FUNCTIONS
// *************************************************************************
#[external(v0)]
#[abi(embed_v0)]
impl EventEmitterImpl of super::IEventEmitter<ContractState> {
/// Emits the `ClaimableCollateralUpdated` event.
fn emit_claimable_collateral_updated(
Expand Down
2 changes: 1 addition & 1 deletion src/exchange/adl_handler.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ mod AdlHandler {
// *************************************************************************
// EXTERNAL FUNCTIONS
// *************************************************************************
#[external(v0)]
#[abi(embed_v0)]
impl AdlHandlerImpl of super::IAdlHandler<ContractState> {
fn update_adl_state(
ref self: ContractState,
Expand Down
2 changes: 1 addition & 1 deletion src/exchange/base_order_handler.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ mod BaseOrderHandler {
// *************************************************************************
// EXTERNAL FUNCTIONS
// *************************************************************************
#[external(v0)]
#[abi(embed_v0)]
impl BaseOrderHandlerImpl of super::IBaseOrderHandler<ContractState> {
fn initialize(
ref self: ContractState,
Expand Down
2 changes: 1 addition & 1 deletion src/exchange/deposit_handler.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ mod DepositHandler {
// *************************************************************************
// EXTERNAL FUNCTIONS
// *************************************************************************
#[external(v0)]
#[abi(embed_v0)]
impl DepositHandlerImpl of super::IDepositHandler<ContractState> {
fn create_deposit(
ref self: ContractState, account: ContractAddress, params: CreateDepositParams
Expand Down
2 changes: 1 addition & 1 deletion src/exchange/liquidation_handler.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ mod LiquidationHandler {
// *************************************************************************
// EXTERNAL FUNCTIONS
// *************************************************************************
#[external(v0)]
#[abi(embed_v0)]
impl LiquidationHandlerImpl of super::ILiquidationHandler<
ContractState
> { // executes a position liquidation
Expand Down
2 changes: 1 addition & 1 deletion src/exchange/order_handler.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ mod OrderHandler {
// *************************************************************************
// EXTERNAL FUNCTIONS
// *************************************************************************
#[external(v0)]
#[abi(embed_v0)]
impl OrderHandlerImpl of super::IOrderHandler<ContractState> {
fn create_order(
ref self: ContractState, account: ContractAddress, params: CreateOrderParams
Expand Down
2 changes: 1 addition & 1 deletion src/exchange/withdrawal_handler.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ mod WithdrawalHandler {
// *************************************************************************
// EXTERNAL FUNCTIONS
// *************************************************************************
#[external(v0)]
#[abi(embed_v0)]
impl WithdrawalHandlerImpl of super::IWithdrawalHandler<ContractState> {
fn create_withdrawal(
ref self: ContractState, account: ContractAddress, params: CreateWithdrawalParams
Expand Down
2 changes: 1 addition & 1 deletion src/fee/fee_handler.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ mod FeeHandler {
// *************************************************************************
// EXTERNAL FUNCTIONS
// *************************************************************************
#[external(v0)]
#[abi(embed_v0)]
impl FeeHandlerImpl of super::IFeeHandler<ContractState> {
fn initialize(
ref self: ContractState,
Expand Down
2 changes: 1 addition & 1 deletion src/market/market.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use zeroable::Zeroable;
use satoru::market::error::MarketError;
use satoru::market::market_token::{IMarketTokenDispatcher, IMarketTokenDispatcherTrait};

/// Deriving the `storage_access::StorageAccess` trait
/// Deriving the `storage_access::Store` trait
/// allows us to store the `Market` struct in a contract's storage.
/// We use `Copy` but this is inneficient.
/// TODO: Optimize this.
Expand Down
2 changes: 1 addition & 1 deletion src/market/market_factory.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ mod MarketFactory {
// *************************************************************************
// EXTERNAL FUNCTIONS
// *************************************************************************
#[external(v0)]
#[abi(embed_v0)]
impl MarketFactory of super::IMarketFactory<ContractState> {
fn create_market(
ref self: ContractState,
Expand Down
3 changes: 1 addition & 2 deletions src/market/market_token.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ mod MarketToken {
//
// External
//

#[external(v0)]
#[abi(embed_v0)]
impl MarketTokenImpl of IMarketToken<ContractState> {
fn name(self: @ContractState) -> felt252 {
self.name.read()
Expand Down
2 changes: 1 addition & 1 deletion src/mock/governable.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ mod Governable {
// *************************************************************************
// EXTERNAL FUNCTIONS
// *************************************************************************
#[external(v0)]
#[abi(embed_v0)]
impl Governable of super::IGovernable<ContractState> {
fn initialize(ref self: ContractState, event_emitter_address: ContractAddress) {
assert(self.gov.read().is_zero(), MockError::ALREADY_INITIALIZED);
Expand Down
2 changes: 1 addition & 1 deletion src/mock/referral_storage.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ mod ReferralStorage {
// *************************************************************************
// EXTERNAL FUNCTIONS
// *************************************************************************
#[external(v0)]
#[abi(embed_v0)]
impl ReferralStorageImpl of super::IReferralStorage<ContractState> {
fn initialize(ref self: ContractState, event_emitter_address: ContractAddress) {
let mut gov_state = Governable::unsafe_new_contract_state();
Expand Down
2 changes: 1 addition & 1 deletion src/oracle/oracle.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ mod Oracle {
// *************************************************************************
// EXTERNAL FUNCTIONS
// *************************************************************************
#[external(v0)]
#[abi(embed_v0)]
impl OracleImpl of super::IOracle<ContractState> {
fn initialize(
ref self: ContractState,
Expand Down
2 changes: 1 addition & 1 deletion src/oracle/oracle_store.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ mod OracleStore {
// *************************************************************************
// EXTERNAL FUNCTIONS
// *************************************************************************
#[external(v0)]
#[abi(embed_v0)]
impl OracleStoreImpl of super::IOracleStore<ContractState> {
fn initialize(
ref self: ContractState,
Expand Down
2 changes: 1 addition & 1 deletion src/oracle/price_feed.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ mod PriceFeed {
#[storage]
struct Storage {}

#[external(v0)]
#[abi(embed_v0)]
impl PriceFeedImpl of super::IPriceFeed<ContractState> {
fn get_data_median(self: @ContractState, data_type: DataType) -> PragmaPricesResponse {
PragmaPricesResponse {
Expand Down
2 changes: 1 addition & 1 deletion src/order/order_vault.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ mod OrderVault {
// *************************************************************************
// EXTERNAL FUNCTIONS
// *************************************************************************
#[external(v0)]
#[abi(embed_v0)]
impl OrderVaultImpl of super::IOrderVault<ContractState> {
fn transfer_out(
ref self: ContractState,
Expand Down
2 changes: 1 addition & 1 deletion src/reader/reader.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ mod Reader {
// *************************************************************************
// EXTERNAL FUNCTIONS
// *************************************************************************
#[external(v0)]
#[abi(embed_v0)]
impl Reader of super::IReader<ContractState> {
fn get_market(
self: @ContractState, data_store: IDataStoreDispatcher, key: ContractAddress
Expand Down
2 changes: 1 addition & 1 deletion src/role/role_module.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ mod RoleModule {
// *************************************************************************
// EXTERNAL FUNCTIONS
// *************************************************************************
#[external(v0)]
#[abi(embed_v0)]
impl RoleModule of super::IRoleModule<ContractState> {
fn initialize(ref self: ContractState, role_store_address: ContractAddress) {
self.role_store.write(IRoleStoreDispatcher { contract_address: role_store_address });
Expand Down
2 changes: 1 addition & 1 deletion src/role/role_store.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ mod RoleStore {
// *************************************************************************
// EXTERNAL FUNCTIONS
// *************************************************************************
#[external(v0)]
#[abi(embed_v0)]
impl RoleStore of super::IRoleStore<ContractState> {
fn has_role(self: @ContractState, account: ContractAddress, role_key: felt252) -> bool {
self._has_role(account, role_key)
Expand Down
2 changes: 1 addition & 1 deletion src/router/exchange_router.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ mod ExchangeRouter {
// *************************************************************************
// EXTERNAL FUNCTIONS
// *************************************************************************
#[external(v0)]
#[abi(embed_v0)]
impl ExchangeRouterImpl of super::IExchangeRouter<ContractState> {
fn send_tokens(
ref self: ContractState, token: ContractAddress, receiver: ContractAddress, amount: u128
Expand Down
2 changes: 1 addition & 1 deletion src/router/router.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ mod Router {
// *************************************************************************
// EXTERNAL FUNCTIONS
// *************************************************************************
#[external(v0)]
#[abi(embed_v0)]
impl RouterImpl of super::IRouter<ContractState> {
fn plugin_transfer(
ref self: ContractState,
Expand Down
2 changes: 1 addition & 1 deletion src/swap/swap_handler.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ mod SwapHandler {
// *************************************************************************
// EXTERNAL FUNCTIONS
// *************************************************************************
#[external(v0)]
#[abi(embed_v0)]
impl SwapHandler of super::ISwapHandler<ContractState> {
fn swap(ref self: ContractState, params: SwapParams) -> (ContractAddress, u128) {
let mut role_module: RoleModule::ContractState =
Expand Down
2 changes: 1 addition & 1 deletion src/token/erc20/erc20.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ mod ERC20 {
// External
//

#[external(v0)]
#[abi(embed_v0)]
impl ERC20Impl of IERC20<ContractState> {
fn name(self: @ContractState) -> felt252 {
self._name.read()
Expand Down
6 changes: 2 additions & 4 deletions src/utils/serializable_dict.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ impl ItemImpl<T> of ItemTrait<T> {
}
}

impl ItemPartialEq<
T, impl TCopy: Copy<T>, impl TPartialEq: PartialEq<T>, impl TDrop: Drop<T>
> of PartialEq<Item<T>> {
impl ItemPartialEq<T, +Copy<T>, +PartialEq<T>, +Drop<T>> of PartialEq<Item<T>> {
fn eq(lhs: @Item<T>, rhs: @Item<T>) -> bool {
if lhs.is_single() && rhs.is_single() {
return lhs.unwrap_single() == rhs.unwrap_single();
Expand Down Expand Up @@ -96,7 +94,7 @@ struct SerializableFelt252Dict<T> {
}

impl SerializableFelt252DictDestruct<
T, impl TDrop: Drop<T>, impl TDefault: Felt252DictValue<T>
T, +Drop<T>, +Felt252DictValue<T>
> of Destruct<SerializableFelt252Dict<T>> {
fn destruct(self: SerializableFelt252Dict<T>) nopanic {
self.values.squash();
Expand Down
Loading

0 comments on commit 0c9ad1a

Please sign in to comment.