Skip to content

Commit

Permalink
Merge branch 'main' into Improvetestsofpricing_utils
Browse files Browse the repository at this point in the history
  • Loading branch information
sparqet authored Oct 14, 2023
2 parents 6e1d790 + 5b114cd commit 4857cac
Show file tree
Hide file tree
Showing 7 changed files with 416 additions and 58 deletions.
10 changes: 10 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "Satoru",
"image": "mcr.microsoft.com/devcontainers/base:jammy",
"customizations": {
"vscode": {
"extensions": ["starkware.cairo1"]
}
},
"postCreateCommand": "curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | sh && curl -L https://raw.githubusercontent.com/foundry-rs/starknet-foundry/master/scripts/install.sh | sh -s -- -v 0.7.0"
}
11 changes: 11 additions & 0 deletions book/src/getting-started/prerequisites.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Prerequisites

There are several ways to run Satoru:
- Install prerequisites on the local system
- Run in a dev container

## Installation on the local system
- [Scarb](https://docs.swmansion.com/scarb/download.html)
- [Starknet Foundry](https://foundry-rs.github.io/starknet-foundry/)

## Run in a dev container
Dev containers provide a dedicated environment for the project. Since the dev container configuration is stored in the `.devcontainer` directory, this ensures that the environment is strictly identical from one developer to the next.

To run inside a dev container, please follow [Dev Containers tutorial](https://code.visualstudio.com/docs/devcontainers/tutorial).
99 changes: 68 additions & 31 deletions src/event/event_utils.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -161,97 +161,134 @@ struct StringArrayKeyValue {

fn set_item_address_items(
mut items: AddressItems, index: u32, key: felt252, value: ContractAddress
) {
) -> AddressItems {
let address_key_value: AddressKeyValue = AddressKeyValue { key, value };
items.items.append(address_key_value);
let mut address: AddressItems = items;
address.items.append(address_key_value);
return address;
}

fn set_item_array_address_items(
mut items: AddressItems, index: u32, key: felt252, value: Array<ContractAddress>
) {
) -> AddressItems {
let address_array_key_value: AddressArrayKeyValue = AddressArrayKeyValue { key, value };
items.array_items.append(address_array_key_value);
let mut array_address: AddressItems = items;
array_address.array_items.append(address_array_key_value);
return array_address;
}

// Uint

fn set_item_uint_items(mut items: UintItems, index: u32, key: felt252, value: u128) {
fn set_item_uint_items(mut items: UintItems, index: u32, key: felt252, value: u128) -> UintItems {
let uint_key_value: UintKeyValue = UintKeyValue { key, value };
items.items.append(uint_key_value);
let mut address: UintItems = items;
address.items.append(uint_key_value);
return address;
}

fn set_item_array_uint_items(mut items: UintItems, index: u32, key: felt252, value: Array<u128>) {
fn set_item_array_uint_items(
mut items: UintItems, index: u32, key: felt252, value: Array<u128>
) -> UintItems {
let uint_array_key_value: UintArrayKeyValue = UintArrayKeyValue { key, value };
items.array_items.append(uint_array_key_value);
let mut array_address: UintItems = items;
array_address.array_items.append(uint_array_key_value);
return array_address;
}

// in128

fn set_item_int_items(mut items: IntItems, index: u32, key: felt252, value: i128) {
fn set_item_int_items(mut items: IntItems, index: u32, key: felt252, value: i128) -> IntItems {
let int_key_value: IntKeyValue = IntKeyValue { key, value };
// items.items.set(index, int_key_value);
items.items.append(int_key_value);
let mut address: IntItems = items;
address.items.append(int_key_value);
return address;
}

fn set_item_array_int_items(mut items: IntItems, index: u32, key: felt252, value: Array<i128>) {
fn set_item_array_int_items(
mut items: IntItems, index: u32, key: felt252, value: Array<i128>
) -> IntItems {
let int_array_key_value: IntArrayKeyValue = IntArrayKeyValue { key, value };
items.array_items.append(int_array_key_value);
let mut array_address: IntItems = items;
array_address.array_items.append(int_array_key_value);
return array_address;
}

// bool

fn set_item_bool_items(mut items: BoolItems, index: u32, key: felt252, value: bool) {
fn set_item_bool_items(mut items: BoolItems, index: u32, key: felt252, value: bool) -> BoolItems {
let bool_key_value: BoolKeyValue = BoolKeyValue { key, value };
items.items.append(bool_key_value);
let mut address: BoolItems = items;
address.items.append(bool_key_value);
return address;
}

fn set_item_array_bool_items(mut items: BoolItems, index: u32, key: felt252, value: Array<bool>) {
fn set_item_array_bool_items(
mut items: BoolItems, index: u32, key: felt252, value: Array<bool>
) -> BoolItems {
let bool_array_key_value: BoolArrayKeyValue = BoolArrayKeyValue { key, value };
items.array_items.append(bool_array_key_value);
let mut array_address: BoolItems = items;
array_address.array_items.append(bool_array_key_value);
return array_address;
}

// felt252

fn set_item_Felt252_items(mut items: Felt252Items, index: u32, key: felt252, value: felt252) {
let Felt252_key_value: Felt252KeyValue = Felt252KeyValue { key, value };
items.items.append(Felt252_key_value);
fn set_item_Felt252_items(
mut items: Felt252Items, index: u32, key: felt252, value: felt252
) -> Felt252Items {
let felt252_key_value: Felt252KeyValue = Felt252KeyValue { key, value };
let mut address: Felt252Items = items;
address.items.append(felt252_key_value);
return address;
}

fn set_item_array_Felt252_items(
mut items: Felt252Items, index: u32, key: felt252, value: Array<felt252>
) {
let Felt252_array_key_value: Felt252ArrayKeyValue = Felt252ArrayKeyValue { key, value };
items.array_items.append(Felt252_array_key_value);
) -> Felt252Items {
let felt252_array_key_value: Felt252ArrayKeyValue = Felt252ArrayKeyValue { key, value };
let mut array_address: Felt252Items = items;
array_address.array_items.append(felt252_array_key_value);
return array_address;
}

// array of felt

fn set_item_array_of_felt_items_items(
mut items: ArrayOfFeltItems, index: u32, key: felt252, value: Array<felt252>
) {
) -> ArrayOfFeltItems {
let array_of_felt_items_key_value: ArrayOfFeltKeyValue = ArrayOfFeltKeyValue { key, value };
items.items.append(array_of_felt_items_key_value);
let mut address: ArrayOfFeltItems = items;
address.items.append(array_of_felt_items_key_value);
return address;
}

fn set_item_array_array_of_felt_items(
mut items: ArrayOfFeltItems, index: u32, key: felt252, value: Array<Array<felt252>>
) {
) -> ArrayOfFeltItems {
let array_of_felt_array_key_value: ArrayOfFeltArrayKeyValue = ArrayOfFeltArrayKeyValue {
key, value
};
items.array_items.append(array_of_felt_array_key_value);
let mut array_address: ArrayOfFeltItems = items;
array_address.array_items.append(array_of_felt_array_key_value);
return array_address;
}

// string

fn set_item_string_items(mut items: StringItems, index: u32, key: felt252, value: felt252) {
fn set_item_string_items(
mut items: StringItems, index: u32, key: felt252, value: felt252
) -> StringItems {
let string_key_value: StringKeyValue = StringKeyValue { key, value };
items.items.append(string_key_value);
let mut address: StringItems = items;
address.items.append(string_key_value);
return address;
}

fn set_item_array_string_items(
mut items: StringItems, index: u32, key: felt252, value: Array<felt252>
) {
) -> StringItems {
let string_array_key_value: StringArrayKeyValue = StringArrayKeyValue { key, value };
items.array_items.append(string_array_key_value);
let mut array_address: StringItems = items;
array_address.array_items.append(string_array_key_value);
return array_address;
}
1 change: 1 addition & 0 deletions src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ mod order {
mod order_store_utils;
mod order_event_utils;
mod error;
mod swap_order_utils;
}

// `position` contains positions management functions
Expand Down
Loading

0 comments on commit 4857cac

Please sign in to comment.