From 33dada94c5e0c4a74e0a3087a7ad80590b66a057 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 18 Apr 2023 11:29:13 -0400 Subject: [PATCH 01/35] update cairo --- cairo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cairo b/cairo index 9c190561c..9812a0999 160000 --- a/cairo +++ b/cairo @@ -1 +1 @@ -Subproject commit 9c190561ce1e8323665857f1a77082925c817b4c +Subproject commit 9812a0999739529c42e24f8c5bce1066646fb6b1 From 503e72dbf4bbf3697eab2c2b08949a43b5bef1b1 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 18 Apr 2023 11:29:27 -0400 Subject: [PATCH 02/35] update Cargo --- Cargo.lock | 699 +++++++++++++++++++++++++---------------------------- Cargo.toml | 18 +- 2 files changed, 343 insertions(+), 374 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2094098a2..d1ee98d15 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,28 +3,30 @@ version = 3 [[package]] -name = "aho-corasick" -version = "0.7.20" +name = "ahash" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ - "memchr", + "cfg-if", + "once_cell", + "version_check", ] [[package]] -name = "android_system_properties" -version = "0.1.5" +name = "aho-corasick" +version = "0.7.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" dependencies = [ - "libc", + "memchr", ] [[package]] name = "anyhow" -version = "1.0.66" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" +checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" [[package]] name = "ark-ff" @@ -182,7 +184,7 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ - "hermit-abi", + "hermit-abi 0.1.19", "libc", "winapi", ] @@ -205,17 +207,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" -[[package]] -name = "bigdecimal" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aaf33151a6429fe9211d1b276eafdf70cdff28b071e76c0b0e1503221ea3744" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits 0.2.15", -] - [[package]] name = "bimap" version = "0.6.2" @@ -224,9 +215,9 @@ checksum = "bc0455254eb5c6964c4545d8bac815e1a1be4f3afe0ae695ea539c12d728d44b" [[package]] name = "bincode" -version = "1.3.3" +version = "2.0.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +checksum = "7bb50c5a2ef4b9b1e7ae73e3a73b52ea24b20312d629f9c4df28260b7ad2c3c4" dependencies = [ "serde", ] @@ -253,12 +244,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] -name = "block-buffer" -version = "0.9.0" +name = "bitvec" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" dependencies = [ - "generic-array", + "funty", + "radium", + "tap", + "wyz", ] [[package]] @@ -294,9 +288,9 @@ checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" [[package]] name = "cairo-felt" -version = "0.1.1" +version = "0.3.0-rc1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a792f409586c42c2d62cff582989e573d45b0855be95e022421d25f608364cc1" +checksum = "a93dedd19b8edf685798f1f12e4e0ac21ac196ea5262c300783f69f3fa0cb28b" dependencies = [ "lazy_static", "num-bigint", @@ -307,7 +301,7 @@ dependencies = [ [[package]] name = "cairo-lang-casm" -version = "1.0.0-alpha.6" +version = "1.0.0-alpha.7" dependencies = [ "cairo-lang-utils", "env_logger", @@ -324,7 +318,7 @@ dependencies = [ [[package]] name = "cairo-lang-compiler" -version = "1.0.0-alpha.6" +version = "1.0.0-alpha.7" dependencies = [ "anyhow", "cairo-lang-defs", @@ -339,7 +333,7 @@ dependencies = [ "cairo-lang-sierra-generator", "cairo-lang-syntax", "cairo-lang-utils", - "clap 4.0.26", + "clap", "log", "salsa", "test-log", @@ -348,7 +342,7 @@ dependencies = [ [[package]] name = "cairo-lang-debug" -version = "1.0.0-alpha.6" +version = "1.0.0-alpha.7" dependencies = [ "cairo-lang-proc-macros", "cairo-lang-utils", @@ -359,7 +353,7 @@ dependencies = [ [[package]] name = "cairo-lang-defs" -version = "1.0.0-alpha.6" +version = "1.0.0-alpha.7" dependencies = [ "cairo-lang-debug", "cairo-lang-diagnostics", @@ -380,7 +374,7 @@ dependencies = [ [[package]] name = "cairo-lang-diagnostics" -version = "1.0.0-alpha.6" +version = "1.0.0-alpha.7" dependencies = [ "cairo-lang-filesystem", "cairo-lang-proc-macros", @@ -395,7 +389,7 @@ dependencies = [ [[package]] name = "cairo-lang-eq-solver" -version = "1.0.0-alpha.6" +version = "1.0.0-alpha.7" dependencies = [ "cairo-lang-utils", "env_logger", @@ -409,20 +403,22 @@ dependencies = [ [[package]] name = "cairo-lang-filesystem" -version = "1.0.0-alpha.6" +version = "1.0.0-alpha.7" dependencies = [ "cairo-lang-debug", "cairo-lang-utils", "env_logger", "path-clean", "salsa", + "serde", + "serde_json", "smol_str", "test-log", ] [[package]] name = "cairo-lang-formatter" -version = "1.0.0-alpha.6" +version = "1.0.0-alpha.7" dependencies = [ "anyhow", "cairo-lang-diagnostics", @@ -430,7 +426,7 @@ dependencies = [ "cairo-lang-parser", "cairo-lang-syntax", "cairo-lang-utils", - "clap 4.0.26", + "clap", "colored", "diffy", "ignore", @@ -445,7 +441,7 @@ dependencies = [ [[package]] name = "cairo-lang-language-server" -version = "1.0.0-alpha.6" +version = "1.0.0-alpha.7" dependencies = [ "anyhow", "cairo-lang-compiler", @@ -477,7 +473,7 @@ dependencies = [ [[package]] name = "cairo-lang-lowering" -version = "1.0.0-alpha.6" +version = "1.0.0-alpha.7" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -506,7 +502,7 @@ dependencies = [ [[package]] name = "cairo-lang-parser" -version = "1.0.0-alpha.6" +version = "1.0.0-alpha.7" dependencies = [ "cairo-lang-diagnostics", "cairo-lang-filesystem", @@ -518,16 +514,19 @@ dependencies = [ "env_logger", "itertools", "log", + "num-bigint", + "num-traits 0.2.15", "pretty_assertions", "salsa", "smol_str", "test-case", "test-log", + "unescaper", ] [[package]] name = "cairo-lang-plugins" -version = "1.0.0-alpha.6" +version = "1.0.0-alpha.7" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -541,8 +540,8 @@ dependencies = [ "env_logger", "indoc", "itertools", - "pretty_assertions", "salsa", + "serde_json", "smol_str", "test-case", "test-log", @@ -550,7 +549,7 @@ dependencies = [ [[package]] name = "cairo-lang-proc-macros" -version = "1.0.0-alpha.6" +version = "1.0.0-alpha.7" dependencies = [ "cairo-lang-debug", "quote", @@ -559,7 +558,7 @@ dependencies = [ [[package]] name = "cairo-lang-project" -version = "1.0.0-alpha.6" +version = "1.0.0-alpha.7" dependencies = [ "cairo-lang-filesystem", "indoc", @@ -572,7 +571,7 @@ dependencies = [ [[package]] name = "cairo-lang-runner" -version = "1.0.0-alpha.6" +version = "1.0.0-alpha.7" dependencies = [ "anyhow", "ark-ff 0.4.0-alpha.7", @@ -588,9 +587,10 @@ dependencies = [ "cairo-lang-sierra-to-casm", "cairo-lang-utils", "cairo-vm", - "clap 4.0.26", + "clap", "itertools", "num-bigint", + "num-integer", "num-traits 0.2.15", "pretty_assertions", "salsa", @@ -600,7 +600,7 @@ dependencies = [ [[package]] name = "cairo-lang-semantic" -version = "1.0.0-alpha.6" +version = "1.0.0-alpha.7" dependencies = [ "assert_matches", "cairo-lang-debug", @@ -625,12 +625,11 @@ dependencies = [ "smol_str", "test-case", "test-log", - "unescaper", ] [[package]] name = "cairo-lang-sierra" -version = "1.0.0-alpha.6" +version = "1.0.0-alpha.7" dependencies = [ "assert_matches", "bimap", @@ -658,7 +657,7 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-ap-change" -version = "1.0.0-alpha.6" +version = "1.0.0-alpha.7" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -673,7 +672,7 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-gas" -version = "1.0.0-alpha.6" +version = "1.0.0-alpha.7" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -690,7 +689,7 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-generator" -version = "1.0.0-alpha.6" +version = "1.0.0-alpha.7" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -721,7 +720,7 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-to-casm" -version = "1.0.0-alpha.6" +version = "1.0.0-alpha.7" dependencies = [ "anyhow", "assert_matches", @@ -731,7 +730,7 @@ dependencies = [ "cairo-lang-sierra-ap-change", "cairo-lang-sierra-gas", "cairo-lang-utils", - "clap 4.0.26", + "clap", "env_logger", "indoc", "itertools", @@ -746,7 +745,7 @@ dependencies = [ [[package]] name = "cairo-lang-starknet" -version = "1.0.0-alpha.6" +version = "1.0.0-alpha.7" dependencies = [ "anyhow", "cairo-lang-casm", @@ -766,17 +765,17 @@ dependencies = [ "cairo-lang-syntax", "cairo-lang-test-utils", "cairo-lang-utils", - "clap 4.0.26", + "clap", "convert_case", "env_logger", "genco", "indoc", "itertools", - "lazy_static", "log", "num-bigint", "num-integer", "num-traits 0.2.15", + "once_cell", "pretty_assertions", "serde", "serde_json", @@ -789,21 +788,25 @@ dependencies = [ [[package]] name = "cairo-lang-syntax" -version = "1.0.0-alpha.6" +version = "1.0.0-alpha.7" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", "cairo-lang-utils", "env_logger", + "num-bigint", + "num-traits 0.2.15", "pretty_assertions", "salsa", "smol_str", "test-log", + "thiserror", + "unescaper", ] [[package]] name = "cairo-lang-syntax-codegen" -version = "1.0.0-alpha.6" +version = "1.0.0-alpha.7" dependencies = [ "cairo-lang-utils", "env_logger", @@ -815,7 +818,7 @@ dependencies = [ [[package]] name = "cairo-lang-test-runner" -version = "1.0.0-alpha.6" +version = "1.0.0-alpha.7" dependencies = [ "anyhow", "cairo-felt", @@ -825,6 +828,7 @@ dependencies = [ "cairo-lang-defs", "cairo-lang-diagnostics", "cairo-lang-filesystem", + "cairo-lang-lowering", "cairo-lang-plugins", "cairo-lang-project", "cairo-lang-runner", @@ -836,19 +840,19 @@ dependencies = [ "cairo-lang-syntax", "cairo-lang-utils", "cairo-vm", - "clap 4.0.26", + "clap", "colored", "itertools", "num-bigint", + "num-traits 0.2.15", "rayon", "salsa", "thiserror", - "unescaper", ] [[package]] name = "cairo-lang-test-utils" -version = "1.0.0-alpha.6" +version = "1.0.0-alpha.7" dependencies = [ "cairo-lang-utils", "env_logger", @@ -859,9 +863,8 @@ dependencies = [ [[package]] name = "cairo-lang-utils" -version = "1.0.0-alpha.6" +version = "1.0.0-alpha.7" dependencies = [ - "chrono", "env_logger", "indexmap", "itertools", @@ -873,18 +876,31 @@ dependencies = [ "serde_json", "test-case", "test-log", + "time", +] + +[[package]] +name = "cairo-take_until_unbalanced" +version = "0.24.2-rc1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4e174056df7cfe9b579376f32de405722e1090c74deb2540bb0cd9e7931772d" +dependencies = [ + "nom", ] [[package]] name = "cairo-vm" -version = "0.1.2" +version = "0.3.0-rc1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4fa1ade23dd2a6e671a923e748406c2c5f6c27fc186950ed04fae392b552a51" +checksum = "9f4af8c3e7be5ac46b7da4a3ab551ee4c8c8e2fdb501a4dda4dceef4c66dbcde" dependencies = [ + "anyhow", "bincode", + "bitvec", "cairo-felt", - "clap 3.2.23", + "cairo-take_until_unbalanced", "generic-array", + "hashbrown 0.13.2", "hex", "keccak", "lazy_static", @@ -893,15 +909,15 @@ dependencies = [ "num-bigint", "num-integer", "num-traits 0.2.15", - "parse-hyperlinks", "rand_core", "serde", "serde_bytes", "serde_json", - "sha2 0.10.6", + "sha2", "sha3", "starknet-crypto", "thiserror", + "thiserror-no-std", ] [[package]] @@ -925,38 +941,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "chrono" -version = "0.4.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" -dependencies = [ - "iana-time-zone", - "js-sys", - "num-integer", - "num-traits 0.2.15", - "time", - "wasm-bindgen", - "winapi", -] - -[[package]] -name = "clap" -version = "3.2.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" -dependencies = [ - "atty", - "bitflags", - "clap_derive 3.2.18", - "clap_lex 0.2.4", - "indexmap", - "once_cell", - "strsim", - "termcolor", - "textwrap", -] - [[package]] name = "clap" version = "4.0.26" @@ -965,26 +949,13 @@ checksum = "2148adefda54e14492fb9bddcc600b4344c5d1a3123bd666dcb939c6f0e0e57e" dependencies = [ "atty", "bitflags", - "clap_derive 4.0.21", - "clap_lex 0.3.0", + "clap_derive", + "clap_lex", "once_cell", "strsim", "termcolor", ] -[[package]] -name = "clap_derive" -version = "3.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65" -dependencies = [ - "heck 0.4.0", - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.103", -] - [[package]] name = "clap_derive" version = "4.0.21" @@ -998,15 +969,6 @@ dependencies = [ "syn 1.0.103", ] -[[package]] -name = "clap_lex" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" -dependencies = [ - "os_str_bytes", -] - [[package]] name = "clap_lex" version = "0.3.0" @@ -1016,16 +978,6 @@ dependencies = [ "os_str_bytes", ] -[[package]] -name = "codespan-reporting" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" -dependencies = [ - "termcolor", - "unicode-width", -] - [[package]] name = "colored" version = "2.0.0" @@ -1052,12 +1004,6 @@ dependencies = [ "unicode-segmentation", ] -[[package]] -name = "core-foundation-sys" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" - [[package]] name = "cpufeatures" version = "0.2.5" @@ -1118,12 +1064,11 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-bigint" -version = "0.3.2" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03c6a1d5fa1de37e071642dfa44ec552ca5b299adb128fab16138e24b548fd21" +checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" dependencies = [ "generic-array", - "rand_core", "subtle", "zeroize", ] @@ -1138,16 +1083,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "crypto-mac" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" -dependencies = [ - "generic-array", - "subtle", -] - [[package]] name = "ctor" version = "0.1.26" @@ -1158,50 +1093,6 @@ dependencies = [ "syn 1.0.103", ] -[[package]] -name = "cxx" -version = "1.0.82" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4a41a86530d0fe7f5d9ea779916b7cadd2d4f9add748b99c2c029cbbdfaf453" -dependencies = [ - "cc", - "cxxbridge-flags", - "cxxbridge-macro", - "link-cplusplus", -] - -[[package]] -name = "cxx-build" -version = "1.0.82" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06416d667ff3e3ad2df1cd8cd8afae5da26cf9cec4d0825040f88b5ca659a2f0" -dependencies = [ - "cc", - "codespan-reporting", - "once_cell", - "proc-macro2", - "quote", - "scratch", - "syn 1.0.103", -] - -[[package]] -name = "cxxbridge-flags" -version = "1.0.82" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "820a9a2af1669deeef27cb271f476ffd196a2c4b6731336011e0ba63e2c7cf71" - -[[package]] -name = "cxxbridge-macro" -version = "1.0.82" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08a6e2fcc370a089ad3b4aaf54db3b1b4cee38ddabce5896b33eb693275f470" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.103", -] - [[package]] name = "darling" version = "0.14.4" @@ -1244,7 +1135,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "907076dfda823b0b36d2a1bb5f90c96660a5bbcd7729e10727f07858f22c4edc" dependencies = [ "cfg-if", - "hashbrown", + "hashbrown 0.12.3", "lock_api", "once_cell", "parking_lot_core 0.9.4", @@ -1322,8 +1213,9 @@ version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" dependencies = [ - "block-buffer 0.10.3", + "block-buffer", "crypto-common", + "subtle", ] [[package]] @@ -1375,6 +1267,27 @@ dependencies = [ "termcolor", ] +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "fixedbitset" version = "0.4.2" @@ -1396,6 +1309,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + [[package]] name = "futures" version = "0.3.25" @@ -1532,7 +1451,7 @@ dependencies = [ "cfg-if", "js-sys", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "wasm-bindgen", ] @@ -1565,6 +1484,16 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash", + "serde", +] + [[package]] name = "heck" version = "0.3.3" @@ -1589,6 +1518,12 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" + [[package]] name = "hex" version = "0.4.3" @@ -1597,21 +1532,11 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hmac" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" -dependencies = [ - "crypto-mac", - "digest 0.9.0", -] - -[[package]] -name = "html-escape" -version = "0.2.13" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d1ad449764d627e22bfd7cd5e8868264fc9236e07c752972b4080cd351cb476" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "utf8-width", + "digest 0.10.6", ] [[package]] @@ -1626,30 +1551,6 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" -[[package]] -name = "iana-time-zone" -version = "0.1.53" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "winapi", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" -dependencies = [ - "cxx", - "cxx-build", -] - [[package]] name = "id-arena" version = "2.2.1" @@ -1696,14 +1597,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", + "serde", ] [[package]] name = "indoc" -version = "1.0.7" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adab1eaa3408fb7f0c777a73e7465fd5656136fc93b670eb6df3c88c2c1344e3" +checksum = "9f2cb48b81b1dc9f39676bf99f5499babfec7cd8fe14307f7b3d747208fb5690" [[package]] name = "instant" @@ -1714,6 +1616,29 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "io-lifetimes" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09270fd4fa1111bc614ed2246c7ef56239a3063d5be0d1ec3b589c505d400aeb" +dependencies = [ + "hermit-abi 0.3.1", + "libc", + "windows-sys 0.45.0", +] + +[[package]] +name = "is-terminal" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8687c819457e979cc940d09cb16e42a1bf70aa6b60a549de6d3a62a0ee90c69e" +dependencies = [ + "hermit-abi 0.3.1", + "io-lifetimes", + "rustix", + "windows-sys 0.45.0", +] + [[package]] name = "itertools" version = "0.10.5" @@ -1749,15 +1674,15 @@ dependencies = [ [[package]] name = "lalrpop" -version = "0.19.8" +version = "0.19.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b30455341b0e18f276fa64540aff54deafb54c589de6aca68659c63dd2d5d823" +checksum = "f34313ec00c2eb5c3c87ca6732ea02dcf3af99c3ff7a8fb622ffb99c9d860a87" dependencies = [ "ascii-canvas", - "atty", "bit-set", "diff", "ena", + "is-terminal", "itertools", "lalrpop-util", "petgraph", @@ -1772,9 +1697,9 @@ dependencies = [ [[package]] name = "lalrpop-util" -version = "0.19.8" +version = "0.19.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcf796c978e9b4d983414f4caedc9273aa33ee214c5b887bd55fde84c85d2dc4" +checksum = "e5c1f7869c94d214466c5fd432dfed12c379fd87786768d36455892d46b18edd" dependencies = [ "regex", ] @@ -1784,6 +1709,9 @@ name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin", +] [[package]] name = "libc" @@ -1802,13 +1730,10 @@ dependencies = [ ] [[package]] -name = "link-cplusplus" -version = "1.0.7" +name = "linux-raw-sys" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369" -dependencies = [ - "cc", -] +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" [[package]] name = "lock_api" @@ -1899,8 +1824,8 @@ checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" dependencies = [ "libc", "log", - "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys", + "wasi", + "windows-sys 0.42.0", ] [[package]] @@ -1998,15 +1923,24 @@ version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5" dependencies = [ - "hermit-abi", + "hermit-abi 0.1.19", + "libc", +] + +[[package]] +name = "num_threads" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44" +dependencies = [ "libc", ] [[package]] name = "once_cell" -version = "1.16.0" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] name = "oorandom" @@ -2014,12 +1948,6 @@ version = "11.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - [[package]] name = "os_str_bytes" version = "6.4.1" @@ -2086,19 +2014,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-sys", -] - -[[package]] -name = "parse-hyperlinks" -version = "0.23.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0181d37c4d5ae35cc8be7cf823c1a933005661da6a08bcb2855aa392c9a54b8e" -dependencies = [ - "html-escape", - "nom", - "percent-encoding", - "thiserror", + "windows-sys 0.42.0", ] [[package]] @@ -2252,6 +2168,12 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + [[package]] name = "rand" version = "0.8.5" @@ -2277,9 +2199,6 @@ name = "rand_core" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] [[package]] name = "rawpointer" @@ -2354,9 +2273,9 @@ checksum = "0df32d82cedd1499386877b062ebe8721f806de80b08d183c70184ef17dd1d42" [[package]] name = "rfc6979" -version = "0.1.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96ef608575f6392792f9ecf7890c00086591d29a83910939d430753f7c050525" +checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" dependencies = [ "crypto-bigint", "hmac", @@ -2413,6 +2332,20 @@ dependencies = [ "semver 1.0.17", ] +[[package]] +name = "rustix" +version = "0.36.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db4165c9963ab29e422d6c26fbc1d37f15bace6b2810221f9d925023480fcf0e" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys 0.45.0", +] + [[package]] name = "rustversion" version = "1.0.9" @@ -2483,12 +2416,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "scratch" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" - [[package]] name = "semver" version = "0.11.0" @@ -2527,9 +2454,9 @@ dependencies = [ [[package]] name = "serde_bytes" -version = "0.11.7" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfc50e8183eeeb6178dcb167ae34a8051d63535023ae38b5d8d12beae193d37b" +checksum = "416bda436f9aab92e02c8e10d49a15ddd339cea90b6e340fe51ed97abb548294" dependencies = [ "serde", ] @@ -2567,19 +2494,6 @@ dependencies = [ "syn 1.0.103", ] -[[package]] -name = "sha2" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if", - "cpufeatures", - "digest 0.9.0", - "opaque-debug", -] - [[package]] name = "sha2" version = "0.10.6" @@ -2633,9 +2547,9 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "smol_str" -version = "0.1.23" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7475118a28b7e3a2e157ce0131ba8c5526ea96e90ee601d9f6bb2e286a35ab44" +checksum = "74212e6bbe9a4352329b2f68ba3130c15a3f26fe88ff22dbdc6cdd58fa85e99c" dependencies = [ "serde", ] @@ -2650,6 +2564,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + [[package]] name = "sprs" version = "0.7.1" @@ -2663,9 +2583,9 @@ dependencies = [ [[package]] name = "starknet-crypto" -version = "0.2.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be7d6b2c959fde2a10dbc31d54bdd0307eecb7ef6c05c23a0263e65b57b3e18a" +checksum = "d49eb65d58fa98a164ad2cd4d04775885386b83bdad6060f168a38ede77c9aed" dependencies = [ "crypto-bigint", "hex", @@ -2674,19 +2594,18 @@ dependencies = [ "num-integer", "num-traits 0.2.15", "rfc6979", - "sha2 0.9.9", + "sha2", "starknet-crypto-codegen", "starknet-curve", "starknet-ff", - "thiserror", "zeroize", ] [[package]] name = "starknet-crypto-codegen" -version = "0.1.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6569d70430f0f6edc41f6820d00acf63356e6308046ca01e57eeac22ad258c47" +checksum = "bff08f74f3ac785ac34ac05c68c5bd4df280107ab35df69dbcbde35183d89eba" dependencies = [ "starknet-curve", "starknet-ff", @@ -2695,27 +2614,23 @@ dependencies = [ [[package]] name = "starknet-curve" -version = "0.1.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84be6079d3060fdbd8b5335574fef3d3783fa2f7ee6474d08ae0c1e4b0a29ba4" +checksum = "fe0dbde7ef14d54c2117bc6d2efb68c2383005f1cd749b277c11df874d07b7af" dependencies = [ "starknet-ff", ] [[package]] name = "starknet-ff" -version = "0.2.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5874510620214ebeac50915b01d67437d8ca10a6682b1de85b93cd01157b58eb" +checksum = "78d484109da192f3a8cd58f674861c2d5e4b3e1765a466362c6f350ef213dfd1" dependencies = [ "ark-ff 0.3.0", - "bigdecimal", "crypto-bigint", "getrandom", "hex", - "num-bigint", - "serde", - "thiserror", ] [[package]] @@ -2777,6 +2692,12 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + [[package]] name = "term" version = "0.7.0" @@ -2832,7 +2753,7 @@ dependencies = [ [[package]] name = "tests" -version = "1.0.0-alpha.6" +version = "1.0.0-alpha.7" dependencies = [ "assert_matches", "cairo-felt", @@ -2857,6 +2778,7 @@ dependencies = [ "itertools", "log", "num-bigint", + "once_cell", "pretty_assertions", "rstest", "salsa", @@ -2864,12 +2786,6 @@ dependencies = [ "test-log", ] -[[package]] -name = "textwrap" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" - [[package]] name = "thiserror" version = "1.0.40" @@ -2890,6 +2806,26 @@ dependencies = [ "syn 2.0.3", ] +[[package]] +name = "thiserror-impl-no-std" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58e6318948b519ba6dc2b442a6d0b904ebfb8d411a3ad3e07843615a72249758" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.103", +] + +[[package]] +name = "thiserror-no-std" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3ad459d94dd517257cc96add8a43190ee620011bb6e6cdc82dafd97dfafafea" +dependencies = [ + "thiserror-impl-no-std", +] + [[package]] name = "thread_local" version = "1.1.4" @@ -2901,13 +2837,31 @@ dependencies = [ [[package]] name = "time" -version = "0.1.44" +version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +checksum = "cd0cbfecb4d19b5ea75bb31ad904eb5b9fa13f21079c3b92017ebdf4999a5890" dependencies = [ + "itoa", "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi", + "num_threads", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" + +[[package]] +name = "time-macros" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd80a657e71da814b8e5d60d3374fc6d35045062245d80224748ae522dd76f36" +dependencies = [ + "time-core", ] [[package]] @@ -3116,12 +3070,6 @@ version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fdbf052a0783de01e944a6ce7a8cb939e295b1e7be835a1112c3b9a7f047a5a" -[[package]] -name = "unicode-width" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" - [[package]] name = "unicode-xid" version = "0.2.4" @@ -3140,12 +3088,6 @@ dependencies = [ "serde", ] -[[package]] -name = "utf8-width" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5190c9442dcdaf0ddd50f37420417d219ae5261bbf5db120d0f9bab996c9cba1" - [[package]] name = "version_check" version = "0.9.4" @@ -3163,12 +3105,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -3275,47 +3211,80 @@ dependencies = [ "windows_x86_64_msvc", ] +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" [[package]] name = "windows_aarch64_msvc" -version = "0.42.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_i686_gnu" -version = "0.42.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_msvc" -version = "0.42.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_x86_64_gnu" -version = "0.42.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" [[package]] name = "windows_x86_64_msvc" -version = "0.42.0" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] [[package]] name = "xshell" diff --git a/Cargo.toml b/Cargo.toml index 107fb5d91..6f4351b7a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,7 +31,7 @@ members = [ ] [workspace.package] -version = "1.0.0-alpha.6" +version = "1.0.0-alpha.7" edition = "2021" repository = "https://github.com/starkware-libs/cairo/" license = "Apache-2.0" @@ -43,9 +43,8 @@ ark-ff = "0.4.0-alpha.7" ark-std = "0.3.0" assert_matches = "1.5" bimap = "0.6.2" -cairo-felt = "0.1.1" -cairo-vm = "0.1.2" -chrono = "0.4.23" +cairo-felt = "0.3.0-rc1" +cairo-vm = "0.3.0-rc1" clap = { version = "4.0", features = ["derive"] } colored = "2" const-fnv1a-hash = "1.1.0" @@ -57,16 +56,16 @@ genco = "0.17.0" good_lp = { version = "1.3.2", features = ["minilp"], default-features = false } id-arena = "2.2.1" ignore = "0.4.20" -indexmap = "1.9.1" -indoc = "1.0.7" +indexmap = { version = "1.9.1", features = ["serde"] } +indoc = "2.0.1" itertools = "0.10.3" -lalrpop-util = { version = "0.19.8", features = ["lexer"] } -lazy_static = "1.4.0" +lalrpop-util = { version = "0.19.9", features = ["lexer"] } log = "0.4" lsp = { version = "0.93", package = "lsp-types" } num-bigint = "0.4" num-integer = "0.1" num-traits = "0.2" +once_cell = "1.17.1" path-clean = "0.1.0" pretty_assertions = "1.2.1" proc-macro2 = "1.0" @@ -78,12 +77,13 @@ scarb-metadata = "1.0.1" serde = { version = "1.0.130", features = ["derive"] } serde_json = "1.0" sha3 = "0.10.6" -smol_str = "0.1.23" +smol_str = { version = "0.2.0", features = ["serde"] } syn = { version = "1.0.99", features = ["full", "extra-traits"] } test-case = "2.2.2" test-case-macros = "2.2.2" test-log = "0.2.11" thiserror = "1.0.32" +time = { version = "0.3.20", features = ["formatting", "macros", "local-offset"] } tokio = { version = "1.18.2", features = ["full", "sync"] } toml = "0.4.2" tower-lsp = "0.17.0" From 3d3f8f9c87382b8b177f4e11e4c774b7c3eeaf3f Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 18 Apr 2023 11:29:45 -0400 Subject: [PATCH 03/35] fix test command --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7969ea043..0ed75752e 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ build: cargo build test: - cargo run --bin cairo-test -- --starknet --path $(SOURCE_FOLDER) + cargo run --bin cairo-test -- --starknet $(SOURCE_FOLDER) format: cargo run --bin cairo-format -- --recursive $(SOURCE_FOLDER) --print-parsing-errors From 59a7aa13f9827219392100b2d92c9ec90f79d53e Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 18 Apr 2023 11:30:26 -0400 Subject: [PATCH 04/35] fix formatting --- src/openzeppelin/security/initializable.cairo | 2 +- src/openzeppelin/security/pausable.cairo | 2 +- src/openzeppelin/tests/test_erc20.cairo | 32 +++++++++---------- .../tests/test_initializable.cairo | 6 ++-- src/openzeppelin/tests/test_pausable.cairo | 12 +++---- src/openzeppelin/token/erc20.cairo | 2 +- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/openzeppelin/security/initializable.cairo b/src/openzeppelin/security/initializable.cairo index 80df38da6..a562a5626 100644 --- a/src/openzeppelin/security/initializable.cairo +++ b/src/openzeppelin/security/initializable.cairo @@ -1,7 +1,7 @@ #[contract] mod Initializable { struct Storage { - initialized: bool, + initialized: bool, } #[internal] diff --git a/src/openzeppelin/security/pausable.cairo b/src/openzeppelin/security/pausable.cairo index 4fcd68384..d8770ef5f 100644 --- a/src/openzeppelin/security/pausable.cairo +++ b/src/openzeppelin/security/pausable.cairo @@ -4,7 +4,7 @@ mod Pausable { use starknet::get_caller_address; struct Storage { - paused: bool, + paused: bool, } #[event] diff --git a/src/openzeppelin/tests/test_erc20.cairo b/src/openzeppelin/tests/test_erc20.cairo index 0b4f7f230..04fb5fcf1 100644 --- a/src/openzeppelin/tests/test_erc20.cairo +++ b/src/openzeppelin/tests/test_erc20.cairo @@ -84,7 +84,7 @@ fn test_approve() { #[test] #[available_gas(2000000)] -#[should_panic(expected = ('ERC20: approve from 0', ))] +#[should_panic(expected: ('ERC20: approve from 0', ))] fn test_approve_from_zero() { let (owner, supply) = setup(); let spender: ContractAddress = contract_address_const::<2>(); @@ -97,7 +97,7 @@ fn test_approve_from_zero() { #[test] #[available_gas(2000000)] -#[should_panic(expected = ('ERC20: approve to 0', ))] +#[should_panic(expected: ('ERC20: approve to 0', ))] fn test_approve_to_zero() { let (owner, supply) = setup(); let spender: ContractAddress = contract_address_const::<0>(); @@ -120,7 +120,7 @@ fn test__approve() { #[test] #[available_gas(2000000)] -#[should_panic(expected = ('ERC20: approve from 0', ))] +#[should_panic(expected: ('ERC20: approve from 0', ))] fn test__approve_from_zero() { let owner: ContractAddress = contract_address_const::<0>(); let spender: ContractAddress = contract_address_const::<1>(); @@ -130,7 +130,7 @@ fn test__approve_from_zero() { #[test] #[available_gas(2000000)] -#[should_panic(expected = ('ERC20: approve to 0', ))] +#[should_panic(expected: ('ERC20: approve to 0', ))] fn test__approve_to_zero() { let (owner, supply) = setup(); @@ -170,7 +170,7 @@ fn test__transfer() { #[test] #[available_gas(2000000)] -#[should_panic(expected = ('u256_sub Overflow', ))] +#[should_panic(expected: ('u256_sub Overflow', ))] fn test__transfer_not_enough_balance() { let (sender, supply) = setup(); @@ -181,7 +181,7 @@ fn test__transfer_not_enough_balance() { #[test] #[available_gas(2000000)] -#[should_panic(expected = ('ERC20: transfer from 0', ))] +#[should_panic(expected: ('ERC20: transfer from 0', ))] fn test__transfer_from_zero() { let sender: ContractAddress = contract_address_const::<0>(); let recipient: ContractAddress = contract_address_const::<1>(); @@ -191,7 +191,7 @@ fn test__transfer_from_zero() { #[test] #[available_gas(2000000)] -#[should_panic(expected = ('ERC20: transfer to 0', ))] +#[should_panic(expected: ('ERC20: transfer to 0', ))] fn test__transfer_to_zero() { let (sender, supply) = setup(); @@ -245,7 +245,7 @@ fn test_transfer_from_doesnt_consume_infinite_allowance() { #[test] #[available_gas(2000000)] -#[should_panic(expected = ('u256_sub Overflow', ))] +#[should_panic(expected: ('u256_sub Overflow', ))] fn test_transfer_from_greater_than_allowance() { let (owner, supply) = setup(); @@ -263,7 +263,7 @@ fn test_transfer_from_greater_than_allowance() { #[test] #[available_gas(2000000)] -#[should_panic(expected = ('ERC20: transfer to 0', ))] +#[should_panic(expected: ('ERC20: transfer to 0', ))] fn test_transfer_from_to_zero_address() { let (owner, supply) = setup(); @@ -280,7 +280,7 @@ fn test_transfer_from_to_zero_address() { #[test] #[available_gas(2000000)] -#[should_panic(expected = ('u256_sub Overflow', ))] +#[should_panic(expected: ('u256_sub Overflow', ))] fn test_transfer_from_from_zero_address() { let (owner, supply) = setup(); @@ -312,7 +312,7 @@ fn test_increase_allowance() { #[test] #[available_gas(2000000)] -#[should_panic(expected = ('ERC20: approve to 0', ))] +#[should_panic(expected: ('ERC20: approve to 0', ))] fn test_increase_allowance_to_zero_address() { let (owner, supply) = setup(); @@ -324,7 +324,7 @@ fn test_increase_allowance_to_zero_address() { #[test] #[available_gas(2000000)] -#[should_panic(expected = ('ERC20: approve from 0', ))] +#[should_panic(expected: ('ERC20: approve from 0', ))] fn test_increase_allowance_from_zero_address() { let (owner, supply) = setup(); @@ -355,7 +355,7 @@ fn test_decrease_allowance() { #[test] #[available_gas(2000000)] -#[should_panic(expected = ('u256_sub Overflow', ))] +#[should_panic(expected: ('u256_sub Overflow', ))] fn test_decrease_allowance_to_zero_address() { let (owner, supply) = setup(); @@ -367,7 +367,7 @@ fn test_decrease_allowance_to_zero_address() { #[test] #[available_gas(2000000)] -#[should_panic(expected = ('u256_sub Overflow', ))] +#[should_panic(expected: ('u256_sub Overflow', ))] fn test_decrease_allowance_from_zero_address() { let (owner, supply) = setup(); @@ -423,7 +423,7 @@ fn test__mint() { #[test] #[available_gas(2000000)] -#[should_panic(expected = ('ERC20: mint to 0', ))] +#[should_panic(expected: ('ERC20: mint to 0', ))] fn test__mint_to_zero() { let minter: ContractAddress = contract_address_const::<0>(); let amount: u256 = u256_from_felt252(100); @@ -445,7 +445,7 @@ fn test__burn() { #[test] #[available_gas(2000000)] -#[should_panic(expected = ('ERC20: burn from 0', ))] +#[should_panic(expected: ('ERC20: burn from 0', ))] fn test__burn_from_zero() { setup(); let zero_address: ContractAddress = contract_address_const::<0>(); diff --git a/src/openzeppelin/tests/test_initializable.cairo b/src/openzeppelin/tests/test_initializable.cairo index bcbb7c503..906564532 100644 --- a/src/openzeppelin/tests/test_initializable.cairo +++ b/src/openzeppelin/tests/test_initializable.cairo @@ -3,14 +3,14 @@ use openzeppelin::security::initializable::Initializable; #[test] #[available_gas(2000000)] fn test_initialize() { - assert(!Initializable::is_initialized(),'Should not be initialized'); + assert(!Initializable::is_initialized(), 'Should not be initialized'); Initializable::initialize(); - assert(Initializable::is_initialized(),'Should be initialized'); + assert(Initializable::is_initialized(), 'Should be initialized'); } #[test] #[available_gas(2000000)] -#[should_panic(expected = ('Contract already initialized', ))] +#[should_panic(expected: ('Contract already initialized', ))] fn test_initialize_when_initialized() { Initializable::initialize(); Initializable::initialize(); diff --git a/src/openzeppelin/tests/test_pausable.cairo b/src/openzeppelin/tests/test_pausable.cairo index 6fe484505..6b76e9375 100644 --- a/src/openzeppelin/tests/test_pausable.cairo +++ b/src/openzeppelin/tests/test_pausable.cairo @@ -3,7 +3,7 @@ use openzeppelin::tests::mocks::mock_pausable::MockPausable; #[test] #[available_gas(2000000)] fn test_pause_when_unpaused() { - assert(! MockPausable::is_paused(), 'Should not be paused'); + assert(!MockPausable::is_paused(), 'Should not be paused'); assert(MockPausable::get_count() == 0, 'Should be 0'); MockPausable::assert_unpaused_and_increment(); assert(MockPausable::get_count() == 1, 'Should increment'); @@ -13,7 +13,7 @@ fn test_pause_when_unpaused() { #[test] #[available_gas(2000000)] -#[should_panic(expected = ('Pausable: paused', ))] +#[should_panic(expected: ('Pausable: paused', ))] fn test_pause_when_paused() { MockPausable::pause(); MockPausable::pause(); @@ -21,7 +21,7 @@ fn test_pause_when_paused() { #[test] #[available_gas(2000000)] -#[should_panic(expected = ('Pausable: paused', ))] +#[should_panic(expected: ('Pausable: paused', ))] fn test_pause_increment() { MockPausable::pause(); MockPausable::assert_unpaused_and_increment(); @@ -33,15 +33,15 @@ fn test_unpause_when_paused() { MockPausable::pause(); assert(MockPausable::is_paused(), 'Should be paused'); MockPausable::unpause(); - assert(! MockPausable::is_paused(), 'Should not be paused'); + assert(!MockPausable::is_paused(), 'Should not be paused'); MockPausable::assert_unpaused_and_increment(); assert(MockPausable::get_count() == 1, 'Should increment'); } #[test] #[available_gas(2000000)] -#[should_panic(expected = ('Pausable: not paused', ))] +#[should_panic(expected: ('Pausable: not paused', ))] fn test_unpause_when_unpaused() { - assert(! MockPausable::is_paused(), 'Should be unpaused'); + assert(!MockPausable::is_paused(), 'Should be unpaused'); MockPausable::unpause(); } diff --git a/src/openzeppelin/token/erc20.cairo b/src/openzeppelin/token/erc20.cairo index 8b84c1a1f..87348ef4c 100644 --- a/src/openzeppelin/token/erc20.cairo +++ b/src/openzeppelin/token/erc20.cairo @@ -17,7 +17,7 @@ mod ERC20 { use openzeppelin::token::erc20::IERC20; use starknet::get_caller_address; use starknet::ContractAddress; - use starknet::ContractAddressZeroable; + //use starknet::ContractAddressZeroable; use zeroable::Zeroable; struct Storage { From e0ae8388d945a5b9038c7699e27dfb5c54d58490 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 18 Apr 2023 11:30:48 -0400 Subject: [PATCH 05/35] add utils and udc --- src/openzeppelin/lib.cairo | 1 + src/openzeppelin/utils.cairo | 1 + src/openzeppelin/utils/udc.cairo | 64 ++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 src/openzeppelin/utils.cairo create mode 100644 src/openzeppelin/utils/udc.cairo diff --git a/src/openzeppelin/lib.cairo b/src/openzeppelin/lib.cairo index 74152ca25..bb725e1b1 100644 --- a/src/openzeppelin/lib.cairo +++ b/src/openzeppelin/lib.cairo @@ -1,3 +1,4 @@ mod security; mod token; +mod utils; mod tests; diff --git a/src/openzeppelin/utils.cairo b/src/openzeppelin/utils.cairo new file mode 100644 index 000000000..7b40c5c64 --- /dev/null +++ b/src/openzeppelin/utils.cairo @@ -0,0 +1 @@ +mod udc; diff --git a/src/openzeppelin/utils/udc.cairo b/src/openzeppelin/utils/udc.cairo new file mode 100644 index 000000000..16ec5de4d --- /dev/null +++ b/src/openzeppelin/utils/udc.cairo @@ -0,0 +1,64 @@ +use starknet::class_hash::ClassHash; +use starknet::ContractAddress; + +// TODO: Fix trait impl errors in abi +// #[abi] +trait IUniversalDeployerContract { + #[event] + fn ContractDeployed( + address: ContractAddress, + deployer: ContractAddress, + unique: bool, + class_hash: ClassHash, + calldata: Array, + salt: felt252, + ); + #[external] + fn deploy_contract( + class_hash: ClassHash, salt: felt252, unique: bool, calldata: Array + ) -> ContractAddress; +} + +#[contract] +mod UniversalDeployerContract { + use array::ArrayTrait; + use hash::pedersen; + use starknet::class_hash::ClassHash; + use starknet::ContractAddress; + use starknet::get_caller_address; + use traits::Into; + + #[event] + fn ContractDeployed( + address: ContractAddress, + deployer: ContractAddress, + unique: bool, + class_hash: ClassHash, + calldata: Array, + salt: felt252, + ) {} + + #[external] + fn deploy_contract( + class_hash: ClassHash, salt: felt252, unique: bool, calldata: Array + ) -> ContractAddress { + let deployer: ContractAddress = get_caller_address(); + + // Defaults for non-unique deployment + let mut _salt: felt252 = salt; + let mut from_zero: bool = true; + + if unique { + _salt = pedersen(deployer.into(), salt); + from_zero = false; + } + + let (address, _) = starknet::syscalls::deploy_syscall( + class_hash, _salt, calldata.span(), from_zero + ).unwrap_syscall(); + + ContractDeployed(address, deployer, unique, class_hash, calldata, salt); + + return address; + } +} From bb77b8d412fc8c512bcdfe7abe6fee0ec50ab84e Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 18 Apr 2023 19:40:29 -0400 Subject: [PATCH 06/35] update cairo --- cairo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cairo b/cairo index 9812a0999..397c8f639 160000 --- a/cairo +++ b/cairo @@ -1 +1 @@ -Subproject commit 9812a0999739529c42e24f8c5bce1066646fb6b1 +Subproject commit 397c8f639a3eef6b961a7c193ac6f39dc5303c56 From a078431b88ce497e2c4f50d5b7c6f215fd72e8ec Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 18 Apr 2023 19:40:41 -0400 Subject: [PATCH 07/35] remove comment --- src/openzeppelin/token/erc20.cairo | 1 - 1 file changed, 1 deletion(-) diff --git a/src/openzeppelin/token/erc20.cairo b/src/openzeppelin/token/erc20.cairo index 87348ef4c..30be16ca3 100644 --- a/src/openzeppelin/token/erc20.cairo +++ b/src/openzeppelin/token/erc20.cairo @@ -17,7 +17,6 @@ mod ERC20 { use openzeppelin::token::erc20::IERC20; use starknet::get_caller_address; use starknet::ContractAddress; - //use starknet::ContractAddressZeroable; use zeroable::Zeroable; struct Storage { From ef593d0da5a0c1e17ea48b4e8abb20285d591e34 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 18 Apr 2023 19:51:35 -0400 Subject: [PATCH 08/35] remove trailing comma --- src/openzeppelin/security/initializable.cairo | 2 +- src/openzeppelin/security/pausable.cairo | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/openzeppelin/security/initializable.cairo b/src/openzeppelin/security/initializable.cairo index a562a5626..00079d280 100644 --- a/src/openzeppelin/security/initializable.cairo +++ b/src/openzeppelin/security/initializable.cairo @@ -1,7 +1,7 @@ #[contract] mod Initializable { struct Storage { - initialized: bool, + initialized: bool } #[internal] diff --git a/src/openzeppelin/security/pausable.cairo b/src/openzeppelin/security/pausable.cairo index d8770ef5f..0a9018f51 100644 --- a/src/openzeppelin/security/pausable.cairo +++ b/src/openzeppelin/security/pausable.cairo @@ -4,7 +4,7 @@ mod Pausable { use starknet::get_caller_address; struct Storage { - paused: bool, + paused: bool } #[event] From ab57f1ef937066d389d7668fce002c9a9ffd3327 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 25 Apr 2023 22:11:38 -0400 Subject: [PATCH 09/35] clean up contract --- src/openzeppelin/utils/udc.cairo | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/src/openzeppelin/utils/udc.cairo b/src/openzeppelin/utils/udc.cairo index 16ec5de4d..ddf6e3e2b 100644 --- a/src/openzeppelin/utils/udc.cairo +++ b/src/openzeppelin/utils/udc.cairo @@ -1,24 +1,3 @@ -use starknet::class_hash::ClassHash; -use starknet::ContractAddress; - -// TODO: Fix trait impl errors in abi -// #[abi] -trait IUniversalDeployerContract { - #[event] - fn ContractDeployed( - address: ContractAddress, - deployer: ContractAddress, - unique: bool, - class_hash: ClassHash, - calldata: Array, - salt: felt252, - ); - #[external] - fn deploy_contract( - class_hash: ClassHash, salt: felt252, unique: bool, calldata: Array - ) -> ContractAddress; -} - #[contract] mod UniversalDeployerContract { use array::ArrayTrait; @@ -58,7 +37,6 @@ mod UniversalDeployerContract { ).unwrap_syscall(); ContractDeployed(address, deployer, unique, class_hash, calldata, salt); - return address; } } From 80b193783f0845cb49d3beccc0be9b6851f8011d Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 28 Apr 2023 15:46:39 -0400 Subject: [PATCH 10/35] set cairo to alpha7 --- cairo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cairo b/cairo index 397c8f639..81c4eb942 160000 --- a/cairo +++ b/cairo @@ -1 +1 @@ -Subproject commit 397c8f639a3eef6b961a7c193ac6f39dc5303c56 +Subproject commit 81c4eb942dace6849a8067dc43263da99579bef8 From fcec06134b828dd3b261dea906160930f4e6f24d Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 28 Apr 2023 15:46:53 -0400 Subject: [PATCH 11/35] set Cargo --- Cargo.lock | 199 ++++++++++++++++++++++++++++++++++++++++------------- Cargo.toml | 2 +- 2 files changed, 152 insertions(+), 49 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d1ee98d15..e4ddc69bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -22,6 +22,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anyhow" version = "1.0.70" @@ -514,14 +523,11 @@ dependencies = [ "env_logger", "itertools", "log", - "num-bigint", - "num-traits 0.2.15", "pretty_assertions", "salsa", "smol_str", "test-case", "test-log", - "unescaper", ] [[package]] @@ -545,6 +551,7 @@ dependencies = [ "smol_str", "test-case", "test-log", + "unescaper", ] [[package]] @@ -625,6 +632,7 @@ dependencies = [ "smol_str", "test-case", "test-log", + "unescaper", ] [[package]] @@ -794,14 +802,10 @@ dependencies = [ "cairo-lang-filesystem", "cairo-lang-utils", "env_logger", - "num-bigint", - "num-traits 0.2.15", "pretty_assertions", "salsa", "smol_str", "test-log", - "thiserror", - "unescaper", ] [[package]] @@ -844,10 +848,10 @@ dependencies = [ "colored", "itertools", "num-bigint", - "num-traits 0.2.15", "rayon", "salsa", "thiserror", + "unescaper", ] [[package]] @@ -865,6 +869,7 @@ dependencies = [ name = "cairo-lang-utils" version = "1.0.0-alpha.7" dependencies = [ + "chrono", "env_logger", "indexmap", "itertools", @@ -876,7 +881,6 @@ dependencies = [ "serde_json", "test-case", "test-log", - "time", ] [[package]] @@ -941,6 +945,21 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-integer", + "num-traits 0.2.15", + "time", + "wasm-bindgen", + "winapi", +] + [[package]] name = "clap" version = "4.0.26" @@ -978,6 +997,16 @@ dependencies = [ "os_str_bytes", ] +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + [[package]] name = "colored" version = "2.0.0" @@ -1004,6 +1033,12 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + [[package]] name = "cpufeatures" version = "0.2.5" @@ -1093,6 +1128,50 @@ dependencies = [ "syn 1.0.103", ] +[[package]] +name = "cxx" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4a41a86530d0fe7f5d9ea779916b7cadd2d4f9add748b99c2c029cbbdfaf453" +dependencies = [ + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06416d667ff3e3ad2df1cd8cd8afae5da26cf9cec4d0825040f88b5ca659a2f0" +dependencies = [ + "cc", + "codespan-reporting", + "once_cell", + "proc-macro2", + "quote", + "scratch", + "syn 1.0.103", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "820a9a2af1669deeef27cb271f476ffd196a2c4b6731336011e0ba63e2c7cf71" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a08a6e2fcc370a089ad3b4aaf54db3b1b4cee38ddabce5896b33eb693275f470" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.103", +] + [[package]] name = "darling" version = "0.14.4" @@ -1451,7 +1530,7 @@ dependencies = [ "cfg-if", "js-sys", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "wasm-bindgen", ] @@ -1551,6 +1630,30 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +[[package]] +name = "iana-time-zone" +version = "0.1.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "winapi", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +dependencies = [ + "cxx", + "cxx-build", +] + [[package]] name = "id-arena" version = "2.2.1" @@ -1729,6 +1832,15 @@ dependencies = [ "libc", ] +[[package]] +name = "link-cplusplus" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369" +dependencies = [ + "cc", +] + [[package]] name = "linux-raw-sys" version = "0.1.4" @@ -1824,7 +1936,7 @@ checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" dependencies = [ "libc", "log", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.42.0", ] @@ -1927,15 +2039,6 @@ dependencies = [ "libc", ] -[[package]] -name = "num_threads" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44" -dependencies = [ - "libc", -] - [[package]] name = "once_cell" version = "1.17.1" @@ -2152,9 +2255,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.52" +version = "1.0.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224" +checksum = "ba466839c78239c09faf015484e5cc04860f88242cff4d03eb038f04b4699b73" dependencies = [ "unicode-ident", ] @@ -2416,6 +2519,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "scratch" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" + [[package]] name = "semver" version = "0.11.0" @@ -2469,7 +2578,7 @@ checksum = "e801c1712f48475582b7696ac71e0ca34ebb30e09338425384269d9717c62cad" dependencies = [ "proc-macro2", "quote", - "syn 2.0.3", + "syn 2.0.9", ] [[package]] @@ -2671,9 +2780,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.3" +version = "2.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8234ae35e70582bfa0f1fedffa6daa248e41dd045310b19800c4a36382c8f60" +checksum = "0da4a3c17e109f700685ec577c0f85efd9b19bcf15c913985f14dc1ac01775aa" dependencies = [ "proc-macro2", "quote", @@ -2803,7 +2912,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.3", + "syn 2.0.9", ] [[package]] @@ -2837,31 +2946,13 @@ dependencies = [ [[package]] name = "time" -version = "0.3.20" +version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd0cbfecb4d19b5ea75bb31ad904eb5b9fa13f21079c3b92017ebdf4999a5890" +checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" dependencies = [ - "itoa", "libc", - "num_threads", - "serde", - "time-core", - "time-macros", -] - -[[package]] -name = "time-core" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" - -[[package]] -name = "time-macros" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd80a657e71da814b8e5d60d3374fc6d35045062245d80224748ae522dd76f36" -dependencies = [ - "time-core", + "wasi 0.10.0+wasi-snapshot-preview1", + "winapi", ] [[package]] @@ -3070,6 +3161,12 @@ version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fdbf052a0783de01e944a6ce7a8cb939e295b1e7be835a1112c3b9a7f047a5a" +[[package]] +name = "unicode-width" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" + [[package]] name = "unicode-xid" version = "0.2.4" @@ -3105,6 +3202,12 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "wasi" +version = "0.10.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" diff --git a/Cargo.toml b/Cargo.toml index 6f4351b7a..bb3d92a73 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,6 +45,7 @@ assert_matches = "1.5" bimap = "0.6.2" cairo-felt = "0.3.0-rc1" cairo-vm = "0.3.0-rc1" +chrono = "0.4.23" clap = { version = "4.0", features = ["derive"] } colored = "2" const-fnv1a-hash = "1.1.0" @@ -83,7 +84,6 @@ test-case = "2.2.2" test-case-macros = "2.2.2" test-log = "0.2.11" thiserror = "1.0.32" -time = { version = "0.3.20", features = ["formatting", "macros", "local-offset"] } tokio = { version = "1.18.2", features = ["full", "sync"] } toml = "0.4.2" tower-lsp = "0.17.0" From e367a276f6372fd948284289f4af0acc868a3e93 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 28 Apr 2023 16:26:08 -0400 Subject: [PATCH 12/35] use address zeroable --- src/openzeppelin/token/erc20.cairo | 1 + 1 file changed, 1 insertion(+) diff --git a/src/openzeppelin/token/erc20.cairo b/src/openzeppelin/token/erc20.cairo index 6e852dff9..f0b63d59d 100644 --- a/src/openzeppelin/token/erc20.cairo +++ b/src/openzeppelin/token/erc20.cairo @@ -17,6 +17,7 @@ mod ERC20 { use super::IERC20; use starknet::get_caller_address; use starknet::ContractAddress; + use starknet::ContractAddressZeroable; use zeroable::Zeroable; struct Storage { From 25b72e628525b640297f9f62f236aa30479f0a7a Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 28 Apr 2023 16:26:32 -0400 Subject: [PATCH 13/35] fix expected syntax --- src/openzeppelin/tests/test_erc165.cairo | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/openzeppelin/tests/test_erc165.cairo b/src/openzeppelin/tests/test_erc165.cairo index 7a4efeac8..c66c1b034 100644 --- a/src/openzeppelin/tests/test_erc165.cairo +++ b/src/openzeppelin/tests/test_erc165.cairo @@ -35,7 +35,7 @@ fn test_register_interface() { #[test] #[available_gas(2000000)] -#[should_panic(expected = ('Invalid id', ))] +#[should_panic(expected: ('Invalid id', ))] fn test_register_invalid_interface() { ERC165::register_interface(INVALID_ID); } @@ -51,7 +51,7 @@ fn test_deregister_interface() { #[test] #[available_gas(2000000)] -#[should_panic(expected = ('Invalid id', ))] +#[should_panic(expected: ('Invalid id', ))] fn test_deregister_default_interface() { ERC165::deregister_interface(IERC165_ID); } From 28e87591d4ecb58e7bb0bbf78995fa1c28bdcc90 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 28 Apr 2023 16:27:03 -0400 Subject: [PATCH 14/35] fix conflict --- src/openzeppelin/lib.cairo | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/openzeppelin/lib.cairo b/src/openzeppelin/lib.cairo index 09ce47b6d..c6913d104 100644 --- a/src/openzeppelin/lib.cairo +++ b/src/openzeppelin/lib.cairo @@ -1,6 +1,5 @@ mod introspection; mod security; mod token; -mod utils; mod tests; -mod utils; +//mod utils; From 9f39597c0030cc2fab1da5020bde6605852c1d66 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 28 Apr 2023 19:18:34 -0400 Subject: [PATCH 15/35] update cairo --- cairo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cairo b/cairo index 81c4eb942..3eb7c83b0 160000 --- a/cairo +++ b/cairo @@ -1 +1 @@ -Subproject commit 81c4eb942dace6849a8067dc43263da99579bef8 +Subproject commit 3eb7c83b0980b205f856d7dc9f6fd6cf1dc2675a From b2c05a4ff9d331b8723c371f856dc274a556d2fb Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 28 Apr 2023 19:19:08 -0400 Subject: [PATCH 16/35] remove comment --- src/openzeppelin/lib.cairo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openzeppelin/lib.cairo b/src/openzeppelin/lib.cairo index c6913d104..14a9204a4 100644 --- a/src/openzeppelin/lib.cairo +++ b/src/openzeppelin/lib.cairo @@ -2,4 +2,4 @@ mod introspection; mod security; mod token; mod tests; -//mod utils; +mod utils; From 5318f6bdbe1043deef0d2aab136a239af17df2bb Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 28 Apr 2023 19:19:37 -0400 Subject: [PATCH 17/35] remove unused import --- src/openzeppelin/token/erc20.cairo | 1 - 1 file changed, 1 deletion(-) diff --git a/src/openzeppelin/token/erc20.cairo b/src/openzeppelin/token/erc20.cairo index f0b63d59d..6e852dff9 100644 --- a/src/openzeppelin/token/erc20.cairo +++ b/src/openzeppelin/token/erc20.cairo @@ -17,7 +17,6 @@ mod ERC20 { use super::IERC20; use starknet::get_caller_address; use starknet::ContractAddress; - use starknet::ContractAddressZeroable; use zeroable::Zeroable; struct Storage { From c65161cf76d641c6d51c66dd8e3b497595d710e4 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 5 May 2023 21:55:27 -0400 Subject: [PATCH 18/35] update cairo to rc0 --- cairo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cairo b/cairo index 3eb7c83b0..05867c82d 160000 --- a/cairo +++ b/cairo @@ -1 +1 @@ -Subproject commit 3eb7c83b0980b205f856d7dc9f6fd6cf1dc2675a +Subproject commit 05867c82de42d5ee5cfa953dcca1cb826402f74b From 4cb9584b214fd78010578dc3b4120bc3de17d6d2 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 5 May 2023 21:55:44 -0400 Subject: [PATCH 19/35] update Cargo --- Cargo.lock | 263 +++++++++++++++++------------------------------------ Cargo.toml | 13 +-- 2 files changed, 91 insertions(+), 185 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e4ddc69bf..85aa935ae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -22,15 +22,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "android_system_properties" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" -dependencies = [ - "libc", -] - [[package]] name = "anyhow" version = "1.0.70" @@ -310,7 +301,7 @@ dependencies = [ [[package]] name = "cairo-lang-casm" -version = "1.0.0-alpha.7" +version = "1.0.0-rc0" dependencies = [ "cairo-lang-utils", "env_logger", @@ -327,7 +318,7 @@ dependencies = [ [[package]] name = "cairo-lang-compiler" -version = "1.0.0-alpha.7" +version = "1.0.0-rc0" dependencies = [ "anyhow", "cairo-lang-defs", @@ -345,13 +336,14 @@ dependencies = [ "clap", "log", "salsa", + "smol_str", "test-log", "thiserror", ] [[package]] name = "cairo-lang-debug" -version = "1.0.0-alpha.7" +version = "1.0.0-rc0" dependencies = [ "cairo-lang-proc-macros", "cairo-lang-utils", @@ -362,7 +354,7 @@ dependencies = [ [[package]] name = "cairo-lang-defs" -version = "1.0.0-alpha.7" +version = "1.0.0-rc0" dependencies = [ "cairo-lang-debug", "cairo-lang-diagnostics", @@ -383,7 +375,7 @@ dependencies = [ [[package]] name = "cairo-lang-diagnostics" -version = "1.0.0-alpha.7" +version = "1.0.0-rc0" dependencies = [ "cairo-lang-filesystem", "cairo-lang-proc-macros", @@ -398,7 +390,7 @@ dependencies = [ [[package]] name = "cairo-lang-eq-solver" -version = "1.0.0-alpha.7" +version = "1.0.0-rc0" dependencies = [ "cairo-lang-utils", "env_logger", @@ -412,7 +404,7 @@ dependencies = [ [[package]] name = "cairo-lang-filesystem" -version = "1.0.0-alpha.7" +version = "1.0.0-rc0" dependencies = [ "cairo-lang-debug", "cairo-lang-utils", @@ -427,7 +419,7 @@ dependencies = [ [[package]] name = "cairo-lang-formatter" -version = "1.0.0-alpha.7" +version = "1.0.0-rc0" dependencies = [ "anyhow", "cairo-lang-diagnostics", @@ -450,7 +442,7 @@ dependencies = [ [[package]] name = "cairo-lang-language-server" -version = "1.0.0-alpha.7" +version = "1.0.0-rc0" dependencies = [ "anyhow", "cairo-lang-compiler", @@ -482,7 +474,7 @@ dependencies = [ [[package]] name = "cairo-lang-lowering" -version = "1.0.0-alpha.7" +version = "1.0.0-rc0" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -511,7 +503,7 @@ dependencies = [ [[package]] name = "cairo-lang-parser" -version = "1.0.0-alpha.7" +version = "1.0.0-rc0" dependencies = [ "cairo-lang-diagnostics", "cairo-lang-filesystem", @@ -523,16 +515,19 @@ dependencies = [ "env_logger", "itertools", "log", + "num-bigint", + "num-traits 0.2.15", "pretty_assertions", "salsa", "smol_str", "test-case", "test-log", + "unescaper", ] [[package]] name = "cairo-lang-plugins" -version = "1.0.0-alpha.7" +version = "1.0.0-rc0" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -551,12 +546,11 @@ dependencies = [ "smol_str", "test-case", "test-log", - "unescaper", ] [[package]] name = "cairo-lang-proc-macros" -version = "1.0.0-alpha.7" +version = "1.0.0-rc0" dependencies = [ "cairo-lang-debug", "quote", @@ -565,7 +559,7 @@ dependencies = [ [[package]] name = "cairo-lang-project" -version = "1.0.0-alpha.7" +version = "1.0.0-rc0" dependencies = [ "cairo-lang-filesystem", "indoc", @@ -578,7 +572,7 @@ dependencies = [ [[package]] name = "cairo-lang-runner" -version = "1.0.0-alpha.7" +version = "1.0.0-rc0" dependencies = [ "anyhow", "ark-ff 0.4.0-alpha.7", @@ -586,16 +580,22 @@ dependencies = [ "cairo-felt", "cairo-lang-casm", "cairo-lang-compiler", + "cairo-lang-defs", "cairo-lang-diagnostics", + "cairo-lang-filesystem", + "cairo-lang-lowering", + "cairo-lang-semantic", "cairo-lang-sierra", "cairo-lang-sierra-ap-change", "cairo-lang-sierra-gas", "cairo-lang-sierra-generator", "cairo-lang-sierra-to-casm", + "cairo-lang-starknet", "cairo-lang-utils", "cairo-vm", "clap", "itertools", + "keccak", "num-bigint", "num-integer", "num-traits 0.2.15", @@ -607,7 +607,7 @@ dependencies = [ [[package]] name = "cairo-lang-semantic" -version = "1.0.0-alpha.7" +version = "1.0.0-rc0" dependencies = [ "assert_matches", "cairo-lang-debug", @@ -632,12 +632,11 @@ dependencies = [ "smol_str", "test-case", "test-log", - "unescaper", ] [[package]] name = "cairo-lang-sierra" -version = "1.0.0-alpha.7" +version = "1.0.0-rc0" dependencies = [ "assert_matches", "bimap", @@ -665,7 +664,7 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-ap-change" -version = "1.0.0-alpha.7" +version = "1.0.0-rc0" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -680,7 +679,7 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-gas" -version = "1.0.0-alpha.7" +version = "1.0.0-rc0" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -697,7 +696,7 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-generator" -version = "1.0.0-alpha.7" +version = "1.0.0-rc0" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -728,7 +727,7 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-to-casm" -version = "1.0.0-alpha.7" +version = "1.0.0-rc0" dependencies = [ "anyhow", "assert_matches", @@ -753,9 +752,10 @@ dependencies = [ [[package]] name = "cairo-lang-starknet" -version = "1.0.0-alpha.7" +version = "1.0.0-rc0" dependencies = [ "anyhow", + "cairo-felt", "cairo-lang-casm", "cairo-lang-compiler", "cairo-lang-defs", @@ -796,21 +796,25 @@ dependencies = [ [[package]] name = "cairo-lang-syntax" -version = "1.0.0-alpha.7" +version = "1.0.0-rc0" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", "cairo-lang-utils", "env_logger", + "num-bigint", + "num-traits 0.2.15", "pretty_assertions", "salsa", "smol_str", "test-log", + "thiserror", + "unescaper", ] [[package]] name = "cairo-lang-syntax-codegen" -version = "1.0.0-alpha.7" +version = "1.0.0-rc0" dependencies = [ "cairo-lang-utils", "env_logger", @@ -822,7 +826,7 @@ dependencies = [ [[package]] name = "cairo-lang-test-runner" -version = "1.0.0-alpha.7" +version = "1.0.0-rc0" dependencies = [ "anyhow", "cairo-felt", @@ -848,15 +852,15 @@ dependencies = [ "colored", "itertools", "num-bigint", + "num-traits 0.2.15", "rayon", "salsa", "thiserror", - "unescaper", ] [[package]] name = "cairo-lang-test-utils" -version = "1.0.0-alpha.7" +version = "1.0.0-rc0" dependencies = [ "cairo-lang-utils", "env_logger", @@ -867,9 +871,8 @@ dependencies = [ [[package]] name = "cairo-lang-utils" -version = "1.0.0-alpha.7" +version = "1.0.0-rc0" dependencies = [ - "chrono", "env_logger", "indexmap", "itertools", @@ -881,6 +884,7 @@ dependencies = [ "serde_json", "test-case", "test-log", + "time", ] [[package]] @@ -945,21 +949,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "chrono" -version = "0.4.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" -dependencies = [ - "iana-time-zone", - "js-sys", - "num-integer", - "num-traits 0.2.15", - "time", - "wasm-bindgen", - "winapi", -] - [[package]] name = "clap" version = "4.0.26" @@ -997,16 +986,6 @@ dependencies = [ "os_str_bytes", ] -[[package]] -name = "codespan-reporting" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" -dependencies = [ - "termcolor", - "unicode-width", -] - [[package]] name = "colored" version = "2.0.0" @@ -1033,12 +1012,6 @@ dependencies = [ "unicode-segmentation", ] -[[package]] -name = "core-foundation-sys" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" - [[package]] name = "cpufeatures" version = "0.2.5" @@ -1128,50 +1101,6 @@ dependencies = [ "syn 1.0.103", ] -[[package]] -name = "cxx" -version = "1.0.82" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4a41a86530d0fe7f5d9ea779916b7cadd2d4f9add748b99c2c029cbbdfaf453" -dependencies = [ - "cc", - "cxxbridge-flags", - "cxxbridge-macro", - "link-cplusplus", -] - -[[package]] -name = "cxx-build" -version = "1.0.82" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06416d667ff3e3ad2df1cd8cd8afae5da26cf9cec4d0825040f88b5ca659a2f0" -dependencies = [ - "cc", - "codespan-reporting", - "once_cell", - "proc-macro2", - "quote", - "scratch", - "syn 1.0.103", -] - -[[package]] -name = "cxxbridge-flags" -version = "1.0.82" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "820a9a2af1669deeef27cb271f476ffd196a2c4b6731336011e0ba63e2c7cf71" - -[[package]] -name = "cxxbridge-macro" -version = "1.0.82" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08a6e2fcc370a089ad3b4aaf54db3b1b4cee38ddabce5896b33eb693275f470" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.103", -] - [[package]] name = "darling" version = "0.14.4" @@ -1530,7 +1459,7 @@ dependencies = [ "cfg-if", "js-sys", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "wasm-bindgen", ] @@ -1630,30 +1559,6 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" -[[package]] -name = "iana-time-zone" -version = "0.1.53" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "winapi", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" -dependencies = [ - "cxx", - "cxx-build", -] - [[package]] name = "id-arena" version = "2.2.1" @@ -1832,15 +1737,6 @@ dependencies = [ "libc", ] -[[package]] -name = "link-cplusplus" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369" -dependencies = [ - "cc", -] - [[package]] name = "linux-raw-sys" version = "0.1.4" @@ -1936,7 +1832,7 @@ checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" dependencies = [ "libc", "log", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "windows-sys 0.42.0", ] @@ -2039,6 +1935,15 @@ dependencies = [ "libc", ] +[[package]] +name = "num_threads" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44" +dependencies = [ + "libc", +] + [[package]] name = "once_cell" version = "1.17.1" @@ -2255,9 +2160,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.53" +version = "1.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba466839c78239c09faf015484e5cc04860f88242cff4d03eb038f04b4699b73" +checksum = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224" dependencies = [ "unicode-ident", ] @@ -2519,12 +2424,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "scratch" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" - [[package]] name = "semver" version = "0.11.0" @@ -2578,7 +2477,7 @@ checksum = "e801c1712f48475582b7696ac71e0ca34ebb30e09338425384269d9717c62cad" dependencies = [ "proc-macro2", "quote", - "syn 2.0.9", + "syn 2.0.3", ] [[package]] @@ -2780,9 +2679,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.9" +version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0da4a3c17e109f700685ec577c0f85efd9b19bcf15c913985f14dc1ac01775aa" +checksum = "e8234ae35e70582bfa0f1fedffa6daa248e41dd045310b19800c4a36382c8f60" dependencies = [ "proc-macro2", "quote", @@ -2862,7 +2761,7 @@ dependencies = [ [[package]] name = "tests" -version = "1.0.0-alpha.7" +version = "1.0.0-rc0" dependencies = [ "assert_matches", "cairo-felt", @@ -2912,7 +2811,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.9", + "syn 2.0.3", ] [[package]] @@ -2946,13 +2845,31 @@ dependencies = [ [[package]] name = "time" -version = "0.1.44" +version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +checksum = "cd0cbfecb4d19b5ea75bb31ad904eb5b9fa13f21079c3b92017ebdf4999a5890" dependencies = [ + "itoa", "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi", + "num_threads", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" + +[[package]] +name = "time-macros" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd80a657e71da814b8e5d60d3374fc6d35045062245d80224748ae522dd76f36" +dependencies = [ + "time-core", ] [[package]] @@ -3161,12 +3078,6 @@ version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fdbf052a0783de01e944a6ce7a8cb939e295b1e7be835a1112c3b9a7f047a5a" -[[package]] -name = "unicode-width" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" - [[package]] name = "unicode-xid" version = "0.2.4" @@ -3202,12 +3113,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" diff --git a/Cargo.toml b/Cargo.toml index bb3d92a73..49e71907f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,10 +3,8 @@ members = [ "cairo/crates/cairo-lang-casm", "cairo/crates/cairo-lang-compiler", - "cairo/crates/cairo-lang-utils", "cairo/crates/cairo-lang-debug", "cairo/crates/cairo-lang-defs", - "cairo/crates/cairo-lang-proc-macros", "cairo/crates/cairo-lang-diagnostics", "cairo/crates/cairo-lang-eq-solver", "cairo/crates/cairo-lang-filesystem", @@ -15,23 +13,25 @@ members = [ "cairo/crates/cairo-lang-lowering", "cairo/crates/cairo-lang-parser", "cairo/crates/cairo-lang-plugins", + "cairo/crates/cairo-lang-proc-macros", "cairo/crates/cairo-lang-project", "cairo/crates/cairo-lang-runner", "cairo/crates/cairo-lang-semantic", + "cairo/crates/cairo-lang-sierra", "cairo/crates/cairo-lang-sierra-ap-change", "cairo/crates/cairo-lang-sierra-gas", "cairo/crates/cairo-lang-sierra-generator", "cairo/crates/cairo-lang-sierra-to-casm", - "cairo/crates/cairo-lang-sierra", "cairo/crates/cairo-lang-starknet", - "cairo/crates/cairo-lang-syntax-codegen", "cairo/crates/cairo-lang-syntax", + "cairo/crates/cairo-lang-syntax-codegen", "cairo/crates/cairo-lang-test-runner", + "cairo/crates/cairo-lang-utils", "cairo/tests", ] [workspace.package] -version = "1.0.0-alpha.7" +version = "1.0.0-rc0" edition = "2021" repository = "https://github.com/starkware-libs/cairo/" license = "Apache-2.0" @@ -45,7 +45,6 @@ assert_matches = "1.5" bimap = "0.6.2" cairo-felt = "0.3.0-rc1" cairo-vm = "0.3.0-rc1" -chrono = "0.4.23" clap = { version = "4.0", features = ["derive"] } colored = "2" const-fnv1a-hash = "1.1.0" @@ -60,6 +59,7 @@ ignore = "0.4.20" indexmap = { version = "1.9.1", features = ["serde"] } indoc = "2.0.1" itertools = "0.10.3" +keccak = "0.1.3" lalrpop-util = { version = "0.19.9", features = ["lexer"] } log = "0.4" lsp = { version = "0.93", package = "lsp-types" } @@ -84,6 +84,7 @@ test-case = "2.2.2" test-case-macros = "2.2.2" test-log = "0.2.11" thiserror = "1.0.32" +time = { version = "0.3.20", features = ["formatting", "macros", "local-offset"] } tokio = { version = "1.18.2", features = ["full", "sync"] } toml = "0.4.2" tower-lsp = "0.17.0" From 88b0e3db4e2b1fe3b057b77c141e7ed506bd2ad4 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 5 May 2023 21:56:11 -0400 Subject: [PATCH 20/35] simplify imports --- src/openzeppelin/token/erc20.cairo | 4 ++-- src/openzeppelin/utils/udc.cairo | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/openzeppelin/token/erc20.cairo b/src/openzeppelin/token/erc20.cairo index 6e852dff9..fc6d845da 100644 --- a/src/openzeppelin/token/erc20.cairo +++ b/src/openzeppelin/token/erc20.cairo @@ -15,8 +15,8 @@ trait IERC20 { #[contract] mod ERC20 { use super::IERC20; - use starknet::get_caller_address; - use starknet::ContractAddress; + use integer::BoundedInt; + use starknet::{ContractAddress, contract_address::ContractAddressZeroable, get_caller_address}; use zeroable::Zeroable; struct Storage { diff --git a/src/openzeppelin/utils/udc.cairo b/src/openzeppelin/utils/udc.cairo index ddf6e3e2b..695fbcb4f 100644 --- a/src/openzeppelin/utils/udc.cairo +++ b/src/openzeppelin/utils/udc.cairo @@ -2,9 +2,7 @@ mod UniversalDeployerContract { use array::ArrayTrait; use hash::pedersen; - use starknet::class_hash::ClassHash; - use starknet::ContractAddress; - use starknet::get_caller_address; + use starknet::{class_hash::ClassHash, ContractAddress, get_caller_address}; use traits::Into; #[event] From 8b2e1d46acbda2a1a6ec42ffd894f81be0f90eba Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 5 May 2023 22:07:21 -0400 Subject: [PATCH 21/35] remove duplicate import --- src/openzeppelin/token/erc20.cairo | 1 - 1 file changed, 1 deletion(-) diff --git a/src/openzeppelin/token/erc20.cairo b/src/openzeppelin/token/erc20.cairo index 5bd22e3e2..e701b72d9 100644 --- a/src/openzeppelin/token/erc20.cairo +++ b/src/openzeppelin/token/erc20.cairo @@ -18,7 +18,6 @@ mod ERC20 { use integer::BoundedInt; use starknet::{ContractAddress, contract_address::ContractAddressZeroable, get_caller_address}; use zeroable::Zeroable; - use integer::BoundedInt; struct Storage { _name: felt252, From 695b16d66a8601d052f77fe7cd7061dec95143cb Mon Sep 17 00:00:00 2001 From: Andrew Fleming Date: Wed, 10 May 2023 20:07:44 -0400 Subject: [PATCH 22/35] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Martín Triay --- src/openzeppelin/utils/udc.cairo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openzeppelin/utils/udc.cairo b/src/openzeppelin/utils/udc.cairo index 695fbcb4f..83b79bff0 100644 --- a/src/openzeppelin/utils/udc.cairo +++ b/src/openzeppelin/utils/udc.cairo @@ -17,7 +17,7 @@ mod UniversalDeployerContract { #[external] fn deploy_contract( - class_hash: ClassHash, salt: felt252, unique: bool, calldata: Array + class_hash: ClassHash, salt: felt252, unique: bool, calldata: Span ) -> ContractAddress { let deployer: ContractAddress = get_caller_address(); From 553f667609fbbef483ade95b9fab741315efc7f2 Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 15 May 2023 01:49:44 -0400 Subject: [PATCH 23/35] bump cairo --- cairo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cairo b/cairo index 05867c82d..ee9a0bb1e 160000 --- a/cairo +++ b/cairo @@ -1 +1 @@ -Subproject commit 05867c82de42d5ee5cfa953dcca1cb826402f74b +Subproject commit ee9a0bb1e496c6e5d922c3a5071d85b45f8bc268 From 362f68882ee6ca3e42fc8aea8ebeab0861a767b2 Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 15 May 2023 02:00:47 -0400 Subject: [PATCH 24/35] rename, add SpanSerde, add underscore to calldata --- src/openzeppelin/utils/udc.cairo | 40 ----------- .../utils/universal_deployer.cairo | 72 +++++++++++++++++++ 2 files changed, 72 insertions(+), 40 deletions(-) delete mode 100644 src/openzeppelin/utils/udc.cairo create mode 100644 src/openzeppelin/utils/universal_deployer.cairo diff --git a/src/openzeppelin/utils/udc.cairo b/src/openzeppelin/utils/udc.cairo deleted file mode 100644 index 83b79bff0..000000000 --- a/src/openzeppelin/utils/udc.cairo +++ /dev/null @@ -1,40 +0,0 @@ -#[contract] -mod UniversalDeployerContract { - use array::ArrayTrait; - use hash::pedersen; - use starknet::{class_hash::ClassHash, ContractAddress, get_caller_address}; - use traits::Into; - - #[event] - fn ContractDeployed( - address: ContractAddress, - deployer: ContractAddress, - unique: bool, - class_hash: ClassHash, - calldata: Array, - salt: felt252, - ) {} - - #[external] - fn deploy_contract( - class_hash: ClassHash, salt: felt252, unique: bool, calldata: Span - ) -> ContractAddress { - let deployer: ContractAddress = get_caller_address(); - - // Defaults for non-unique deployment - let mut _salt: felt252 = salt; - let mut from_zero: bool = true; - - if unique { - _salt = pedersen(deployer.into(), salt); - from_zero = false; - } - - let (address, _) = starknet::syscalls::deploy_syscall( - class_hash, _salt, calldata.span(), from_zero - ).unwrap_syscall(); - - ContractDeployed(address, deployer, unique, class_hash, calldata, salt); - return address; - } -} diff --git a/src/openzeppelin/utils/universal_deployer.cairo b/src/openzeppelin/utils/universal_deployer.cairo new file mode 100644 index 000000000..875faa0c8 --- /dev/null +++ b/src/openzeppelin/utils/universal_deployer.cairo @@ -0,0 +1,72 @@ +use array::ArrayTrait; +use array::SpanTrait; +use option::OptionTrait; +use serde::Serde; +use serde::serialize_array_helper; +use serde::deserialize_array_helper; +use starknet::class_hash::ClassHash; +use starknet::ContractAddress; + +#[abi] +trait IUniversalDeployer { + fn deploy_contract( + class_hash: ClassHash, salt: felt252, unique: bool, _calldata: Span + ) -> ContractAddress; +} + +#[contract] +mod UniversalDeployer { + use super::SpanSerde; + + use array::SpanTrait; + use hash::pedersen; + use starknet::class_hash::ClassHash; + use starknet::ContractAddress; + use starknet::get_caller_address; + use traits::Into; + + #[event] + fn ContractDeployed( + address: ContractAddress, + deployer: ContractAddress, + unique: bool, + class_hash: ClassHash, + _calldata: Span, + salt: felt252, + ) {} + + #[external] + fn deploy_contract( + class_hash: ClassHash, salt: felt252, unique: bool, _calldata: Span + ) -> ContractAddress { + let deployer: ContractAddress = get_caller_address(); + + // Defaults for non-unique deployment + let mut _salt: felt252 = salt; + let mut from_zero: bool = true; + + if unique { + _salt = pedersen(deployer.into(), salt); + from_zero = false; + } + + let (address, _) = starknet::syscalls::deploy_syscall( + class_hash, _salt, _calldata, from_zero + ).unwrap_syscall(); + + ContractDeployed(address, deployer, unique, class_hash, _calldata, salt); + return address; + } +} + +impl SpanSerde, impl TCopy: Copy, impl TDrop: Drop> of Serde::> { + fn serialize(self: @Span, ref output: Array) { + (*self).len().serialize(ref output); + serialize_array_helper(*self, ref output); + } + fn deserialize(ref serialized: Span) -> Option> { + let length = *serialized.pop_front()?; + let mut arr = ArrayTrait::new(); + Option::Some(deserialize_array_helper(ref serialized, arr, length)?.span()) + } +} From 1873990a37edbfe21c0847ad43af5c8bba1c7ef2 Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 15 May 2023 02:01:10 -0400 Subject: [PATCH 25/35] fix udc name --- src/openzeppelin/utils.cairo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openzeppelin/utils.cairo b/src/openzeppelin/utils.cairo index 9a83bb006..aba83f94f 100644 --- a/src/openzeppelin/utils.cairo +++ b/src/openzeppelin/utils.cairo @@ -1,2 +1,2 @@ mod constants; -mod udc; +mod universal_deployer; From 4c6d61cb9b613d300ee04bbaec48e7be93fb20fd Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 15 May 2023 02:04:19 -0400 Subject: [PATCH 26/35] fix erc20 abi --- src/openzeppelin/token/erc20.cairo | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/openzeppelin/token/erc20.cairo b/src/openzeppelin/token/erc20.cairo index e701b72d9..6ff5797df 100644 --- a/src/openzeppelin/token/erc20.cairo +++ b/src/openzeppelin/token/erc20.cairo @@ -1,14 +1,24 @@ use starknet::ContractAddress; +#[abi] trait IERC20 { + #[view] fn name() -> felt252; + #[view] fn symbol() -> felt252; + #[view] fn decimals() -> u8; + #[view] fn total_supply() -> u256; + #[view] fn balance_of(account: ContractAddress) -> u256; + #[view] fn allowance(owner: ContractAddress, spender: ContractAddress) -> u256; + #[external] fn transfer(recipient: ContractAddress, amount: u256) -> bool; + #[external] fn transfer_from(sender: ContractAddress, recipient: ContractAddress, amount: u256) -> bool; + #[external] fn approve(spender: ContractAddress, amount: u256) -> bool; } From c909d4658631f3c8808d8118437b1f9550b3c127 Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 15 May 2023 02:05:55 -0400 Subject: [PATCH 27/35] add test draft --- src/openzeppelin/tests.cairo | 1 + src/openzeppelin/tests/test_udc.cairo | 60 +++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 src/openzeppelin/tests/test_udc.cairo diff --git a/src/openzeppelin/tests.cairo b/src/openzeppelin/tests.cairo index ac9e6b924..5e1c1a83d 100644 --- a/src/openzeppelin/tests.cairo +++ b/src/openzeppelin/tests.cairo @@ -2,4 +2,5 @@ mod test_erc165; mod test_erc20; mod test_pausable; mod test_initializable; +mod test_udc; mod mocks; diff --git a/src/openzeppelin/tests/test_udc.cairo b/src/openzeppelin/tests/test_udc.cairo new file mode 100644 index 000000000..c901ed3ec --- /dev/null +++ b/src/openzeppelin/tests/test_udc.cairo @@ -0,0 +1,60 @@ +use array::ArrayTrait; +use core::result::ResultTrait; +use core::traits::Into; +use debug::PrintTrait; +use option::OptionTrait; +use starknet::class_hash::ClassHash; +use starknet::class_hash::Felt252TryIntoClassHash; +use starknet::ContractAddress; +use starknet::contract_address_const; +use traits::TryInto; + +use openzeppelin::utils::universal_deployer::UniversalDeployer; +use openzeppelin::utils::universal_deployer::IUniversalDeployerDispatcher; +use openzeppelin::utils::universal_deployer::IUniversalDeployerDispatcherTrait; + +use openzeppelin::token::erc20::ERC20; +use openzeppelin::token::erc20::IERC20Dispatcher; +use openzeppelin::token::erc20::IERC20DispatcherTrait; + +fn deploy_udc() -> IUniversalDeployerDispatcher { + let calldata = ArrayTrait::::new(); + let (address, _) = starknet::deploy_syscall( + UniversalDeployer::TEST_CLASS_HASH.try_into().unwrap(), 0, calldata.span(), false + ) + .unwrap(); + + IUniversalDeployerDispatcher { contract_address: address } +} + +#[test] +#[available_gas(2000000)] +fn test_deploy() { + let udc = deploy_udc(); + + // udc args + let erc20_class_hash = ERC20::TEST_CLASS_HASH.try_into().unwrap(); + let salt = 123456789; + let unique = false; + + // calldata (erc20 args) + let name = 0; + let symbol = 0; + let initial_supply = 1000_u256; + let recipient = contract_address_const::<0x123>(); + let mut calldata = ArrayTrait::::new(); + calldata.append(name); + calldata.append(symbol); + calldata.append(initial_supply.low.into()); + calldata.append(initial_supply.high.into()); + calldata.append(recipient.into()); + + let addr = udc.deploy_contract( + erc20_class_hash, + salt, + unique, + calldata.span(), + ); + addr.print(); +} + From d5c1ed453f700b195b9b3b1a574748ebbf81236c Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 15 May 2023 02:07:12 -0400 Subject: [PATCH 28/35] fix formatting --- src/openzeppelin/tests/test_udc.cairo | 7 +------ src/openzeppelin/utils/universal_deployer.cairo | 7 +++++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/openzeppelin/tests/test_udc.cairo b/src/openzeppelin/tests/test_udc.cairo index c901ed3ec..8def4ea85 100644 --- a/src/openzeppelin/tests/test_udc.cairo +++ b/src/openzeppelin/tests/test_udc.cairo @@ -49,12 +49,7 @@ fn test_deploy() { calldata.append(initial_supply.high.into()); calldata.append(recipient.into()); - let addr = udc.deploy_contract( - erc20_class_hash, - salt, - unique, - calldata.span(), - ); + let addr = udc.deploy_contract(erc20_class_hash, salt, unique, calldata.span()); addr.print(); } diff --git a/src/openzeppelin/utils/universal_deployer.cairo b/src/openzeppelin/utils/universal_deployer.cairo index 875faa0c8..c67136dd8 100644 --- a/src/openzeppelin/utils/universal_deployer.cairo +++ b/src/openzeppelin/utils/universal_deployer.cairo @@ -52,14 +52,17 @@ mod UniversalDeployer { let (address, _) = starknet::syscalls::deploy_syscall( class_hash, _salt, _calldata, from_zero - ).unwrap_syscall(); + ) + .unwrap_syscall(); ContractDeployed(address, deployer, unique, class_hash, _calldata, salt); return address; } } -impl SpanSerde, impl TCopy: Copy, impl TDrop: Drop> of Serde::> { +impl SpanSerde< + T, impl TSerde: Serde, impl TCopy: Copy, impl TDrop: Drop +> of Serde> { fn serialize(self: @Span, ref output: Array) { (*self).len().serialize(ref output); serialize_array_helper(*self, ref output); From 6eca68852285372a94587b2f2894093f1df8d375 Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 15 May 2023 02:11:03 -0400 Subject: [PATCH 29/35] remove print --- src/openzeppelin/tests/test_udc.cairo | 1 - 1 file changed, 1 deletion(-) diff --git a/src/openzeppelin/tests/test_udc.cairo b/src/openzeppelin/tests/test_udc.cairo index 8def4ea85..9dc2bd818 100644 --- a/src/openzeppelin/tests/test_udc.cairo +++ b/src/openzeppelin/tests/test_udc.cairo @@ -50,6 +50,5 @@ fn test_deploy() { calldata.append(recipient.into()); let addr = udc.deploy_contract(erc20_class_hash, salt, unique, calldata.span()); - addr.print(); } From 390488cd961ff9767a7b4a5c95b327ca87685fe0 Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 15 May 2023 11:51:56 -0400 Subject: [PATCH 30/35] fix imports --- src/openzeppelin/token/erc20.cairo | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/openzeppelin/token/erc20.cairo b/src/openzeppelin/token/erc20.cairo index 6ff5797df..18861db1a 100644 --- a/src/openzeppelin/token/erc20.cairo +++ b/src/openzeppelin/token/erc20.cairo @@ -26,7 +26,8 @@ trait IERC20 { mod ERC20 { use super::IERC20; use integer::BoundedInt; - use starknet::{ContractAddress, contract_address::ContractAddressZeroable, get_caller_address}; + use starknet::ContractAddress; + use starknet::get_caller_address; use zeroable::Zeroable; struct Storage { From b23e1ef619d869bdc7279d151e678b2d1b612f76 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 23 May 2023 15:37:34 -0400 Subject: [PATCH 31/35] simplify import --- src/openzeppelin/utils/universal_deployer.cairo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openzeppelin/utils/universal_deployer.cairo b/src/openzeppelin/utils/universal_deployer.cairo index c67136dd8..04a339631 100644 --- a/src/openzeppelin/utils/universal_deployer.cairo +++ b/src/openzeppelin/utils/universal_deployer.cairo @@ -50,7 +50,7 @@ mod UniversalDeployer { from_zero = false; } - let (address, _) = starknet::syscalls::deploy_syscall( + let (address, _) = starknet::deploy_syscall( class_hash, _salt, _calldata, from_zero ) .unwrap_syscall(); From f5a65fa5e0aaaf2bec702ceb61d300a291cc4cf6 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 2 Jun 2023 12:18:44 -0400 Subject: [PATCH 32/35] add compute_hash and address calculation --- src/openzeppelin/tests/utils.cairo | 51 ++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/openzeppelin/tests/utils.cairo b/src/openzeppelin/tests/utils.cairo index d3b720cce..964daa08d 100644 --- a/src/openzeppelin/tests/utils.cairo +++ b/src/openzeppelin/tests/utils.cairo @@ -1,10 +1,22 @@ use array::ArrayTrait; use core::result::ResultTrait; +use core::traits::Into; +use debug::PrintTrait; +use hash::pedersen; +use integer::u256_safe_divmod; use option::OptionTrait; use starknet::class_hash::Felt252TryIntoClassHash; +use starknet::class_hash::ClassHash; use starknet::ContractAddress; +use starknet::contract_address_const; +use starknet::contract_address::contract_address_try_from_felt252; use traits::TryInto; +// from_bytes(b"STARKNET_CONTRACT_ADDRESS") +const CONTRACT_ADDRESS_PREFIX: felt252 = 0x535441524b4e45545f434f4e54524143545f41444452455353; +// 2**251 - 256 +const L2_ADDRESS_UPPER_BOUND: felt252 = 0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00; + fn deploy(contract_class_hash: felt252, calldata: Array) -> ContractAddress { let (address, _) = starknet::deploy_syscall( contract_class_hash.try_into().unwrap(), 0, calldata.span(), false @@ -12,3 +24,42 @@ fn deploy(contract_class_hash: felt252, calldata: Array) -> ContractAdd .unwrap(); address } + +fn compute_hash_on_elements(mut data: Array::) -> felt252 { + let data_len: usize = data.len(); + let mut hash = 0; + loop { + match data.pop_front() { + Option::Some(x) => { + hash = pedersen(hash, x); + }, + Option::None(_) => { + hash = pedersen(hash, data_len.into()); + break (); + }, + }; + }; + hash +} + +fn calculate_contract_address_from_hash( + salt: felt252, + class_hash: ClassHash, + constructor_calldata: Array::, + deployer_address: ContractAddress + ) -> ContractAddress { + let constructor_calldata_hash = compute_hash_on_elements(constructor_calldata); + + let mut data = ArrayTrait::new(); + data.append(CONTRACT_ADDRESS_PREFIX); + data.append(deployer_address.into()); + data.append(salt); + data.append(class_hash.into()); + data.append(constructor_calldata_hash); + let raw_address = compute_hash_on_elements(data); + + // Felt modulo is discouraged, hence the conversion to u256 + let u256_addr: u256 = raw_address.into() % L2_ADDRESS_UPPER_BOUND.into(); + let felt_addr = u256_addr.try_into().unwrap(); + contract_address_try_from_felt252(felt_addr).unwrap() +} From aac54f1aaaadeeb466362f964645a02fe6091699 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 2 Jun 2023 14:25:05 -0400 Subject: [PATCH 33/35] change array to span --- src/openzeppelin/tests/utils.cairo | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/openzeppelin/tests/utils.cairo b/src/openzeppelin/tests/utils.cairo index 964daa08d..c63e906ec 100644 --- a/src/openzeppelin/tests/utils.cairo +++ b/src/openzeppelin/tests/utils.cairo @@ -1,4 +1,5 @@ use array::ArrayTrait; +use array::SpanTrait; use core::result::ResultTrait; use core::traits::Into; use debug::PrintTrait; @@ -25,13 +26,13 @@ fn deploy(contract_class_hash: felt252, calldata: Array) -> ContractAdd address } -fn compute_hash_on_elements(mut data: Array::) -> felt252 { +fn compute_hash_on_elements(mut data: Span::) -> felt252 { let data_len: usize = data.len(); let mut hash = 0; loop { match data.pop_front() { Option::Some(x) => { - hash = pedersen(hash, x); + hash = pedersen(hash, *x); }, Option::None(_) => { hash = pedersen(hash, data_len.into()); @@ -45,7 +46,7 @@ fn compute_hash_on_elements(mut data: Array::) -> felt252 { fn calculate_contract_address_from_hash( salt: felt252, class_hash: ClassHash, - constructor_calldata: Array::, + constructor_calldata: Span::, deployer_address: ContractAddress ) -> ContractAddress { let constructor_calldata_hash = compute_hash_on_elements(constructor_calldata); @@ -56,7 +57,7 @@ fn calculate_contract_address_from_hash( data.append(salt); data.append(class_hash.into()); data.append(constructor_calldata_hash); - let raw_address = compute_hash_on_elements(data); + let raw_address = compute_hash_on_elements(data.span()); // Felt modulo is discouraged, hence the conversion to u256 let u256_addr: u256 = raw_address.into() % L2_ADDRESS_UPPER_BOUND.into(); From f3bc0f53092c8fde5b373f9120ef085129b56d85 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 2 Jun 2023 15:15:25 -0400 Subject: [PATCH 34/35] integrate calculate address to tests --- src/openzeppelin/tests/test_udc.cairo | 54 +++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/src/openzeppelin/tests/test_udc.cairo b/src/openzeppelin/tests/test_udc.cairo index 9dc2bd818..4d8ec1002 100644 --- a/src/openzeppelin/tests/test_udc.cairo +++ b/src/openzeppelin/tests/test_udc.cairo @@ -8,6 +8,8 @@ use starknet::class_hash::Felt252TryIntoClassHash; use starknet::ContractAddress; use starknet::contract_address_const; use traits::TryInto; +use zeroable::Zeroable; +use super::utils; use openzeppelin::utils::universal_deployer::UniversalDeployer; use openzeppelin::utils::universal_deployer::IUniversalDeployerDispatcher; @@ -17,6 +19,12 @@ use openzeppelin::token::erc20::ERC20; use openzeppelin::token::erc20::IERC20Dispatcher; use openzeppelin::token::erc20::IERC20DispatcherTrait; +const RAW_SALT: felt252 = 123456789; + +fn ACCOUNT() -> ContractAddress { + contract_address_const::<10>() +} + fn deploy_udc() -> IUniversalDeployerDispatcher { let calldata = ArrayTrait::::new(); let (address, _) = starknet::deploy_syscall( @@ -29,12 +37,11 @@ fn deploy_udc() -> IUniversalDeployerDispatcher { #[test] #[available_gas(2000000)] -fn test_deploy() { +fn test_deploy_not_unique() { let udc = deploy_udc(); // udc args let erc20_class_hash = ERC20::TEST_CLASS_HASH.try_into().unwrap(); - let salt = 123456789; let unique = false; // calldata (erc20 args) @@ -49,6 +56,47 @@ fn test_deploy() { calldata.append(initial_supply.high.into()); calldata.append(recipient.into()); - let addr = udc.deploy_contract(erc20_class_hash, salt, unique, calldata.span()); + let expected_addr = utils::calculate_contract_address_from_hash( + RAW_SALT, + erc20_class_hash, + calldata.span(), + Zeroable::zero() + ); + + let deployed_addr = udc.deploy_contract(erc20_class_hash, RAW_SALT, unique, calldata.span()); + //assert(deployed_addr == expected_addr, 'Deployed address != expected'); +} + +#[test] +#[available_gas(2000000)] +fn test_deploy_unique() { + let udc = deploy_udc(); + + // udc args + let erc20_class_hash = ERC20::TEST_CLASS_HASH.try_into().unwrap(); + let unique = true; + + // calldata (erc20 args) + let name = 0; + let symbol = 0; + let initial_supply = 1000_u256; + let recipient = contract_address_const::<0x123>(); + let mut calldata = ArrayTrait::::new(); + calldata.append(name); + calldata.append(symbol); + calldata.append(initial_supply.low.into()); + calldata.append(initial_supply.high.into()); + calldata.append(recipient.into()); + + let hashed_salt = pedersen(ACCOUNT().into(), RAW_SALT); + let expected_addr = utils::calculate_contract_address_from_hash( + hashed_salt, + erc20_class_hash, + calldata.span(), + udc.contract_address + ); + + let deployed_addr = udc.deploy_contract(erc20_class_hash, hashed_salt, unique, calldata.span()); + //assert(deployed_addr == expected_addr, 'Deployed address != expected'); } From 5553241322b92a1a5f56d9cfc88f2ec4adc0ad5c Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 2 Jun 2023 16:49:58 -0400 Subject: [PATCH 35/35] clean up code --- src/openzeppelin/tests/test_udc.cairo | 14 ++++------- src/openzeppelin/tests/utils.cairo | 19 +++++++-------- .../utils/universal_deployer.cairo | 23 ++----------------- 3 files changed, 14 insertions(+), 42 deletions(-) diff --git a/src/openzeppelin/tests/test_udc.cairo b/src/openzeppelin/tests/test_udc.cairo index 4d8ec1002..14dffdafe 100644 --- a/src/openzeppelin/tests/test_udc.cairo +++ b/src/openzeppelin/tests/test_udc.cairo @@ -57,14 +57,11 @@ fn test_deploy_not_unique() { calldata.append(recipient.into()); let expected_addr = utils::calculate_contract_address_from_hash( - RAW_SALT, - erc20_class_hash, - calldata.span(), - Zeroable::zero() + RAW_SALT, erc20_class_hash, calldata.span(), Zeroable::zero() ); let deployed_addr = udc.deploy_contract(erc20_class_hash, RAW_SALT, unique, calldata.span()); - //assert(deployed_addr == expected_addr, 'Deployed address != expected'); +/// assert(deployed_addr == expected_addr, 'Deployed address != expected'); } #[test] @@ -90,13 +87,10 @@ fn test_deploy_unique() { let hashed_salt = pedersen(ACCOUNT().into(), RAW_SALT); let expected_addr = utils::calculate_contract_address_from_hash( - hashed_salt, - erc20_class_hash, - calldata.span(), - udc.contract_address + hashed_salt, erc20_class_hash, calldata.span(), udc.contract_address ); let deployed_addr = udc.deploy_contract(erc20_class_hash, hashed_salt, unique, calldata.span()); - //assert(deployed_addr == expected_addr, 'Deployed address != expected'); +/// assert(deployed_addr == expected_addr, 'Deployed address != expected'); } diff --git a/src/openzeppelin/tests/utils.cairo b/src/openzeppelin/tests/utils.cairo index c63e906ec..b0bd67597 100644 --- a/src/openzeppelin/tests/utils.cairo +++ b/src/openzeppelin/tests/utils.cairo @@ -2,21 +2,18 @@ use array::ArrayTrait; use array::SpanTrait; use core::result::ResultTrait; use core::traits::Into; -use debug::PrintTrait; use hash::pedersen; -use integer::u256_safe_divmod; use option::OptionTrait; use starknet::class_hash::Felt252TryIntoClassHash; use starknet::class_hash::ClassHash; use starknet::ContractAddress; -use starknet::contract_address_const; -use starknet::contract_address::contract_address_try_from_felt252; use traits::TryInto; // from_bytes(b"STARKNET_CONTRACT_ADDRESS") const CONTRACT_ADDRESS_PREFIX: felt252 = 0x535441524b4e45545f434f4e54524143545f41444452455353; // 2**251 - 256 -const L2_ADDRESS_UPPER_BOUND: felt252 = 0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00; +const L2_ADDRESS_UPPER_BOUND: felt252 = + 0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00; fn deploy(contract_class_hash: felt252, calldata: Array) -> ContractAddress { let (address, _) = starknet::deploy_syscall( @@ -44,11 +41,11 @@ fn compute_hash_on_elements(mut data: Span::) -> felt252 { } fn calculate_contract_address_from_hash( - salt: felt252, - class_hash: ClassHash, - constructor_calldata: Span::, - deployer_address: ContractAddress - ) -> ContractAddress { + salt: felt252, + class_hash: ClassHash, + constructor_calldata: Span::, + deployer_address: ContractAddress +) -> ContractAddress { let constructor_calldata_hash = compute_hash_on_elements(constructor_calldata); let mut data = ArrayTrait::new(); @@ -62,5 +59,5 @@ fn calculate_contract_address_from_hash( // Felt modulo is discouraged, hence the conversion to u256 let u256_addr: u256 = raw_address.into() % L2_ADDRESS_UPPER_BOUND.into(); let felt_addr = u256_addr.try_into().unwrap(); - contract_address_try_from_felt252(felt_addr).unwrap() + starknet::contract_address_try_from_felt252(felt_addr).unwrap() } diff --git a/src/openzeppelin/utils/universal_deployer.cairo b/src/openzeppelin/utils/universal_deployer.cairo index 04a339631..b9c9fedc2 100644 --- a/src/openzeppelin/utils/universal_deployer.cairo +++ b/src/openzeppelin/utils/universal_deployer.cairo @@ -1,11 +1,8 @@ -use array::ArrayTrait; use array::SpanTrait; use option::OptionTrait; -use serde::Serde; -use serde::serialize_array_helper; -use serde::deserialize_array_helper; use starknet::class_hash::ClassHash; use starknet::ContractAddress; +use openzeppelin::utils::serde::SpanSerde; #[abi] trait IUniversalDeployer { @@ -50,26 +47,10 @@ mod UniversalDeployer { from_zero = false; } - let (address, _) = starknet::deploy_syscall( - class_hash, _salt, _calldata, from_zero - ) + let (address, _) = starknet::deploy_syscall(class_hash, _salt, _calldata, from_zero) .unwrap_syscall(); ContractDeployed(address, deployer, unique, class_hash, _calldata, salt); return address; } } - -impl SpanSerde< - T, impl TSerde: Serde, impl TCopy: Copy, impl TDrop: Drop -> of Serde> { - fn serialize(self: @Span, ref output: Array) { - (*self).len().serialize(ref output); - serialize_array_helper(*self, ref output); - } - fn deserialize(ref serialized: Span) -> Option> { - let length = *serialized.pop_front()?; - let mut arr = ArrayTrait::new(); - Option::Some(deserialize_array_helper(ref serialized, arr, length)?.span()) - } -}