Skip to content

Commit

Permalink
Update examples to use Cairo 2 + add them to the workspace (lambdacla…
Browse files Browse the repository at this point in the history
…ss#1122)

* Delete old version of contract execution example

* Update example contract to cairo 2

* Make examples/contract_execution a proper crate

* Update contract execution example to use cairo 2 contracts

* Use same chain-id + restore expects

* Adjust values to pass validations

* Remove create_for_simulation

* Remove skip_validate

* Add comments

* fmt + clippy

* Embed aux contracts

* Update contract paths

* fmt

* Fix crate setup
  • Loading branch information
fmoletta authored Nov 6, 2023
1 parent ec86e49 commit 6a5530a
Show file tree
Hide file tree
Showing 11 changed files with 375 additions and 350 deletions.
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ cairo_1_tests = []
metrics = []

[workspace]
members = ["cli", "fuzzer", "rpc_state_reader"]
members = ["cli", "fuzzer", "rpc_state_reader", "examples/contract_execution"]

[workspace.dependencies]
cairo-lang-casm = "2.2.0"
Expand All @@ -35,7 +35,7 @@ cairo-lang-sierra = { workspace = true }
cairo-lang-starknet = { workspace = true }
cairo-lang-utils = { workspace = true }
cairo-native = { git = "https://github.com/lambdaclass/cairo_native", rev = "4012a10b97530e208b76d42169aa9608a6a9d8fd", optional = true }
cairo-vm = { workspace = true, features = ["cairo-1-hints"] }
cairo-vm = { workspace = true }
flate2 = "1.0.25"
getset = "0.1.2"
hex = "0.4.3"
Expand Down
14 changes: 14 additions & 0 deletions examples/contract_execution/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "contract_execution"
version = "0.4.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
cairo-vm = { workspace = true }
starknet_in_rust = { path = "../../", version = "0.4.0" }
serde_json = { version = "1.0", features = [
"arbitrary_precision",
"raw_value",
] }
9 changes: 2 additions & 7 deletions examples/contract_execution/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,12 @@ As declare and deploy transactions are currently WIP, we encapsulate all the fun

- Add your contract to this directory.

- Remember that in order to call functions you must use the *external* decorator.

- You also must add ```%lang starknet``` at the beggining of the contract.


- Compile the contract:
- ```source starknet-venv/bin/activate```
- ```starknet-compile your_contract.cairo --output your_contract.json```
- ```cairo2/bin/starknet-compile your_contract.cairo --single-file your_contract.json```

- Add a test for your contract calling ```test_contract``` passing:
- Your compiled contract path
- The entrypoint you are wanting to execute
- The parameters needed in order to call that entrypoint
- The expected returned value
- The expected returned value
32 changes: 0 additions & 32 deletions examples/contract_execution/example_contract.cairo

This file was deleted.

136 changes: 0 additions & 136 deletions examples/contract_execution/execute_contract.rs

This file was deleted.

Loading

0 comments on commit 6a5530a

Please sign in to comment.